org.apache.jdo.tck.query
Class QueryTest

java.lang.Object
  extended byjunit.framework.Assert
      extended byjunit.framework.TestCase
          extended byorg.apache.jdo.tck.JDO_Test
              extended byorg.apache.jdo.tck.query.QueryTest
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
AggregateResult, AllowedAPIMethods, AssignmentPrePostIncrementDecrementNotSupported, BinaryAddition, BinarySubtraction, BitwiseComplement, BooleanLogicalAND, BooleanLogicalOR, BoundParameterCheck, Cast, ChangeQuery, CharacterAndStringLiterals, Close, CloseAll, ComparingCollectionFieldToNull, ComparingPersistentAndNonPersistentInstance, CompileQuery, ConditionalAND, ConditionalOR, DeclareImports, DeclareParameters, DeclareVariables, DefaultResult, DefaultUnique, DeleteCallback, DeletePersistentAll, DeleteQueryElements, DenoteUniquenessInFilter, DistinctCandidateInstances, DistinctQuery, Division, EqualityAndComparisonsBetweenDateFieldsAndParameters, EqualityAndComparisonsBetweenPrimitivesAndWrapperInstances, EqualityAndComparisonsBetweenStringFieldsAndParameters, ExecuteQuery, ExecuteQueryWhenPersistenceManagerIsClosed, ExecuteQueryWithArray, ExecuteQueryWithMap, ExecutingQueryWhenNoTransactionNoNontransactionalRead, GetFetchPlan, GetIgnoreCache, GetPersistenceManager, GetPersistenceManagerFromRestoredSerializedQuery, Grouping, Having, IdentifiersEqualFieldNames, IgnoreCacheFalse, ImmutableQueryResult, ImplicitParameters, Instanceof, InvalidNamedQuery, InvalidUseOfKeywords, KeywordsAsFieldNames, LogicalComplement, MetadataSearchOrder, MethodsAndObjectConstructionNotSupported, MixedParameters, MixedVariables, Modulo, MultipleActiveQueryInstanceInSamePersistenceManager, MultipleIdenticalImports, Multiplication, NamedQueryNotFound, NamespaceOfIdentifiers, NavigationThroughACollectionField, NavigationThroughANullValuedField, NavigationThroughReferencesUsesDotOperator, NegativeRange, NewNamedQuery, NewQuery, NewQueryFromExistingQueryBoundToPMFromSameVendor, NewQueryFromRestoredSerializedQuery, NewQuerySingleString, NewQueryWithCandidateClass, NewQueryWithCandidateClassAndCollection, NewQueryWithCandidateClassAndExtent, NewQueryWithCandidateClassAndFilter, NewQueryWithCandidateClassCollectionFilter, NewQueryWithExtent, NewQueryWithExtentAndFilter, NewQueryWithSpecifiedLanguageAndQuery, NoCandidateClass, NPEInResultExpr, NullCollectionsAndContainsMethod, NullCollectionsAndIsEmpty, NullResults, OrderingSpecification, OrderOfParameters, ParameterBoundToDifferentPM, ParameterDeclaredWithSameNameAsFieldOfCandidateClass, ParenthesesMarkOperatorPrecedence, PositiveRange, PrimitiveParameterPassedAsNull, PromotionOfNumericOperands, QueryExtentions, QueryIsSerializable, QueryResultPassedToAnotherQuery, QueryWithNoFilter, RangeAsString, RestoredSerializedQueryInstanceLosesAssociationWithPM, ResultClassRequirements, ResultExpressions, SeparateNamespaceForTypeNames, SetCandidateCollection, SetCandidateExtent, SetFilter, SetGrouping, SetIgnoreCache, SetOrdering, SetRange, SetResult, SetResultClass, SetterReplacePreviousValues, SetUnique, ShapeOfResult, ShapeOfResult, SignInversion, SingleString, SingleStringQuery, StartsWithAndEndsWith, StringConcatenation, SupportedCollectionMethods, SupportedJDOHelperMethods, SupportedMapMethods, SupportedMathMethods, SupportedStringMethods, ThisIsReservedWordForElementOfCollection, UnaryPlus, UnconstrainedVariable, Unique, UnmodifiableQuery, UppercaseLowercase, UseOfThisToAcessHiddenField, VariableDeclaredWithSameNameAsFieldOfCandidateClass, VariableInResult, VariablesAndFields, VariablesWithoutExtent, WhiteSpaceIsACharacterAndIgnored

public abstract class QueryTest
extends JDO_Test


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 org.apache.jdo.tck.JDO_Test
addTearDownClass, addTearDownClass, addTearDownInstance, addTearDownObjectId, appendMessage, cleanupPM, cleanupPM, closePMF, compareStates, currentState, deleteTearDownClasses, deleteTearDownInstances, dumpSupportedOptions, fail, failOnError, getAllObjects, getFailedPersistenceManagers, getModifiableFields, getPM, getPMF, getPMFProperty, getStateOfInstance, isApplicationIdentitySupported, isArrayListSupported, isArraySupported, isBinaryCompatibilitySupported, isChangeApplicationIdentitySupported, isClassLoadable, isDataStoreConnectionSupported, isDatastoreIdentitySupported, isHashMapSupported, isHashtableSupported, isJRE14orBetter, isLinkedListSupported, isListSupported, isMapSupported, isNonDurableIdentitySupported, isNontransactionalReadSupported, isNontransactionalWriteSupported, isNullCollectionSupported, isOptimisticSupported, isRetainValuesSupported, isSQLSupported, isTestToBePerformed, isTransientTransactionalSupported, isTreeMapSupported, isTreeSetSupported, isUnconstrainedVariablesSupported, isVectorSupported, loadProperties, localSetUp, localTearDown, mangleObject, printNonApplicableIdentityType, printUnsupportedOptionalFeatureNotTested, retrieveMessages, runBare, runsWithApplicationIdentity, setUp, tearDown
 
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

SERIALZED_QUERY

public static final java.lang.String SERIALZED_QUERY
See Also:
Constant Field Values

COMPANY_TESTDATA

public static final java.lang.String COMPANY_TESTDATA
See Also:
Constant Field Values

MYLIB_TESTDATA

public static final java.lang.String MYLIB_TESTDATA
See Also:
Constant Field Values

inserted

protected java.util.List inserted
List of inserted instances (see methods insertPCPoints and getFromInserted).

Constructor Detail

QueryTest

public QueryTest()
Method Detail

loadAndPersistPCPoints

public void loadAndPersistPCPoints(javax.jdo.PersistenceManager pm)

insertPCPoints

protected void insertPCPoints(javax.jdo.PersistenceManager pm,
                              int numInsert)

getFromInserted

public java.util.List getFromInserted(java.util.List list)

loadAndPersistCompanyModel

public CompanyModelReader loadAndPersistCompanyModel(javax.jdo.PersistenceManager pm)
Reads a graph of company model objects from the internal reader. This methods explictly calls makePersistent for all named instances using the specified PersistenceManager. The method returns the CompanyModelReader instance allowing to access a compay model instance by name.


loadAndPersistMylib

public MylibReader loadAndPersistMylib(javax.jdo.PersistenceManager pm)
Reads a graph of mylib objects from the internal reader. This methods explictly calls makePersistent for all named instances using the specified PersistenceManager. The method returns the CompanyModelReader instance allowing to access a compay model instance by name.


getPersistentCompanyModelInstance

protected java.lang.Object getPersistentCompanyModelInstance(java.lang.String beanName)
Returns a persistent company model instance for the given bean name.

Parameters:
beanName - the bean name.
Returns:
the persistent company model instance.

getTransientCompanyModelInstance

protected java.lang.Object getTransientCompanyModelInstance(java.lang.String beanName)
Returns a transient company model instance for the given bean name.

Parameters:
beanName - the bean name.
Returns:
the transient company model instance.

getPersistentCompanyModelInstances

protected java.lang.Object[] getPersistentCompanyModelInstances(java.lang.String[] beanNames)
Returns an array of persistent company model instances for bean names in the given argument.

Parameters:
beanNames - the bean names of company mode instances.
Returns:
the array of persistent company model instances.

getTransientCompanyModelInstances

protected java.lang.Object[] getTransientCompanyModelInstances(java.lang.String[] beanNames)
Returns an array of transient company model instances for bean names in the given argument.

Parameters:
beanNames - the bean names of company mode instances.
Returns:
the array of transient company model instances.

getPersistentCompanyModelInstancesAsList

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.

Parameters:
beanNames - the bean names of company model instances.
Returns:
the list of persistent company model instances.

getTransientCompanyModelInstancesAsList

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.

Parameters:
beanNames - the bean names of company model instances.
Returns:
the list of transient company model instances.

getPersistentMylibInstance

protected java.lang.Object getPersistentMylibInstance(java.lang.String beanName)
Returns a persistent mylib instance for the given bean name.

Parameters:
beanName - the bean name.
Returns:
the persistent mylib instance.

getTransientMylibInstance

protected java.lang.Object getTransientMylibInstance(java.lang.String beanName)
Returns a transient mylib instance for the given bean name.

Parameters:
beanName - the bean name.
Returns:
the transient mylib instance.

getPersistentMylibInstances

protected java.lang.Object[] getPersistentMylibInstances(java.lang.String[] beanNames)
Returns an array of persistent mylib instances for beans names in the given argument.

Parameters:
beanNames - the bean names of mylib instances.
Returns:
the array of persistent mylib instances.

getTransientMylibInstances

protected java.lang.Object[] getTransientMylibInstances(java.lang.String[] beanNames)
Returns an array of transient mylib instances for beans names in the given argument.

Parameters:
beanNames - the bean names of mylib instances.
Returns:
the array of transient mylib instances.

getPersistentMylibInstancesAsList

protected java.util.List getPersistentMylibInstancesAsList(java.lang.String[] beanNames)
Returns a list of persistent mylib instances for beans names in the given argument.

Parameters:
beanNames - the bean names of mylib instances.
Returns:
the list of persistent mylib instances.

getTransientMylibInstancesAsList

protected java.util.List getTransientMylibInstancesAsList(java.lang.String[] beanNames)
Returns a list of transient mylib instances for beans names in the given argument.

Parameters:
beanNames - the bean names of mylib instances.
Returns:
the list of transient mylib instances.

loadAndPersistPrimitiveTypes

public void loadAndPersistPrimitiveTypes(javax.jdo.PersistenceManager pm)

insertPrimitiveTypes

protected void insertPrimitiveTypes(javax.jdo.PersistenceManager pm)

runSimplePrimitiveTypesQuery

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. The method checks whether the query returns the expected result.


runParameterPrimitiveTypesQuery

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. The method checks whether the query returns the expected result.


checkQueryResultWithOrder

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. If not equal, fail the test. If there is a filter != null, do not use this method. Use the method of the same name that takes a String as the second argument.


checkQueryResultWithoutOrder

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. If not equal, fail the test. If there is a filter != null, do not use this method. Use the method of the same name that takes a String as the second argument.


checkQueryResultWithOrder

protected void checkQueryResultWithOrder(java.lang.String assertion,
                                         java.lang.String query,
                                         java.lang.Object result,
                                         java.lang.Object expected)

checkQueryResultWithoutOrder

protected void checkQueryResultWithoutOrder(java.lang.String assertion,
                                            java.lang.String query,
                                            java.lang.Object result,
                                            java.lang.Object expected)

equals

protected boolean equals(java.lang.Object o1,
                         java.lang.Object o2)
Returns 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.

Parameters:
o1 - the first object
o2 - the second object
Returns:
true if o1 and o2 equal.

equalsObjectArray

protected boolean equalsObjectArray(java.lang.Object[] o1,
                                    java.lang.Object[] o2)
Returns 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.

Parameters:
o1 - the first object array
o2 - the second object array
Returns:
true if o1 and o2 equal.

equalsList

protected boolean equalsList(java.util.List o1,
                             java.util.List o2)
Returns 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.

Parameters:
o1 - the first list
o2 - the second list
Returns:
true if o1 and o2 equal.

equalsCollection

protected boolean equalsCollection(java.util.Collection o1,
                                   java.util.Collection o2)
Returns 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.

Parameters:
o1 - the first collection
o2 - the second collection
Returns:
true if o1 and o2 equal.

equalsMap

protected boolean equalsMap(java.util.Map o1,
                            java.util.Map o2)
Returns 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.

Parameters:
o1 - the first map
o2 - the second map
Returns:
true if o1 and o2 equal.

closeEnough

public 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. 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.

Parameters:
d1 - one double to be tested for close enough
d2 - the other double to be tested for close enough
Returns:
true if the specified values are close enough.

closeEnough

public 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. 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.

Parameters:
f1 - one float to be tested for close enough
f2 - the other float to be tested for close enough
Returns:
true if the specified values are close enough.

printOutput

protected void printOutput(java.lang.Object results,
                           java.util.Collection expected)

compileAPIQuery

protected void compileAPIQuery(java.lang.String assertion,
                               QueryElementHolder queryElementHolder,
                               boolean positive)
Compiles the given query element holder instance as a JDO API query. Argument 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.

Parameters:
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.

compileSingleStringQuery

protected void compileSingleStringQuery(java.lang.String assertion,
                                        QueryElementHolder queryElementHolder,
                                        boolean positive)
Compiles the given query element holder instance as a JDO single string query. Argument 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.

Parameters:
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.

compileSingleStringQuery

protected void compileSingleStringQuery(java.lang.String assertion,
                                        java.lang.String singleStringQuery,
                                        boolean positive)
Compiles the given single string query. Argument 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.

Parameters:
assertion - the assertion to prompt if the test case fails.
singleStringQuery - the single string query
positive - determines if the compilation is supposed to succeed or to fail.

compile

protected void compile(java.lang.String assertion,
                       javax.jdo.Query query,
                       java.lang.String queryText,
                       boolean positive)
Compiles the given query instance. Argument 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.

Parameters:
assertion -
query -
queryText -
positive -

executeAPIQuery

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. The result of that query is compared against the given argument expectedResult. If the expected result does not match the returned query result, then the test case fails prompting argument assertion.

Parameters:
assertion - the assertion to prompt if the test case fails.
queryElementHolder - the query to execute.
expectedResult - the expected query result.

executeAPIQuery

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. The result of that query is compared against the given argument expectedResult. If the expected result does not match the returned query result, then the test case fails prompting argument assertion.

Parameters:
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.

executeSingleStringQuery

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. The result of that query is compared against the given argument expectedResult. If the expected result does not match the returned query result, then the test case fails prompting argument assertion.

Parameters:
assertion - the assertion to prompt if the test case fails.
queryElementHolder - the query to execute.
expectedResult - the expected query result.

executeSingleStringQuery

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. The result of that query is compared against the given argument expectedResult. If the expected result does not match the returned query result, then the test case fails prompting argument assertion.

Parameters:
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.

executeJDOQuery

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). Logs argument singleStringQuery if debug logging is enabled.

Parameters:
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
Returns:
the query result

executeSQLQuery

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. The result of that query is compared against the given argument 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".

Parameters:
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.

deletePersistentAllByAPIQuery

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. Calls 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.

Parameters:
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.

deletePersistentAllBySingleStringQuery

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. Calls 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.

Parameters:
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.


Copyright © 2005-2007 Apache Software Foundation. All Rights Reserved.