Commits

tbrugz committed 719e177

test: added DiffTwoQueriesTest

Comments (0)

Files changed (3)

src_test/tbrugz/sqldiff/DiffTwoQueriesTest.java

+package tbrugz.sqldiff;
+
+import java.util.Properties;
+
+import org.junit.Test;
+
+public class DiffTwoQueriesTest {
+
+	@Test
+	public void testNoDiff() throws Exception {
+		Properties p = new Properties();
+		p.load(DiffTwoQueriesTest.class.getResourceAsStream("diff2qtest.properties"));
+		DiffTwoQueries d2q = new DiffTwoQueries();
+		d2q.doMain(new String[]{}, p);
+	}
+
+	@Test(expected=RuntimeException.class)
+	public void testError() throws Exception {
+		Properties p = new Properties();
+		p.load(DiffTwoQueriesTest.class.getResourceAsStream("diff2qtest.properties"));
+		p.setProperty("diff2q.keycols", "idx");
+		DiffTwoQueries d2q = new DiffTwoQueries();
+		d2q.doMain(new String[]{}, p);
+	}
+}

src_test/tbrugz/sqldiff/diff2qtest.properties

+
+diff2q.targetsql=\
+select 1 as id, 'one' as desc union all \
+select 2, 'two' union all \
+select 3, 'tree'
+diff2q.sourcesql=\
+select 1 as id, 'one' as desc union all \
+select 2, 'two' union all \
+select 3, 'tree'
+diff2q.keycols=ID
+
+diff2q.driverclass=org.h2.Driver
+diff2q.dburl=jdbc:h2:mem:r2g

src_test/tbrugz/sqldump/AllTestSuite.java

 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
+import tbrugz.sqldiff.DiffTwoQueriesTest;
 import tbrugz.sqldiff.SQLDiffMainTest;
 import tbrugz.sqldiff.apply.DiffApplyTest;
 import tbrugz.sqldiff.datadiff.ResultSetDiffTest;
 	//diff
 	DiffFromJAXB.class,
 	ResultSetDiffTest.class,
+	DiffTwoQueriesTest.class,
 
 	//diff + database
 	SQLDiffTest.class,