cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r737246 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ systests/src/test/java/org/apache/cxf/systest/jaxrs/ systests/src/test/resources/jaxrs_soap_rest/WEB-...
Date Fri, 23 Jan 2009 23:27:26 GMT
Author: sergeyb
Date: Fri Jan 23 23:27:26 2009
New Revision: 737246

URL: http://svn.apache.org/viewvc?rev=737246&view=rev
Log:
CXF-1949 : adding test case, fixing HTTPMethod inheritance issue

Added:
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrs.java   (with
props)
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxws.java   (with
props)
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl2.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
    cxf/trunk/systests/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java?rev=737246&r1=737245&r2=737246&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServerFactoryBean.java
Fri Jan 23 23:27:26 2009
@@ -22,11 +22,15 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.logging.Logger;
 
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingConfiguration;
 import org.apache.cxf.binding.BindingFactory;
 import org.apache.cxf.binding.BindingFactoryManager;
+import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.AbstractEndpointFactory;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.endpoint.EndpointException;
@@ -58,6 +62,10 @@
  * This will start a server for you and register it with the ServerManager.
  */
 public class JAXRSServerFactoryBean extends AbstractEndpointFactory {
+    
+    private static final Logger LOG = LogUtils.getL7dLogger(JAXRSServerFactoryBean.class);
+    private static final ResourceBundle BUNDLE = BundleUtils.getBundle(JAXRSServerFactoryBean.class);
+    
     protected boolean doInit;
     private Server server;
     private Invoker invoker;
@@ -89,6 +97,13 @@
     
     public Server create() {
         try {
+            if (!serviceFactory.resourcesAvailable()) {
+                org.apache.cxf.common.i18n.Message msg = 
+                    new org.apache.cxf.common.i18n.Message("NO_RESOURCES_AVAILABLE", 
+                                                           BUNDLE);
+                LOG.severe(msg.toString());
+                throw new EndpointException(msg);
+            }
             Endpoint ep = createEndpoint();
             server = new ServerImpl(getBus(), 
                                     ep, 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java?rev=737246&r1=737245&r2=737246&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/JAXRSServiceFactoryBean.java
Fri Jan 23 23:27:26 2009
@@ -61,6 +61,10 @@
         this.enableStatic = staticResolution;
     }
     
+    public boolean resourcesAvailable() {
+        return !classResourceInfos.isEmpty();
+    }
+    
     @Override
     public Service create() {
         initializeServiceModel();

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties?rev=737246&r1=737245&r2=737246&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/Messages.properties Fri
Jan 23 23:27:26 2009
@@ -18,7 +18,7 @@
 #    under the License.
 #
 #
-NO_RESOURCE_OP_EXC=No resource methods found for resource class {0}
+NO_RESOURCES_AVAILABLE=No resource classes found, endpoint can not be created
 NO_SUBRESOURCE_FOUND=No subresource locator found for path {0}
 NULL_SUBRESOURCE=Null subresource locator is returned for path {0}
 

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java?rev=737246&r1=737245&r2=737246&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/AnnotationUtils.java
Fri Jan 23 23:27:26 2009
@@ -128,7 +128,7 @@
     
     public static boolean isMethodAnnotation(Annotation a) { 
         return METHOD_ANNOTATION_CLASSES.contains(a.annotationType())
-               || a.annotationType() == HttpMethod.class;
+               || a.annotationType().getAnnotation(HttpMethod.class) != null;
     }
     
     public static String getAnnotationValue(Annotation a) {

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties?rev=737246&r1=737245&r2=737246&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/Messages.properties
Fri Jan 23 23:27:26 2009
@@ -18,6 +18,7 @@
 #    under the License.
 #
 #
+NO_RESOURCE_OP_EXC=No resource methods found for resource class {0}
 NO_CONTENT_TYPE_SPECIFIED=No Content-Type specified for HTTP {0}
 METHOD_INJECTION_FAILURE=Method {0} injection failure
 METHOD_ACCESS_FAILURE=Method {0} can not be accessed due to security manager restrictions

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java?rev=737246&r1=737245&r2=737246&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/utils/ResourceUtils.java
Fri Jan 23 23:27:26 2009
@@ -100,7 +100,7 @@
         if (cr.getMethodDispatcher().getOperationResourceInfos().isEmpty()) {
             LOG.warning(new org.apache.cxf.common.i18n.Message("NO_RESOURCE_OP_EXC", 
                                                                BUNDLE, 
-                                                               cr.getClass().getName()).toString());
+                                                               cr.getServiceClass().getName()).toString());
             return false;
         }
         return true;

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrs.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrs.java?rev=737246&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrs.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrs.java Fri
Jan 23 23:27:26 2009
@@ -0,0 +1,30 @@
+/**
+ * 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.cxf.systest.jaxrs;
+
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("/myRestService")
+public interface BookStoreJaxrs {
+
+    @GET
+    int getId();
+} 

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrs.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxrs.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxws.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxws.java?rev=737246&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxws.java (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxws.java Fri
Jan 23 23:27:26 2009
@@ -0,0 +1,29 @@
+/**
+ * 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.cxf.systest.jaxrs;
+
+import javax.jws.WebMethod;
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://books.com")
+public interface BookStoreJaxws {
+    @WebMethod
+    int getId();
+} 

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxws.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreJaxws.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl2.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl2.java?rev=737246&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl2.java
(added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl2.java
Fri Jan 23 23:27:26 2009
@@ -0,0 +1,30 @@
+/**
+ * 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.cxf.systest.jaxrs;
+
+
+public class BookStoreSoapRestImpl2 implements BookStoreJaxws, BookStoreJaxrs  {
+
+    public int getId() {
+        return 0;
+    }
+
+        
+}

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreSoapRestImpl2.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java?rev=737246&r1=737245&r2=737246&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSSoapBookTest.java Fri
Jan 23 23:27:26 2009
@@ -45,6 +45,14 @@
     }
     
     @Test
+    public void testGetAll() throws Exception {
+        
+        InputStream in = getRestInputStream("http://localhost:9092/test/services/rest2/myRestService");
+        assertEquals("0", getStringFromInputStream(in));
+                
+    }
+    
+    @Test
     public void testGetBook123() throws Exception {
         
         InputStream in = getRestInputStream("http://localhost:9092/test/services/rest/bookstore/123");
@@ -105,17 +113,8 @@
     private InputStream getRestInputStream(String endpointAddress) throws Exception {
         URL url = new URL(endpointAddress);
         
-        for (int count = 0; count < 25; count++) {
-            URLConnection connect = url.openConnection();
-            connect.addRequestProperty("Accept", "application/xml");
-            try {
-                return connect.getInputStream();
-            } catch (Exception ex) {
-                // continue;
-            }
-        }
-        fail("REST endpoint can not be accessed");
-        // unreachable
-        return null;
+        URLConnection connect = url.openConnection();
+        connect.addRequestProperty("Accept", "application/xml,text/plain");
+        return connect.getInputStream();
     }
 }

Modified: cxf/trunk/systests/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml?rev=737246&r1=737245&r2=737246&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/src/test/resources/jaxrs_soap_rest/WEB-INF/beans.xml Fri Jan 23 23:27:26
2009
@@ -51,6 +51,22 @@
   </jaxrs:server>
   <bean id="bookstore" class="org.apache.cxf.systest.jaxrs.BookStoreSoapRestImpl">
   </bean>
+  
+  <jaxws:endpoint xmlns:s="http://books.com"
+      serviceName="s:BookService"
+      endpointName="s:BookPort"
+      id="soapservice2"
+      implementor="#bookstore2"
+      address="/soap/bookservice2" />
+
+  <jaxrs:server id="restservice2"
+		        address="/rest2">
+    <jaxrs:serviceBeans>
+      <ref bean="bookstore2"/>
+    </jaxrs:serviceBeans>		   
+  </jaxrs:server>
+  <bean id="bookstore2" class="org.apache.cxf.systest.jaxrs.BookStoreSoapRestImpl2">
+  </bean>
 
 </beans>
 <!-- END SNIPPET: beans -->



Mime
View raw message