Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HV-1604 Fix instantiation of the JPATraversableResolver
Also raise the log message to WARN as it's important to be warned if there is an issue instantiating it.
- Loading branch information
Showing
5 changed files
with
66 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...c/test/java/org/hibernate/validator/integration/wildfly/jpa/JPATraversableResolverIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Hibernate Validator, declare and validate application constraints | ||
* | ||
* License: Apache License, Version 2.0 | ||
* See the license.txt file in the root directory or <http://www.apache.org/licenses/LICENSE-2.0>. | ||
*/ | ||
package org.hibernate.validator.integration.wildfly.jpa; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import javax.validation.TraversableResolver; | ||
|
||
import org.hibernate.validator.integration.AbstractArquillianIT; | ||
import org.hibernate.validator.internal.engine.resolver.JPATraversableResolver; | ||
import org.hibernate.validator.internal.engine.resolver.TraversableResolvers; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.asset.Asset; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.descriptor.api.Descriptors; | ||
import org.jboss.shrinkwrap.descriptor.api.persistence20.PersistenceDescriptor; | ||
import org.testng.annotations.Test; | ||
|
||
/** | ||
* Tests that the default {@link TraversableResolver} for a JPA environment is {@code JPATraversableResolver}. | ||
* | ||
* @author Guillaume Smet | ||
*/ | ||
public class JPATraversableResolverIT extends AbstractArquillianIT { | ||
|
||
private static final String WAR_FILE_NAME = JPATraversableResolverIT.class.getSimpleName() + ".war"; | ||
|
||
@Deployment | ||
public static Archive<?> createTestArchive() { | ||
return buildTestArchive( WAR_FILE_NAME ) | ||
.addAsResource( persistenceXml(), "META-INF/persistence.xml" ) | ||
.addAsWebInfResource( EmptyAsset.INSTANCE, "beans.xml" ); | ||
} | ||
|
||
private static Asset persistenceXml() { | ||
String persistenceXml = Descriptors.create( PersistenceDescriptor.class ) | ||
.version( "2.0" ) | ||
.createPersistenceUnit() | ||
.name( "default" ) | ||
.jtaDataSource( "java:jboss/datasources/ExampleDS" ) | ||
.up() | ||
.exportAsString(); | ||
return new StringAsset( persistenceXml ); | ||
} | ||
|
||
@Test | ||
public void testDefaultTraversableResolverInJPAEnvironmentIsJPATraversableResolver() throws Exception { | ||
assertThat( TraversableResolvers.getDefault() ).isInstanceOf( JPATraversableResolver.class ); | ||
} | ||
} |