Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 116656 Details for
Bug 253004
Need new JPA tests to be run in Oracle High Availability environment
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch file for changes
253004.patch (text/plain), 8.96 KB, created by
Edwin Tang
on 2008-10-31 16:37:04 EDT
(
hide
)
Description:
patch file for changes
Filename:
MIME Type:
Creator:
Edwin Tang
Created:
2008-10-31 16:37:04 EDT
Size:
8.96 KB
patch
obsolete
>Index: jpa/eclipselink.jpa.test/build.xml >=================================================================== >--- jpa/eclipselink.jpa.test/build.xml (revision 2699) >+++ jpa/eclipselink.jpa.test/build.xml (working copy) >@@ -1129,6 +1129,23 @@ > </antcall> > </target> > >+ <!-- This target can only be called in an Oracle High Availability environment - >+ a WebLogic server configured with Multi Data Sources to connect to Oracle RAC database >+ --> >+ <target name="server-test-sessionbean-ha"> >+ <antcall target="server-run-all" inheritRefs="true"> >+ <param name="PERSISTENCE_UNIT_NAME" value="sessionbean"/> >+ <param name="MODEL_DIR" value="org/eclipse/persistence/testing/models/jpa/sessionbean"/> >+ <param name="MODEL_DIR2" value="org/eclipse/persistence/testing/models/jpa/fieldaccess/advanced"/> >+ <param name="MODEL_NAME" value="eclipselink-sessionbean-model"/> >+ <param name="TEST_DIR" value="org/eclipse/persistence/testing/tests/jpa/sessionbean"/> >+ <param name="TEST_NAME" value="eclipselink-sessionbean-model"/> >+ <param name="EAR_NAME" value="eclipselink-sessionbean-model"/> >+ <param name="TEST_SUITE" value="org.eclipse.persistence.testing.tests.jpa.sessionbean.SessionBeanHATests"/> >+ <param name="eclipselink.jpa.test.dir" value="."/> >+ </antcall> >+ </target> >+ > <target name="server-test-fieldaccess-advanced"> > <antcall target="server-run-all" inheritRefs="true"> > <param name="PERSISTENCE_UNIT_NAME" value="fieldaccess"/> >Index: jpa/eclipselink.jpa.test/resource/server/persistence.xml >=================================================================== >--- jpa/eclipselink.jpa.test/resource/server/persistence.xml (revision 2673) >+++ jpa/eclipselink.jpa.test/resource/server/persistence.xml (working copy) >@@ -5,6 +5,7 @@ > <properties> > <property name="eclipselink.target-server" value="%%server-platform%%"/> > <property name="eclipselink.validate-existence" value="true"/> >+ <!--property name="eclipselink.logging.level" value="FINEST"/--> > </properties> > </persistence-unit> > </persistence> >Index: jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/sessionbean/SessionBeanHATests.java >=================================================================== >--- jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/sessionbean/SessionBeanHATests.java (revision 0) >+++ jpa/eclipselink.jpa.test/src/org/eclipse/persistence/testing/tests/jpa/sessionbean/SessionBeanHATests.java (revision 0) >@@ -0,0 +1,154 @@ >+/******************************************************************************* >+ * Copyright (c) 1998, 2008 Oracle. All rights reserved. >+ * This program and the accompanying materials are made available under the >+ * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0 >+ * which accompanies this distribution. >+ * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html >+ * and the Eclipse Distribution License is available at >+ * http://www.eclipse.org/org/documents/edl-v10.php. >+ * >+ * Contributors: >+ * etang - initial API and implementation from Oracle TopLink >+ ******************************************************************************/ >+ package org.eclipse.persistence.testing.tests.jpa.sessionbean; >+ >+import java.util.Random; >+import java.util.Iterator; >+import java.util.List; >+import java.util.Properties; >+import javax.naming.Context; >+import javax.naming.InitialContext; >+import javax.naming.NameNotFoundException; >+import javax.rmi.PortableRemoteObject; >+ >+import junit.framework.*; >+ >+import org.eclipse.persistence.sessions.server.ServerSession; >+ >+import org.eclipse.persistence.exceptions.ValidationException; >+import org.eclipse.persistence.testing.framework.junit.JUnitTestCase; >+import org.eclipse.persistence.testing.models.jpa.fieldaccess.advanced.Department; >+import org.eclipse.persistence.testing.models.jpa.fieldaccess.advanced.Employee; >+import org.eclipse.persistence.testing.models.jpa.fieldaccess.advanced.Address; >+import org.eclipse.persistence.testing.models.jpa.fieldaccess.advanced.AdvancedTableCreator; >+import org.eclipse.persistence.testing.models.jpa.sessionbean.EmployeeService; >+ >+/** >+ * EJB 3 SessionBean tests using EclipseLink JPA >+ * These tests can only be run in Oracle High Availability environment - >+ * a WebLogic server configured with Multi Data Sources to connect to Oracle RAC database >+ * They read/write entity bean repeatly for 300 times, in the meantime, RAC database failures can be simulated, >+ * to ensure no exceptions would be caused the RAC database failures. >+ */ >+public class SessionBeanHATests extends JUnitTestCase { >+ protected EmployeeService service; >+ >+ public SessionBeanHATests() { >+ super(); >+ } >+ >+ public SessionBeanHATests(String name) { >+ super(name); >+ } >+ >+ public SessionBeanHATests(String name, boolean shouldRunTestOnServer) { >+ super(name); >+ this.shouldRunTestOnServer = shouldRunTestOnServer; >+ } >+ >+ public static Test suite() { >+ TestSuite suite = new TestSuite("SessionBeanHATests"); >+ suite.addTest(new SessionBeanHATests("testSetup", true)); >+ suite.addTest(new SessionBeanHATests("testFindAll", false)); >+ suite.addTest(new SessionBeanHATests("testUpdate", false)); >+ >+ return suite; >+ } >+ >+ public void testSetup() throws Exception { >+ new AdvancedTableCreator().replaceTables(JUnitTestCase.getServerSession("sessionbean")); >+ Employee bob = new Employee(); >+ bob.setFirstName("Bob"); >+ bob.setLastName("Jones"); >+ bob.setAddress(new Address()); >+ bob.setDepartment(new Department()); >+ getEmployeeService().insert(bob); >+ Employee joe = new Employee(); >+ joe.setFirstName("Joe"); >+ joe.setLastName("Smith"); >+ joe.setAddress(new Address()); >+ joe.setDepartment(new Department()); >+ getEmployeeService().insert(joe); >+ } >+ >+ public EmployeeService getEmployeeService() throws Exception { >+ if (service == null) { >+ Properties properties = new Properties(); >+ String url = System.getProperty("server-url"); >+ if (url != null) { >+ properties.put("java.naming.provider.url", url); >+ } >+ Context context = new InitialContext(properties); >+ >+ try { >+ service = (EmployeeService) PortableRemoteObject.narrow(context.lookup("EmployeeService#org.eclipse.persistence.testing.models.jpa.sessionbean.EmployeeService"), EmployeeService.class); >+ } catch (NameNotFoundException notFoundException) { >+ throw new Error("Lookup failed.", notFoundException); >+ } >+ } >+ return service; >+ } >+ >+ public void testFindAll() throws Exception { >+ int repeatTimes = 300; >+ >+ for (int i = 1; i <= repeatTimes; i++) { >+ try { >+ System.out.println("===FindAll iteration " + i); >+ List result = getEmployeeService().findAll(); >+ int employCount = 0; >+ for (Iterator iterator = result.iterator(); iterator.hasNext(); ) { >+ Employee employee = (Employee)iterator.next(); >+ employCount++; >+ } >+ if (employCount != 2) { >+ fail("The count is " + employCount +", Failed to find all employees"); >+ } >+ Thread.currentThread().sleep(3000); >+ } catch (Exception e) { >+ fail(e.toString()); >+ } >+ } >+ } >+ >+ public void testUpdate() throws Exception { >+ Employee employee = new Employee(); >+ employee.setFirstName("Bob"); >+ employee.setLastName("Smith"); >+ Employee manager = new Employee(); >+ manager.setFirstName("Jon"); >+ manager.setLastName("Way"); >+ employee.setAddress(new Address()); >+ employee.getAddress().setCity("Nepean"); >+ employee.setManager(manager); >+ >+ int id = getEmployeeService().insert(employee); >+ >+ int repeatTimes = 300; >+ Random generator = new Random(); >+ >+ for (int i = 1; i <= repeatTimes; i++) { >+ try { >+ System.out.println("===Update iteration " + i); >+ >+ employee = getEmployeeService().findById(id); >+ employee.setLastName(String.valueOf(generator.nextInt())); >+ employee.getAddress().setCity(String.valueOf(generator.nextInt())); >+ getEmployeeService().update(employee); >+ Thread.currentThread().sleep(3000); >+ } catch (Exception e) { >+ fail(e.toString()); >+ } >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 253004
: 116656