Skip to content
This repository was archived by the owner on May 28, 2018. It is now read-only.

Commit 50e9a5c

Browse files
committed
#3582: @ValidateOnExecution was not processed correctly.
Change-Id: I2d0d1e831c96becce06597a3ced3cfe0c2a3b394
1 parent 0095db5 commit 50e9a5c

File tree

9 files changed

+39
-35
lines changed

9 files changed

+39
-35
lines changed

ext/bean-validation/src/main/java/org/glassfish/jersey/server/validation/internal/DefaultConfiguredValidator.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2012-2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2012-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -171,7 +171,10 @@ public void onValidate(final ValidationInterceptorContext ctx) {
171171
handlingMethod.getParameterTypes());
172172

173173
if (methodDescriptor != null
174-
&& methodDescriptor.hasConstrainedParameters()) {
174+
&& methodDescriptor.hasConstrainedParameters()
175+
&& validateOnExecutionHandler.validateMethod(resource.getClass(),
176+
resourceMethod.getDefinitionMethod(),
177+
resourceMethod.getHandlingMethod())) {
175178
constraintViolations.addAll(forExecutables().validateParameters(resource, handlingMethod, args));
176179
}
177180
}

tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionAbstractTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void testOnMethodValidateInputPassValidateExecutableMiss() throws Excepti
8181

8282
@Test
8383
public void testOnMethodValidateInputPassBiggerValidateExecutableMiss() throws Exception {
84-
_testOnMethod("validateExecutableMiss", 15, 400);
84+
_testOnMethod("validateExecutableMiss", 15, 200);
8585
}
8686

8787
@Test
@@ -91,7 +91,7 @@ public void testOnMethodValidateInputPassValidateExecutableNone() throws Excepti
9191

9292
@Test
9393
public void testOnMethodValidateInputPassBiggerValidateExecutableNone() throws Exception {
94-
_testOnMethod("validateExecutableNone", 15, 400);
94+
_testOnMethod("validateExecutableNone", 15, 200);
9595
}
9696

9797
@Test
@@ -156,7 +156,7 @@ public void testOnTypeValidateInputPassValidateExecutableMiss() throws Exception
156156

157157
@Test
158158
public void testOnTypeValidateInputPassBiggerValidateExecutableMiss() throws Exception {
159-
_testOnType("miss", 15, 400);
159+
_testOnType("miss", 15, 200);
160160
}
161161

162162
@Test
@@ -166,7 +166,7 @@ public void testOnTypeValidateInputPassValidateExecutableNone() throws Exception
166166

167167
@Test
168168
public void testOnTypeValidateInputPassBiggerValidateExecutableNone() throws Exception {
169-
_testOnType("none", 15, 400);
169+
_testOnType("none", 15, 200);
170170
}
171171

172172
@Test
@@ -229,7 +229,7 @@ public void testMixedValidatePassNone() throws Exception {
229229

230230
@Test
231231
public void testMixedValidateInputPassNone() throws Exception {
232-
_test("mixed-none", 15, 400);
232+
_test("mixed-none", 15, 200);
233233
}
234234

235235
@Test

tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionBasicTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,16 @@
5959
import org.glassfish.jersey.server.ResourceConfig;
6060
import org.glassfish.jersey.server.ServerProperties;
6161
import org.glassfish.jersey.test.TestProperties;
62-
import org.glassfish.jersey.test.util.runner.ConcurrentRunner;
6362
import org.glassfish.jersey.test.util.runner.RunSeparately;
6463

6564
import org.junit.Test;
66-
import org.junit.runner.RunWith;
67-
6865
import static org.hamcrest.CoreMatchers.equalTo;
6966
import static org.junit.Assert.assertThat;
7067

7168
/**
7269
* @author Michal Gajdos
7370
*/
74-
@RunWith(ConcurrentRunner.class)
71+
// @RunWith(ConcurrentRunner.class)
7572
public class ValidateOnExecutionBasicTest extends ValidateOnExecutionAbstractTest {
7673

7774
/**
@@ -351,6 +348,16 @@ public void testOnTypeValidateResultFailValidateExecutableDefault() throws Excep
351348
_testOnType("default", -15, 500);
352349
}
353350

351+
@Test
352+
public void testOnTypeValidateInputPassBiggerValidateExecutableMiss() throws Exception {
353+
_testOnType("miss", 15, 200);
354+
}
355+
356+
@Test
357+
public void testOnTypeValidateInputPassBiggerValidateExecutableNone() throws Exception {
358+
_testOnType("none", 15, 200);
359+
}
360+
354361
@Test
355362
public void testOnMethodGetterDefault() throws Exception {
356363
final WebTarget target = target("getter-on-method-default");

tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceGenericsTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
/**
6060
* @author Michal Gajdos
6161
*/
62-
@RunWith(ConcurrentRunner.class)
62+
// @RunWith(ConcurrentRunner.class)
6363
public class ValidateOnExecutionInheritanceGenericsTest extends ValidateOnExecutionAbstractTest {
6464

6565
/**
@@ -434,7 +434,7 @@ protected Application configure() {
434434

435435
@Test
436436
public void testOnTypeValidateInputPassValidateExecutableDefault() throws Exception {
437-
_testOnType("default", 15, 400);
437+
_testOnType("default", 15, 200);
438438
}
439439

440440
@Test

tests/e2e-server/src/test/java/org/glassfish/jersey/tests/e2e/server/validation/validateonexecution/ValidateOnExecutionInheritanceTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,13 @@
5151

5252
import org.glassfish.jersey.server.ResourceConfig;
5353
import org.glassfish.jersey.server.ServerProperties;
54-
import org.glassfish.jersey.test.util.runner.ConcurrentRunner;
5554

5655
import org.junit.Test;
57-
import org.junit.runner.RunWith;
5856

5957
/**
6058
* @author Michal Gajdos
6159
*/
62-
@RunWith(ConcurrentRunner.class)
60+
// @RunWith(ConcurrentRunner.class)
6361
public class ValidateOnExecutionInheritanceTest extends ValidateOnExecutionAbstractTest {
6462

6563
/**
@@ -332,7 +330,7 @@ protected Application configure() {
332330

333331
@Test
334332
public void testOnTypeValidateInputPassValidateExecutableDefault() throws Exception {
335-
_testOnType("default", 15, 400);
333+
_testOnType("default", 15, 200);
336334
}
337335

338336
@Test
@@ -347,7 +345,7 @@ public void testMixedClassValidatePassDefault() throws Exception {
347345

348346
@Test
349347
public void testMixedClassValidateInputPassValidateDefault() throws Exception {
350-
_test("mixed-class-default", 15, 400);
348+
_test("mixed-class-default", 15, 200);
351349
}
352350

353351
@Test
@@ -362,7 +360,7 @@ public void testMixedClassValidatePassNone() throws Exception {
362360

363361
@Test
364362
public void testMixedClassValidateInputPassNone() throws Exception {
365-
_test("mixed-class-none", 15, 400);
363+
_test("mixed-class-none", 15, 200);
366364
}
367365

368366
@Test

tests/integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/CdiOldFashionedResource.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -39,14 +39,12 @@
3939
*/
4040
package org.glassfish.jersey.tests.cdi.bv;
4141

42-
import javax.enterprise.context.RequestScoped;
43-
import javax.validation.constraints.NotNull;
44-
import javax.validation.executable.ExecutableType;
45-
import javax.validation.executable.ValidateOnExecution;
4642
import javax.ws.rs.GET;
4743
import javax.ws.rs.Path;
4844
import javax.ws.rs.QueryParam;
49-
import javax.ws.rs.core.Context;
45+
46+
import javax.enterprise.context.RequestScoped;
47+
import javax.validation.constraints.NotNull;
5048

5149
/**
5250
* This CDI backed resource should get validated.
@@ -64,7 +62,6 @@ public class CdiOldFashionedResource {
6462
*/
6563
@Path("validate")
6664
@GET
67-
@ValidateOnExecution(type = ExecutableType.NONE)
6865
public String getQ(@QueryParam("q") @NotNull String q) {
6966

7067
return q;

tests/integration/cdi-beanvalidation-webapp/src/main/java/org/glassfish/jersey/tests/cdi/bv/Hk2OldFashionedResource.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -39,16 +39,15 @@
3939
*/
4040
package org.glassfish.jersey.tests.cdi.bv;
4141

42-
import javax.enterprise.inject.Vetoed;
43-
import javax.validation.constraints.NotNull;
4442
import javax.ws.rs.GET;
4543
import javax.ws.rs.Path;
4644
import javax.ws.rs.QueryParam;
47-
import javax.ws.rs.core.Context;
45+
46+
import javax.enterprise.inject.Vetoed;
47+
import javax.validation.constraints.NotNull;
4848

4949
/**
50-
* This HK2 managed resource should get validated and validation
51-
* result injected via resource method parameter.
50+
* This HK2 managed resource should get validated.
5251
*
5352
* @author Jakub Podlesak (jakub.podlesak at oracle.com)
5453
*/

tests/integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/BaseValidationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
33
*
4-
* Copyright (c) 2015-2016 Oracle and/or its affiliates. All rights reserved.
4+
* Copyright (c) 2015-2017 Oracle and/or its affiliates. All rights reserved.
55
*
66
* The contents of this file are subject to the terms of either the GNU
77
* General Public License Version 2 only ("GPL") or the Common Development
@@ -47,8 +47,8 @@
4747

4848
import org.glassfish.jersey.logging.LoggingFeature;
4949
import org.glassfish.jersey.test.JerseyTest;
50-
import org.junit.Test;
5150

51+
import org.junit.Test;
5252
import static org.hamcrest.CoreMatchers.is;
5353
import static org.junit.Assert.assertThat;
5454

tests/integration/cdi-beanvalidation-webapp/src/test/java/org/glassfish/jersey/tests/cdi/bv/CombinedTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,4 +218,4 @@ private static String getSystemProperty(final String propertyName, final String
218218
final Properties systemProperties = System.getProperties();
219219
return systemProperties.getProperty(propertyName, defaultValue);
220220
}
221-
}
221+
}

0 commit comments

Comments
 (0)