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-7032] Adding a test
Date Tue, 30 Aug 2016 14:15:02 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes a2b365d6a -> 9a8a70b19


[CXF-7032] 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/9a8a70b1
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9a8a70b1
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9a8a70b1

Branch: refs/heads/3.0.x-fixes
Commit: 9a8a70b1965136183c659ef71d416290db377c0a
Parents: a2b365d
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Tue Aug 30 10:29:47 2016 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Tue Aug 30 15:14:48 2016 +0100

----------------------------------------------------------------------
 tools/wadlto/jaxrs/pom.xml                      |  5 +++
 .../tools/wadlto/jaxrs/JAXRSContainerTest.java  | 32 +++++++++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/9a8a70b1/tools/wadlto/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/tools/wadlto/jaxrs/pom.xml b/tools/wadlto/jaxrs/pom.xml
index 01250d2..04f28dd 100644
--- a/tools/wadlto/jaxrs/pom.xml
+++ b/tools/wadlto/jaxrs/pom.xml
@@ -65,5 +65,10 @@
             <version>0.6.4</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>javax.validation</groupId>
+            <artifactId>validation-api</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/9a8a70b1/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 e4c9c15..37e1130 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
@@ -27,11 +27,13 @@ import java.net.URL;
 import java.net.URLClassLoader;
 import java.util.List;
 
+import javax.validation.Valid;
 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.Produces;
 import javax.ws.rs.QueryParam;
 
 import org.apache.cxf.helpers.FileUtils;
@@ -465,13 +467,41 @@ public class JAXRSContainerTest extends ProcessorTestBase {
             context.put(WadlToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
             context.put(WadlToolConstants.CFG_WADLURL, getLocation("/wadl/resourceSameTargetNsSchemas.xml"));
             context.put(WadlToolConstants.CFG_BEAN_VALIDATION, "true");
-            //context.put(WadlToolConstants.CFG_COMPILE, "true");
+            context.put(WadlToolConstants.CFG_COMPILE, "true");
 
             container.setContext(context);
             container.execute();
 
             assertNotNull(output.list());
             
+            List<File> files = FileUtils.getFilesRecurse(output, ".+\\." + "class"
+ "$");
+            assertEquals(4, 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);
+            Method m = test1Methods[0];
+            assertEquals(5, m.getAnnotations().length);
+            assertNotNull(m.getAnnotation(Valid.class));
+            assertNotNull(m.getAnnotation(Path.class));
+            assertNotNull(m.getAnnotation(Consumes.class));
+            assertNotNull(m.getAnnotation(Produces.class));
+            assertNotNull(m.getAnnotation(PUT.class));
+            
+            Class<?>[] paramTypes = m.getParameterTypes();
+            assertEquals(2, paramTypes.length);
+            Annotation[][] paramAnns = m.getParameterAnnotations();
+            assertEquals(String.class, paramTypes[0]);
+            assertEquals(1, paramAnns[0].length);
+            PathParam methodPathParam1 = (PathParam)paramAnns[0][0];
+            assertEquals("id", methodPathParam1.value());
+            
+            assertEquals(1, paramAnns[1].length);
+            assertTrue(paramAnns[1][0] instanceof Valid);
+            
         } catch (Exception e) {
             e.printStackTrace();
             fail();


Mime
View raw message