Permalink
Browse files

added test cases

  • Loading branch information...
1 parent c3c675b commit 3827bcb91096bb85ad08b7186e75b1bf9af366b4 Slawomir Chodnicki committed Feb 21, 2011
View
@@ -3,4 +3,5 @@ bin
dist
testdist
testclasses
+package
.DS_Store
View
@@ -27,7 +27,7 @@
<property name="package" location="package" />
<property name="pluginname" value="Ruby" />
<property name="jarfilename" value="ruby-step.jar" />
- <property name="zipfilename" value="${pluginname}Plugin_Kettle_4.0.zip" />
+ <property name="zipfilename" value="${pluginname}Plugin_Kettle_4.zip" />
<!-- used for running the tests -->
<path id="test.classpath">
@@ -155,19 +155,13 @@
<delete dir="${package}" />
<mkdir dir="${package}" />
<mkdir dir="${package}/Sources" />
- <mkdir dir="${package}/Samples" />
<mkdir dir="${package}/${pluginname}" />
<!-- copy plugin -->
<copy todir="${package}/${pluginname}">
<fileset dir="${dist}" includes="**/*.*" />
</copy>
- <!-- copy samples -->
- <copy todir="${package}/Samples">
- <fileset dir="samples" includes="**/*.*" />
- </copy>
-
<!-- prepare sources -->
<copy todir="${package}/Sources/plugin">
<fileset dir="plugin" includes="**/*.*" />
@@ -179,18 +173,18 @@
<copy todir="${package}/Sources/lib">
<fileset dir="lib" includes="**/*.*" />
</copy>
- <copy todir="${package}/Sources/build">
- <fileset dir="build" includes="**/build.xml" />
+ <copy todir="${package}/Sources">
+ <fileset dir="." includes="build.xml" />
+ <fileset dir="." includes="build.properties" />
</copy>
<!-- zip up the contents -->
<delete file="${package}/${zipfilename}" />
<zip destfile="${package}/${zipfilename}">
<zipfileset dir="${package}/${pluginname}" prefix="${pluginname}" />
<zipfileset dir="${package}/Sources" prefix="Sources" />
- <zipfileset dir="${package}/Samples" prefix="Samples" />
- <zipfileset dir="build" includes="INSTALLATION.txt" />
- <zipfileset dir="build" includes="LICENSE.txt" />
+ <zipfileset dir="." includes="INSTALLATION.txt" />
+ <zipfileset dir="." includes="LICENSE.txt" />
</zip>
</target>
@@ -206,14 +200,14 @@
<target name="test-compile" depends="init" description="compile the test sources">
<mkdir dir="${testclasses}" />
<javac target="1.6" srcdir="${testsrc}" destdir="${testclasses}" debuglevel="lines,vars,source" debug="true">
- <classpath refid="compile.classpath" />
+ <classpath refid="test.classpath" />
</javac>
</target>
<target name="test" depends="test-compile,test-dist">
<junit fork="yes" haltonfailure="yes" maxmemory="256m">
- <test name="org.typeexit.kettle.plugin.steps.ruby.TestSamples" />
+ <test name="org.typeexit.kettle.plugin.steps.ruby.TestSuite" />
<formatter type="plain" usefile="false" />
<classpath refid="test.classpath" />
</junit>
@@ -73,7 +73,7 @@
<server/>
<type>H2</type>
<access>Native</access>
- <database>mem:MyDatabase;DB_CLOSE_DELAY=-1</database>
+ <database>mem:MyDatabase;DB_CLOSE_DELAY=-1;MULTI_THREADED=0</database>
<port>8082</port>
<username>H2</username>
<password>Encrypted </password>
@@ -192,6 +192,7 @@ while result.next do
end
# close the db connection
+result.close
conn.close
</body>
<role>ROW_SCRIPT</role>
@@ -228,24 +229,6 @@ conn.close
</step>
<step>
- <name>output critters</name>
- <type>Dummy</type>
- <description/>
- <distribute>Y</distribute>
- <copies>1</copies>
- <partitioning>
- <method>none</method>
- <schema_name/>
- </partitioning>
- <cluster_schema/>
- <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
- <xloc>422</xloc>
- <yloc>154</yloc>
- <draw>Y</draw>
- </GUI>
- </step>
-
- <step>
<name>Read function info about in-memory H2 DB</name>
<type>TypeExitRubyStep</type>
<description/>
@@ -348,24 +331,6 @@ end</body>
</step>
<step>
- <name>output function info</name>
- <type>Dummy</type>
- <description/>
- <distribute>Y</distribute>
- <copies>1</copies>
- <partitioning>
- <method>none</method>
- <schema_name/>
- </partitioning>
- <cluster_schema/>
- <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
- <xloc>423</xloc>
- <yloc>267</yloc>
- <draw>Y</draw>
- </GUI>
- </step>
-
- <step>
<name>Read supported data types from in-memory H2 DB</name>
<type>TypeExitRubyStep</type>
<description/>
@@ -416,6 +381,7 @@ while rs.next do
end
# close the db connection
+rs.close
conn.close
</body>
<role>ROW_SCRIPT</role>
@@ -524,6 +490,24 @@ end</body>
</step>
<step>
+ <name>output critters</name>
+ <type>Dummy</type>
+ <description/>
+ <distribute>Y</distribute>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <cluster_schema/>
+ <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
+ <xloc>422</xloc>
+ <yloc>154</yloc>
+ <draw>Y</draw>
+ </GUI>
+ </step>
+
+ <step>
<name>output datatype info</name>
<type>Dummy</type>
<description/>
@@ -541,6 +525,24 @@ end</body>
</GUI>
</step>
+ <step>
+ <name>output function info</name>
+ <type>Dummy</type>
+ <description/>
+ <distribute>Y</distribute>
+ <copies>1</copies>
+ <partitioning>
+ <method>none</method>
+ <schema_name/>
+ </partitioning>
+ <cluster_schema/>
+ <remotesteps> <input> </input> <output> </output> </remotesteps> <GUI>
+ <xloc>423</xloc>
+ <yloc>267</yloc>
+ <draw>Y</draw>
+ </GUI>
+ </step>
+
<step_error_handling>
</step_error_handling>
<slave-step-copy-partition-distribution>
@@ -14,16 +14,12 @@
public class BufferStreamReader {
-// private BaseStep step;
-// private SimpleExecutionModel model;
private RubyStepData data;
private RubyArray buffer;
private long readPointer;
public BufferStreamReader(SimpleExecutionModel model, RubyArray buffer) throws KettleStepException{
-// this.model = model;
-// this.step = model.getStep();
this.data = model.getData();
this.buffer = buffer;
@@ -0,0 +1,41 @@
+package org.typeexit.kettle.plugin.steps.ruby;
+
+import org.jruby.embed.ScriptingContainer;
+import org.typeexit.kettle.plugin.steps.ruby.RubyStepMeta.RubyVersion;
+
+import junit.framework.TestCase;
+
+public class TestFactory extends TestCase{
+
+ public void testFactory(){
+
+ ScriptingContainer c = RubyStepFactory.createScriptingContainer(false, RubyVersion.RUBY_1_8);
+ c.runScriptlet("puts \"Ruby version: #{RUBY_VERSION}\"");
+
+ }
+
+ public void testJDBCDrivers(){
+ // this is a regression test for JDBC drivers disappearing from the JVM, since jruby will
+ // remove them by default.
+ // The factory is supposed to create a container that does not do that
+
+ // this script will raise an exception if the org.h2.Driver got unregistered
+ // see http://jira.codehaus.org/browse/JRUBY-5528
+ String testScript = "require 'java'" + "\n" +
+ "Java::org.h2.Driver" + "\n" +
+ "url = 'jdbc:h2:mem:MyDatabase'" + "\n" +
+ "conn = java.sql.DriverManager.get_connection(url, 'H2', '')" + "\n" +
+ "conn.close";
+
+ // if the script can be executed repeatedly, all is fine. It raises an exception
+ // if the driver got unregistered at some point.
+ for (int i=1;i<=5;i++){
+ ScriptingContainer c = RubyStepFactory.createScriptingContainer(false, RubyVersion.RUBY_1_8);
+ c.runScriptlet(testScript);
+ c.terminate();
+ System.out.println("Testing JDBC Driver persistence: iteration "+i);
+ }
+
+ }
+
+}
@@ -11,7 +11,7 @@
//
// NOTE: this is a blackbox test that works on distribution files
-// It should only be run run after "ant testdist" has put a test distribution into place
+// It should only be run run after "ant test-dist" has put a test distribution into place
//
public class TestSamples extends TestCase {
@@ -0,0 +1,10 @@
+package org.typeexit.kettle.plugin.steps.ruby;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses({ TestFactory.class, TestSamples.class })
+public class TestSuite {
+
+}

0 comments on commit 3827bcb

Please sign in to comment.