Browse Source
Added integration tests in org.springframework.data.jpa.infrastructure that will not be included in the normal test execution as they are purely means to quickly identify potential differences in persistence provider implementations.pull/19/merge
4 changed files with 139 additions and 0 deletions
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
/* |
||||
* Copyright 2013 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.data.jpa.infrastructure; |
||||
|
||||
import org.springframework.test.context.ContextConfiguration; |
||||
|
||||
/** |
||||
* Metamodel tests using OpenJPA. |
||||
* |
||||
* @author Oliver Gierke |
||||
*/ |
||||
@ContextConfiguration("classpath:eclipselink.xml") |
||||
public class EclipseLinkMetamodelIntegrationTests extends MetamodelIntegrationTests { |
||||
|
||||
} |
||||
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
/* |
||||
* Copyright 2013 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.data.jpa.infrastructure; |
||||
|
||||
import static org.hamcrest.CoreMatchers.*; |
||||
import static org.junit.Assert.*; |
||||
|
||||
import javax.persistence.EntityManager; |
||||
import javax.persistence.PersistenceContext; |
||||
import javax.persistence.criteria.CriteriaBuilder; |
||||
import javax.persistence.criteria.CriteriaQuery; |
||||
import javax.persistence.criteria.Path; |
||||
import javax.persistence.criteria.Root; |
||||
import javax.persistence.metamodel.Attribute; |
||||
import javax.persistence.metamodel.Bindable.BindableType; |
||||
import javax.persistence.metamodel.ManagedType; |
||||
import javax.persistence.metamodel.Metamodel; |
||||
|
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.springframework.data.jpa.domain.sample.User; |
||||
import org.springframework.test.context.ContextConfiguration; |
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; |
||||
|
||||
/** |
||||
* @author Oliver Gierke |
||||
*/ |
||||
@RunWith(SpringJUnit4ClassRunner.class) |
||||
@ContextConfiguration({ "classpath:infrastructure.xml" }) |
||||
public class MetamodelIntegrationTests { |
||||
|
||||
@PersistenceContext |
||||
EntityManager em; |
||||
|
||||
@Test |
||||
public void considersOneToOneAttributeAnAssociation() { |
||||
|
||||
Metamodel metamodel = em.getMetamodel(); |
||||
ManagedType<User> type = metamodel.managedType(User.class); |
||||
|
||||
Attribute<? super User, ?> attribute = type.getSingularAttribute("manager"); |
||||
assertThat(attribute.isAssociation(), is(true)); |
||||
} |
||||
|
||||
@Test |
||||
public void pathToEntityIsOfBindableTypeEntityType() { |
||||
|
||||
CriteriaBuilder builder = em.getCriteriaBuilder(); |
||||
CriteriaQuery<User> query = builder.createQuery(User.class); |
||||
|
||||
Root<User> root = query.from(User.class); |
||||
Path<Object> path = root.get("manager"); |
||||
|
||||
assertThat(path.getModel().getBindableType(), is(BindableType.ENTITY_TYPE)); |
||||
} |
||||
} |
||||
@ -0,0 +1,28 @@
@@ -0,0 +1,28 @@
|
||||
/* |
||||
* Copyright 2013 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.data.jpa.infrastructure; |
||||
|
||||
import org.springframework.test.context.ContextConfiguration; |
||||
|
||||
/** |
||||
* Metamodel tests using OpenJPA. |
||||
* |
||||
* @author Oliver Gierke |
||||
*/ |
||||
@ContextConfiguration("classpath:openjpa.xml") |
||||
public class OpenJpaMetamodelIntegrationTests extends MetamodelIntegrationTests { |
||||
|
||||
} |
||||
Loading…
Reference in new issue