|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjunit.framework.Assert
junit.framework.TestCase
org.apache.jdo.tck.JDO_Test
org.apache.jdo.tck.query.QueryTest
Field Summary | |
static java.lang.String |
COMPANY_TESTDATA
|
protected java.util.List |
inserted
List of inserted instances (see methods insertPCPoints and getFromInserted). |
static java.lang.String |
MYLIB_TESTDATA
|
static java.lang.String |
SERIALZED_QUERY
|
Fields inherited from class org.apache.jdo.tck.JDO_Test |
APPLICATION_IDENTITY, cleanupData, closePMFAfterEachTest, DATASTORE_IDENTITY, debug, DETACHED_CLEAN, DETACHED_DIRTY, HOLLOW, identitytype, ILLEGAL_STATE, logger, messages, NL, NUM_STATES, PERSISTENT_CLEAN, PERSISTENT_DELETED, PERSISTENT_DIRTY, PERSISTENT_NEW, PERSISTENT_NEW_DELETED, PERSISTENT_NONTRANSACTIONAL, PERSISTENT_NONTRANSACTIONAL_DIRTY, pm, pmf, PMFProperties, PMFPropertiesObject, states, testSucceeded, TRANSIENT, TRANSIENT_CLEAN, TRANSIENT_DIRTY |
Constructor Summary | |
QueryTest()
|
Method Summary | |
protected void |
checkQueryResultWithOrder(java.lang.String assertion,
java.lang.Object result,
java.lang.Object expected)
Verify that expected equals result, including the order of the elements. |
protected void |
checkQueryResultWithOrder(java.lang.String assertion,
java.lang.String query,
java.lang.Object result,
java.lang.Object expected)
|
protected void |
checkQueryResultWithoutOrder(java.lang.String assertion,
java.lang.Object result,
java.lang.Object expected)
Verify that expected equals result, ignoring the order of the elements. |
protected void |
checkQueryResultWithoutOrder(java.lang.String assertion,
java.lang.String query,
java.lang.Object result,
java.lang.Object expected)
|
boolean |
closeEnough(double d1,
double d2)
Returns true if the specified float values are close
enough to be considered to be equal for a deep equals
comparison. |
boolean |
closeEnough(float f1,
float f2)
Returns true if the specified float values are close
enough to be considered to be equal for a deep equals
comparison. |
protected void |
compile(java.lang.String assertion,
javax.jdo.Query query,
java.lang.String queryText,
boolean positive)
Compiles the given query instance. |
protected void |
compileAPIQuery(java.lang.String assertion,
QueryElementHolder queryElementHolder,
boolean positive)
Compiles the given query element holder instance as a JDO API query. |
protected void |
compileSingleStringQuery(java.lang.String assertion,
QueryElementHolder queryElementHolder,
boolean positive)
Compiles the given query element holder instance as a JDO single string query. |
protected void |
compileSingleStringQuery(java.lang.String assertion,
java.lang.String singleStringQuery,
boolean positive)
Compiles the given single string query. |
protected void |
deletePersistentAllByAPIQuery(java.lang.String assertion,
QueryElementHolder queryElementHolder,
java.lang.Object parameters,
long expectedNrOfDeletedObjects)
Converts the given query element holder instance to a JDO query instance. |
protected void |
deletePersistentAllBySingleStringQuery(java.lang.String assertion,
QueryElementHolder queryElementHolder,
java.lang.Object parameters,
long expectedNrOfDeletedObjects)
Converts the given query element holder instance to a JDO query instance. |
protected boolean |
equals(java.lang.Object o1,
java.lang.Object o2)
Returns true
if o1 and o2 equal. |
protected boolean |
equalsCollection(java.util.Collection o1,
java.util.Collection o2)
Returns true
if o1 and o2 equal. |
protected boolean |
equalsList(java.util.List o1,
java.util.List o2)
Returns true
if o1 and o2 equal. |
protected boolean |
equalsMap(java.util.Map o1,
java.util.Map o2)
Returns true
if o1 and o2 equal. |
protected boolean |
equalsObjectArray(java.lang.Object[] o1,
java.lang.Object[] o2)
Returns true
if o1 and o2 equal. |
protected void |
executeAPIQuery(java.lang.String assertion,
QueryElementHolder queryElementHolder,
java.lang.Object expectedResult)
Executes the given query element holder instance as a JDO API query. |
protected void |
executeAPIQuery(java.lang.String assertion,
QueryElementHolder queryElementHolder,
java.lang.Object[] parameters,
java.lang.Object expectedResult)
Executes the given query element holder instance as a JDO API query. |
protected java.lang.Object |
executeJDOQuery(java.lang.String assertion,
javax.jdo.Query query,
java.lang.String singleStringQuery,
boolean hasOrdering,
java.lang.Object[] parameters,
java.lang.Object expectedResult,
boolean positive)
Executes the given query instance delegating to execute(String, Query, String, boolean, Object, Object, boolean). |
protected void |
executeSingleStringQuery(java.lang.String assertion,
QueryElementHolder queryElementHolder,
java.lang.Object expectedResult)
Executes the given query element holder instance as a JDO single string query. |
protected void |
executeSingleStringQuery(java.lang.String assertion,
QueryElementHolder queryElementHolder,
java.lang.Object[] parameters,
java.lang.Object expectedResult)
Executes the given query element holder instance as a JDO single string query. |
protected void |
executeSQLQuery(java.lang.String assertion,
java.lang.String sql,
java.lang.Class candidateClass,
java.lang.Class resultClass,
java.lang.Object[] parameters,
java.lang.Object expectedResult,
boolean unique)
Executes the given SQL string as a JDO SQL query. |
java.util.List |
getFromInserted(java.util.List list)
|
protected java.lang.Object |
getPersistentCompanyModelInstance(java.lang.String beanName)
Returns a persistent company model instance for the given bean name. |
protected java.lang.Object[] |
getPersistentCompanyModelInstances(java.lang.String[] beanNames)
Returns an array of persistent company model instances for bean names in the given argument. |
protected java.util.List |
getPersistentCompanyModelInstancesAsList(java.lang.String[] beanNames)
Returns a list of persistent company model instances instances for beans names in the given argument. |
protected java.lang.Object |
getPersistentMylibInstance(java.lang.String beanName)
Returns a persistent mylib instance for the given bean name. |
protected java.lang.Object[] |
getPersistentMylibInstances(java.lang.String[] beanNames)
Returns an array of persistent mylib instances for beans names in the given argument. |
protected java.util.List |
getPersistentMylibInstancesAsList(java.lang.String[] beanNames)
Returns a list of persistent mylib instances for beans names in the given argument. |
protected java.lang.Object |
getTransientCompanyModelInstance(java.lang.String beanName)
Returns a transient company model instance for the given bean name. |
protected java.lang.Object[] |
getTransientCompanyModelInstances(java.lang.String[] beanNames)
Returns an array of transient company model instances for bean names in the given argument. |
protected java.util.List |
getTransientCompanyModelInstancesAsList(java.lang.String[] beanNames)
Returns a list of transient company model instances instances for beans names in the given argument. |
protected java.lang.Object |
getTransientMylibInstance(java.lang.String beanName)
Returns a transient mylib instance for the given bean name. |
protected java.lang.Object[] |
getTransientMylibInstances(java.lang.String[] beanNames)
Returns an array of transient mylib instances for beans names in the given argument. |
protected java.util.List |
getTransientMylibInstancesAsList(java.lang.String[] beanNames)
Returns a list of transient mylib instances for beans names in the given argument. |
protected void |
insertPCPoints(javax.jdo.PersistenceManager pm,
int numInsert)
|
protected void |
insertPrimitiveTypes(javax.jdo.PersistenceManager pm)
|
CompanyModelReader |
loadAndPersistCompanyModel(javax.jdo.PersistenceManager pm)
Reads a graph of company model objects from the internal reader. |
MylibReader |
loadAndPersistMylib(javax.jdo.PersistenceManager pm)
Reads a graph of mylib objects from the internal reader. |
void |
loadAndPersistPCPoints(javax.jdo.PersistenceManager pm)
|
void |
loadAndPersistPrimitiveTypes(javax.jdo.PersistenceManager pm)
|
protected void |
printOutput(java.lang.Object results,
java.util.Collection expected)
|
protected void |
runParameterPrimitiveTypesQuery(java.lang.String filter,
java.lang.String paramDecl,
java.lang.Object paramValue,
javax.jdo.PersistenceManager pm,
java.util.Collection expected,
java.lang.String assertion)
Creates and executes a PrimitiveTypes query with the specified filter, parameter declarations and parameter values. |
protected void |
runSimplePrimitiveTypesQuery(java.lang.String filter,
javax.jdo.PersistenceManager pm,
java.util.Collection expected,
java.lang.String assertion)
Creates and executes a PrimitiveTypes query with the specified filter. |
Methods inherited from class junit.framework.TestCase |
countTestCases, createResult, getName, run, run, runTest, setName, toString |
Methods inherited from class junit.framework.Assert |
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String SERIALZED_QUERY
public static final java.lang.String COMPANY_TESTDATA
public static final java.lang.String MYLIB_TESTDATA
protected java.util.List inserted
Constructor Detail |
public QueryTest()
Method Detail |
public void loadAndPersistPCPoints(javax.jdo.PersistenceManager pm)
protected void insertPCPoints(javax.jdo.PersistenceManager pm, int numInsert)
public java.util.List getFromInserted(java.util.List list)
public CompanyModelReader loadAndPersistCompanyModel(javax.jdo.PersistenceManager pm)
public MylibReader loadAndPersistMylib(javax.jdo.PersistenceManager pm)
protected java.lang.Object getPersistentCompanyModelInstance(java.lang.String beanName)
beanName
- the bean name.
protected java.lang.Object getTransientCompanyModelInstance(java.lang.String beanName)
beanName
- the bean name.
protected java.lang.Object[] getPersistentCompanyModelInstances(java.lang.String[] beanNames)
beanNames
- the bean names of company mode instances.
protected java.lang.Object[] getTransientCompanyModelInstances(java.lang.String[] beanNames)
beanNames
- the bean names of company mode instances.
protected java.util.List getPersistentCompanyModelInstancesAsList(java.lang.String[] beanNames)
beanNames
- the bean names of company model instances.
protected java.util.List getTransientCompanyModelInstancesAsList(java.lang.String[] beanNames)
beanNames
- the bean names of company model instances.
protected java.lang.Object getPersistentMylibInstance(java.lang.String beanName)
beanName
- the bean name.
protected java.lang.Object getTransientMylibInstance(java.lang.String beanName)
beanName
- the bean name.
protected java.lang.Object[] getPersistentMylibInstances(java.lang.String[] beanNames)
beanNames
- the bean names of mylib instances.
protected java.lang.Object[] getTransientMylibInstances(java.lang.String[] beanNames)
beanNames
- the bean names of mylib instances.
protected java.util.List getPersistentMylibInstancesAsList(java.lang.String[] beanNames)
beanNames
- the bean names of mylib instances.
protected java.util.List getTransientMylibInstancesAsList(java.lang.String[] beanNames)
beanNames
- the bean names of mylib instances.
public void loadAndPersistPrimitiveTypes(javax.jdo.PersistenceManager pm)
protected void insertPrimitiveTypes(javax.jdo.PersistenceManager pm)
protected void runSimplePrimitiveTypesQuery(java.lang.String filter, javax.jdo.PersistenceManager pm, java.util.Collection expected, java.lang.String assertion)
protected void runParameterPrimitiveTypesQuery(java.lang.String filter, java.lang.String paramDecl, java.lang.Object paramValue, javax.jdo.PersistenceManager pm, java.util.Collection expected, java.lang.String assertion)
protected void checkQueryResultWithOrder(java.lang.String assertion, java.lang.Object result, java.lang.Object expected)
protected void checkQueryResultWithoutOrder(java.lang.String assertion, java.lang.Object result, java.lang.Object expected)
protected void checkQueryResultWithOrder(java.lang.String assertion, java.lang.String query, java.lang.Object result, java.lang.Object expected)
protected void checkQueryResultWithoutOrder(java.lang.String assertion, java.lang.String query, java.lang.Object result, java.lang.Object expected)
protected boolean equals(java.lang.Object o1, java.lang.Object o2)
true
if o1
and o2
equal.
This method is capable to compare object arrays,
collections of object arrays, maps of object arrays.
This method implements a narrowing in case of floating point values.
In case of big decimals it calls
BigDecimal.compareTo(java.lang.Object)
.
It allows o1
and/or o2
to be null
.
o1
- the first objecto2
- the second object
true
if o1
and o2
equal.protected boolean equalsObjectArray(java.lang.Object[] o1, java.lang.Object[] o2)
true
if o1
and o2
equal.
This method iterates over both object arrays and calls
equals(Object, Object)
passing
corresponding instances.
equals(Object, Object)
is called rather than
Object.equals(java.lang.Object)
because object arrays
having equal elements cannot be compared calling
Object.equals(java.lang.Object)
.
This method does not allow o1
and o2
to be null
both.
o1
- the first object arrayo2
- the second object array
true
if o1
and o2
equal.protected boolean equalsList(java.util.List o1, java.util.List o2)
true
if o1
and o2
equal.
This method iterates both lists and
calls equals(Object, Object)
on corresponding elements.
equals(Object, Object)
is called rather than
Object.equals(java.lang.Object)
because object arrays
having equal elements cannot be compared calling
Object.equals(java.lang.Object)
.
This method does not allow o1
and o2
to be null
both.
o1
- the first listo2
- the second list
true
if o1
and o2
equal.protected boolean equalsCollection(java.util.Collection o1, java.util.Collection o2)
true
if o1
and o2
equal.
This method iterates over the first collection and
checks if each instance is contained in the second collection
by calling contains(Collection, Object).
This method does not allow o1
and o2
to be null
both.
o1
- the first collectiono2
- the second collection
true
if o1
and o2
equal.protected boolean equalsMap(java.util.Map o1, java.util.Map o2)
true
if o1
and o2
equal.
This method checks if the key sets and the value sets of both
maps equal calling equalsCollection(Collection, Collection).
This method does not allow o1
and o2
to be null
both.
o1
- the first mapo2
- the second map
true
if o1
and o2
equal.public boolean closeEnough(double d1, double d2)
true
if the specified float values are close
enough to be considered to be equal for a deep equals
comparison. Floating point values are not exact, so comparing them
using ==
might not return useful results. This method
checks that both double values are within some percent of each
other.
d1
- one double to be tested for close enoughd2
- the other double to be tested for close enough
true
if the specified values are close enough.public boolean closeEnough(float f1, float f2)
true
if the specified float values are close
enough to be considered to be equal for a deep equals
comparison. Floating point values are not exact, so comparing them
using ==
might not return useful results. This method
checks that both float values are within some percent of each
other.
f1
- one float to be tested for close enoughf2
- the other float to be tested for close enough
true
if the specified values are close enough.protected void printOutput(java.lang.Object results, java.util.Collection expected)
protected void compileAPIQuery(java.lang.String assertion, QueryElementHolder queryElementHolder, boolean positive)
positive
determines if the compilation is supposed
to succeed or to fail. If true
and the compilation fails,
then the test case fails prompting argument assertion
.
If false
and the compilation succeeds,
then the test case fails prompting argument assertion
.
Otherwise the test case succeeds.
assertion
- the assertion to prompt if the test case fails.queryElementHolder
- the query to execute.positive
- determines if the compilation is supposed
to succeed or to fail.protected void compileSingleStringQuery(java.lang.String assertion, QueryElementHolder queryElementHolder, boolean positive)
positive
determines if the compilation is supposed
to succeed or to fail. If true
and the compilation fails,
then the test case fails prompting argument assertion
.
If false
and the compilation succeeds,
then the test case fails prompting argument assertion
.
Otherwise the test case succeeds.
assertion
- the assertion to prompt if the test case fails.queryElementHolder
- the query to execute.positive
- determines if the compilation is supposed
to succeed or to fail.protected void compileSingleStringQuery(java.lang.String assertion, java.lang.String singleStringQuery, boolean positive)
positive
determines if the compilation is supposed
to succeed or to fail. If true
and the compilation fails,
then the test case fails prompting argument assertion
.
If false
and the compilation succeeds,
then the test case fails prompting argument assertion
.
Otherwise the test case succeeds.
assertion
- the assertion to prompt if the test case fails.singleStringQuery
- the single string querypositive
- determines if the compilation is supposed
to succeed or to fail.protected void compile(java.lang.String assertion, javax.jdo.Query query, java.lang.String queryText, boolean positive)
positive
determines if the compilation is supposed
to succeed or to fail.
If true
and the compilation fails,
then the test case fails prompting arguments assertion
and queryText
.
If false
and the compilation succeeds,
then the test case fails prompting argument assertion
and queryText
.
Otherwise the test case succeeds.
assertion
- query
- queryText
- positive
- protected void executeAPIQuery(java.lang.String assertion, QueryElementHolder queryElementHolder, java.lang.Object expectedResult)
expectedResult
.
If the expected result does not match the returned query result,
then the test case fails prompting argument assertion
.
assertion
- the assertion to prompt if the test case fails.queryElementHolder
- the query to execute.expectedResult
- the expected query result.protected void executeAPIQuery(java.lang.String assertion, QueryElementHolder queryElementHolder, java.lang.Object[] parameters, java.lang.Object expectedResult)
expectedResult
.
If the expected result does not match the returned query result,
then the test case fails prompting argument assertion
.
assertion
- the assertion to prompt if the test case fails.queryElementHolder
- the query to execute.parameters
- the parmaters of the query.expectedResult
- the expected query result.protected void executeSingleStringQuery(java.lang.String assertion, QueryElementHolder queryElementHolder, java.lang.Object expectedResult)
expectedResult
.
If the expected result does not match the returned query result,
then the test case fails prompting argument assertion
.
assertion
- the assertion to prompt if the test case fails.queryElementHolder
- the query to execute.expectedResult
- the expected query result.protected void executeSingleStringQuery(java.lang.String assertion, QueryElementHolder queryElementHolder, java.lang.Object[] parameters, java.lang.Object expectedResult)
expectedResult
.
If the expected result does not match the returned query result,
then the test case fails prompting argument assertion
.
assertion
- the assertion to prompt if the test case fails.queryElementHolder
- the query to execute.parameters
- the parmaters of the query.expectedResult
- the expected query result.protected java.lang.Object executeJDOQuery(java.lang.String assertion, javax.jdo.Query query, java.lang.String singleStringQuery, boolean hasOrdering, java.lang.Object[] parameters, java.lang.Object expectedResult, boolean positive)
singleStringQuery
if debug logging is enabled.
assertion
- the assertion to prompt if the test case fails.query
- the query to execute.singleStringQuery
- the single string representation of the query.
This parameter is only used as part of the falure message.hasOrdering
- indicates if the query has an ordering clause.parameters
- the parmaters of the query.expectedResult
- the expected query result.positive
- indicates if query execution is supposed to fail
protected void executeSQLQuery(java.lang.String assertion, java.lang.String sql, java.lang.Class candidateClass, java.lang.Class resultClass, java.lang.Object[] parameters, java.lang.Object expectedResult, boolean unique)
expectedResult
.
If the expected result does not match the returned query result,
then the test case fails prompting argument assertion
.
Argument unique
indicates, if the query is supposed
to return a single result.
Argument sql
may contain the substring "{0}"
.
All occurences of this substring are replaced
by the value of PMF property "javax.jdo.mapping.Schema"
.
assertion
- the assertion to prompt if the test case fails.sql
- the SQL string.candidateClass
- the candidate class.resultClass
- the result class.parameters
- the parameters of the query.expectedResult
- the expected query result.unique
- indicates, if the query is supposed
to return a single result.protected void deletePersistentAllByAPIQuery(java.lang.String assertion, QueryElementHolder queryElementHolder, java.lang.Object parameters, long expectedNrOfDeletedObjects)
Query.deletePersistentAll()
, or
Query.deletePersistentAll(java.util.Map)
, or
Query.deletePersistentAll(java.lang.Object[])
depending on the type of argument parameters
.
If the number of deleted objects does not
match expectedNrOfDeletedObjects
,
then the test case fails prompting argument assertion
.
assertion
- the assertion to prompt if the test case fails.queryElementHolder
- the query to execute.parameters
- the parmaters of the query.expectedNrOfDeletedObjects
- the expected number of deleted objects.protected void deletePersistentAllBySingleStringQuery(java.lang.String assertion, QueryElementHolder queryElementHolder, java.lang.Object parameters, long expectedNrOfDeletedObjects)
Query.deletePersistentAll()
, or
Query.deletePersistentAll(java.util.Map)
, or
Query.deletePersistentAll(java.lang.Object[])
depending on the type of argument parameters
.
If the number of deleted objects does not
match expectedNrOfDeletedObjects
,
then the test case fails prompting argument assertion
.
assertion
- the assertion to prompt if the test case fails.queryElementHolder
- the query to execute.parameters
- the parmaters of the query.expectedNrOfDeletedObjects
- the expected number of deleted objects.
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |