================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tldev/source/essentials/oracle/toplink/essentials/exceptions/EJBQLException.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.18 Report generated at Thu Oct 12 16:18:02 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.18 Thu Oct 12 15:27:58 2006 --- /ade/shanchen_toplink_main_temp/tldev/source/essentials/oracle/toplink/essentials/exceptions/EJBQLException.java Thu Oct 12 16:18:02 2006 *************** *** 24,29 **** --- 24,31 ---- import java.util.*; import oracle.toplink.essentials.exceptions.i18n.*; + import persistence.antlr.ANTLRException; + /** *
Purpose: EJBQL parsing and resolution problems will raise this exception */ *************** *** 332,368 **** return exception; } ! public static EJBQLException syntaxError(String query) { Object[] args = { query }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, syntaxError, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(syntaxError); return exception; } ! public static EJBQLException syntaxErrorAt(String query, String token) { Object[] args = { query, token }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, syntaxErrorAt, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(syntaxErrorAt); return exception; } ! public static EJBQLException unexpectedToken(String query, String token) { Object[] args = { query, token }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, unexpectedToken, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(unexpectedToken); return exception; } ! public static EJBQLException unexpectedChar(String query, String unexpected) { Object[] args = { query, unexpected }; String message = ExceptionMessageGenerator.buildMessage( --- 334,370 ---- return exception; } ! public static EJBQLException syntaxError(String query, ANTLRException ex) { Object[] args = { query }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, syntaxError, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(syntaxError); return exception; } ! public static EJBQLException syntaxErrorAt(String query, String token, ANTLRException ex) { Object[] args = { query, token }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, syntaxErrorAt, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(syntaxErrorAt); return exception; } ! public static EJBQLException unexpectedToken(String query, String token, ANTLRException ex) { Object[] args = { query, token }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, unexpectedToken, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(unexpectedToken); return exception; } ! public static EJBQLException unexpectedChar(String query, String unexpected, ANTLRException ex) { Object[] args = { query, unexpected }; String message = ExceptionMessageGenerator.buildMessage( *************** *** 372,393 **** return exception; } ! public static EJBQLException expectedCharFound(String query, String expected, String found) { Object[] args = { query, expected, found }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, expectedCharFound, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(expectedCharFound); return exception; } ! public static EJBQLException unexpectedEOF(String query) { Object[] args = { query }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, unexpectedEOF, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(unexpectedEOF); return exception; } --- 374,395 ---- return exception; } ! public static EJBQLException expectedCharFound(String query, String expected, String found, ANTLRException ex) { Object[] args = { query, expected, found }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, expectedCharFound, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(expectedCharFound); return exception; } ! public static EJBQLException unexpectedEOF(String query, ANTLRException ex) { Object[] args = { query }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, unexpectedEOF, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(unexpectedEOF); return exception; } ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tldev/source/essentials/oracle/toplink/essentials/internal/parsing/ejbql/EJBQLParserBase.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.17 Report generated at Thu Oct 12 16:18:03 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.17 Thu Oct 12 15:29:03 2006 --- /ade/shanchen_toplink_main_temp/tldev/source/essentials/oracle/toplink/essentials/internal/parsing/ejbql/EJBQLParserBase.java Thu Oct 12 16:18:02 2006 *************** *** 205,222 **** addError(error); } ! /** */ protected EJBQLException handleANTLRException(ANTLRException ex) { EJBQLException result = null; if (ex instanceof MismatchedCharException) { MismatchedCharException mismatched = (MismatchedCharException)ex; if (mismatched.foundChar == EOF_CHAR) { ! result = EJBQLException.unexpectedEOF(getEjbqlString()); } else if (mismatched.mismatchType == MismatchedCharException.CHAR) { result = EJBQLException.expectedCharFound( getEjbqlString(), String.valueOf((char)mismatched.expecting), ! String.valueOf((char)mismatched.foundChar)); } } else if (ex instanceof MismatchedTokenException) { --- 205,223 ---- addError(error); } ! /** */ ! //gf1166 Wrap ANTLRException inside EJBQLException protected EJBQLException handleANTLRException(ANTLRException ex) { EJBQLException result = null; if (ex instanceof MismatchedCharException) { MismatchedCharException mismatched = (MismatchedCharException)ex; if (mismatched.foundChar == EOF_CHAR) { ! result = EJBQLException.unexpectedEOF(getEjbqlString(), ex); } else if (mismatched.mismatchType == MismatchedCharException.CHAR) { result = EJBQLException.expectedCharFound( getEjbqlString(), String.valueOf((char)mismatched.expecting), ! String.valueOf((char)mismatched.foundChar), ex); } } else if (ex instanceof MismatchedTokenException) { *************** *** 224,234 **** Token token = mismatched.token; if (token != null) { if (token.getType() == Token.EOF_TYPE) { ! result = EJBQLException.unexpectedEOF(getEjbqlString()); } else { result = EJBQLException.syntaxErrorAt( ! getEjbqlString(), token.getText()); } } } --- 225,235 ---- Token token = mismatched.token; if (token != null) { if (token.getType() == Token.EOF_TYPE) { ! result = EJBQLException.unexpectedEOF(getEjbqlString(), ex); } else { result = EJBQLException.syntaxErrorAt( ! getEjbqlString(), token.getText(), ex); } } } *************** *** 236,253 **** Token token = ((NoViableAltException)ex).token; if (token != null) { if (token.getType() == Token.EOF_TYPE) { ! result = EJBQLException.unexpectedEOF(getEjbqlString()); } else { result = EJBQLException.unexpectedToken( ! getEjbqlString(), token.getText()); } } } else if (ex instanceof NoViableAltForCharException) { NoViableAltForCharException noViableAlt = (NoViableAltForCharException)ex; result = EJBQLException.unexpectedChar( ! getEjbqlString(), String.valueOf((char)noViableAlt.foundChar)); } else if (ex instanceof TokenStreamRecognitionException) { result = handleANTLRException(((TokenStreamRecognitionException)ex).recog); --- 237,254 ---- Token token = ((NoViableAltException)ex).token; if (token != null) { if (token.getType() == Token.EOF_TYPE) { ! result = EJBQLException.unexpectedEOF(getEjbqlString(), ex); } else { result = EJBQLException.unexpectedToken( ! getEjbqlString(), token.getText(), ex); } } } else if (ex instanceof NoViableAltForCharException) { NoViableAltForCharException noViableAlt = (NoViableAltForCharException)ex; result = EJBQLException.unexpectedChar( ! getEjbqlString(), String.valueOf((char)noViableAlt.foundChar), ex); } else if (ex instanceof TokenStreamRecognitionException) { result = handleANTLRException(((TokenStreamRecognitionException)ex).recog); *************** *** 256,262 **** if (result == null) { // no special handling from aboves matches the exception if this // line is reached => make it a syntax error ! result = EJBQLException.syntaxError(getEjbqlString()); } return result; } --- 257,263 ---- if (result == null) { // no special handling from aboves matches the exception if this // line is reached => make it a syntax error ! result = EJBQLException.syntaxError(getEjbqlString(), ex); } return result; } ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/ejb/ejbqltesting/JUnitEJBQLValidationTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.25 Report generated at Thu Oct 12 16:18:03 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.25 Thu Oct 12 15:30:39 2006 --- /ade/shanchen_toplink_main_temp/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/ejb/ejbqltesting/JUnitEJBQLValidationTestSuite.java Thu Oct 12 16:18:02 2006 *************** *** 75,80 **** --- 75,82 ---- import oracle.toplink.essentials.testing.models.cmp3.advanced.AdvancedTableCreator; import oracle.toplink.essentials.threetier.ServerSession; + import persistence.antlr.ANTLRException; + /** *
* Purpose: Test EJBQL exceptions. *************** *** 125,130 **** --- 127,134 ---- suite.addTest(new JUnitEJBQLValidationTestSuite("malformedEjbqlExceptionTest5")); suite.addTest(new JUnitEJBQLValidationTestSuite("malformedEjbqlExceptionTest6")); suite.addTest(new JUnitEJBQLValidationTestSuite("malformedEjbqlExceptionTest7")); + //gf1166 + suite.addTest(new JUnitEJBQLValidationTestSuite("malformedEjbqlExceptionTest8")); suite.addTest(new JUnitEJBQLValidationTestSuite("badAliasExceptionTest")); suite.addTest(new JUnitEJBQLValidationTestSuite("noAliasWithWHEREAndParameterExceptionTest")); suite.addTest(new JUnitEJBQLValidationTestSuite("missingDescriptorExceptionTest")); *************** *** 489,494 **** --- 493,518 ---- } + //gf1166 Wrap ANTLRException inside EJBQLException + public void malformedEjbqlExceptionTest8() + { + + String ejbqlString = "SELECT e FROM"; + + try + { + List result = createEntityManager().createQuery(ejbqlString).getResultList(); + fail("Expected unexpected end of query exception."); + } + + catch(IllegalArgumentException ex) + { + assertFalse("Failed to wrap the exception", ((EJBQLException) ex.getCause()).getInternalException() == null); + assertTrue("Failed to wrap the ANTLRException", ((EJBQLException) ex.getCause()).getInternalException() instanceof ANTLRException); + } + + } + public void badAliasExceptionTest() { ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tltest/source/essentials/oracle/toplink/essentials/testing/tests/ejbql/EJBQLExceptionTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.4 Report generated at Thu Oct 12 16:18:03 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.4 Thu Oct 12 15:47:24 2006 --- /ade/shanchen_toplink_main_temp/tltest/source/essentials/oracle/toplink/essentials/testing/tests/ejbql/EJBQLExceptionTest.java Thu Oct 12 16:18:02 2006 *************** *** 14,20 **** public static EJBQLExceptionTest recognitionExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROW Employee emp"); theTest.setName("Recognition Exception Test"); return theTest; --- 14,20 ---- public static EJBQLExceptionTest recognitionExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROW Employee emp"); theTest.setName("Recognition Exception Test"); return theTest; *************** *** 22,28 **** public static EJBQLExceptionTest missingSelectExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("OBJECT(emp) FROM Employee emp"); theTest.setName("Missing Select Exception Test"); return theTest; --- 22,28 ---- public static EJBQLExceptionTest missingSelectExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("OBJECT(emp) FROM Employee emp"); theTest.setName("Missing Select Exception Test"); return theTest; *************** *** 30,36 **** public static EJBQLExceptionTest malformedEjbqlExceptionTest1() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName == \"Fred\""); theTest.setName("Malformed EJBQL Exception Test1"); return theTest; --- 30,36 ---- public static EJBQLExceptionTest malformedEjbqlExceptionTest1() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName == \"Fred\""); theTest.setName("Malformed EJBQL Exception Test1"); return theTest; *************** *** 38,44 **** public static EJBQLExceptionTest malformedEjbqlExceptionTest2() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" AND 1"); theTest.setName("Malformed EJBQL Exception Test2"); return theTest; --- 38,44 ---- public static EJBQLExceptionTest malformedEjbqlExceptionTest2() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" AND 1"); theTest.setName("Malformed EJBQL Exception Test2"); return theTest; *************** *** 46,52 **** public static EJBQLExceptionTest malformedEjbqlExceptionTest3() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" OR \"Freda\""); theTest.setName("Malformed EJBQL Exception Test3"); return theTest; --- 46,52 ---- public static EJBQLExceptionTest malformedEjbqlExceptionTest3() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" OR \"Freda\""); theTest.setName("Malformed EJBQL Exception Test3"); return theTest; *************** *** 54,60 **** public static EJBQLExceptionTest malformedEjbqlExceptionTest4() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SLEECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" OR \"Freda\""); theTest.setName("Malformed EJBQL Exception Test4"); return theTest; --- 54,60 ---- public static EJBQLExceptionTest malformedEjbqlExceptionTest4() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SLEECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" OR \"Freda\""); theTest.setName("Malformed EJBQL Exception Test4"); return theTest; *************** *** 71,77 **** //This test produced a stack overflow in the Beta of Pine public static EJBQLExceptionTest noAliasWithWHEREAndParameterExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("FROM Employee WHERE firstName = ?1"); theTest.setName("No Alias With WHERE and Parameter Exception Test"); return theTest; --- 71,77 ---- //This test produced a stack overflow in the Beta of Pine public static EJBQLExceptionTest noAliasWithWHEREAndParameterExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("FROM Employee WHERE firstName = ?1"); theTest.setName("No Alias With WHERE and Parameter Exception Test"); return theTest; *************** *** 79,85 **** public static EJBQLExceptionTest generalExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SELECT FROM EMPLOYEE emp"); theTest.setName("General Exception test"); --- 79,85 ---- public static EJBQLExceptionTest generalExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SELECT FROM EMPLOYEE emp"); theTest.setName("General Exception test"); ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tltest/source/essentials/oracle/toplink/essentials/testing/tests/ejbql/IdentifierTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.3 Report generated at Thu Oct 12 16:18:03 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.3 Thu Oct 12 15:47:36 2006 --- /ade/shanchen_toplink_main_temp/tltest/source/essentials/oracle/toplink/essentials/testing/tests/ejbql/IdentifierTest.java Thu Oct 12 16:18:02 2006 *************** *** 50,56 **** EJBQLExceptionTest theTest = new EJBQLExceptionTest(); theTest.setName("Bad Identifier test1"); theTest.setEjbqlString("SELECT OBJECT(+emp1) FROM Employee +emp1"); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null); return theTest; } --- 50,56 ---- EJBQLExceptionTest theTest = new EJBQLExceptionTest(); theTest.setName("Bad Identifier test1"); theTest.setEjbqlString("SELECT OBJECT(+emp1) FROM Employee +emp1"); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null, null); return theTest; } *************** *** 59,65 **** EJBQLExceptionTest theTest = new EJBQLExceptionTest(); theTest.setName("Bad Identifier test2"); theTest.setEjbqlString("SELECT OBJECT(emp 1) FROM Employee emp 1"); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null); return theTest; } --- 59,65 ---- EJBQLExceptionTest theTest = new EJBQLExceptionTest(); theTest.setName("Bad Identifier test2"); theTest.setEjbqlString("SELECT OBJECT(emp 1) FROM Employee emp 1"); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null, null); return theTest; } ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tldev/source/essentials/oracle/toplink/essentials/exceptions/EJBQLException.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.18 Report generated at Thu Oct 12 16:19:02 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000003/AB0952363AC40CBFE034080020E8C54E.18 Thu Oct 12 15:27:58 2006 --- /ade/shanchen_toplink_main_temp/tldev/source/essentials/oracle/toplink/essentials/exceptions/EJBQLException.java Thu Oct 12 16:18:02 2006 *************** *** 24,29 **** --- 24,31 ---- import java.util.*; import oracle.toplink.essentials.exceptions.i18n.*; + import persistence.antlr.ANTLRException; + /** *
Purpose: EJBQL parsing and resolution problems will raise this exception */ *************** *** 332,368 **** return exception; } ! public static EJBQLException syntaxError(String query) { Object[] args = { query }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, syntaxError, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(syntaxError); return exception; } ! public static EJBQLException syntaxErrorAt(String query, String token) { Object[] args = { query, token }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, syntaxErrorAt, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(syntaxErrorAt); return exception; } ! public static EJBQLException unexpectedToken(String query, String token) { Object[] args = { query, token }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, unexpectedToken, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(unexpectedToken); return exception; } ! public static EJBQLException unexpectedChar(String query, String unexpected) { Object[] args = { query, unexpected }; String message = ExceptionMessageGenerator.buildMessage( --- 334,370 ---- return exception; } ! public static EJBQLException syntaxError(String query, ANTLRException ex) { Object[] args = { query }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, syntaxError, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(syntaxError); return exception; } ! public static EJBQLException syntaxErrorAt(String query, String token, ANTLRException ex) { Object[] args = { query, token }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, syntaxErrorAt, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(syntaxErrorAt); return exception; } ! public static EJBQLException unexpectedToken(String query, String token, ANTLRException ex) { Object[] args = { query, token }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, unexpectedToken, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(unexpectedToken); return exception; } ! public static EJBQLException unexpectedChar(String query, String unexpected, ANTLRException ex) { Object[] args = { query, unexpected }; String message = ExceptionMessageGenerator.buildMessage( *************** *** 372,393 **** return exception; } ! public static EJBQLException expectedCharFound(String query, String expected, String found) { Object[] args = { query, expected, found }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, expectedCharFound, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(expectedCharFound); return exception; } ! public static EJBQLException unexpectedEOF(String query) { Object[] args = { query }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, unexpectedEOF, args); ! EJBQLException exception = new EJBQLException(message); exception.setErrorCode(unexpectedEOF); return exception; } --- 374,395 ---- return exception; } ! public static EJBQLException expectedCharFound(String query, String expected, String found, ANTLRException ex) { Object[] args = { query, expected, found }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, expectedCharFound, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(expectedCharFound); return exception; } ! public static EJBQLException unexpectedEOF(String query, ANTLRException ex) { Object[] args = { query }; String message = ExceptionMessageGenerator.buildMessage( EJBQLException.class, unexpectedEOF, args); ! EJBQLException exception = new EJBQLException(message, ex); exception.setErrorCode(unexpectedEOF); return exception; } ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tldev/source/essentials/oracle/toplink/essentials/internal/parsing/ejbql/EJBQLParserBase.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.17 Report generated at Thu Oct 12 16:19:02 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000004/AB0952363AC40CBFE034080020E8C54E.17 Thu Oct 12 15:29:03 2006 --- /ade/shanchen_toplink_main_temp/tldev/source/essentials/oracle/toplink/essentials/internal/parsing/ejbql/EJBQLParserBase.java Thu Oct 12 16:18:02 2006 *************** *** 205,222 **** addError(error); } ! /** */ protected EJBQLException handleANTLRException(ANTLRException ex) { EJBQLException result = null; if (ex instanceof MismatchedCharException) { MismatchedCharException mismatched = (MismatchedCharException)ex; if (mismatched.foundChar == EOF_CHAR) { ! result = EJBQLException.unexpectedEOF(getEjbqlString()); } else if (mismatched.mismatchType == MismatchedCharException.CHAR) { result = EJBQLException.expectedCharFound( getEjbqlString(), String.valueOf((char)mismatched.expecting), ! String.valueOf((char)mismatched.foundChar)); } } else if (ex instanceof MismatchedTokenException) { --- 205,223 ---- addError(error); } ! /** */ ! //gf1166 Wrap ANTLRException inside EJBQLException protected EJBQLException handleANTLRException(ANTLRException ex) { EJBQLException result = null; if (ex instanceof MismatchedCharException) { MismatchedCharException mismatched = (MismatchedCharException)ex; if (mismatched.foundChar == EOF_CHAR) { ! result = EJBQLException.unexpectedEOF(getEjbqlString(), ex); } else if (mismatched.mismatchType == MismatchedCharException.CHAR) { result = EJBQLException.expectedCharFound( getEjbqlString(), String.valueOf((char)mismatched.expecting), ! String.valueOf((char)mismatched.foundChar), ex); } } else if (ex instanceof MismatchedTokenException) { *************** *** 224,234 **** Token token = mismatched.token; if (token != null) { if (token.getType() == Token.EOF_TYPE) { ! result = EJBQLException.unexpectedEOF(getEjbqlString()); } else { result = EJBQLException.syntaxErrorAt( ! getEjbqlString(), token.getText()); } } } --- 225,235 ---- Token token = mismatched.token; if (token != null) { if (token.getType() == Token.EOF_TYPE) { ! result = EJBQLException.unexpectedEOF(getEjbqlString(), ex); } else { result = EJBQLException.syntaxErrorAt( ! getEjbqlString(), token.getText(), ex); } } } *************** *** 236,253 **** Token token = ((NoViableAltException)ex).token; if (token != null) { if (token.getType() == Token.EOF_TYPE) { ! result = EJBQLException.unexpectedEOF(getEjbqlString()); } else { result = EJBQLException.unexpectedToken( ! getEjbqlString(), token.getText()); } } } else if (ex instanceof NoViableAltForCharException) { NoViableAltForCharException noViableAlt = (NoViableAltForCharException)ex; result = EJBQLException.unexpectedChar( ! getEjbqlString(), String.valueOf((char)noViableAlt.foundChar)); } else if (ex instanceof TokenStreamRecognitionException) { result = handleANTLRException(((TokenStreamRecognitionException)ex).recog); --- 237,254 ---- Token token = ((NoViableAltException)ex).token; if (token != null) { if (token.getType() == Token.EOF_TYPE) { ! result = EJBQLException.unexpectedEOF(getEjbqlString(), ex); } else { result = EJBQLException.unexpectedToken( ! getEjbqlString(), token.getText(), ex); } } } else if (ex instanceof NoViableAltForCharException) { NoViableAltForCharException noViableAlt = (NoViableAltForCharException)ex; result = EJBQLException.unexpectedChar( ! getEjbqlString(), String.valueOf((char)noViableAlt.foundChar), ex); } else if (ex instanceof TokenStreamRecognitionException) { result = handleANTLRException(((TokenStreamRecognitionException)ex).recog); *************** *** 256,262 **** if (result == null) { // no special handling from aboves matches the exception if this // line is reached => make it a syntax error ! result = EJBQLException.syntaxError(getEjbqlString()); } return result; } --- 257,263 ---- if (result == null) { // no special handling from aboves matches the exception if this // line is reached => make it a syntax error ! result = EJBQLException.syntaxError(getEjbqlString(), ex); } return result; } ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/ejb/ejbqltesting/JUnitEJBQLValidationTestSuite.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.25 Report generated at Thu Oct 12 16:19:02 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000005/AB0952363AC40CBFE034080020E8C54E.25 Thu Oct 12 15:30:39 2006 --- /ade/shanchen_toplink_main_temp/tltest/source/entity-persistence-tests/src/java/oracle/toplink/essentials/testing/tests/ejb/ejbqltesting/JUnitEJBQLValidationTestSuite.java Thu Oct 12 16:18:02 2006 *************** *** 75,80 **** --- 75,82 ---- import oracle.toplink.essentials.testing.models.cmp3.advanced.AdvancedTableCreator; import oracle.toplink.essentials.threetier.ServerSession; + import persistence.antlr.ANTLRException; + /** *
* Purpose: Test EJBQL exceptions. *************** *** 125,130 **** --- 127,134 ---- suite.addTest(new JUnitEJBQLValidationTestSuite("malformedEjbqlExceptionTest5")); suite.addTest(new JUnitEJBQLValidationTestSuite("malformedEjbqlExceptionTest6")); suite.addTest(new JUnitEJBQLValidationTestSuite("malformedEjbqlExceptionTest7")); + //gf1166 + suite.addTest(new JUnitEJBQLValidationTestSuite("malformedEjbqlExceptionTest8")); suite.addTest(new JUnitEJBQLValidationTestSuite("badAliasExceptionTest")); suite.addTest(new JUnitEJBQLValidationTestSuite("noAliasWithWHEREAndParameterExceptionTest")); suite.addTest(new JUnitEJBQLValidationTestSuite("missingDescriptorExceptionTest")); *************** *** 489,494 **** --- 493,518 ---- } + //gf1166 Wrap ANTLRException inside EJBQLException + public void malformedEjbqlExceptionTest8() + { + + String ejbqlString = "SELECT e FROM"; + + try + { + List result = createEntityManager().createQuery(ejbqlString).getResultList(); + fail("Expected unexpected end of query exception."); + } + + catch(IllegalArgumentException ex) + { + assertFalse("Failed to wrap the exception", ((EJBQLException) ex.getCause()).getInternalException() == null); + assertTrue("Failed to wrap the ANTLRException", ((EJBQLException) ex.getCause()).getInternalException() instanceof ANTLRException); + } + + } + public void badAliasExceptionTest() { ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tltest/source/essentials/oracle/toplink/essentials/testing/tests/ejbql/EJBQLExceptionTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.4 Report generated at Thu Oct 12 16:19:02 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000006/AB0952363AC40CBFE034080020E8C54E.4 Thu Oct 12 15:47:24 2006 --- /ade/shanchen_toplink_main_temp/tltest/source/essentials/oracle/toplink/essentials/testing/tests/ejbql/EJBQLExceptionTest.java Thu Oct 12 16:18:02 2006 *************** *** 14,20 **** public static EJBQLExceptionTest recognitionExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROW Employee emp"); theTest.setName("Recognition Exception Test"); return theTest; --- 14,20 ---- public static EJBQLExceptionTest recognitionExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROW Employee emp"); theTest.setName("Recognition Exception Test"); return theTest; *************** *** 22,28 **** public static EJBQLExceptionTest missingSelectExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("OBJECT(emp) FROM Employee emp"); theTest.setName("Missing Select Exception Test"); return theTest; --- 22,28 ---- public static EJBQLExceptionTest missingSelectExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("OBJECT(emp) FROM Employee emp"); theTest.setName("Missing Select Exception Test"); return theTest; *************** *** 30,36 **** public static EJBQLExceptionTest malformedEjbqlExceptionTest1() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName == \"Fred\""); theTest.setName("Malformed EJBQL Exception Test1"); return theTest; --- 30,36 ---- public static EJBQLExceptionTest malformedEjbqlExceptionTest1() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName == \"Fred\""); theTest.setName("Malformed EJBQL Exception Test1"); return theTest; *************** *** 38,44 **** public static EJBQLExceptionTest malformedEjbqlExceptionTest2() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" AND 1"); theTest.setName("Malformed EJBQL Exception Test2"); return theTest; --- 38,44 ---- public static EJBQLExceptionTest malformedEjbqlExceptionTest2() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" AND 1"); theTest.setName("Malformed EJBQL Exception Test2"); return theTest; *************** *** 46,52 **** public static EJBQLExceptionTest malformedEjbqlExceptionTest3() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" OR \"Freda\""); theTest.setName("Malformed EJBQL Exception Test3"); return theTest; --- 46,52 ---- public static EJBQLExceptionTest malformedEjbqlExceptionTest3() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SELECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" OR \"Freda\""); theTest.setName("Malformed EJBQL Exception Test3"); return theTest; *************** *** 54,60 **** public static EJBQLExceptionTest malformedEjbqlExceptionTest4() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SLEECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" OR \"Freda\""); theTest.setName("Malformed EJBQL Exception Test4"); return theTest; --- 54,60 ---- public static EJBQLExceptionTest malformedEjbqlExceptionTest4() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SLEECT OBJECT(emp) FROM Employee emp WHERE emp.firstName = \"Fred\" OR \"Freda\""); theTest.setName("Malformed EJBQL Exception Test4"); return theTest; *************** *** 71,77 **** //This test produced a stack overflow in the Beta of Pine public static EJBQLExceptionTest noAliasWithWHEREAndParameterExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("FROM Employee WHERE firstName = ?1"); theTest.setName("No Alias With WHERE and Parameter Exception Test"); return theTest; --- 71,77 ---- //This test produced a stack overflow in the Beta of Pine public static EJBQLExceptionTest noAliasWithWHEREAndParameterExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("FROM Employee WHERE firstName = ?1"); theTest.setName("No Alias With WHERE and Parameter Exception Test"); return theTest; *************** *** 79,85 **** public static EJBQLExceptionTest generalExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null); theTest.setEjbqlString("SELECT FROM EMPLOYEE emp"); theTest.setName("General Exception test"); --- 79,85 ---- public static EJBQLExceptionTest generalExceptionTest() { EJBQLExceptionTest theTest = new EJBQLExceptionTest(); ! theTest.expectedException = EJBQLException.unexpectedToken(null, null, null); theTest.setEjbqlString("SELECT FROM EMPLOYEE emp"); theTest.setName("General Exception test"); ================================================================================ Merge Diffs: /ade/shanchen_toplink_main_temp/tltest/source/essentials/oracle/toplink/essentials/testing/tests/ejbql/IdentifierTest.java vs. /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.3 Report generated at Thu Oct 12 16:19:02 2006 -------------------------------------------------------------------------------- *** /net/stottnfs2.ca.oracle.com/vol/vol1/ade_ottawa_txn/shanchen/shanchen_10_gf1166_061012/ade_storage/000007/AB0952363AC40CBFE034080020E8C54E.3 Thu Oct 12 15:47:36 2006 --- /ade/shanchen_toplink_main_temp/tltest/source/essentials/oracle/toplink/essentials/testing/tests/ejbql/IdentifierTest.java Thu Oct 12 16:18:02 2006 *************** *** 50,56 **** EJBQLExceptionTest theTest = new EJBQLExceptionTest(); theTest.setName("Bad Identifier test1"); theTest.setEjbqlString("SELECT OBJECT(+emp1) FROM Employee +emp1"); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null); return theTest; } --- 50,56 ---- EJBQLExceptionTest theTest = new EJBQLExceptionTest(); theTest.setName("Bad Identifier test1"); theTest.setEjbqlString("SELECT OBJECT(+emp1) FROM Employee +emp1"); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null, null); return theTest; } *************** *** 59,65 **** EJBQLExceptionTest theTest = new EJBQLExceptionTest(); theTest.setName("Bad Identifier test2"); theTest.setEjbqlString("SELECT OBJECT(emp 1) FROM Employee emp 1"); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null); return theTest; } --- 59,65 ---- EJBQLExceptionTest theTest = new EJBQLExceptionTest(); theTest.setName("Bad Identifier test2"); theTest.setEjbqlString("SELECT OBJECT(emp 1) FROM Employee emp 1"); ! theTest.expectedException = EJBQLException.syntaxErrorAt(null, null, null); return theTest; }