View | Details | Raw Unified | Return to bug 265885 | Differences between
and this patch

Collapse All | Expand All

(-)foundation/eclipselink.extension.oracle.test/src/org/eclipse/persistence/testing/tests/jpa/structconverter/StructConverterServerTestSuite.java (+114 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 1998, 2008 Oracle. All rights reserved.
3
 * This program and the accompanying materials are made available under the 
4
 * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 
5
 * which accompanies this distribution. 
6
 * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
7
 * and the Eclipse Distribution License is available at 
8
 * http://www.eclipse.org/org/documents/edl-v10.php.
9
 *
10
 * Contributors:
11
 *     Oracle - initial API and implementation from Oracle TopLink
12
 ******************************************************************************/  
13
package org.eclipse.persistence.testing.tests.jpa.structconverter;
14
15
import javax.persistence.EntityManager;
16
17
import junit.extensions.TestSetup;
18
import junit.framework.Test;
19
import junit.framework.TestSuite;
20
import oracle.spatial.geometry.JGeometry;
21
22
import org.eclipse.persistence.platform.database.converters.StructConverter;
23
24
import org.eclipse.persistence.testing.framework.junit.JUnitTestCase;
25
import org.eclipse.persistence.testing.models.jpa.structconverter.SimpleSpatial;
26
import org.eclipse.persistence.testing.models.jpa.structconverter.SimpleXMLSpatial;
27
import org.eclipse.persistence.testing.models.jpa.structconverter.JGeometryTableCreator;
28
import org.eclipse.persistence.testing.models.jpa.structconverter.DummyStructConverterType;
29
30
/**
31
 * TestSuite to ensure Annotation-based struct converters get properly added to the project
32
 * 
33
 * This test suite ensures the project is properly set-up and does a sanity test using one of the
34
 * converters.  Other tests are handled by the StructConverter tests suites in the TestBrowser.
35
 * @author tware
36
 *
37
 */
38
public class StructConverterServerTestSuite extends JUnitTestCase {
39
40
    public static final String STRUCT_CONVERTER_PU = "structConverter";
41
42
    public StructConverterServerTestSuite(){
43
    }
44
45
    public StructConverterServerTestSuite(String name){
46
        super(name);
47
    }
48
    
49
    public static Test suite() {
50
        TestSuite suite = new TestSuite();
51
        suite.setName("Struct Converter Test Suite");
52
        suite.addTest(new StructConverterServerTestSuite("testSetup"));
53
        suite.addTest(new StructConverterServerTestSuite("testPlatform"));
54
        suite.addTest(new StructConverterServerTestSuite("testSimpleSpatialWrite"));
55
        return suite;
56
    }
57
58
    public void testSetup() {
59
        clearCache();
60
        new JGeometryTableCreator().replaceTables(JUnitTestCase.getServerSession(STRUCT_CONVERTER_PU));
61
    }
62
    
63
    /**
64
     * Ensure the DatabasePlatform is setup with the proper StructConverters
65
     */
66
    public void testPlatform(){
67
            EntityManager em = createEntityManager(STRUCT_CONVERTER_PU);
68
            try{
69
                // trigger deploy
70
                em.find(SimpleSpatial.class, new Long(1));
71
            } catch (Exception e){};
72
            
73
            StructConverter converter = getServerSession(STRUCT_CONVERTER_PU).getPlatform().getTypeConverters().get(JGeometry.class);
74
            assertNotNull("Platform does not have correct JGeometryConverter.", converter);
75
            assertTrue("JGeometery struct converter is wrong type.", converter.getClass().getName().indexOf("JGeometryConverter") >= 0);
76
            
77
            converter = getServerSession(STRUCT_CONVERTER_PU).getPlatform().getTypeConverters().get(DummyStructConverterType.class);
78
            assertNotNull("Platform does not have correct DummyStructConverter.", converter);
79
            assertTrue("JGeometery struct converter is wrong type.", converter.getClass().getName().indexOf("DummyStructConverter") >= 0);
80
    }
81
    
82
    /**
83
     * Sanity test to ensure a read and a write with a Converter specified by 
84
     * annotations work properly
85
     */
86
    public void testSimpleSpatialWrite(){
87
            EntityManager em = createEntityManager(STRUCT_CONVERTER_PU);
88
89
            beginTransaction(em);
90
            SimpleSpatial simpleSpatial = new SimpleSpatial(1000, pointCluster1());
91
            em.persist(simpleSpatial);
92
            em.flush();
93
            
94
            em.clear();
95
            
96
            simpleSpatial = em.find(SimpleSpatial.class, new Long(1000));
97
            
98
            assertNotNull("JGeometry was not properly read in.", simpleSpatial.getJGeometry());
99
            rollbackTransaction(em);
100
    }
101
    
102
    /**
103
     * mdsys.sdo_geometry(5,
104
     *                   NULL, null,
105
     *                   mdsys.sdo_elem_info_array(1,1,3),
106
     *                   mdsys.sdo_ordinate_array(1.1, 1.1, 2.2, 2.2, 3.3, 4.4)));
107
     */
108
    public JGeometry pointCluster1() {
109
        Object[] points = 
110
            new Object[] { new double[] { 1.1, 1.1 }, new double[] { 2.2,                                                                      2.2 }, 
111
                           new double[] { 3.3, 4.4 } };
112
        return JGeometry.createMultiPoint(points, 2, 0);
113
    }
114
}
(-)jpa/eclipselink.jpa.test/build.xml (+26 lines)
Lines 174-179 Link Here
174
        <path id="compile.server.path">
174
        <path id="compile.server.path">
175
            <path refid="compile.path"/>
175
            <path refid="compile.path"/>
176
            <pathelement path="${jdbc.driver.jar}"/>
176
            <pathelement path="${jdbc.driver.jar}"/>
177
            <pathelement path="${oracle.extensions.depend.dir}/${oracle.spatial.lib}"/>
177
        </path>
178
        </path>
178
    </target>
179
    </target>
179
180
Lines 1458-1463 Link Here
1458
        </antcall>
1459
        </antcall>
1459
    </target>
1460
    </target>
1460
1461
1462
    <target name="server-test-struct-converter" if="is.oracle">
1463
        <echo message="Creating MY_GEOMETRY datatype for spatial tests: ${db.url}..."/>
1464
        <sql driver="${db.driver}"
1465
            url="${db.url}"
1466
            userid="${db.user}"
1467
            password="${db.pwd}"
1468
            onerror="continue"
1469
            >
1470
            <classpath>
1471
                <pathelement location="${jdbc.driver.jar}"/>
1472
            </classpath>
1473
CREATE OR REPLACE TYPE MY_GEOMETRY AS OBJECT (id NUMBER, geom MDSYS.SDO_GEOMETRY);
1474
        </sql>
1475
        <antcall target="server-run-all" inheritRefs="true">
1476
            <param name="PERSISTENCE_UNIT_NAME" value="structConverter"/>
1477
            <param name="MODEL_DIR" value="org/eclipse/persistence/testing/models/jpa/structconverter"/>
1478
            <param name="MODEL_NAME" value="eclipselink-structconverter-model"/>
1479
            <param name="TEST_DIR" value="org/eclipse/persistence/testing/tests/jpa/structconverter"/>
1480
            <param name="TEST_NAME" value="eclipselink-structconverter-model"/>
1481
            <param name="EAR_NAME" value="eclipselink-structconverter-model"/>
1482
            <param name="TEST_SUITE" value="org.eclipse.persistence.testing.tests.jpa.structconverter.StructConverterServerTestSuite"/>
1483
            <param name="eclipselink.jpa.test.dir" value="./../../foundation/eclipselink.extension.oracle.test"/>
1484
        </antcall>
1485
    </target>
1486
1461
    <!-- *********** CacheCoordination Test Targets -->
1487
    <!-- *********** CacheCoordination Test Targets -->
1462
    <target name="server-start-cachecoordination" depends="detect-os,config-trunk, config-flat">
1488
    <target name="server-start-cachecoordination" depends="detect-os,config-trunk, config-flat">
1463
      <ant antfile="${eclipselink.jpa.test}/cachecoordination_${server.name}.xml" target="${server.name}-start-cachecoordination" inheritRefs="true"/>
1489
      <ant antfile="${eclipselink.jpa.test}/cachecoordination_${server.name}.xml" target="${server.name}-start-cachecoordination" inheritRefs="true"/>
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/lob/LobJUnitTestCase.java (-1 / +2 lines)
Lines 64-70 Link Here
64
        EntityManager em = createEntityManager();
64
        EntityManager em = createEntityManager();
65
        beginTransaction(em);
65
        beginTransaction(em);
66
        try {
66
        try {
67
            Image image = ImageSimulator.generateImage(1000, 800);
67
            //Image image = ImageSimulator.generateImage(1000, 800);
68
            Image image = ImageSimulator.generateImage(4800, 4500);
68
            originalImage = image;
69
            originalImage = image;
69
            em.persist(image);
70
            em.persist(image);
70
            imageId = image.getId();
71
            imageId = image.getId();
(-)jpa/eclipselink.jpa.test/weblogic.xml (+1 lines)
Lines 76-81 Link Here
76
        <copy file="${eclipselink.jar.name}" todir="${weblogic.domain}/lib"/>
76
        <copy file="${eclipselink.jar.name}" todir="${weblogic.domain}/lib"/>
77
        <copy file="${jdbc.driver.jar}" todir="${weblogic.domain}/lib"/>
77
        <copy file="${jdbc.driver.jar}" todir="${weblogic.domain}/lib"/>
78
        <copy file="${oracle.extensions.depend.dir}/${oracle.xdb.lib}" todir="${weblogic.domain}/lib"/>
78
        <copy file="${oracle.extensions.depend.dir}/${oracle.xdb.lib}" todir="${weblogic.domain}/lib"/>
79
        <copy file="${oracle.extensions.depend.dir}/${oracle.spatial.lib}" todir="${weblogic.domain}/lib"/>
79
        <antcall target="weblogic-stop" inheritRefs="true"/>
80
        <antcall target="weblogic-stop" inheritRefs="true"/>
80
    </target>
81
    </target>
81
82

Return to bug 265885