You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/11/17 16:46:47 UTC
tomee git commit: TOMEE-1656 allow to configure mandatory provider
activation as well
Repository: tomee
Updated Branches:
refs/heads/master e7c080987 -> 7bc0bfa29
TOMEE-1656 allow to configure mandatory provider activation as well
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/7bc0bfa2
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/7bc0bfa2
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/7bc0bfa2
Branch: refs/heads/master
Commit: 7bc0bfa290ff2f350fcbb6a686e946c76bece54c
Parents: e7c0809
Author: Romain Manni-Bucau <rm...@gmail.com>
Authored: Tue Nov 17 07:46:41 2015 -0800
Committer: Romain Manni-Bucau <rm...@gmail.com>
Committed: Tue Nov 17 07:46:41 2015 -0800
----------------------------------------------------------------------
.../server/cxf/rs/CxfRsHttpListener.java | 12 +++-
.../cxf/rs/IgnoreMandatoryProviderTest.java | 65 ++++++++++++++++++++
2 files changed, 74 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/7bc0bfa2/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
index 3771f0a..ec7555f 100644
--- a/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
+++ b/server/openejb-cxf-rs/src/main/java/org/apache/openejb/server/cxf/rs/CxfRsHttpListener.java
@@ -466,9 +466,15 @@ public class CxfRsHttpListener implements RsHttpListener {
}
private static void addMandatoryProviders(final Collection<Object> instances) {
- instances.add(new WadlDocumentMessageBodyWriter());
- instances.add(new EJBExceptionMapper());
- instances.add(new ValidationExceptionMapper());
+ if (!shouldSkipProvider(WadlDocumentMessageBodyWriter.class.getName())) {
+ instances.add(new WadlDocumentMessageBodyWriter());
+ }
+ if (!shouldSkipProvider(EJBExceptionMapper.class.getName())) {
+ instances.add(new EJBExceptionMapper());
+ }
+ if (!shouldSkipProvider(ValidationExceptionMapper.class.getName())) {
+ instances.add(new ValidationExceptionMapper());
+ }
}
private Object newProvider(final Class<?> clazz) throws IllegalAccessException, InstantiationException {
http://git-wip-us.apache.org/repos/asf/tomee/blob/7bc0bfa2/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/IgnoreMandatoryProviderTest.java
----------------------------------------------------------------------
diff --git a/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/IgnoreMandatoryProviderTest.java b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/IgnoreMandatoryProviderTest.java
new file mode 100644
index 0000000..3275e83
--- /dev/null
+++ b/server/openejb-cxf-rs/src/test/java/org/apache/openejb/server/cxf/rs/IgnoreMandatoryProviderTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.openejb.server.cxf.rs;
+
+import org.apache.cxf.jaxrs.client.WebClient;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.loader.IO;
+import org.apache.openejb.testing.Classes;
+import org.apache.openejb.testing.ContainerProperties;
+import org.apache.openejb.testing.EnableServices;
+import org.apache.openejb.testing.RandomPort;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import javax.validation.ConstraintViolation;
+import javax.validation.ConstraintViolationException;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.core.Response;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.util.Collections;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(ApplicationComposer.class)
+@EnableServices("jaxrs")
+@Classes(innerClassesAsBean = true)
+@ContainerProperties(@ContainerProperties.Property(name = "org.apache.cxf.jaxrs.validation.ValidationExceptionMapper.activated", value = "false"))
+public class IgnoreMandatoryProviderTest {
+ @RandomPort("http")
+ private URL base;
+
+ @Test
+ public void noHandler() throws IOException {
+ final Response response = WebClient.create(base.toExternalForm()).path("openejb/ignore-mandatory").get();
+ assertEquals(HttpURLConnection.HTTP_INTERNAL_ERROR, response.getStatus()); // 400 with the handler
+ assertTrue(IO.slurp(InputStream.class.cast(response.getEntity())).contains("<h3>Internal Server Error</h3>"));
+ }
+
+ @Path("ignore-mandatory")
+ public static class Thrower {
+ @GET
+ public String throwIt() {
+ throw new ConstraintViolationException(Collections.<ConstraintViolation<?>>emptySet());
+ }
+ }
+}