You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by bu...@apache.org on 2021/04/07 12:44:41 UTC

[cxf] branch master updated: JAXRSServerFactoryBeanDefinitionParser: fix scan condition

This is an automated email from the ASF dual-hosted git repository.

buhhunyx pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new a06d000  JAXRSServerFactoryBeanDefinitionParser: fix scan condition
a06d000 is described below

commit a06d00066c88077a1cf25766b841bd8f6cabb027
Author: Alexey Markevich <bu...@gmail.com>
AuthorDate: Wed Apr 7 15:43:52 2021 +0300

    JAXRSServerFactoryBeanDefinitionParser: fix scan condition
    
    revert 31d685f1ea2d0af72c0d4a0cbf99bd86e7e55f3a
---
 .../JAXRSServerFactoryBeanDefinitionParser.java    |  2 +-
 .../systest/sts/basic_auth/JaxrsBasicAuthTest.java | 31 +++++-----------
 .../org/apache/cxf/systest/sts/jaas/JAASTest.java  | 42 ++++++++--------------
 3 files changed, 25 insertions(+), 50 deletions(-)

diff --git a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
index e2e182e..2115f6d 100644
--- a/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
+++ b/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/spring/JAXRSServerFactoryBeanDefinitionParser.java
@@ -237,7 +237,7 @@ public class JAXRSServerFactoryBeanDefinitionParser extends AbstractBeanDefiniti
                     throw new BeanCreationException("Failed to create bean from classfile", ex);
                 }
             } else if (serviceAnnotationClass != null
-                || !serviceBeansAvailable && !providerBeansAvailable && !resourceProvidersAvailable) {
+                && !serviceBeansAvailable && !providerBeansAvailable && !resourceProvidersAvailable) {
                 discoverContextResources(serviceAnnotationClass);
             }
             if (bus == null) {
diff --git a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/basic_auth/JaxrsBasicAuthTest.java b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/basic_auth/JaxrsBasicAuthTest.java
index f9b726b..0a19a7e 100644
--- a/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/basic_auth/JaxrsBasicAuthTest.java
+++ b/services/sts/systests/advanced/src/test/java/org/apache/cxf/systest/sts/basic_auth/JaxrsBasicAuthTest.java
@@ -18,7 +18,7 @@
  */
 package org.apache.cxf.systest.sts.basic_auth;
 
-import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.InternalServerErrorException;
 
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.systest.sts.deployment.STSServer;
@@ -62,23 +62,20 @@ public class JaxrsBasicAuthTest extends AbstractBusClientServerTestBase {
 
     @org.junit.Test
     public void testBasicAuth() throws Exception {
-
-        doubleIt("alice", "clarinet", false);
+        doubleIt("alice", "clarinet");
     }
 
-    @org.junit.Test(expected = RuntimeException.class)
+    @org.junit.Test(expected = InternalServerErrorException.class)
     public void testBadBasicAuth() throws Exception {
-
-        doubleIt("alice", "trombon", true);
+        doubleIt("alice", "trombon");
     }
 
-    @org.junit.Test(expected = RuntimeException.class)
+    @org.junit.Test(expected = InternalServerErrorException.class)
     public void testNoBasicAuth() throws Exception {
-
-        doubleIt(null, null, true);
+        doubleIt(null, null);
     }
 
-    private static void doubleIt(String username, String password, boolean authFailureExpected) {
+    private static void doubleIt(String username, String password) {
         final String configLocation = "org/apache/cxf/systest/sts/basic_auth/cxf-client.xml";
         final String address = "https://localhost:" + PORT + "/doubleit/services/doubleit-rs";
         final int numToDouble = 25;
@@ -90,17 +87,7 @@ public class JaxrsBasicAuthTest extends AbstractBusClientServerTestBase {
             client = WebClient.create(address, configLocation);
         }
         client.type("text/plain").accept("text/plain");
-        try {
-            int resp = client.post(numToDouble, Integer.class);
-            if (authFailureExpected) {
-                throw new RuntimeException("Exception expected");
-            }
-            org.junit.Assert.assertEquals(2 * numToDouble, resp);
-        } catch (WebApplicationException ex) {
-            if (!authFailureExpected) {
-                throw new RuntimeException("Unexpected exception");
-            }
-            org.junit.Assert.assertEquals(500, ex.getResponse().getStatus());
-        }
+        int resp = client.post(numToDouble, Integer.class);
+        org.junit.Assert.assertEquals(2 * numToDouble, resp);
     }
 }
diff --git a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/jaas/JAASTest.java b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/jaas/JAASTest.java
index efde6e4..f604c3a 100644
--- a/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/jaas/JAASTest.java
+++ b/services/sts/systests/basic/src/test/java/org/apache/cxf/systest/sts/jaas/JAASTest.java
@@ -20,7 +20,7 @@ package org.apache.cxf.systest.sts.jaas;
 
 import java.net.URL;
 
-import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.InternalServerErrorException;
 import javax.xml.namespace.QName;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Service;
@@ -269,43 +269,43 @@ public class JAASTest extends AbstractBusClientServerTestBase {
     @org.junit.Test
     public void testJAXRSSuccessfulInvocation() throws Exception {
         final String address = "https://localhost:" + PORT + "/doubleit/services/doubleit-rs";
-        doubleIt("alice", "clarinet", address, false);
+        doubleIt("alice", "clarinet", address);
     }
 
-    @org.junit.Test(expected = RuntimeException.class)
+    @org.junit.Test(expected = InternalServerErrorException.class)
     public void testJAXRSUnsuccessfulAuthentication() throws Exception {
         final String address = "https://localhost:" + PORT + "/doubleit/services/doubleit-rs";
-        doubleIt("alice", "clarinet2", address, true);
+        doubleIt("alice", "clarinet2", address);
     }
 
-    @org.junit.Test(expected = RuntimeException.class)
+    @org.junit.Test(expected = InternalServerErrorException.class)
     public void testJAXRSUnsuccessfulAuthorization() throws Exception {
         final String address = "https://localhost:" + PORT + "/doubleit/services/doubleit-rs";
-        doubleIt("bob", "trombone", address, true);
+        doubleIt("bob", "trombone", address);
     }
 
     @org.junit.Test
     public void testJAXRSSuccessfulPassthroughInvocation() throws Exception {
         final String address = "https://localhost:" + PORT + "/doubleit/services/doubleit-rs3";
-        doubleIt("alice", "clarinet", address, false);
+        doubleIt("alice", "clarinet", address);
     }
 
-    @org.junit.Test(expected = RuntimeException.class)
+    @org.junit.Test(expected = InternalServerErrorException.class)
     public void testJAXRSUnsuccessfulAuthenticationPassthroughInvocation() throws Exception {
         final String address = "https://localhost:" + PORT + "/doubleit/services/doubleit-rs3";
-        doubleIt("alice", "clarinet2", address, true);
+        doubleIt("alice", "clarinet2", address);
     }
 
-    @org.junit.Test(expected = RuntimeException.class)
+    @org.junit.Test(expected = InternalServerErrorException.class)
     public void testJAXRSUnsuccessfulAuthorizationPassthroughInvocation() throws Exception {
         final String address = "https://localhost:" + PORT + "/doubleit/services/doubleit-rs3";
-        doubleIt("bob", "trombone", address, true);
+        doubleIt("bob", "trombone", address);
     }
 
     @org.junit.Test
     public void testJAXRSSuccessfulInvocationConfig() throws Exception {
         final String address = "https://localhost:" + PORT2 + "/doubleit/services/doubleit-rs";
-        doubleIt("alice", "clarinet", address, false);
+        doubleIt("alice", "clarinet", address);
     }
 
     private static void doubleIt(DoubleItPortType port, int numToDouble) {
@@ -313,9 +313,7 @@ public class JAASTest extends AbstractBusClientServerTestBase {
         assertEquals(numToDouble * 2L, resp);
     }
 
-    private static void doubleIt(String username, String password,
-                                 String address,
-                                 boolean authFailureExpected) {
+    private static void doubleIt(String username, String password, String address) {
         final String configLocation = "org/apache/cxf/systest/sts/jaas/cxf-client.xml";
         final int numToDouble = 25;
 
@@ -326,18 +324,8 @@ public class JAASTest extends AbstractBusClientServerTestBase {
             client = WebClient.create(address, configLocation);
         }
         client.type("text/plain").accept("text/plain");
-        try {
-            int resp = client.post(numToDouble, Integer.class);
-            if (authFailureExpected) {
-                throw new RuntimeException("Exception expected");
-            }
-            assertEquals(2 * numToDouble, resp);
-        } catch (WebApplicationException ex) {
-            if (!authFailureExpected) {
-                throw new RuntimeException("Unexpected exception");
-            }
-            assertEquals(500, ex.getResponse().getStatus());
-        }
+        int resp = client.post(numToDouble, Integer.class);
+        assertEquals(2 * numToDouble, resp);
     }
 
 }