Index: cpa/src/test/java/org/castor/cpa/query/castorql/TestCastorQLParser.java =================================================================== --- cpa/src/test/java/org/castor/cpa/query/castorql/TestCastorQLParser.java (revision 8897) +++ cpa/src/test/java/org/castor/cpa/query/castorql/TestCastorQLParser.java (working copy) @@ -15,11 +15,13 @@ */ package org.castor.cpa.query.castorql; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.InputStreamReader; -import junit.framework.TestCase; +import org.junit.Test; /** * Junit test for analyzing the performance of CastorQL Parser created by JavaCC @@ -31,15 +33,11 @@ * 2006) $ * @since 1.3 */ -public class TestCastorQLParser extends TestCase { - - // -------------------------------------------------------------------------- - public TestCastorQLParser(final String name) { - super(name); - } - +public class TestCastorQLParser { // -------------------------------------------------------------------------- - public static void testParserPerformance() { + + @Test + public final void testParserPerformance() { System.out.println("start : Castor"); @@ -63,7 +61,29 @@ System.out.println(" in " + (stop - start) / 1000000.0 + " milliseconds"); + } + + @Test + public final void testParserPerformanceTypedParameter() { + + System.out.println("start : Castor"); + + long start = 0L; + start = System.nanoTime(); + + String oql = "SELECT o.item from de.jsci.pcv.jdo.LieferantJDO as o" + + " where $1 = 1000"; + try { + runParser(oql); + long stop = System.nanoTime(); + + System.out.println("end : Castor Parsed :" + oql); + System.out.println(" in " + (stop - start) / 1000000.0 + + " milliseconds"); + } catch (Exception e) { + fail(e.getMessage()); + } } // -------------------------------------------------------------------------- Index: cpa/src/test/java/org/castor/cpa/query/castorql/TestCastorQLTreeWalker.java =================================================================== --- cpa/src/test/java/org/castor/cpa/query/castorql/TestCastorQLTreeWalker.java (revision 8897) +++ cpa/src/test/java/org/castor/cpa/query/castorql/TestCastorQLTreeWalker.java (working copy) @@ -15,16 +15,19 @@ */ package org.castor.cpa.query.castorql; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; -import junit.framework.TestCase; - import org.castor.cpa.query.ParseException; import org.castor.cpa.query.QueryObject; import org.castor.cpa.query.TokenManagerError; +import org.junit.Test; /** * Junit test for testing CastorQL Tree Walker. @@ -34,9 +37,10 @@ * @version $Revision: 7121 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $ * @since 1.3 */ -public class TestCastorQLTreeWalker extends TestCase { +public class TestCastorQLTreeWalker { // -------------------------------------------------------------------------- + @Test public final void testConstructor() { try { @@ -71,6 +75,7 @@ } + @Test public final void testOrderBy() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -87,6 +92,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLimitOffsetWithInt() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -101,6 +107,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLimitOffsetWithParameter() throws UnsupportedEncodingException, ParseException { @@ -116,6 +123,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithBoolean() throws UnsupportedEncodingException, ParseException { @@ -131,6 +139,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithLong() throws UnsupportedEncodingException, ParseException { @@ -146,6 +155,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithDouble() throws UnsupportedEncodingException, ParseException { @@ -161,6 +171,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithString() throws UnsupportedEncodingException, ParseException { @@ -176,6 +187,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithDate() throws UnsupportedEncodingException, ParseException { @@ -191,6 +203,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithTime() throws UnsupportedEncodingException, ParseException { @@ -206,6 +219,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -221,6 +235,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithBoolean() throws UnsupportedEncodingException, ParseException { @@ -238,6 +253,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithLong() throws UnsupportedEncodingException, ParseException { @@ -253,6 +269,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithDouble() throws UnsupportedEncodingException, ParseException { @@ -268,6 +285,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithString() throws UnsupportedEncodingException, ParseException { @@ -283,6 +301,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithDate() throws UnsupportedEncodingException, ParseException { @@ -298,6 +317,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithTime() throws UnsupportedEncodingException, ParseException { @@ -313,6 +333,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -330,6 +351,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithLong() throws UnsupportedEncodingException, ParseException { @@ -345,6 +367,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithDouble() throws UnsupportedEncodingException, ParseException { @@ -360,6 +383,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithString() throws UnsupportedEncodingException, ParseException { @@ -375,6 +399,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithDate() throws UnsupportedEncodingException, ParseException { @@ -390,6 +415,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithTime() throws UnsupportedEncodingException, ParseException { @@ -405,6 +431,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -420,6 +447,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithLong() throws UnsupportedEncodingException, ParseException { @@ -435,6 +463,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithDouble() throws UnsupportedEncodingException, ParseException { @@ -450,6 +479,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithString() throws UnsupportedEncodingException, ParseException { @@ -465,6 +495,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithDate() throws UnsupportedEncodingException, ParseException { @@ -480,6 +511,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithTime() throws UnsupportedEncodingException, ParseException { @@ -495,6 +527,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -510,6 +543,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithLong() throws UnsupportedEncodingException, ParseException { @@ -525,6 +559,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithDouble() throws UnsupportedEncodingException, ParseException { @@ -540,6 +575,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithString() throws UnsupportedEncodingException, ParseException { @@ -555,6 +591,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithDate() throws UnsupportedEncodingException, ParseException { @@ -570,6 +607,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithTime() throws UnsupportedEncodingException, ParseException { @@ -585,6 +623,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -600,6 +639,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithLong() throws UnsupportedEncodingException, ParseException { @@ -615,6 +655,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithDouble() throws UnsupportedEncodingException, ParseException { @@ -630,6 +671,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithString() throws UnsupportedEncodingException, ParseException { @@ -645,6 +687,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithDate() throws UnsupportedEncodingException, ParseException { @@ -660,6 +703,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithTime() throws UnsupportedEncodingException, ParseException { @@ -675,6 +719,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -690,6 +735,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithString() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -704,6 +750,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithStringChar() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -718,6 +765,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithStringParameter() throws UnsupportedEncodingException, ParseException { @@ -733,6 +781,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithParameter() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -747,6 +796,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithParameterChar() throws UnsupportedEncodingException, ParseException { @@ -762,6 +812,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithParameterParameter() throws UnsupportedEncodingException, ParseException { @@ -777,6 +828,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithString() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -791,6 +843,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithStringChar() throws UnsupportedEncodingException, ParseException { @@ -806,6 +859,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithStringParameter() throws UnsupportedEncodingException, ParseException { @@ -821,6 +875,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithParameter() throws UnsupportedEncodingException, ParseException { @@ -836,6 +891,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithParameterChar() throws UnsupportedEncodingException, ParseException { @@ -851,6 +907,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithParameterParameter() throws UnsupportedEncodingException, ParseException { @@ -866,6 +923,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithLong() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -880,6 +938,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithDouble() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -894,6 +953,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithString() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -905,9 +965,8 @@ assertEquals(expected, actual); } - - // -------------------------------------------------------------------------- - + + @Test public final void testBetweenWithDate() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -922,6 +981,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithTime() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -936,6 +996,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -953,6 +1014,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithLong() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -967,6 +1029,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithDouble() throws UnsupportedEncodingException, ParseException { @@ -982,6 +1045,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithString() throws UnsupportedEncodingException, ParseException { @@ -997,6 +1061,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithDate() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1011,6 +1076,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithTime() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1025,6 +1091,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -1042,6 +1109,7 @@ // -------------------------------------------------------------------------- + @Test public final void testInWithPath() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1056,6 +1124,7 @@ // -------------------------------------------------------------------------- + @Test public final void testInParameter() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1070,6 +1139,7 @@ // -------------------------------------------------------------------------- + @Test public final void testInLiterals() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1084,6 +1154,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNull() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1098,6 +1169,7 @@ // -------------------------------------------------------------------------- + @Test public final void testComplex() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1114,6 +1186,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCustomFunction() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1128,6 +1201,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCustomFunctionMoreParameters() throws UnsupportedEncodingException, ParseException { @@ -1143,6 +1217,7 @@ // -------------------------------------------------------------------------- + @Test public final void testUndefinedFunction() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1162,7 +1237,77 @@ assertEquals(expected, actual); } + + // -------------------------------------------------------------------------- + + @Test + public final void testBetweenWithParameter() + throws UnsupportedEncodingException, ParseException { + + String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" + + " where o.deleted betweEn $1 and $2 "; + QueryObject qo = getQO(oql); + String expected = "SELECT DISTINCT o.item FROM de.jsci.pcv.jdo.LieferantJDO AS o " + + "WHERE (o.deleted BETWEEN ?1 AND ?2)"; + String actual = qo.toString(); + assertEquals(expected, actual); + + } + + // -------------------------------------------------------------------------- + @Test + public final void testNumberedParameter() throws UnsupportedEncodingException, ParseException { + String oql = "SELECT o.item from de.jsci.pcv.jdo.LieferantJDO as o " + + "where $1 = 1000"; + QueryObject qo = getQO(oql); + + String expected = "SELECT o.item FROM de.jsci.pcv.jdo.LieferantJDO AS o " + + "WHERE (?1 = 1000)"; + String actual = qo.toString(); + assertEquals(expected, actual); + } + + // -------------------------------------------------------------------------- + + @Test + public final void testTypedNumberedParameter() + throws UnsupportedEncodingException, ParseException { + String oql = "SELECT o.item from de.jsci.pcv.jdo.LieferantJDO as o " + + "where $(int)1 = 1000"; + QueryObject qo = getQO(oql); + + String expected = "SELECT o.item FROM de.jsci.pcv.jdo.LieferantJDO AS o " + + "WHERE (?(int)1 = 1000)"; + String actual = qo.toString(); + assertEquals(expected, actual); + } + + // -------------------------------------------------------------------------- + + @Test + public final void testSelectStar() + throws UnsupportedEncodingException, ParseException { + String oql = "SELECT * from de.jsci.pcv.jdo.LieferantJDO as o "; + QueryObject qo = getQO(oql); + + String expected = "SELECT * FROM de.jsci.pcv.jdo.LieferantJDO AS o "; + String actual = qo.toString(); + assertEquals(expected, actual); + } + + // -------------------------------------------------------------------------- + + @Test + public final void testCountAggregation() throws UnsupportedEncodingException, ParseException { + String oql = "SELECT COUNT(o.item) from de.jsci.pcv.jdo.LieferantJDO as o"; + QueryObject qo = getQO(oql); + + String expected = "SELECT COUNT(o.item) FROM de.jsci.pcv.jdo.LieferantJDO AS o"; + String actual = qo.toString(); + assertEquals(expected, actual); + } + // -------------------------------------------------------------------------- private QueryObject getQO(final String oql) Index: cpa/src/test/java/org/castor/cpa/query/ejbql/TestEjbQLTreeWalker.java =================================================================== --- cpa/src/test/java/org/castor/cpa/query/ejbql/TestEjbQLTreeWalker.java (revision 8897) +++ cpa/src/test/java/org/castor/cpa/query/ejbql/TestEjbQLTreeWalker.java (working copy) @@ -15,16 +15,19 @@ */ package org.castor.cpa.query.ejbql; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; -import junit.framework.TestCase; - import org.castor.cpa.query.ParseException; import org.castor.cpa.query.QueryObject; import org.castor.cpa.query.TokenManagerError; +import org.junit.Test; /** * Junit test for testing EjbQL Tree Walker. @@ -35,9 +38,10 @@ * 2006) $ * @since 1.3 */ -public class TestEjbQLTreeWalker extends TestCase { +public class TestEjbQLTreeWalker { // -------------------------------------------------------------------------- + @Test public final void testConstructor() throws ParseException { try { @@ -72,6 +76,7 @@ } + @Test public final void testOrderBy() throws UnsupportedEncodingException, ParseException { @@ -89,6 +94,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLimitOffsetWithInt() throws UnsupportedEncodingException, ParseException { @@ -104,6 +110,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLimitOffsetWithParameter() throws UnsupportedEncodingException, ParseException { @@ -119,6 +126,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithBoolean() throws UnsupportedEncodingException, ParseException { @@ -134,6 +142,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithLong() throws UnsupportedEncodingException, ParseException { @@ -149,6 +158,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithDouble() throws UnsupportedEncodingException, ParseException { @@ -164,6 +174,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithString() throws UnsupportedEncodingException, ParseException { @@ -179,6 +190,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithDate() throws UnsupportedEncodingException, ParseException { @@ -194,6 +206,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithTime() throws UnsupportedEncodingException, ParseException { @@ -209,6 +222,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareEqualWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -224,6 +238,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithBoolean() throws UnsupportedEncodingException, ParseException { @@ -241,6 +256,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithLong() throws UnsupportedEncodingException, ParseException { @@ -256,6 +272,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithDouble() throws UnsupportedEncodingException, ParseException { @@ -271,6 +288,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithString() throws UnsupportedEncodingException, ParseException { @@ -286,6 +304,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithDate() throws UnsupportedEncodingException, ParseException { @@ -301,6 +320,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithTime() throws UnsupportedEncodingException, ParseException { @@ -316,6 +336,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareNotEqualWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -333,6 +354,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithLong() throws UnsupportedEncodingException, ParseException { @@ -348,6 +370,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithDouble() throws UnsupportedEncodingException, ParseException { @@ -363,6 +386,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithString() throws UnsupportedEncodingException, ParseException { @@ -378,6 +402,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithDate() throws UnsupportedEncodingException, ParseException { @@ -393,6 +418,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithTime() throws UnsupportedEncodingException, ParseException { @@ -408,6 +434,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessThanWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -423,6 +450,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithLong() throws UnsupportedEncodingException, ParseException { @@ -438,6 +466,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithDouble() throws UnsupportedEncodingException, ParseException { @@ -453,6 +482,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithString() throws UnsupportedEncodingException, ParseException { @@ -468,6 +498,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithDate() throws UnsupportedEncodingException, ParseException { @@ -483,6 +514,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithTime() throws UnsupportedEncodingException, ParseException { @@ -498,6 +530,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareLessEqualWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -513,6 +546,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithLong() throws UnsupportedEncodingException, ParseException { @@ -528,6 +562,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithDouble() throws UnsupportedEncodingException, ParseException { @@ -543,6 +578,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithString() throws UnsupportedEncodingException, ParseException { @@ -558,6 +594,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithDate() throws UnsupportedEncodingException, ParseException { @@ -573,6 +610,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithTime() throws UnsupportedEncodingException, ParseException { @@ -588,6 +626,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterEqualWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -603,6 +642,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithLong() throws UnsupportedEncodingException, ParseException { @@ -618,6 +658,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithDouble() throws UnsupportedEncodingException, ParseException { @@ -633,6 +674,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithString() throws UnsupportedEncodingException, ParseException { @@ -648,6 +690,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithDate() throws UnsupportedEncodingException, ParseException { @@ -663,6 +706,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithTime() throws UnsupportedEncodingException, ParseException { @@ -678,6 +722,7 @@ // -------------------------------------------------------------------------- + @Test public final void testCompareGreaterThanWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -693,6 +738,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithString() throws UnsupportedEncodingException, ParseException { @@ -708,6 +754,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithStringChar() throws UnsupportedEncodingException, ParseException { @@ -723,6 +770,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithStringParameter() throws UnsupportedEncodingException, ParseException { @@ -738,6 +786,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithParameter() throws UnsupportedEncodingException, ParseException { @@ -753,6 +802,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithParameterChar() throws UnsupportedEncodingException, ParseException { @@ -768,6 +818,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLikeWithParameterParameter() throws UnsupportedEncodingException, ParseException { @@ -783,6 +834,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithString() throws UnsupportedEncodingException, ParseException { @@ -798,6 +850,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithStringChar() throws UnsupportedEncodingException, ParseException { @@ -813,6 +866,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithStringParameter() throws UnsupportedEncodingException, ParseException { @@ -828,6 +882,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithParameter() throws UnsupportedEncodingException, ParseException { @@ -843,6 +898,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithParameterChar() throws UnsupportedEncodingException, ParseException { @@ -858,6 +914,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotLikeWithParameterParameter() throws UnsupportedEncodingException, ParseException { @@ -873,6 +930,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithLong() throws UnsupportedEncodingException, ParseException { @@ -888,6 +946,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithDouble() throws UnsupportedEncodingException, ParseException { @@ -903,6 +962,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithString() throws UnsupportedEncodingException, ParseException { @@ -918,6 +978,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithDate() throws UnsupportedEncodingException, ParseException { @@ -933,6 +994,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithTime() throws UnsupportedEncodingException, ParseException { @@ -948,6 +1010,7 @@ // -------------------------------------------------------------------------- + @Test public final void testBetweenWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -965,6 +1028,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithLong() throws UnsupportedEncodingException, ParseException { @@ -980,6 +1044,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithDouble() throws UnsupportedEncodingException, ParseException { @@ -995,6 +1060,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithString() throws UnsupportedEncodingException, ParseException { @@ -1010,6 +1076,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithDate() throws UnsupportedEncodingException, ParseException { @@ -1025,6 +1092,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithTime() throws UnsupportedEncodingException, ParseException { @@ -1040,6 +1108,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNotBetweenWithTimestamp() throws UnsupportedEncodingException, ParseException { @@ -1057,6 +1126,7 @@ // -------------------------------------------------------------------------- + @Test public final void testInWithPath() throws UnsupportedEncodingException, ParseException { @@ -1074,6 +1144,7 @@ // -------------------------------------------------------------------------- + @Test public final void testInWithPathFail() throws UnsupportedEncodingException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1090,6 +1161,7 @@ // -------------------------------------------------------------------------- + @Test public final void testInParameter() throws UnsupportedEncodingException, ParseException { @@ -1105,6 +1177,7 @@ // -------------------------------------------------------------------------- + @Test public final void testInLiterals() throws UnsupportedEncodingException, ParseException { @@ -1120,6 +1193,7 @@ // -------------------------------------------------------------------------- + @Test public final void testNull() throws UnsupportedEncodingException, ParseException { @@ -1135,6 +1209,7 @@ // -------------------------------------------------------------------------- + @Test public final void testComplex() throws UnsupportedEncodingException, ParseException { @@ -1152,6 +1227,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLengthFunction() throws UnsupportedEncodingException, ParseException { @@ -1167,6 +1243,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLocateFunction() throws UnsupportedEncodingException, ParseException { @@ -1190,6 +1267,7 @@ // -------------------------------------------------------------------------- + @Test public final void testAbsFunction() throws UnsupportedEncodingException, ParseException { @@ -1205,6 +1283,7 @@ // -------------------------------------------------------------------------- + @Test public final void testSqrtFunction() throws UnsupportedEncodingException, ParseException { @@ -1220,6 +1299,7 @@ // -------------------------------------------------------------------------- + @Test public final void testModFunction() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1234,6 +1314,7 @@ // -------------------------------------------------------------------------- + @Test public final void testConcateFunction() throws UnsupportedEncodingException, ParseException { @@ -1249,6 +1330,7 @@ // -------------------------------------------------------------------------- + @Test public final void testSubstringFunction() throws UnsupportedEncodingException, ParseException { @@ -1264,6 +1346,7 @@ // -------------------------------------------------------------------------- + @Test public final void testTrimFunction() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1301,6 +1384,7 @@ // -------------------------------------------------------------------------- + @Test public final void testLowerFunction() throws UnsupportedEncodingException, ParseException { @@ -1314,6 +1398,7 @@ } + @Test public final void testUpperFunction() throws UnsupportedEncodingException, ParseException { String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" @@ -1327,6 +1412,76 @@ } // -------------------------------------------------------------------------- + + @Test + public final void testBetweenWithParameter() + throws UnsupportedEncodingException, ParseException { + + String oql = "SelecT DisTinct o.item from de.jsci.pcv.jdo.LieferantJDO as o" + + " where o.deleted betweEn $1 and $2 "; + QueryObject qo = getQO(oql); + String expected = "SELECT DISTINCT o.item FROM de.jsci.pcv.jdo.LieferantJDO AS o " + + "WHERE (o.deleted BETWEEN ?1 AND ?2)"; + String actual = qo.toString(); + assertEquals(expected, actual); + + } + + // -------------------------------------------------------------------------- + + @Test + public final void testNumberedParameter() throws UnsupportedEncodingException, ParseException { + String oql = "SELECT o.item from de.jsci.pcv.jdo.LieferantJDO as o " + + "where $1 = 1000"; + QueryObject qo = getQO(oql); + + String expected = "SELECT o.item FROM de.jsci.pcv.jdo.LieferantJDO AS o " + + "WHERE (?1 = 1000)"; + String actual = qo.toString(); + assertEquals(expected, actual); + } + + // -------------------------------------------------------------------------- + + @Test + public final void testTypedNumberedParameter() + throws UnsupportedEncodingException, ParseException { + String oql = "SELECT o.item from de.jsci.pcv.jdo.LieferantJDO as o " + + "where $(int)1 = 1000"; + QueryObject qo = getQO(oql); + + String expected = "SELECT o.item FROM de.jsci.pcv.jdo.LieferantJDO AS o " + + "WHERE (?(int)1 = 1000)"; + String actual = qo.toString(); + assertEquals(expected, actual); + } + + // -------------------------------------------------------------------------- + + @Test + public final void testSelectStar() + throws UnsupportedEncodingException, ParseException { + String oql = "SELECT * from de.jsci.pcv.jdo.LieferantJDO as o "; + QueryObject qo = getQO(oql); + + String expected = "SELECT * FROM de.jsci.pcv.jdo.LieferantJDO AS o "; + String actual = qo.toString(); + assertEquals(expected, actual); + } + + // -------------------------------------------------------------------------- + + @Test + public final void testCountAggregation() throws UnsupportedEncodingException, ParseException { + String oql = "SELECT COUNT(o.item) from de.jsci.pcv.jdo.LieferantJDO as o"; + QueryObject qo = getQO(oql); + + String expected = "SELECT COUNT(o.item) FROM de.jsci.pcv.jdo.LieferantJDO AS o"; + String actual = qo.toString(); + assertEquals(expected, actual); + } + + // -------------------------------------------------------------------------- private QueryObject getQO(final String oql) throws UnsupportedEncodingException, ParseException {