Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HV-771, HV-772 Making sure the configuration from highest interface o…
…r superclass is used to determine execution type
- Loading branch information
1 parent
1248db0
commit 7f447bd
Showing
12 changed files
with
361 additions
and
20 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
16 changes: 16 additions & 0 deletions
16
...java/org/hibernate/validator/integration/cdi/methodvalidation/getter/DeliveryService.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
68 changes: 68 additions & 0 deletions
68
...or/integration/cdi/methodvalidation/inheritance/ClassInheritanceMethodValidationTest.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,68 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.hibernate.validator.integration.cdi.methodvalidation.inheritance; | ||
|
||
import javax.inject.Inject; | ||
import javax.validation.ConstraintViolationException; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class ClassInheritanceMethodValidationTest { | ||
|
||
@Deployment | ||
public static JavaArchive createDeployment() { | ||
return ShrinkWrap.create( JavaArchive.class ) | ||
.addClass( SecretService.class ) | ||
.addClass( SecretServiceBase.class ) | ||
.addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" ); | ||
} | ||
|
||
@Inject | ||
SecretService secretService; | ||
|
||
@Test | ||
public void testOverriddenExecutionTypeIsConsidered() { | ||
try { | ||
secretService.whisper( null ); | ||
fail( "Method invocation should have caused a ConstraintViolationException" ); | ||
} | ||
catch ( ConstraintViolationException e ) { | ||
assertEquals( | ||
e.getConstraintViolations() | ||
.iterator() | ||
.next() | ||
.getConstraintDescriptor() | ||
.getAnnotation() | ||
.annotationType(), NotNull.class | ||
); | ||
} | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...on/cdi/methodvalidation/inheritance/MultipleInterfaceInheritanceMethodValidationTest.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,70 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.hibernate.validator.integration.cdi.methodvalidation.inheritance; | ||
|
||
import javax.inject.Inject; | ||
import javax.validation.ConstraintViolationException; | ||
import javax.validation.constraints.NotNull; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static junit.framework.Assert.assertEquals; | ||
import static org.junit.Assert.fail; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class MultipleInterfaceInheritanceMethodValidationTest { | ||
|
||
@Deployment | ||
public static JavaArchive createDeployment() { | ||
return ShrinkWrap.create( JavaArchive.class ) | ||
.addClass( ShipmentServiceFirstInHierarchy.class ) | ||
.addClass( ShipmentServiceSecondInHierarchy.class ) | ||
.addClass( Shipment.class ) | ||
.addClass( ShipmentServiceImpl.class ) | ||
.addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml" ); | ||
} | ||
|
||
@Inject | ||
ShipmentServiceSecondInHierarchy shipmentService; | ||
|
||
@Test | ||
public void testExecutableValidationUsesSettingFromHighestMethodInHierarchy() throws Exception { | ||
try { | ||
shipmentService.getShipment(); | ||
fail( "Method invocation should have caused a ConstraintViolationException" ); | ||
} | ||
catch ( ConstraintViolationException e ) { | ||
assertEquals( | ||
e.getConstraintViolations() | ||
.iterator() | ||
.next() | ||
.getConstraintDescriptor() | ||
.getAnnotation() | ||
.annotationType(), NotNull.class | ||
); | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...a/org/hibernate/validator/integration/cdi/methodvalidation/inheritance/SecretService.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,35 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.hibernate.validator.integration.cdi.methodvalidation.inheritance; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import javax.validation.executable.ExecutableType; | ||
import javax.validation.executable.ValidateOnExecution; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
public class SecretService extends SecretServiceBase { | ||
|
||
// The @ValidateOnExecution annotations here are expected to be ignored | ||
// since the methods override super-type methods | ||
|
||
@ValidateOnExecution(type = ExecutableType.NONE) | ||
@Override | ||
public void whisper(@NotNull String secret) { | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
...g/hibernate/validator/integration/cdi/methodvalidation/inheritance/SecretServiceBase.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,31 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.hibernate.validator.integration.cdi.methodvalidation.inheritance; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import javax.validation.executable.ExecutableType; | ||
import javax.validation.executable.ValidateOnExecution; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
@ValidateOnExecution(type = ExecutableType.ALL) | ||
public class SecretServiceBase { | ||
|
||
public void whisper(@NotNull String id) { | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...t/java/org/hibernate/validator/integration/cdi/methodvalidation/inheritance/Shipment.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,32 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.hibernate.validator.integration.cdi.methodvalidation.inheritance; | ||
|
||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* @author Gunnar Morling | ||
*/ | ||
public class Shipment { | ||
|
||
@NotNull | ||
private String name; | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...lidator/integration/cdi/methodvalidation/inheritance/ShipmentServiceFirstInHierarchy.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,25 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2013, Red Hat, Inc. and/or its affiliates, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* 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.hibernate.validator.integration.cdi.methodvalidation.inheritance; | ||
|
||
/** | ||
* @author Hardy Ferentschik | ||
*/ | ||
public interface ShipmentServiceFirstInHierarchy extends ShipmentServiceSecondInHierarchy { | ||
@Override | ||
Shipment getShipment(); | ||
} |
Oops, something went wrong.