use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class NamedQueryTests method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("NamedQueryTests");
suite.addTest(new NamedQueryTests("testNamedSessionQueryNoBinding"));
suite.addTest(new NamedQueryTests("testNamedSessionQueryBindAllParameters"));
suite.addTest(new NamedQueryTests("testNamedSessionQueryBindQueryParameters"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryNoBinding"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryBindAllParameter"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryBindQueryParameter"));
return new TestSetup(suite) {
protected void setUp() {
try {
SimpleSpatialTestCase.repopulate(getSession(), true);
ReadAllQuery raq = new ReadAllQuery(SimpleSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
SpatialParameters parameters = new SpatialParameters();
parameters.setQueryType(SpatialParameters.QueryType.WINDOW).setMask(Mask.ANYINTERACT);
Expression selectionCriteria = SpatialExpressionFactory.relate(eb.get("geometry"), eb.getParameter("GEOMETRY"), parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
raq.addArgument("GEOMETRY", JGeometry.class);
getSession().addQuery(SESSION_QUERY_NAME, raq);
raq = new ReadAllQuery(SimpleSpatial.class);
eb = raq.getExpressionBuilder();
parameters = new SpatialParameters();
parameters.setDistance(10d);
selectionCriteria = SpatialExpressionFactory.withinDistance(eb.get("geometry"), eb.getParameter("GEOMETRY"), parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
raq.addArgument("GEOMETRY", JGeometry.class);
getSession().getClassDescriptor(SimpleSpatial.class).getDescriptorQueryManager().addQuery(DESCRIPTOR_QUERY_NAME, raq);
} catch (Exception e) {
throw new TestProblemException("Could not setup JGeometry test model", e);
}
}
protected void tearDown() {
try {
getSession().removeQuery(SESSION_QUERY_NAME);
getSession().getClassDescriptor(SimpleSpatial.class).getDescriptorQueryManager().removeQuery(DESCRIPTOR_QUERY_NAME);
} catch (Exception e) {
throw new TestProblemException("Could not tearDown NamedQueryTests for SimpleSpatialTestCase.", e);
}
}
};
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class NamedQueryTests method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("NamedQueryTests");
suite.addTest(new NamedQueryTests("testNamedSessionQueryNoBinding"));
suite.addTest(new NamedQueryTests("testNamedSessionQueryBindAllParameters"));
suite.addTest(new NamedQueryTests("testNamedSessionQueryBindQueryParameters"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryNoBinding"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryBindAllParameter"));
suite.addTest(new NamedQueryTests("testDescriptorNamedQueryBindQueryParameter"));
return new TestSetup(suite) {
protected void setUp() {
try {
WrappedSpatialTestCase.repopulate(getSession(), true);
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
ExpressionBuilder eb = raq.getExpressionBuilder();
SpatialParameters parameters = new SpatialParameters();
parameters.setMask(Mask.ANYINTERACT).setQueryType(QueryType.WINDOW);
Expression selectionCriteria = SpatialExpressionFactory.relate(eb.get("geometry").getField("geom"), eb.getParameter("GEOMETRY"), parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
raq.addArgument("GEOMETRY", JGeometry.class);
getSession().addQuery(SESSION_QUERY_NAME, raq);
raq = new ReadAllQuery(WrappedSpatial.class);
eb = raq.getExpressionBuilder();
parameters = new SpatialParameters();
parameters.setDistance(10d);
selectionCriteria = SpatialExpressionFactory.withinDistance(eb.get("geometry").getField("geom"), eb.getParameter("GEOMETRY"), parameters);
raq.setSelectionCriteria(selectionCriteria);
raq.addAscendingOrdering("id");
raq.addArgument("GEOMETRY", MyGeometry.class);
getSession().getClassDescriptor(WrappedSpatial.class).getDescriptorQueryManager().addQuery(DESCRIPTOR_QUERY_NAME, raq);
} catch (Exception e) {
throw new TestProblemException("Could not setup JGeometry test model. Note: This model requires you to run the following CREATE OR REPLACE TYPE MY_GEOMETRY AS OBJECT (id NUMBER, geom MDSYS.SDO_GEOMETRY): ", e);
}
}
protected void tearDown() {
try {
getSession().removeQuery(SESSION_QUERY_NAME);
getSession().getClassDescriptor(WrappedSpatial.class).getDescriptorQueryManager().removeQuery(DESCRIPTOR_QUERY_NAME);
} catch (Exception e) {
throw new TestProblemException("Could not tearDown NamedQueryTests for SimpleSpatialTestCase.", e);
}
}
};
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class Query_OrderedHint method suite.
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("Query_OrderedHint");
suite.addTest(new Query_OrderedHint("testReadAll"));
return new TestSetup(suite) {
protected void setUp() {
try {
WrappedSpatialTestCase.repopulate(getSession(), true);
} catch (Exception e) {
throw new TestProblemException("Could not setup JGeometry test model. Note: This model requires you to run the following CREATE OR REPLACE TYPE MY_GEOMETRY AS OBJECT (id NUMBER, geom MDSYS.SDO_GEOMETRY): ", e);
}
}
protected void tearDown() {
}
};
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class AllChangeSetsTest method test.
@Override
public void test() {
UnitOfWork uow = getSession().acquireUnitOfWork();
Vector employees = uow.readAllObjects(Employee.class);
// let's require at least 5 object
if (employees.size() <= 4) {
throw new TestProblemException("only " + employees.size() + " employees were read, need at least 5");
}
// Existing object has changed - should be counted
Employee emp = (Employee) employees.firstElement();
emp.setFirstName("Changed");
changedObjectsCount++;
Address add = emp.getAddress();
if (emp.getAddress() != null) {
// Existing object has changed - should be counted
add.setCity("Changed");
changedObjectsCount++;
}
// New object - should be counted
Employee newEmp = new Employee();
Employee newEmpClone = (Employee) uow.registerObject(newEmp);
newEmpClone.setFirstName("New");
changedObjectsCount++;
Iterator it = emp.getPhoneNumbers().iterator();
while (it.hasNext()) {
PhoneNumber phone = (PhoneNumber) it.next();
// to force reading the phone in and therefore registering in uow
// Registered but not changed - should NOT be counted
String code = phone.getAreaCode();
}
// forcedUpdate with false - should NOT be counted (doesn't affect cache)
Employee emp1 = (Employee) employees.elementAt(1);
uow.forceUpdateToVersionField(emp1, false);
// forcedUpdate with true - should be counted
Employee emp2 = (Employee) employees.elementAt(2);
uow.forceUpdateToVersionField(emp2, true);
changedObjectsCount++;
uow.commit();
}
use of org.eclipse.persistence.testing.framework.TestProblemException in project eclipselink by eclipse-ee4j.
the class CommitAfterExecuteModifyQueryDuringTransTest method reset.
/**
* Test makes modifications that is not wrapped in a transaction..
* so we have to reset our change
*/
@Override
public void reset() {
Vector myV = new Vector();
myV.addElement(originalEmployee.firstName);
myV.addElement(initialVersionField);
myV.addElement(originalEmployee.lastName);
try {
getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
getSession().executeQuery(dataModifyQuery, myV);
} catch (Exception internalException) {
throw new TestProblemException("Test case may not have cleaned up correctly affecting other tests", internalException);
}
}
Aggregations