cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6676] Adding a test
Date Thu, 19 Nov 2015 21:29:37 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes c8887c9b2 -> 296ce494a


[CXF-6676] Adding a test


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/296ce494
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/296ce494
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/296ce494

Branch: refs/heads/3.1.x-fixes
Commit: 296ce494aaca47e362fee3f736da20125a0ce1d8
Parents: c8887c9
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Thu Nov 19 21:28:00 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Thu Nov 19 21:29:18 2015 +0000

----------------------------------------------------------------------
 .../tools/wadlto/jaxrs/JAXRSContainerTest.java  | 48 ++++++++++++++++++++
 .../src/test/resources/wadl/testComplexPath.xml | 13 ++++++
 2 files changed, 61 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/296ce494/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
index 5c0ab34..bbcde20 100644
--- a/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
+++ b/tools/wadlto/jaxrs/src/test/java/org/apache/cxf/tools/wadlto/jaxrs/JAXRSContainerTest.java
@@ -28,7 +28,10 @@ import java.net.URLClassLoader;
 import java.util.List;
 
 import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
 import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.QueryParam;
 
 import org.apache.cxf.helpers.FileUtils;
@@ -405,6 +408,51 @@ public class JAXRSContainerTest extends ProcessorTestBase {
         }
     }
     
+    @Test
+    public void testComplexPath() {
+        try {
+            JAXRSContainer container = new JAXRSContainer(null);
+
+            ToolContext context = new ToolContext();
+            context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/testComplexPath.xml"));
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
+
+            container.setContext(context);
+            container.execute();
+
+            assertNotNull(output.list());
+            
+            List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class"
+ "$");
+            assertEquals(1, files.size());
+            assertTrue(checkContains(files, "application.Resource.class"));
+            @SuppressWarnings("resource")
+            ClassLoader loader = new URLClassLoader(new URL[] {output.toURI().toURL() });
+            
+            Class<?> test1 = loader.loadClass("application.Resource");
+            Method[] test1Methods = test1.getDeclaredMethods();
+            assertEquals(1, test1Methods.length);
+            assertEquals(2, test1Methods[0].getAnnotations().length);
+            assertNotNull(test1Methods[0].getAnnotation(GET.class));            
+            Path path = test1Methods[0].getAnnotation(Path.class);
+            assertNotNull(path);
+            assertEquals("/get-add-method", path.value());
+            
+            assertEquals("getGetaddmethod", test1Methods[0].getName());
+            Class<?>[] paramTypes = test1Methods[0].getParameterTypes();
+            assertEquals(1, paramTypes.length);
+            Annotation[][] paramAnns = test1Methods[0].getParameterAnnotations();
+            assertEquals(String.class, paramTypes[0]);
+            assertEquals(1, paramAnns[0].length);
+            PathParam test1PathParam1 = (PathParam)paramAnns[0][0];
+            assertEquals("id", test1PathParam1.value());
+            
+        } catch (Exception e) {
+            e.printStackTrace();
+            fail();
+        }
+    }
+    
     @Test    
     public void testCodeGenWithImportedSchemaAndResourceSet() {
         try {

http://git-wip-us.apache.org/repos/asf/cxf/blob/296ce494/tools/wadlto/jaxrs/src/test/resources/wadl/testComplexPath.xml
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/src/test/resources/wadl/testComplexPath.xml b/tools/wadlto/jaxrs/src/test/resources/wadl/testComplexPath.xml
new file mode 100644
index 0000000..372ca85
--- /dev/null
+++ b/tools/wadlto/jaxrs/src/test/resources/wadl/testComplexPath.xml
@@ -0,0 +1,13 @@
+<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
+	<grammars />
+	<resources>
+	 <resource path="/">
+       <resource path="/get-add-method">
+        <param name="id" style="template"/>
+        <method name="GET">
+          <response/>
+        </method>
+      </resource>
+     </resource>
+	</resources>
+</application>


Mime
View raw message