You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by GitBox <gi...@apache.org> on 2017/12/06 21:47:41 UTC

[GitHub] typekpb commented on a change in pull request #324: RFC introduced: Supress generated date switch for wsdl2java

typekpb commented on a change in pull request #324: RFC introduced: Supress generated date switch for wsdl2java
URL: https://github.com/apache/cxf/pull/324#discussion_r155371258
 
 

 ##########
 File path: tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenOptionTest.java
 ##########
 @@ -294,6 +294,104 @@ private int countGeneratedAnnotations(String str) {
         return count;
     }
 
+    /**
+     * Tests that, when 'suppress-generated-date' option is set, javadocs
+     * won't contain the current date in all the generated java classes.
+     */
+    @Test
+    public void testSuppressGeneratedDatePresentOption() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_SUPPRESS_GENERATED_DATE, "true");
+        env.put(ToolConstants.CFG_COMPILE, null);
+        env.put(ToolConstants.CFG_CLASSDIR, null);
+        processor.setContext(env);
+        processor.execute();
+
+        File dir = new File(output, "org");
+        assertTrue("org directory is not found", dir.exists());
+        dir = new File(dir, "apache");
+        assertTrue("apache directory is not found", dir.exists());
+        assertTrue("apache directory is not found", dir.exists());
+        dir = new File(dir, "cxf");
+        assertTrue("cxf directory is not found", dir.exists());
+        dir = new File(dir, "w2j");
+        assertTrue("w2j directory is not found", dir.exists());
+        dir = new File(dir, "hello_world_soap_http");
+        assertTrue("hello_world_soap_http directory is not found", dir.exists());
+        File types = new File(dir, "types");
+        assertTrue("types directory is not found", dir.exists());
+
+        String str = IOUtils.readStringFromStream(new FileInputStream(new File(dir, "Greeter.java")));
+        assertFalse(currentDatePresent(str));
+        str = IOUtils.readStringFromStream(new FileInputStream(new File(types, "SayHi.java")));
+        assertFalse(currentDatePresent(str));
+        str = IOUtils.readStringFromStream(new FileInputStream(new File(types, "SayHiResponse.java")));
+        assertFalse(currentDatePresent(str));
+    }
+
+    /**
+     * Tests that, when 'suppress-generated-date' option is not present, javadocs
+     * will contain the current date in all the generated java classes.
+     */
+    @Test
+    public void testSuppressGeneratedDateNotPresentOption() throws Exception {
+        env.put(ToolConstants.CFG_WSDLURL, getLocation("/wsdl2java_wsdl/hello_world.wsdl"));
+        env.put(ToolConstants.CFG_MARK_GENERATED, "true");
+        env.put(ToolConstants.CFG_COMPILE, null);
+        env.put(ToolConstants.CFG_CLASSDIR, null);
+        processor.setContext(env);
+        processor.execute();
+
+        File dir = new File(output, "org");
+        assertTrue("org directory is not found", dir.exists());
+        dir = new File(dir, "apache");
+        assertTrue("apache directory is not found", dir.exists());
+        dir = new File(dir, "cxf");
+        assertTrue("cxf directory is not found", dir.exists());
+        dir = new File(dir, "w2j");
+        assertTrue("w2j directory is not found", dir.exists());
+        dir = new File(dir, "hello_world_soap_http");
+        assertTrue("hello_world_soap_http directory is not found", dir.exists());
+        File types = new File(dir, "types");
+        assertTrue("types directory is not found", dir.exists());
+
+        String str = IOUtils.readStringFromStream(new FileInputStream(new File(dir, "Greeter.java")));
+        assertTrue(currentDatePresent(str));
+        str = IOUtils.readStringFromStream(new FileInputStream(new File(types, "SayHi.java")));
+        assertFalse(currentDatePresent(str));
+        str = IOUtils.readStringFromStream(new FileInputStream(new File(types, "SayHiResponse.java")));
+        assertFalse(currentDatePresent(str));
+    }
+
+    private boolean currentDatePresent(String str) {
+        String[] lines = str.split(System.getProperty("line.separator"));
+        boolean expectDate = false;
+
+        for (String line : lines) {
+            if (expectDate) {
+                if (line.contains("Generated source version")) {
+                    break;
+                } else {
+                    return true;
+                }
+            }
+            expectDate = line.contains("This class was generated by");
+        }
+
+        return false;
+    }
+
+    private boolean generatedAnnotationPresent(String str) {
 
 Review comment:
   fixed, thanks

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services