use of org.eclipse.persistence.platform.server.ServerPlatform in project eclipselink by eclipse-ee4j.
the class WebLogic_12_PlatformTest method testUsesPartitions.
@Test
public void testUsesPartitions() {
Assume.assumeFalse("Java version is 12 above. Test will be skipped.", JavaSEPlatform.CURRENT.getMajor() >= 12);
ServerPlatform platform = new WebLogic_12_Platform(null);
Assert.assertFalse(platform.usesPartitions());
setContextHelper();
Assert.assertTrue(platform.usesPartitions());
}
use of org.eclipse.persistence.platform.server.ServerPlatform in project eclipselink by eclipse-ee4j.
the class WebLogic_12_PlatformTest method testGetPartitionId.
@Test
public void testGetPartitionId() {
Assume.assumeFalse("Java version is 12 above. Test will be skipped.", JavaSEPlatform.CURRENT.getMajor() >= 12);
setContextHelper();
ServerPlatform platform = new WebLogic_12_Platform(null);
ICtx.ctx = "test3";
Assert.assertEquals("test3", platform.getPartitionID());
ICtx.ctx = "test1";
Assert.assertEquals("test1", platform.getPartitionID());
}
use of org.eclipse.persistence.platform.server.ServerPlatform in project eclipselink by eclipse-ee4j.
the class EntityManagerJUnitTestSuite method testApplicationManagedInServer.
/**
* The same persistence unit in the server should have the same session for container or application managed.
*/
public void testApplicationManagedInServer() {
EntityManagerFactoryImpl factory;
if (getServerPlatform().isWeblogic()) {
HashMap<String, String> properties = new HashMap<>();
String applicationId = "eclipselink-advanced-model";
ServerPlatform serverPlatform = getServerSession().getServerPlatform();
if (serverPlatform.usesPartitions()) {
WebLogic_12_Platform webLogic12Platform = (WebLogic_12_Platform) serverPlatform;
if (!webLogic12Platform.isGlobalRuntime()) {
applicationId += ("$" + webLogic12Platform.getPartitionName());
}
}
properties.put("weblogic.application-id", applicationId);
factory = (EntityManagerFactoryImpl) Persistence.createEntityManagerFactory("default", properties);
} else {
factory = (EntityManagerFactoryImpl) Persistence.createEntityManagerFactory("default");
}
try {
if (getDatabaseSession() != factory.getServerSession()) {
fail("Application managed persistence unit is not the same as the container managed session. Deployment is broken." + getDatabaseSession().getName() + " != " + factory.getServerSession().getName());
}
} finally {
factory.close();
}
}
use of org.eclipse.persistence.platform.server.ServerPlatform in project eclipselink by eclipse-ee4j.
the class EntityManagerJUnitTestSuite method testEMFTargetServerEnforcing.
public void testEMFTargetServerEnforcing() {
// the test requires passing properties to createEMF or createContainerEMF method.
if (isOnServer()) {
return;
}
EntityManagerFactory emf = null;
try {
System.setProperty(SystemProperties.ENFORCE_TARGET_SERVER, "true");
Map<String, String> properties = new HashMap<>(JUnitTestCaseHelper.getDatabaseProperties());
properties.put(PersistenceUnitProperties.TARGET_SERVER, Platform.class.getName());
properties.put(PersistenceUnitProperties.SESSION_NAME, "dummy-default-session");
PersistenceProvider provider = new PersistenceProvider();
JPAInitializer initializer = provider.getInitializer(getPersistenceUnitName(), properties);
SEPersistenceUnitInfo sePUImpl = initializer.findPersistenceUnitInfo(getPersistenceUnitName(), properties);
emf = provider.createContainerEntityManagerFactory(sePUImpl, properties);
ServerPlatform server = ((JpaEntityManagerFactory) emf).getServerSession().getServerPlatform();
assertNotNull(server);
assertFalse("server should be overridden", server instanceof Platform);
} finally {
System.clearProperty(SystemProperties.ENFORCE_TARGET_SERVER);
if (emf != null) {
emf.close();
}
}
}
use of org.eclipse.persistence.platform.server.ServerPlatform in project eclipselink by eclipse-ee4j.
the class VerifyClientBrokerCreationTest method test.
@Override
public void test() {
serverBroker = new SessionBroker();
ServerSession ssession1 = new ServerSession(ServerBrokerTestModel.getLogin1());
ServerSession ssession2 = new ServerSession(ServerBrokerTestModel.getLogin2());
ssession1.addDescriptors(new EmployeeProject1());
ssession2.addDescriptors(new EmployeeProject2());
serverBroker.registerSession("broker1", ssession1);
serverBroker.registerSession("broker2", ssession2);
serverBroker.setLog(getSession().getLog());
serverBroker.setLogLevel(SessionLog.FINE);
serverBroker.setShouldPropagateChanges(true);
ServerPlatform platform = new CustomServerPlatform(serverBroker);
platform.setExternalTransactionControllerClass(JTATransactionController.class);
serverBroker.setServerPlatform(platform);
serverBroker.login();
clientBroker = serverBroker.acquireClientSessionBroker();
}
Aggregations