Author: doogie
Date: Mon Aug 2 17:42:33 2010 New Revision: 981623 URL: http://svn.apache.org/viewvc?rev=981623&view=rev Log: TESTS: Test reparsing of all statements. Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/SQLTest.java Modified: ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/SQLTest.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/SQLTest.java?rev=981623&r1=981622&r2=981623&view=diff ============================================================================== --- ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/SQLTest.java (original) +++ ofbiz/trunk/framework/sql/src/org/ofbiz/sql/test/SQLTest.java Mon Aug 2 17:42:33 2010 @@ -18,6 +18,8 @@ */ package org.ofbiz.sql.test; +import java.io.StringReader; +import java.net.URL; import java.util.Collections; import java.util.Iterator; import java.util.List; @@ -61,6 +63,10 @@ public class SQLTest extends GenericTest super(name); } + private static Parser parser(SQLStatement s) throws Exception { + return new Parser(new StringReader(s.toString())); + } + public void testParse() throws Exception { List<SQLStatement<?>> statements = new Parser(getClass().getResourceAsStream("GoodParseAll.sql")).SQLFile(); for (SQLStatement<?> statement: statements) { @@ -138,6 +144,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("firstSelect", select, stmt); + assertEquals("firstSelect:parse", parser(select).SelectStatement(), parser(stmt).SelectStatement()); } { SQLInsert insert = new SQLInsert( @@ -152,6 +159,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("firstInsert", insert, stmt); + assertEquals("firstInsert:parse", parser(insert).InsertStatement(), parser(stmt).InsertStatement()); } { SQLInsert insert = new SQLInsert( @@ -176,6 +184,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("secondInsert", insert, stmt); + assertEquals("secondInsert:parse", parser(insert).InsertStatement(), parser(stmt).InsertStatement()); } { SQLUpdate update = new SQLUpdate( @@ -187,6 +196,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("firstUpdate", update, stmt); + assertEquals("firstUpdate:parse", parser(update).UpdateStatement(), parser(stmt).UpdateStatement()); } { SQLUpdate update = new SQLUpdate( @@ -200,6 +210,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("secondUpdate", update, stmt); + assertEquals("secondUpdate:parse", parser(update).UpdateStatement(), parser(stmt).UpdateStatement()); } { SQLUpdate update = new SQLUpdate( @@ -214,6 +225,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("thirdUpdate", update, stmt); + assertEquals("thirdUpdate:parse", parser(update).UpdateStatement(), parser(stmt).UpdateStatement()); } { SQLDelete delete = new SQLDelete( @@ -222,6 +234,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("firstDelete", delete, stmt); + assertEquals("firstDelete:parse", parser(delete).DeleteStatement(), parser(stmt).DeleteStatement()); } { SQLDelete delete = new SQLDelete( @@ -230,6 +243,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("secondDelete", delete, stmt); + assertEquals("secondDelete:parse", parser(delete).DeleteStatement(), parser(stmt).DeleteStatement()); } { SQLView view = new SQLView( @@ -250,6 +264,7 @@ public class SQLTest extends GenericTest ); SQLStatement stmt = stmtIt.next(); assertEquals("firstView", view, stmt); + assertEquals("firstView:parse", parser(view).ViewStatement(), parser(stmt).ViewStatement()); } } /* |
Free forum by Nabble | Edit this page |