blob: 66912cc9f14f2cf097cbc98544a4cedc8ad09c72 [file] [log] [blame]
/*
* Copyright (c) 1998, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0,
* or the Eclipse Distribution License v. 1.0 which is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
*/
// Contributors:
// Oracle - initial API and implementation from Oracle TopLink
package org.eclipse.persistence.testing.tests.spatial.jgeometry.wrapped;
import java.util.List;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.persistence.queries.ReadAllQuery;
import org.eclipse.persistence.testing.framework.TestProblemException;
import org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.Spatial;
import org.eclipse.persistence.testing.models.spatial.jgeometry.wrapped.WrappedSpatial;
import org.eclipse.persistence.testing.tests.spatial.jgeometry.SQLReader;
/**
* This test requires the following SQL be run prior to running the test suite:
* CREATE OR REPLACE TYPE MY_GEOMETRY AS OBJECT (id NUMBER, geom MDSYS.SDO_GEOMETRY)
*
* Query tests that do not involve using a spatial operator in the selection
* criteria.
*/
public class Query_OrderedHint extends WrappedSpatialTestCase {
public Query_OrderedHint(String name){
super(name);
}
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() {
}
};
}
public void testReadAll() throws Exception {
String sql =
"SELECT /*+ ORDERED */ GID, GEOMETRY FROM WRAPPED_SPATIAL WS ORDER BY GID";
SQLReader reader = new SQLReader(session, sql);
ReadAllQuery raq = new ReadAllQuery(WrappedSpatial.class);
raq.addAscendingOrdering("id");
raq.setHintString("/*+ ORDERED */ ");
List<Spatial> results = (List<Spatial>)session.executeQuery(raq);
String compareResult = reader.compare(results);
assertNull(compareResult, compareResult);
}
}