Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions hibernate-validator/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>hibernate-validator-parent</artifactId>
<groupId>org.hibernate</groupId>
Expand Down Expand Up @@ -99,15 +101,20 @@
<artifactId>slf4j-log4j12</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
<db.dialect>org.hibernate.dialect.H2Dialect</db.dialect>
<jdbc.driver>org.h2.Driver</jdbc.driver>
<jdbc.url>jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1</jdbc.url>
<jdbc.user>sa</jdbc.user>
<jdbc.pass />
<jdbc.isolation />
<jdbc.pass/>
<jdbc.isolation/>
</properties>

<build>
Expand Down Expand Up @@ -236,7 +243,7 @@
</relocation>
</relocations>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer"/>
</transformers>
</configuration>
</execution>
Expand Down Expand Up @@ -264,7 +271,7 @@
</execution>
</executions>
</plugin>
<plugin>
<plugin>
<groupId>org.jboss.maven.plugins</groupId>
<artifactId>maven-jdocbook-style-plugin</artifactId>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ public class ScriptAssertValidatorTest {

@Test
public void scriptEvaluatesToTrue() throws Exception {
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator( "javascript", "true" );
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator( "groovy", "true" );

assertTrue( validator.isValid( new Object(), null ) );
}

@Test
public void scriptEvaluatesToFalse() throws Exception {
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator( "javascript", "false" );
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator( "groovy", "false" );

assertFalse( validator.isValid( new Object(), null ) );
}

@Test
public void scriptExpressionReferencingAnnotatedObject() throws Exception {
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator(
"javascript", "_this.startDate.before(_this.endDate)"
"groovy", "_this.startDate.before(_this.endDate)"
);

Date startDate = new GregorianCalendar( 2009, 8, 20 ).getTime();
Expand All @@ -69,7 +69,7 @@ public void scriptExpressionReferencingAnnotatedObject() throws Exception {
@Test
public void scriptExpressionUsingCustomizedAlias() throws Exception {
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator(
"javascript", "_.startDate.before(_.endDate)", "_"
"groovy", "_.startDate.before(_.endDate)", "_"
);

Date startDate = new GregorianCalendar( 2009, 8, 20 ).getTime();
Expand Down Expand Up @@ -102,22 +102,22 @@ public void unknownLanguageNameRaisesException() throws Exception {

@Test(expectedExceptions = ConstraintDeclarationException.class)
public void illegalScriptExpressionRaisesException() throws Exception {
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator( "javascript", "foo" );
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator( "groovy", "foo" );

validator.isValid( new Object(), null );
}

@Test(expectedExceptions = ConstraintDeclarationException.class)
public void scriptExpressionReturningNullRaisesException() throws Exception {
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator( "javascript", "null" );
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator( "groovy", "null" );

validator.isValid( new Object(), null );
}

@Test(expectedExceptions = ConstraintDeclarationException.class)
public void scriptExpressionReturningNoBooleanRaisesException() throws Exception {
ConstraintValidator<ScriptAssert, Object> validator = getInitializedValidator(
"javascript", "new java.util.Date()"
"groovy", "new java.util.Date()"
);

validator.isValid( new Object(), null );
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@
<artifactId>testng</artifactId>
<version>5.14.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
Expand Down Expand Up @@ -504,5 +509,5 @@
<module>hibernate-validator-distribution</module>
</modules>
</profile>
</profiles>
</profiles>
</project>