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

2017-12-06 Thread GitBox
deki 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_r155334050
 
 

 ##
 File path: 
tools/wsdlto/databinding/jaxb/src/main/java/org/apache/cxf/tools/wsdlto/databinding/jaxb/JAXBDataBinding.java
 ##
 @@ -437,24 +437,20 @@ public void initialize(ToolContext c) throws 
ToolException {
 throw new ToolException(e);
 }
 }
-addSchemas(opts, schemaCompiler, schemas);
-addBindingFiles(opts, jaxbBindings, schemas);
-
 
-for (String ns : context.getNamespacePackageMap().keySet()) {
-File file = JAXBUtils.getPackageMappingSchemaBindingFile(ns, 
context.mapPackageName(ns));
+if (context.optionSet(ToolConstants.CFG_SUPPRESS_GENERATED_DATE)) {
+// Prevents dumping current date as part of javadocs of the Java 
files generated.
+// This is done by passing '-suppress-generated-date' attribute to 
jaxb xjc.
 
 Review comment:
   XJC has no such option, why should we pass it? After removing this codeblock 
the test still passes.


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:
us...@infra.apache.org


With regards,
Apache Git Services


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

2017-12-06 Thread GitBox
deki 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_r155332951
 
 

 ##
 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:
   This method is unused.


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:
us...@infra.apache.org


With regards,
Apache Git Services