Drop native OpenJPA support
Issue: SPR-14426
This commit is contained in:
@@ -36,20 +36,11 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests extends org.s
|
||||
"/org/springframework/orm/jpa/hibernate/hibernate-manager.xml", "/org/springframework/orm/jpa/memdb.xml",
|
||||
"/org/springframework/orm/jpa/inject.xml"};
|
||||
|
||||
protected static final String[] OPENJPA_CONFIG_LOCATIONS = new String[] {
|
||||
"/org/springframework/orm/jpa/openjpa/openjpa-manager.xml", "/org/springframework/orm/jpa/memdb.xml",
|
||||
"/org/springframework/orm/jpa/inject.xml"};
|
||||
|
||||
|
||||
private static Provider getProvider() {
|
||||
String provider = System.getProperty("org.springframework.orm.jpa.provider");
|
||||
if (provider != null) {
|
||||
if (provider.toLowerCase().contains("hibernate")) {
|
||||
return Provider.HIBERNATE;
|
||||
}
|
||||
if (provider.toLowerCase().contains("openjpa")) {
|
||||
return Provider.OPENJPA;
|
||||
}
|
||||
if (provider != null && provider.toLowerCase().contains("hibernate")) {
|
||||
return Provider.HIBERNATE;
|
||||
}
|
||||
return Provider.ECLIPSELINK;
|
||||
}
|
||||
@@ -69,8 +60,6 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests extends org.s
|
||||
return ECLIPSELINK_CONFIG_LOCATIONS;
|
||||
case HIBERNATE:
|
||||
return HIBERNATE_CONFIG_LOCATIONS;
|
||||
case OPENJPA:
|
||||
return OPENJPA_CONFIG_LOCATIONS;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown provider: " + provider);
|
||||
}
|
||||
@@ -92,7 +81,7 @@ public abstract class AbstractEntityManagerFactoryIntegrationTests extends org.s
|
||||
|
||||
static enum Provider {
|
||||
|
||||
ECLIPSELINK, HIBERNATE, OPENJPA
|
||||
ECLIPSELINK, HIBERNATE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.orm.jpa.openjpa;
|
||||
|
||||
import java.util.List;
|
||||
import javax.persistence.FlushModeType;
|
||||
import javax.persistence.Query;
|
||||
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManager;
|
||||
import org.apache.openjpa.persistence.OpenJPAEntityManagerFactory;
|
||||
|
||||
import org.springframework.orm.jpa.AbstractContainerEntityManagerFactoryIntegrationTests;
|
||||
import org.springframework.orm.jpa.EntityManagerFactoryInfo;
|
||||
import org.springframework.orm.jpa.SharedEntityManagerCreator;
|
||||
import org.springframework.orm.jpa.domain.Person;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||
import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
/**
|
||||
* OpenJPA-specific JPA tests.
|
||||
*
|
||||
* @author Costin Leau
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class OpenJpaEntityManagerFactoryIntegrationTests extends AbstractContainerEntityManagerFactoryIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected String[] getConfigPaths() {
|
||||
return OPENJPA_CONFIG_LOCATIONS;
|
||||
}
|
||||
|
||||
public void testCanCastNativeEntityManagerFactoryToOpenJpaEntityManagerFactoryImpl() {
|
||||
EntityManagerFactoryInfo emfi = (EntityManagerFactoryInfo) entityManagerFactory;
|
||||
assertTrue("native EMF expected", emfi.getNativeEntityManagerFactory() instanceof OpenJPAEntityManagerFactory);
|
||||
}
|
||||
|
||||
public void testCanCastSharedEntityManagerProxyToOpenJpaEntityManager() {
|
||||
assertTrue("native EM expected", sharedEntityManager instanceof OpenJPAEntityManager);
|
||||
}
|
||||
|
||||
public void testCanGetSharedOpenJpaEntityManagerProxy() {
|
||||
OpenJPAEntityManager openJPAEntityManager = (OpenJPAEntityManager) SharedEntityManagerCreator.createSharedEntityManager(
|
||||
entityManagerFactory, null, OpenJPAEntityManager.class);
|
||||
assertNotNull(openJPAEntityManager.getDelegate());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSavepoint() {
|
||||
TransactionTemplate tt = new TransactionTemplate(transactionManager);
|
||||
tt.setPropagationBehavior(TransactionTemplate.PROPAGATION_NESTED);
|
||||
tt.execute(new TransactionCallbackWithoutResult() {
|
||||
@Override
|
||||
protected void doInTransactionWithoutResult(TransactionStatus status) {
|
||||
Person tony = new Person();
|
||||
tony.setFirstName("Tony");
|
||||
sharedEntityManager.merge(tony);
|
||||
Query q = sharedEntityManager.createQuery("select p from Person as p");
|
||||
q.setFlushMode(FlushModeType.COMMIT);
|
||||
List<Person> people = q.getResultList();
|
||||
assertEquals(1, people.size());
|
||||
assertEquals("Tony", people.get(0).getFirstName());
|
||||
status.setRollbackOnly();
|
||||
}
|
||||
});
|
||||
Query q = sharedEntityManager.createQuery("select p from Person as p");
|
||||
List<Person> people = q.getResultList();
|
||||
assertEquals(0, people.size());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.orm.jpa.openjpa;
|
||||
|
||||
/**
|
||||
* Test that AspectJ weaving (in particular the currently shipped aspects) works
|
||||
* with JPA (see SPR-3873 for more details).
|
||||
*
|
||||
* @author Ramnivas Laddad
|
||||
* @author Chris Beams
|
||||
*/
|
||||
public class OpenJpaEntityManagerFactoryWithAspectJWeavingIntegrationTests extends OpenJpaEntityManagerFactoryIntegrationTests {
|
||||
|
||||
@Override
|
||||
protected String[] getConfigPaths() {
|
||||
return new String[] {
|
||||
"/org/springframework/orm/jpa/openjpa/openjpa-manager-aspectj-weaving.xml",
|
||||
"/org/springframework/orm/jpa/memdb.xml",
|
||||
"/org/springframework/orm/jpa/inject.xml"};
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user