Search in sources :

Example 1 with ServerPlatform

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());
}
Also used : ServerPlatform(org.eclipse.persistence.platform.server.ServerPlatform) WebLogic_12_Platform(org.eclipse.persistence.platform.server.wls.WebLogic_12_Platform) Test(org.junit.Test)

Example 2 with ServerPlatform

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());
}
Also used : ServerPlatform(org.eclipse.persistence.platform.server.ServerPlatform) WebLogic_12_Platform(org.eclipse.persistence.platform.server.wls.WebLogic_12_Platform) Test(org.junit.Test)

Example 3 with ServerPlatform

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();
    }
}
Also used : HashMap(java.util.HashMap) EntityManagerFactoryImpl(org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl) ServerPlatform(org.eclipse.persistence.platform.server.ServerPlatform) WebLogic_12_Platform(org.eclipse.persistence.platform.server.wls.WebLogic_12_Platform)

Example 4 with ServerPlatform

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();
        }
    }
}
Also used : WebLogic_12_Platform(org.eclipse.persistence.platform.server.wls.WebLogic_12_Platform) ServerPlatform(org.eclipse.persistence.platform.server.ServerPlatform) WebSphere_7_Platform(org.eclipse.persistence.platform.server.was.WebSphere_7_Platform) HashMap(java.util.HashMap) EntityManagerFactory(jakarta.persistence.EntityManagerFactory) JpaEntityManagerFactory(org.eclipse.persistence.jpa.JpaEntityManagerFactory) PersistenceProvider(org.eclipse.persistence.jpa.PersistenceProvider) JPAInitializer(org.eclipse.persistence.internal.jpa.deployment.JPAInitializer) SEPersistenceUnitInfo(org.eclipse.persistence.internal.jpa.deployment.SEPersistenceUnitInfo) ServerPlatform(org.eclipse.persistence.platform.server.ServerPlatform)

Example 5 with ServerPlatform

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();
}
Also used : ServerSession(org.eclipse.persistence.sessions.server.ServerSession) CustomServerPlatform(org.eclipse.persistence.platform.server.CustomServerPlatform) SessionBroker(org.eclipse.persistence.sessions.broker.SessionBroker) ServerPlatform(org.eclipse.persistence.platform.server.ServerPlatform) CustomServerPlatform(org.eclipse.persistence.platform.server.CustomServerPlatform)

Aggregations

ServerPlatform (org.eclipse.persistence.platform.server.ServerPlatform)9 WebLogic_12_Platform (org.eclipse.persistence.platform.server.wls.WebLogic_12_Platform)4 PrivilegedActionException (java.security.PrivilegedActionException)3 ValidationException (org.eclipse.persistence.exceptions.ValidationException)3 PrivilegedNewInstanceFromClass (org.eclipse.persistence.internal.security.PrivilegedNewInstanceFromClass)3 CustomServerPlatform (org.eclipse.persistence.platform.server.CustomServerPlatform)3 OptimisticLockException (jakarta.persistence.OptimisticLockException)2 PersistenceException (jakarta.persistence.PersistenceException)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MalformedURLException (java.net.MalformedURLException)2 RemoteException (java.rmi.RemoteException)2 HashMap (java.util.HashMap)2 ConversionException (org.eclipse.persistence.exceptions.ConversionException)2 DatabaseException (org.eclipse.persistence.exceptions.DatabaseException)2 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)2 EclipseLinkException (org.eclipse.persistence.exceptions.EclipseLinkException)2 EntityManagerSetupException (org.eclipse.persistence.exceptions.EntityManagerSetupException)2 IntegrityException (org.eclipse.persistence.exceptions.IntegrityException)2