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

Collapse All | Expand All

(-)foundation/eclipselink.core.test/build.xml (-18 / +58 lines)
Lines 98-121 Link Here
98
        <pathelement path="${tools.jar}"/>
98
        <pathelement path="${tools.jar}"/>
99
    </path>
99
    </path>
100
100
101
    <!-- Runs the test using the PromptTestRunner -->
102
    <target name="test.prompt-runner" depends="process.resource">
103
        <java   classname="org.eclipse.persistence.testing.framework.PromptTestRunner"
104
             fork="true"
105
             maxmemory="512m"
106
             failonerror="true"
107
             dir="${run.dir}">
108
            <jvmarg value="-Djava.security.policy=${eclipselink.core.test}/resource/java.policy.allpermissions"/>
109
            <arg value="pfile=${eclipselink.core.test}/${core.test.properties}" />
110
            <arg value="testmodel=org.eclipse.persistence.testing.tests.TestRunModel" />
111
            <arg value="regressionlog=${eclipselink.core.test}/${core.test.regression.log}" />
112
113
            <classpath>
114
                <path refid="run.classpath"/>
115
            </classpath>
116
        </java>
117
    </target>
118
119
    <!-- Default test target, runs test.class from test.properties (default is LRG). -->
101
    <!-- Default test target, runs test.class from test.properties (default is LRG). -->
120
    <target name="test">
102
    <target name="test">
121
        <antcall target="run.test" inheritRefs="true">
103
        <antcall target="run.test" inheritRefs="true">
Lines 137-142 Link Here
137
        </antcall>
119
        </antcall>
138
    </target>
120
    </target>
139
121
122
    <!-- Prompt runner test target, runs test.class from test.properties (default is LRG). -->
123
    <target name="test.prompt">
124
        <antcall target="run.test.prompt" inheritRefs="true">
125
            <param name="TEST_CLASS" value="${test.class}"/>
126
        </antcall>
127
    </target>
128
129
    <!-- Runs performance tests. -->
130
    <target name="test.performance">
131
        <antcall target="run.test.prompt" inheritRefs="true">
132
            <param name="TEST_CLASS" value="org.eclipse.persistence.testing.tests.performance.PerformanceTestModel"/>
133
        </antcall>
134
    </target>
135
136
    <!-- Launches the testing browser -->
137
    <target name="test.browser">
138
        <echo>Running test browser with ${test.properties}</echo>
139
        <mkdir dir="${eclipselink.core.test}/${run.dir}"/>
140
        <mkdir dir="${eclipselink.core.test}/${report.dir}"/>
141
        <java classname="org.eclipse.persistence.testing.framework.ui.TestingBrowserFrame"
142
             fork="true"
143
             maxmemory="512m"
144
             failonerror="true"
145
             dir="${eclipselink.core.test}/${run.dir}">
146
            <jvmarg value="-Declipselink.logging.level=${logging.level}"/>
147
            <jvmarg value="-Dtest.properties=${test.properties.run}"/>
148
            <jvmarg value="-Djava.security.manager"/>
149
            <jvmarg value="-Djava.security.policy=./java.policy.allpermissions"/>
150
            <classpath>
151
                <path refid="run.classpath"/>
152
            </classpath>
153
        </java>
154
    </target>
155
140
    <!-- Generic target for running tests. -->
156
    <!-- Generic target for running tests. -->
141
    <target name="run.test">
157
    <target name="run.test">
142
        <echo>Running test with ${test.properties} on ${db.url}</echo>
158
        <echo>Running test with ${test.properties} on ${db.url}</echo>
Lines 163-166 Link Here
163
        <fail message="Some of the junit tests failed.  See the ${report.dir}/junit-noframes.html file for details." if="junit.failed"/>
179
        <fail message="Some of the junit tests failed.  See the ${report.dir}/junit-noframes.html file for details." if="junit.failed"/>
164
    </target>
180
    </target>
165
181
182
    <!-- Runs the test using the PromptTestRunner -->
183
    <target name="run.test.prompt">
184
        <echo>Running test with ${test.properties} on ${db.url}</echo>
185
        <mkdir dir="${eclipselink.core.test}/${run.dir}"/>
186
        <mkdir dir="${eclipselink.core.test}/${report.dir}"/>
187
        <java classname="org.eclipse.persistence.testing.framework.PromptTestRunner"
188
             fork="true"
189
             maxmemory="512m"
190
             failonerror="true"
191
             dir="${eclipselink.core.test}/${run.dir}">
192
            <jvmarg value="-Declipselink.logging.level=${logging.level}"/>
193
            <jvmarg value="-Dtest.properties=${test.properties.run}"/>
194
            <jvmarg value="-Djava.security.manager"/>
195
            <jvmarg value="-Djava.security.policy=./java.policy.allpermissions"/>
196
            <arg value="pfile=${test.properties.run}" />
197
            <arg value="testmodel=${TEST_CLASS}" />
198
            <arg value="regressionlog=../${report.dir}/test.log" />
199
            <arg value="saveresults=true" />
200
            <classpath>
201
                <path refid="run.classpath"/>
202
            </classpath>
203
        </java>
204
    </target>
205
166
</project>
206
</project>
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/LoadBuildProject.java (-12 / +17 lines)
Lines 33-42 Link Here
33
    protected void applyLOGIN() {
33
    protected void applyLOGIN() {
34
        org.eclipse.persistence.sessions.DatabaseLogin login = new org.eclipse.persistence.sessions.DatabaseLogin();
34
        org.eclipse.persistence.sessions.DatabaseLogin login = new org.eclipse.persistence.sessions.DatabaseLogin();
35
35
36
        login.setUserName("jsutherl");
36
        login.setUserName("loadbuild");
37
        login.setPassword("password");
37
        login.setPassword("results");
38
        login.setDriverClassName("oracle.jdbc.OracleDriver");
38
        login.setDriverClassName("oracle.jdbc.OracleDriver");
39
        login.setConnectionString("jdbc:oracle:thin:@tlsvrdb3.ca.oracle.com:1521:toplink");
39
        login.setConnectionString("jdbc:oracle:thin:@toplinkdb.ca.oracle.com:1521:STARTEAM");
40
        login.setPlatformClassName("org.eclipse.persistence.platform.database.oracle.OraclePlatform");
40
        login.setPlatformClassName("org.eclipse.persistence.platform.database.oracle.OraclePlatform");
41
        NativeSequence sequence = new NativeSequence();
41
        NativeSequence sequence = new NativeSequence();
42
        sequence.setPreallocationSize(500);
42
        sequence.setPreallocationSize(500);
Lines 56-71 Link Here
56
        Vector vector = new Vector();
56
        Vector vector = new Vector();
57
        vector.addElement("LOADBUILD");
57
        vector.addElement("LOADBUILD");
58
        descriptor.setTableNames(vector);
58
        descriptor.setTableNames(vector);
59
        descriptor.addPrimaryKeyFieldName("LOADBUILD.id");
59
        //descriptor.addPrimaryKeyFieldName("LOADBUILD.id");
60
        descriptor.addPrimaryKeyFieldName("LOADBUILD.lbtimestamp");
60
61
61
        // SECTION: PROPERTIES
62
        // SECTION: PROPERTIES
62
        descriptor.setSequenceNumberName("RESULTSUM_SEQ");
63
        //descriptor.setSequenceNumberName("RESULTSUM_SEQ");
63
        descriptor.setSequenceNumberFieldName("id");
64
        //descriptor.setSequenceNumberFieldName("id");
64
65
65
        DirectToFieldMapping idMapping = new DirectToFieldMapping();
66
        /*DirectToFieldMapping idMapping = new DirectToFieldMapping();
66
        idMapping.setAttributeName("id");
67
        idMapping.setAttributeName("id");
67
        idMapping.setFieldName("LOADBUILD.id");
68
        idMapping.setFieldName("LOADBUILD.id");
68
        descriptor.addMapping(idMapping);
69
        descriptor.addMapping(idMapping);*/
69
        
70
        
70
        DirectToFieldMapping directtofieldmapping = new DirectToFieldMapping();
71
        DirectToFieldMapping directtofieldmapping = new DirectToFieldMapping();
71
        directtofieldmapping.setAttributeName("errors");
72
        directtofieldmapping.setAttributeName("errors");
Lines 123-129 Link Here
123
        onetomanymapping.setSetMethodName("setResultsHolder");
124
        onetomanymapping.setSetMethodName("setResultsHolder");
124
        onetomanymapping.setReferenceClass(org.eclipse.persistence.testing.framework.TestResult.class);
125
        onetomanymapping.setReferenceClass(org.eclipse.persistence.testing.framework.TestResult.class);
125
        onetomanymapping.setIsPrivateOwned(true);
126
        onetomanymapping.setIsPrivateOwned(true);
126
        onetomanymapping.addTargetForeignKeyFieldName("RESULT.lbuildId", "LOADBUILD.id");
127
        onetomanymapping.addTargetForeignKeyFieldName("RESULT.lbuildTimestamp", "LOADBUILD.lbtimestamp");
128
        //onetomanymapping.addTargetForeignKeyFieldName("RESULT.lbuildId", "LOADBUILD.id");
127
        descriptor.addMapping(onetomanymapping);
129
        descriptor.addMapping(onetomanymapping);
128
130
129
        org.eclipse.persistence.mappings.OneToManyMapping onetomanymapping1 = new org.eclipse.persistence.mappings.OneToManyMapping();
131
        org.eclipse.persistence.mappings.OneToManyMapping onetomanymapping1 = new org.eclipse.persistence.mappings.OneToManyMapping();
Lines 132-138 Link Here
132
        onetomanymapping1.setSetMethodName("setSummariesHolder");
134
        onetomanymapping1.setSetMethodName("setSummariesHolder");
133
        onetomanymapping1.setReferenceClass(org.eclipse.persistence.testing.framework.TestResultsSummary.class);
135
        onetomanymapping1.setReferenceClass(org.eclipse.persistence.testing.framework.TestResultsSummary.class);
134
        onetomanymapping1.setIsPrivateOwned(true);
136
        onetomanymapping1.setIsPrivateOwned(true);
135
        onetomanymapping1.addTargetForeignKeyFieldName("SUMMARY.lbuildId", "LOADBUILD.id");
137
        onetomanymapping1.addTargetForeignKeyFieldName("SUMMARY.lbuildTimestamp", "LOADBUILD.lbtimestamp");
138
        //onetomanymapping1.addTargetForeignKeyFieldName("SUMMARY.lbuildId", "LOADBUILD.id");
136
        descriptor.addMapping(onetomanymapping1);
139
        descriptor.addMapping(onetomanymapping1);
137
140
138
        addDescriptor(descriptor);
141
        addDescriptor(descriptor);
Lines 208-214 Link Here
208
        onetoonemapping.setGetMethodName("getLoadBuildSummaryHolder");
211
        onetoonemapping.setGetMethodName("getLoadBuildSummaryHolder");
209
        onetoonemapping.setSetMethodName("setLoadBuildSummaryHolder");
212
        onetoonemapping.setSetMethodName("setLoadBuildSummaryHolder");
210
        onetoonemapping.setReferenceClass(org.eclipse.persistence.testing.framework.LoadBuildSummary.class);
213
        onetoonemapping.setReferenceClass(org.eclipse.persistence.testing.framework.LoadBuildSummary.class);
211
        onetoonemapping.addForeignKeyFieldName("RESULT.lbuildId", "LOADBUILD.id");
214
        onetoonemapping.addForeignKeyFieldName("RESULT.lbuildTimestamp", "LOADBUILD.lbtimestamp");
215
        //onetoonemapping.addForeignKeyFieldName("RESULT.lbuildId", "LOADBUILD.id");
212
        descriptor.addMapping(onetoonemapping);
216
        descriptor.addMapping(onetoonemapping);
213
217
214
        // SECTION: ONETOONEMAPPING
218
        // SECTION: ONETOONEMAPPING
Lines 331-337 Link Here
331
        onetoonemapping.setGetMethodName("getLoadBuildSummaryHolder");
335
        onetoonemapping.setGetMethodName("getLoadBuildSummaryHolder");
332
        onetoonemapping.setSetMethodName("setLoadBuildSummaryHolder");
336
        onetoonemapping.setSetMethodName("setLoadBuildSummaryHolder");
333
        onetoonemapping.setReferenceClass(org.eclipse.persistence.testing.framework.LoadBuildSummary.class);
337
        onetoonemapping.setReferenceClass(org.eclipse.persistence.testing.framework.LoadBuildSummary.class);
334
        onetoonemapping.addForeignKeyFieldName("SUMMARY.lbuildId", "LOADBUILD.id");
338
        onetoonemapping.addForeignKeyFieldName("SUMMARY.lbuildTimestamp", "LOADBUILD.lbtimestamp");
339
        //onetoonemapping.addForeignKeyFieldName("SUMMARY.lbuildId", "LOADBUILD.id");
335
        descriptor.addMapping(onetoonemapping);
340
        descriptor.addMapping(onetoonemapping);
336
341
337
        org.eclipse.persistence.mappings.OneToOneMapping onetoonemapping1 = new org.eclipse.persistence.mappings.OneToOneMapping();
342
        org.eclipse.persistence.mappings.OneToOneMapping onetoonemapping1 = new org.eclipse.persistence.mappings.OneToOneMapping();
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/LoadBuildSummary.java (+4 lines)
Lines 52-57 Link Here
52
            this.jvm = System.getProperty("java.vm.version");
52
            this.jvm = System.getProperty("java.vm.version");
53
            this.toplinkVersion = Version.getVersion() + " :" + Version.getBuildNumber();
53
            this.toplinkVersion = Version.getVersion() + " :" + Version.getBuildNumber();
54
            this.machine = InetAddress.getLocalHost().getHostName();
54
            this.machine = InetAddress.getLocalHost().getHostName();
55
            // Trim the machine name only because of network issues.
56
            if (this.machine.indexOf(".") != -1) {
57
                this.machine = this.machine.substring(0, this.machine.indexOf("."));
58
            }
55
        } catch (Exception ignore) {
59
        } catch (Exception ignore) {
56
        }
60
        }
57
    }
61
    }
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/MemoryLeakTestCase.java (+91 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.framework;
14
15
import java.util.ArrayList;
16
import java.util.List;
17
import java.lang.ref.WeakReference;
18
19
/**
20
 * Generic test for testing for memory leaks.
21
 */
22
public abstract class MemoryLeakTestCase extends TestCase {
23
24
    /** Stores objects that should garbage collect. */
25
    protected List<WeakReference> weakList;
26
    /** Set number of objects allowed not to garbage collect. */
27
    protected int threshold = 0;
28
    
29
    /**
30
     * Add a weak reference to the object to ensure it garbage collects.
31
     */
32
    public void addWeakReference(Object reference) {
33
        this.weakList.add(new WeakReference(reference));
34
    }
35
    
36
    /**
37
     * Add a weak reference to the object to ensure it garbage collects.
38
     */
39
    public void addWeakReferences(List references) {
40
        for (Object ref : references) {
41
            addWeakReference(ref);
42
        }
43
    }
44
    
45
    public int getThreshold() {
46
        return threshold;
47
    }
48
    
49
    public void setThreshold(int threshold) {
50
        this.threshold = threshold;
51
    }
52
53
    public void setup() {
54
       this.weakList = new ArrayList();
55
       getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
56
    }
57
    
58
    public void verify() {
59
        forceGC();
60
        int count = 0;
61
        for (WeakReference ref : this.weakList) {
62
            if (ref.get() != null) {
63
                count++;
64
            }
65
        }
66
        if (count > this.threshold) {
67
            throwError("Objects did not garbage collect: " + count);
68
        }
69
    }
70
    
71
    /**
72
     * Force a garbage collection.
73
     */
74
    public void forceGC() {
75
        WeakReference ref = new WeakReference(new Object());
76
        for (int loops = 0; loops < 10; loops++) {
77
            List junk = new ArrayList (50000);
78
            for (int i = 0; i < 50000; i++) {
79
                junk.add(new java.math.BigDecimal(i));
80
            }
81
82
            // Force garbage collection.
83
            System.gc();
84
            System.runFinalization();
85
        }
86
        // Check if a garbage collect really occurred.
87
        if (ref.get() != null) {
88
            System.out.println("WARNING: gc did not occur");
89
        }
90
    }    
91
}
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/PromptTestRunner.java (-6 / +6 lines)
Lines 29-44 Link Here
29
    protected static final String LOG_MESSAGES_KEY = "session.logMessages";
29
    protected static final String LOG_MESSAGES_KEY = "session.logMessages";
30
    protected static final String SESSION_LOG_LEVEL_KEY = "session.log.level";
30
    protected static final String SESSION_LOG_LEVEL_KEY = "session.log.level";
31
    protected static final String HANDLE_ERRORS_KEY = "executor.handleErrors";
31
    protected static final String HANDLE_ERRORS_KEY = "executor.handleErrors";
32
    protected static final String DATABASE_PLATFORM_KEY = "login.databaseplatform";
32
    protected static final String DATABASE_PLATFORM_KEY = "db.platform";
33
    protected static final String DRIVER_CLASS_KEY = "login.driverClass";
33
    protected static final String DRIVER_CLASS_KEY = "db.driver";
34
    protected static final String DATABASE_URL_KEY = "login.databaseURL";
34
    protected static final String DATABASE_URL_KEY = "db.url";
35
    protected static final String USER_NAME_KEY = "login.username";
35
    protected static final String USER_NAME_KEY = "db.user";
36
    protected static final String PASSWORD_KEY = "login.password";
36
    protected static final String PASSWORD_KEY = "db.pwd";
37
    protected static final String DEFAULT_SESSION_LOG = "console";
37
    protected static final String DEFAULT_SESSION_LOG = "console";
38
    protected static final String DEFAULT_LOG_MESSAGES = "false";
38
    protected static final String DEFAULT_LOG_MESSAGES = "false";
39
    protected static final String DEFAULT_LOG_LEVEL = "INFO";
39
    protected static final String DEFAULT_LOG_LEVEL = "INFO";
40
    protected static final String DEFAULT_HANDLE_ERRORS = "true";
40
    protected static final String DEFAULT_HANDLE_ERRORS = "true";
41
    protected static final String DEFAULT_DATABASE_PLATFORM = "oracle";
41
    protected static final String DEFAULT_DATABASE_PLATFORM = "org.eclipse.persistence.platform.database.oracle.OraclePlatform";
42
    protected static final String DEFAULT_DRIVER_CLASS = "oracle.jdbc.OracleDriver";
42
    protected static final String DEFAULT_DRIVER_CLASS = "oracle.jdbc.OracleDriver";
43
    protected static final String DEFAULT_DATABASE_URL = "jdbc:oracle:thin:@localhost:1521:ORCL";
43
    protected static final String DEFAULT_DATABASE_URL = "jdbc:oracle:thin:@localhost:1521:ORCL";
44
    protected static final String DEFAULT_USER_NAME = "scott";
44
    protected static final String DEFAULT_USER_NAME = "scott";
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/framework/TestCase.java (-4 / +1 lines)
Lines 149-158 Link Here
149
            }
149
            }
150
    
150
    
151
            try {
151
            try {
152
                long testStartTime = System.currentTimeMillis();
152
                executeTest();    
153
                executeTest();
154
                long testEndTime = System.currentTimeMillis();
155
    
156
                verify();
153
                verify();
157
            } catch (EclipseLinkException exception) {
154
            } catch (EclipseLinkException exception) {
158
                executeFailed = true;
155
                executeFailed = true;
(-)foundation/eclipselink.core.test/src/org/eclipse/persistence/testing/tests/TestRunModel.java (+1 lines)
Lines 327-332 Link Here
327
        performanceTests.addElement("org.eclipse.persistence.testing.tests.performance.ConcurrencyRegressionTestModel");
327
        performanceTests.addElement("org.eclipse.persistence.testing.tests.performance.ConcurrencyRegressionTestModel");
328
        performanceTests.addElement("org.eclipse.persistence.testing.tests.performance.JavaPerformanceComparisonModel");
328
        performanceTests.addElement("org.eclipse.persistence.testing.tests.performance.JavaPerformanceComparisonModel");
329
        performanceTests.addElement("org.eclipse.persistence.testing.tests.jpa.performance.JPAPerformanceTestModel");
329
        performanceTests.addElement("org.eclipse.persistence.testing.tests.jpa.performance.JPAPerformanceTestModel");
330
        performanceTests.addElement("org.eclipse.persistence.testing.tests.jpa.memory.JPAMemoryTestModel");
330
                    
331
                    
331
        TestModel performanceModel = new TestModel();
332
        TestModel performanceModel = new TestModel();
332
        performanceModel.setName("Performance Tests");
333
        performanceModel.setName("Performance Tests");
(-)jpa/eclipselink.jpa.test/build.xml (-2 / +2 lines)
Lines 21-27 Link Here
21
    <!-- Allows a user to overide certain user specific properties. -->
21
    <!-- Allows a user to overide certain user specific properties. -->
22
    <property file="${user.home}/build.properties"/>
22
    <property file="${user.home}/build.properties"/>
23
    <property file="${user.home}/test.properties"/>
23
    <property file="${user.home}/test.properties"/>
24
    <property file="./build.properties"/>
24
    <property name="eclipselink.jpa.test" value="."/>
25
    <property file="${eclipselink.jpa.test}/build.properties"/>
25
    <property file="${eclipselink.jpa.test}/build.properties"/>
26
    <property file="${eclipselink.jpa.test}/local.build.properties"/>
26
    <property file="${eclipselink.jpa.test}/local.build.properties"/>
27
    <property file="${eclipselink.jpa.test}/${test.properties}"/>
27
    <property file="${eclipselink.jpa.test}/${test.properties}"/>
Lines 95-101 Link Here
95
    </target>
95
    </target>
96
96
97
    <!-- Packages JPA persistent unit test jars. -->
97
    <!-- Packages JPA persistent unit test jars. -->
98
    <target name="package" depends="package.annotation, package.ddl, package.xml-only, package.xml-merge, package.xml-extended, package.validation-failed, package.jpa-advanced-field-access, package.jpa-advanced-properties" description="build EclipseLink jar">
98
    <target name="package" depends="config.trunk, config.flat, package.annotation, package.ddl, package.xml-only, package.xml-merge, package.xml-extended, package.validation-failed, package.jpa-advanced-field-access, package.jpa-advanced-properties, package.jpa-performance" description="build EclipseLink jar">
99
        <jar jarfile="${eclipselink.jpa.test}/${eclipselink.tests.jar}">
99
        <jar jarfile="${eclipselink.jpa.test}/${eclipselink.tests.jar}">
100
           <fileset dir="${eclipselink.jpa.test}/${classes.dir}"
100
           <fileset dir="${eclipselink.jpa.test}/${classes.dir}"
101
                    includes="org/eclipse/persistence/testing/framework/**/*.class,
101
                    includes="org/eclipse/persistence/testing/framework/**/*.class,
(-)jpa/eclipselink.jpa.test/resource/jpa-performance/META-INF/persistence.xml (-1 / +1 lines)
Lines 1-6 Link Here
1
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
1
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence persistence_1_0.xsd" version="1.0">
2
    <persistence-unit name="performance" transaction-type="RESOURCE_LOCAL">
2
    <persistence-unit name="performance" transaction-type="RESOURCE_LOCAL">
3
        <mapping-file>jpa-orm.xml</mapping-file>
3
        <mapping-file>META-INF/jpa-orm.xml</mapping-file>
4
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
4
        <exclude-unlisted-classes>false</exclude-unlisted-classes>
5
    </persistence-unit>
5
    </persistence-unit>
6
</persistence>
6
</persistence>
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/memory/JPAMemoryLeakModel.java (+205 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.memory;
14
15
import java.util.List;
16
import java.util.HashMap;
17
import java.util.Map;
18
19
import javax.persistence.EntityManager;
20
import javax.persistence.Query;
21
import javax.persistence.spi.PersistenceProvider;
22
23
import org.eclipse.persistence.testing.models.performance.*;
24
import org.eclipse.persistence.internal.helper.Helper;
25
import org.eclipse.persistence.jpa.JpaEntityManager;
26
import org.eclipse.persistence.jpa.config.CacheUsage;
27
import org.eclipse.persistence.testing.framework.*;
28
29
/**
30
 * Memory tests that test for memory leaks.
31
 */
32
public class JPAMemoryLeakModel extends TestModel {
33
34
    public JPAMemoryLeakModel() {
35
        setDescription("Memory tests that test for memory leaks.");
36
    }
37
38
    public void addRequiredSystems() {
39
        addRequiredSystem(new EmployeeSystem());
40
    }
41
42
    public void addTests() {
43
        addTest(buildReadTest());
44
        addTest(buildInsertTest());
45
        addTest(buildUpdateTest());
46
    }
47
48
    /**
49
     * Create/populate database.
50
     */
51
    public void setup() {
52
        // Populate database (through TopLink).
53
        for (int j = 0; j < 100; j++) {
54
            Employee empInsert = new Employee();
55
            empInsert.setFirstName("Brendan");
56
            empInsert.setMale();
57
            empInsert.setLastName("" + j + "");
58
            empInsert.setSalary(100000);
59
            EmploymentPeriod employmentPeriod = new EmploymentPeriod();
60
            java.sql.Date startDate = Helper.dateFromString("1901-12-31");
61
            java.sql.Date endDate = Helper.dateFromString("1895-01-01");
62
            employmentPeriod.setEndDate(startDate);
63
            employmentPeriod.setStartDate(endDate);
64
            empInsert.setPeriod(employmentPeriod);
65
            empInsert.setAddress(new Address());
66
            empInsert.getAddress().setCity("Nepean");
67
            empInsert.getAddress().setPostalCode("N5J2N5");
68
            empInsert.getAddress().setProvince("ON");
69
            empInsert.getAddress().setStreet("1111 Mountain Blvd. Floor 13, suite " + j);
70
            empInsert.getAddress().setCountry("Canada");
71
            empInsert.addPhoneNumber(new PhoneNumber("Work Fax", "613", "2255943"));
72
            empInsert.addPhoneNumber(new PhoneNumber("Home", "613", "2224599"));
73
            getDatabaseSession().insertObject(empInsert);
74
        }
75
        setupProvider();
76
        getSession().logMessage(getExecutor().getEntityManagerFactory().getClass().toString());
77
        System.out.println(getExecutor().getEntityManagerFactory().getClass().toString());
78
    }
79
    
80
    /**
81
     * Setup the JPA provider.
82
     */
83
    public void setupProvider() {
84
        // Configure provider to be TopLink.
85
        String providerClass = "org.eclipse.persistence.jpa.PersistenceProvider";
86
        PersistenceProvider provider = null;
87
        try {
88
            provider = (PersistenceProvider)Class.forName(providerClass).newInstance();
89
        } catch (Exception error) {
90
            throw new TestProblemException("Failed to create persistence provider.", error);
91
        }
92
        Map properties = getPersistenceProperties();
93
        getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
94
    }
95
    
96
    /**
97
     * Build the persistence properties.
98
     */
99
    public Map getPersistenceProperties() {    
100
        Map properties = new HashMap();
101
        properties.put("eclipselink.jdbc.driver", getSession().getLogin().getDriverClassName());
102
        properties.put("eclipselink.jdbc.url", getSession().getLogin().getConnectionString());
103
        properties.put("eclipselink.jdbc.user", getSession().getLogin().getUserName());
104
        properties.put("eclipselink.jdbc.password", getSession().getLogin().getPassword());
105
        properties.put("eclipselink.logging.level", getSession().getSessionLog().getLevelString());
106
        properties.put("eclipselink.jdbc.cache-statements", "true");
107
        return properties;
108
    }
109
    
110
    /**
111
     * Test that inserts allow the garbage collection of the persisted objects.
112
     */
113
    public TestCase buildInsertTest() {
114
        MemoryLeakTestCase test = new MemoryLeakTestCase() {
115
            public void test() {
116
                EntityManager manager = createEntityManager();
117
                ((JpaEntityManager)manager).getUnitOfWork().getParent().getIdentityMapAccessor().initializeAllIdentityMaps();
118
                manager.getTransaction().begin();
119
                for (int count = 0; count < 500; count++) {
120
                    Employee employee = new Employee();
121
                    employee.setFirstName("NewGuy");
122
                    employee.setLastName("Smith");
123
    
124
                    manager.persist(employee);
125
                    addWeakReference(employee);
126
                }
127
                manager.getTransaction().commit();
128
                Query query = manager.createQuery("Select e from Employee e");
129
                query.setHint("eclipselink.return-shared", true);
130
                query.setHint("eclipselink.cache-usage", CacheUsage.CheckCacheOnly);
131
                addWeakReferences(query.getResultList());
132
                addWeakReference(manager);
133
                addWeakReference(((JpaEntityManager)manager).getUnitOfWork());
134
                addWeakReference(((JpaEntityManager)manager).getSession());
135
                manager.close();
136
            }
137
            
138
            public void reset() {
139
                getSession().executeNonSelectingSQL("Delete from PHONE where P_NUMBER = '9991111'");
140
                getSession().executeNonSelectingSQL("Delete from EMPLOYEE where F_NAME = 'NewGuy'");
141
                getSession().executeNonSelectingSQL("Delete from ADDRESS where STREET = 'Hasting Perf'");
142
            }
143
        };
144
        test.setName("InsertMemoryLeakTest");
145
        test.setThreshold(100);
146
        return test;
147
    }
148
149
    /**
150
     * Test that update allow the garbage collection of the objects.
151
     */
152
    public TestCase buildUpdateTest() {
153
        MemoryLeakTestCase test = new MemoryLeakTestCase() {
154
            public void test() {
155
                EntityManager manager = createEntityManager();
156
                ((JpaEntityManager)manager).getUnitOfWork().getParent().getIdentityMapAccessor().initializeAllIdentityMaps();
157
                manager.getTransaction().begin();
158
                Query query = manager.createQuery("Select e from Employee e");
159
                List<Employee> employees = query.getResultList();
160
                for (Employee employee : employees) {
161
                    employee.setFirstName("UpdatedGuy");
162
        
163
                    addWeakReference(employee);
164
                }
165
                manager.getTransaction().commit();
166
                query = manager.createQuery("Select e from Employee e");
167
                query.setHint("eclipselink.return-shared", true);
168
                addWeakReferences(query.getResultList());
169
                addWeakReference(manager);
170
                addWeakReference(((JpaEntityManager)manager).getUnitOfWork());
171
                addWeakReference(((JpaEntityManager)manager).getUnitOfWork().getParent());
172
                manager.close();
173
            }
174
        };
175
        test.setName("UpdateMemoryLeakTest");
176
        test.setThreshold(100);
177
        return test;
178
    }
179
    
180
    /**
181
     * Test that read allow the garbage collection of the objects.
182
     */
183
    public TestCase buildReadTest() {
184
        MemoryLeakTestCase test = new MemoryLeakTestCase() {
185
            public void test() {
186
                EntityManager manager = createEntityManager();
187
                ((JpaEntityManager)manager).getUnitOfWork().getParent().getIdentityMapAccessor().initializeAllIdentityMaps();
188
                Query query = manager.createQuery("Select e from Employee e");
189
                query.setHint("eclipselink.return-shared", true);
190
                addWeakReferences(query.getResultList());
191
                addWeakReference(query);
192
                query = manager.createQuery("Select e from Employee e");
193
                addWeakReferences(query.getResultList());
194
                addWeakReference(query);
195
                addWeakReference(manager);
196
                addWeakReference(((JpaEntityManager)manager).getUnitOfWork());
197
                addWeakReference(((JpaEntityManager)manager).getSession());
198
                manager.close();
199
            }
200
        };
201
        test.setName("ReadMemoryLeakTest");
202
        test.setThreshold(100);
203
        return test;
204
    }
205
}
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/memory/JPAMemoryTestModel.java (+27 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.memory;
14
15
import org.eclipse.persistence.testing.framework.*;
16
17
/**
18
 * Memory tests that compare JPA memory.
19
 */
20
public class JPAMemoryTestModel extends TestModel {
21
22
    public JPAMemoryTestModel() {
23
        setDescription("Memory tests that compare JPA memory usage.");
24
        addTest(new JPAMemoryLeakModel());
25
        addTest(new JPAMemoryRegressionModel());
26
    }
27
}
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/memory/JPAMemoryRegressionModel.java (+105 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.memory;
14
15
16
import java.util.HashMap;
17
import java.util.Map;
18
19
import javax.persistence.spi.PersistenceProvider;
20
21
import org.eclipse.persistence.testing.models.performance.*;
22
import org.eclipse.persistence.internal.helper.Helper;
23
import org.eclipse.persistence.testing.framework.*;
24
25
/**
26
 * Memory tests that compare JPA memory usage.
27
 */
28
public class JPAMemoryRegressionModel extends TestModel {
29
30
    public JPAMemoryRegressionModel() {
31
        setDescription("Memory tests that compare JPA memory usage.");
32
    }
33
34
    public void addRequiredSystems() {
35
        addRequiredSystem(new EmployeeSystem());
36
    }
37
38
    public void addTests() {
39
        //addTest(new ServerSessionMemoryRegressionTest());
40
        //addTest(new ReadMemoryRegressionTest());
41
        //addTest(new WriteMemoryRegressionTest());
42
    }
43
44
    /**
45
     * Create/populate database.
46
     */
47
    public void setup() {
48
        // Populate database (through EclipseLink).
49
        for (int j = 0; j < 100; j++) {
50
            Employee empInsert = new Employee();
51
            empInsert.setFirstName("Brendan");
52
            empInsert.setMale();
53
            empInsert.setLastName("" + j + "");
54
            empInsert.setSalary(100000);
55
            EmploymentPeriod employmentPeriod = new EmploymentPeriod();
56
            java.sql.Date startDate = Helper.dateFromString("1901-12-31");
57
            java.sql.Date endDate = Helper.dateFromString("1895-01-01");
58
            employmentPeriod.setEndDate(startDate);
59
            employmentPeriod.setStartDate(endDate);
60
            empInsert.setPeriod(employmentPeriod);
61
            empInsert.setAddress(new Address());
62
            empInsert.getAddress().setCity("Nepean");
63
            empInsert.getAddress().setPostalCode("N5J2N5");
64
            empInsert.getAddress().setProvince("ON");
65
            empInsert.getAddress().setStreet("1111 Mountain Blvd. Floor 13, suite " + j);
66
            empInsert.getAddress().setCountry("Canada");
67
            empInsert.addPhoneNumber(new PhoneNumber("Work Fax", "613", "2255943"));
68
            empInsert.addPhoneNumber(new PhoneNumber("Home", "613", "2224599"));
69
            getDatabaseSession().insertObject(empInsert);
70
        }
71
        setupProvider();
72
        getSession().logMessage(getExecutor().getEntityManagerFactory().getClass().toString());
73
        System.out.println(getExecutor().getEntityManagerFactory().getClass().toString());
74
    }
75
    
76
    /**
77
     * Setup the JPA provider.
78
     */
79
    public void setupProvider() {
80
        // Configure provider to be EclipseLink.
81
        String providerClass = "org.eclipse.persistence.jpa.PersistenceProvider";
82
        PersistenceProvider provider = null;
83
        try {
84
            provider = (PersistenceProvider)Class.forName(providerClass).newInstance();
85
        } catch (Exception error) {
86
            throw new TestProblemException("Failed to create persistence provider.", error);
87
        }
88
        Map properties = getPersistenceProperties();
89
        getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
90
    }
91
    
92
    /**
93
     * Build the persistence properties.
94
     */
95
    public Map getPersistenceProperties() {    
96
        Map properties = new HashMap();
97
        properties.put("eclipselink.jdbc.driver", getSession().getLogin().getDriverClassName());
98
        properties.put("eclipselink.jdbc.url", getSession().getLogin().getConnectionString());
99
        properties.put("eclipselink.jdbc.user", getSession().getLogin().getUserName());
100
        properties.put("eclipselink.jdbc.password", getSession().getLogin().getPassword());
101
        properties.put("eclipselink.logging.level", getSession().getSessionLog().getLevelString());
102
        properties.put("eclipselink.jdbc.cache-statements", "true");
103
        return properties;
104
    }    
105
}
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/memory/JPAMemoryLeakModel.java (+205 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.memory;
14
15
import java.util.List;
16
import java.util.HashMap;
17
import java.util.Map;
18
19
import javax.persistence.EntityManager;
20
import javax.persistence.Query;
21
import javax.persistence.spi.PersistenceProvider;
22
23
import org.eclipse.persistence.testing.models.performance.*;
24
import org.eclipse.persistence.internal.helper.Helper;
25
import org.eclipse.persistence.jpa.JpaEntityManager;
26
import org.eclipse.persistence.jpa.config.CacheUsage;
27
import org.eclipse.persistence.testing.framework.*;
28
29
/**
30
 * Memory tests that test for memory leaks.
31
 */
32
public class JPAMemoryLeakModel extends TestModel {
33
34
    public JPAMemoryLeakModel() {
35
        setDescription("Memory tests that test for memory leaks.");
36
    }
37
38
    public void addRequiredSystems() {
39
        addRequiredSystem(new EmployeeSystem());
40
    }
41
42
    public void addTests() {
43
        addTest(buildReadTest());
44
        addTest(buildInsertTest());
45
        addTest(buildUpdateTest());
46
    }
47
48
    /**
49
     * Create/populate database.
50
     */
51
    public void setup() {
52
        // Populate database (through TopLink).
53
        for (int j = 0; j < 100; j++) {
54
            Employee empInsert = new Employee();
55
            empInsert.setFirstName("Brendan");
56
            empInsert.setMale();
57
            empInsert.setLastName("" + j + "");
58
            empInsert.setSalary(100000);
59
            EmploymentPeriod employmentPeriod = new EmploymentPeriod();
60
            java.sql.Date startDate = Helper.dateFromString("1901-12-31");
61
            java.sql.Date endDate = Helper.dateFromString("1895-01-01");
62
            employmentPeriod.setEndDate(startDate);
63
            employmentPeriod.setStartDate(endDate);
64
            empInsert.setPeriod(employmentPeriod);
65
            empInsert.setAddress(new Address());
66
            empInsert.getAddress().setCity("Nepean");
67
            empInsert.getAddress().setPostalCode("N5J2N5");
68
            empInsert.getAddress().setProvince("ON");
69
            empInsert.getAddress().setStreet("1111 Mountain Blvd. Floor 13, suite " + j);
70
            empInsert.getAddress().setCountry("Canada");
71
            empInsert.addPhoneNumber(new PhoneNumber("Work Fax", "613", "2255943"));
72
            empInsert.addPhoneNumber(new PhoneNumber("Home", "613", "2224599"));
73
            getDatabaseSession().insertObject(empInsert);
74
        }
75
        setupProvider();
76
        getSession().logMessage(getExecutor().getEntityManagerFactory().getClass().toString());
77
        System.out.println(getExecutor().getEntityManagerFactory().getClass().toString());
78
    }
79
    
80
    /**
81
     * Setup the JPA provider.
82
     */
83
    public void setupProvider() {
84
        // Configure provider to be TopLink.
85
        String providerClass = "org.eclipse.persistence.jpa.PersistenceProvider";
86
        PersistenceProvider provider = null;
87
        try {
88
            provider = (PersistenceProvider)Class.forName(providerClass).newInstance();
89
        } catch (Exception error) {
90
            throw new TestProblemException("Failed to create persistence provider.", error);
91
        }
92
        Map properties = getPersistenceProperties();
93
        getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
94
    }
95
    
96
    /**
97
     * Build the persistence properties.
98
     */
99
    public Map getPersistenceProperties() {    
100
        Map properties = new HashMap();
101
        properties.put("eclipselink.jdbc.driver", getSession().getLogin().getDriverClassName());
102
        properties.put("eclipselink.jdbc.url", getSession().getLogin().getConnectionString());
103
        properties.put("eclipselink.jdbc.user", getSession().getLogin().getUserName());
104
        properties.put("eclipselink.jdbc.password", getSession().getLogin().getPassword());
105
        properties.put("eclipselink.logging.level", getSession().getSessionLog().getLevelString());
106
        properties.put("eclipselink.jdbc.cache-statements", "true");
107
        return properties;
108
    }
109
    
110
    /**
111
     * Test that inserts allow the garbage collection of the persisted objects.
112
     */
113
    public TestCase buildInsertTest() {
114
        MemoryLeakTestCase test = new MemoryLeakTestCase() {
115
            public void test() {
116
                EntityManager manager = createEntityManager();
117
                ((JpaEntityManager)manager).getUnitOfWork().getParent().getIdentityMapAccessor().initializeAllIdentityMaps();
118
                manager.getTransaction().begin();
119
                for (int count = 0; count < 500; count++) {
120
                    Employee employee = new Employee();
121
                    employee.setFirstName("NewGuy");
122
                    employee.setLastName("Smith");
123
    
124
                    manager.persist(employee);
125
                    addWeakReference(employee);
126
                }
127
                manager.getTransaction().commit();
128
                Query query = manager.createQuery("Select e from Employee e");
129
                query.setHint("eclipselink.return-shared", true);
130
                query.setHint("eclipselink.cache-usage", CacheUsage.CheckCacheOnly);
131
                addWeakReferences(query.getResultList());
132
                addWeakReference(manager);
133
                addWeakReference(((JpaEntityManager)manager).getUnitOfWork());
134
                addWeakReference(((JpaEntityManager)manager).getSession());
135
                manager.close();
136
            }
137
            
138
            public void reset() {
139
                getSession().executeNonSelectingSQL("Delete from PHONE where P_NUMBER = '9991111'");
140
                getSession().executeNonSelectingSQL("Delete from EMPLOYEE where F_NAME = 'NewGuy'");
141
                getSession().executeNonSelectingSQL("Delete from ADDRESS where STREET = 'Hasting Perf'");
142
            }
143
        };
144
        test.setName("InsertMemoryLeakTest");
145
        test.setThreshold(100);
146
        return test;
147
    }
148
149
    /**
150
     * Test that update allow the garbage collection of the objects.
151
     */
152
    public TestCase buildUpdateTest() {
153
        MemoryLeakTestCase test = new MemoryLeakTestCase() {
154
            public void test() {
155
                EntityManager manager = createEntityManager();
156
                ((JpaEntityManager)manager).getUnitOfWork().getParent().getIdentityMapAccessor().initializeAllIdentityMaps();
157
                manager.getTransaction().begin();
158
                Query query = manager.createQuery("Select e from Employee e");
159
                List<Employee> employees = query.getResultList();
160
                for (Employee employee : employees) {
161
                    employee.setFirstName("UpdatedGuy");
162
        
163
                    addWeakReference(employee);
164
                }
165
                manager.getTransaction().commit();
166
                query = manager.createQuery("Select e from Employee e");
167
                query.setHint("eclipselink.return-shared", true);
168
                addWeakReferences(query.getResultList());
169
                addWeakReference(manager);
170
                addWeakReference(((JpaEntityManager)manager).getUnitOfWork());
171
                addWeakReference(((JpaEntityManager)manager).getUnitOfWork().getParent());
172
                manager.close();
173
            }
174
        };
175
        test.setName("UpdateMemoryLeakTest");
176
        test.setThreshold(100);
177
        return test;
178
    }
179
    
180
    /**
181
     * Test that read allow the garbage collection of the objects.
182
     */
183
    public TestCase buildReadTest() {
184
        MemoryLeakTestCase test = new MemoryLeakTestCase() {
185
            public void test() {
186
                EntityManager manager = createEntityManager();
187
                ((JpaEntityManager)manager).getUnitOfWork().getParent().getIdentityMapAccessor().initializeAllIdentityMaps();
188
                Query query = manager.createQuery("Select e from Employee e");
189
                query.setHint("eclipselink.return-shared", true);
190
                addWeakReferences(query.getResultList());
191
                addWeakReference(query);
192
                query = manager.createQuery("Select e from Employee e");
193
                addWeakReferences(query.getResultList());
194
                addWeakReference(query);
195
                addWeakReference(manager);
196
                addWeakReference(((JpaEntityManager)manager).getUnitOfWork());
197
                addWeakReference(((JpaEntityManager)manager).getSession());
198
                manager.close();
199
            }
200
        };
201
        test.setName("ReadMemoryLeakTest");
202
        test.setThreshold(100);
203
        return test;
204
    }
205
}
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/memory/JPAMemoryRegressionModel.java (+105 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.memory;
14
15
16
import java.util.HashMap;
17
import java.util.Map;
18
19
import javax.persistence.spi.PersistenceProvider;
20
21
import org.eclipse.persistence.testing.models.performance.*;
22
import org.eclipse.persistence.internal.helper.Helper;
23
import org.eclipse.persistence.testing.framework.*;
24
25
/**
26
 * Memory tests that compare JPA memory usage.
27
 */
28
public class JPAMemoryRegressionModel extends TestModel {
29
30
    public JPAMemoryRegressionModel() {
31
        setDescription("Memory tests that compare JPA memory usage.");
32
    }
33
34
    public void addRequiredSystems() {
35
        addRequiredSystem(new EmployeeSystem());
36
    }
37
38
    public void addTests() {
39
        //addTest(new ServerSessionMemoryRegressionTest());
40
        //addTest(new ReadMemoryRegressionTest());
41
        //addTest(new WriteMemoryRegressionTest());
42
    }
43
44
    /**
45
     * Create/populate database.
46
     */
47
    public void setup() {
48
        // Populate database (through EclipseLink).
49
        for (int j = 0; j < 100; j++) {
50
            Employee empInsert = new Employee();
51
            empInsert.setFirstName("Brendan");
52
            empInsert.setMale();
53
            empInsert.setLastName("" + j + "");
54
            empInsert.setSalary(100000);
55
            EmploymentPeriod employmentPeriod = new EmploymentPeriod();
56
            java.sql.Date startDate = Helper.dateFromString("1901-12-31");
57
            java.sql.Date endDate = Helper.dateFromString("1895-01-01");
58
            employmentPeriod.setEndDate(startDate);
59
            employmentPeriod.setStartDate(endDate);
60
            empInsert.setPeriod(employmentPeriod);
61
            empInsert.setAddress(new Address());
62
            empInsert.getAddress().setCity("Nepean");
63
            empInsert.getAddress().setPostalCode("N5J2N5");
64
            empInsert.getAddress().setProvince("ON");
65
            empInsert.getAddress().setStreet("1111 Mountain Blvd. Floor 13, suite " + j);
66
            empInsert.getAddress().setCountry("Canada");
67
            empInsert.addPhoneNumber(new PhoneNumber("Work Fax", "613", "2255943"));
68
            empInsert.addPhoneNumber(new PhoneNumber("Home", "613", "2224599"));
69
            getDatabaseSession().insertObject(empInsert);
70
        }
71
        setupProvider();
72
        getSession().logMessage(getExecutor().getEntityManagerFactory().getClass().toString());
73
        System.out.println(getExecutor().getEntityManagerFactory().getClass().toString());
74
    }
75
    
76
    /**
77
     * Setup the JPA provider.
78
     */
79
    public void setupProvider() {
80
        // Configure provider to be EclipseLink.
81
        String providerClass = "org.eclipse.persistence.jpa.PersistenceProvider";
82
        PersistenceProvider provider = null;
83
        try {
84
            provider = (PersistenceProvider)Class.forName(providerClass).newInstance();
85
        } catch (Exception error) {
86
            throw new TestProblemException("Failed to create persistence provider.", error);
87
        }
88
        Map properties = getPersistenceProperties();
89
        getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
90
    }
91
    
92
    /**
93
     * Build the persistence properties.
94
     */
95
    public Map getPersistenceProperties() {    
96
        Map properties = new HashMap();
97
        properties.put("eclipselink.jdbc.driver", getSession().getLogin().getDriverClassName());
98
        properties.put("eclipselink.jdbc.url", getSession().getLogin().getConnectionString());
99
        properties.put("eclipselink.jdbc.user", getSession().getLogin().getUserName());
100
        properties.put("eclipselink.jdbc.password", getSession().getLogin().getPassword());
101
        properties.put("eclipselink.logging.level", getSession().getSessionLog().getLevelString());
102
        properties.put("eclipselink.jdbc.cache-statements", "true");
103
        return properties;
104
    }    
105
}
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/memory/JPAMemoryTestModel.java (+27 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.memory;
14
15
import org.eclipse.persistence.testing.framework.*;
16
17
/**
18
 * Memory tests that compare JPA memory.
19
 */
20
public class JPAMemoryTestModel extends TestModel {
21
22
    public JPAMemoryTestModel() {
23
        setDescription("Memory tests that compare JPA memory usage.");
24
        addTest(new JPAMemoryLeakModel());
25
        addTest(new JPAMemoryRegressionModel());
26
    }
27
}
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/performance/EssentialsJPAPerformanceRegressionModel.java (-6 / +6 lines)
Lines 32-38 Link Here
32
     */
32
     */
33
    public void setupProvider() {
33
    public void setupProvider() {
34
        // Configure provider to be TopLink.
34
        // Configure provider to be TopLink.
35
        String providerClass = "org.eclipse.persistence.essentials.PersistenceProvider";
35
        String providerClass = "oracle.toplink.essentials.PersistenceProvider";
36
        PersistenceProvider provider = null;
36
        PersistenceProvider provider = null;
37
        try {
37
        try {
38
            provider = (PersistenceProvider)Class.forName(providerClass).newInstance();
38
            provider = (PersistenceProvider)Class.forName(providerClass).newInstance();
Lines 40-50 Link Here
40
            throw new TestProblemException("Failed to create persistence provider.", error);
40
            throw new TestProblemException("Failed to create persistence provider.", error);
41
        }
41
        }
42
        Map properties = new HashMap();
42
        Map properties = new HashMap();
43
        properties.put("eclipselink.jdbc.driver", getSession().getLogin().getDriverClassName());
43
        properties.put("toplink.jdbc.driver", getSession().getLogin().getDriverClassName());
44
        properties.put("eclipselink.jdbc.url", getSession().getLogin().getConnectionString());
44
        properties.put("toplink.jdbc.url", getSession().getLogin().getConnectionString());
45
        properties.put("eclipselink.jdbc.user", getSession().getLogin().getUserName());
45
        properties.put("toplink.jdbc.user", getSession().getLogin().getUserName());
46
        properties.put("eclipselink.jdbc.password", getSession().getLogin().getPassword());
46
        properties.put("toplink.jdbc.password", getSession().getLogin().getPassword());
47
        properties.put("eclipselink.logging.level", getSession().getSessionLog().getLevelString());
47
        properties.put("toplink.logging.level", getSession().getSessionLog().getLevelString());
48
        getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
48
        getExecutor().setEntityManagerFactory(provider.createEntityManagerFactory("performance", properties));
49
    }
49
    }
50
}
50
}
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/performance/JPAPerformanceRegressionModel.java (-4 lines)
Lines 116-125 Link Here
116
        return suite;        
116
        return suite;        
117
    }
117
    }
118
118
119
    public String getMappingResource() {
120
        return "org/eclipse/persistence/testing/models/performance/hibernate/employee.hbm.xml";
121
    }
122
123
    /**
119
    /**
124
     * Create/populate database.
120
     * Create/populate database.
125
     */
121
     */
(-)jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/performance/JPAPerformanceTestModel.java (+1 lines)
Lines 24-29 Link Here
24
        addTest(new JPAPerformanceRegressionModel());
24
        addTest(new JPAPerformanceRegressionModel());
25
        addTest(new JPAIsolatedPerformanceRegressionModel());
25
        addTest(new JPAIsolatedPerformanceRegressionModel());
26
        addTest(new HibernateJPAPerformanceRegressionModel());
26
        addTest(new HibernateJPAPerformanceRegressionModel());
27
        addTest(new TopLinkJPAPerformanceRegressionModel());
27
        addTest(new EssentialsJPAPerformanceRegressionModel());
28
        addTest(new EssentialsJPAPerformanceRegressionModel());
28
    }
29
    }
29
}
30
}
(-)jpa/eclipselink.jpa.test/Testing Browser (JPA).launch (+2 lines)
Lines 35-40 Link Here
35
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/eclipselink.jpa.test/eclipselink-validation-failed-model.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
35
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/eclipselink.jpa.test/eclipselink-validation-failed-model.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
36
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/eclipselink.jpa.test/eclipselink-xml-merge-model.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
36
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/eclipselink.jpa.test/eclipselink-xml-merge-model.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
37
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/eclipselink.jpa.test/eclipselink-xml-only-model.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
37
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/eclipselink.jpa.test/eclipselink-xml-only-model.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
38
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/eclipselink.jpa.test/eclipselink-xml-extended-model.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
39
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/eclipselink.jpa.test/jpa-performance.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
38
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/Engineering/EclipseLink/extension.lib.external/db2java_9.zip&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
40
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/Engineering/EclipseLink/extension.lib.external/db2java_9.zip&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
39
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/Engineering/EclipseLink/extension.lib.external/jconn3.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
41
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/Engineering/EclipseLink/extension.lib.external/jconn3.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
40
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/Engineering/EclipseLink/extension.lib.external/mysql-connector-java-5.0.7-bin.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>
42
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#13;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;C:/Engineering/EclipseLink/extension.lib.external/mysql-connector-java-5.0.7-bin.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#13;&#10;"/>

Return to bug 218628