You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2018/10/27 20:27:13 UTC

svn commit: r1844986 - in /axis/axis2/java/core/trunk/modules/jaxbri-codegen: pom.xml src/test/java/org/apache/axis2/jaxbri/CodeGenerationUtilityTest.java

Author: veithen
Date: Sat Oct 27 20:27:13 2018
New Revision: 1844986

URL: http://svn.apache.org/viewvc?rev=1844986&view=rev
Log:
Add test case for namespace to package mapping.

Modified:
    axis/axis2/java/core/trunk/modules/jaxbri-codegen/pom.xml
    axis/axis2/java/core/trunk/modules/jaxbri-codegen/src/test/java/org/apache/axis2/jaxbri/CodeGenerationUtilityTest.java

Modified: axis/axis2/java/core/trunk/modules/jaxbri-codegen/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri-codegen/pom.xml?rev=1844986&r1=1844985&r2=1844986&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri-codegen/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/jaxbri-codegen/pom.xml Sat Oct 27 20:27:13 2018
@@ -73,6 +73,11 @@
             <artifactId>xmlunit</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>com.google.truth</groupId>
+            <artifactId>truth</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
     <url>http://axis.apache.org/axis2/java/core/</url>
     <scm>

Modified: axis/axis2/java/core/trunk/modules/jaxbri-codegen/src/test/java/org/apache/axis2/jaxbri/CodeGenerationUtilityTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jaxbri-codegen/src/test/java/org/apache/axis2/jaxbri/CodeGenerationUtilityTest.java?rev=1844986&r1=1844985&r2=1844986&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/jaxbri-codegen/src/test/java/org/apache/axis2/jaxbri/CodeGenerationUtilityTest.java (original)
+++ axis/axis2/java/core/trunk/modules/jaxbri-codegen/src/test/java/org/apache/axis2/jaxbri/CodeGenerationUtilityTest.java Sat Oct 27 20:27:13 2018
@@ -19,6 +19,7 @@
 
 package org.apache.axis2.jaxbri;
 
+import static com.google.common.truth.Truth.assertThat;
 import static org.junit.Assert.assertEquals;
 
 import java.io.File;
@@ -34,22 +35,37 @@ import org.apache.axis2.wsdl.codegen.Cod
 import org.apache.axis2.wsdl.databinding.TypeMapper;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaCollection;
+import org.junit.Rule;
 import org.junit.Test;
+import org.junit.rules.TemporaryFolder;
 
 public class CodeGenerationUtilityTest {
-    private static List<XmlSchema> loadSampleSchemaFile() throws Exception {
+    @Rule
+    public final TemporaryFolder outputLocation = new TemporaryFolder();
+
+    private static List<XmlSchema> loadSampleSchemaFile() {
         return Collections.singletonList(new XmlSchemaCollection().read(new StreamSource(
                 CodeGenerationUtilityTest.class.getResource("sampleSchema1.xsd").toString())));
     }
 
     @Test
-    public void testProcessSchemas() throws Exception {
+    public void testProcessSchemas() {
         CodeGenConfiguration codeGenConfiguration = new CodeGenConfiguration();
         codeGenConfiguration.setBaseURI("localhost/test");
-        codeGenConfiguration.setOutputLocation(new File("target"));
+        codeGenConfiguration.setOutputLocation(outputLocation.getRoot());
         TypeMapper mapper = CodeGenerationUtility.processSchemas(loadSampleSchemaFile(), null, codeGenConfiguration);
         Map map = mapper.getAllMappedNames();
         String s = map.get(new QName("http://www.w3schools.com", "note")).toString();
         assertEquals("com.w3schools.Note", s);
     }
+
+    @Test
+    public void testNamespaceMapping() {
+        CodeGenConfiguration codeGenConfiguration = new CodeGenConfiguration();
+        codeGenConfiguration.setBaseURI("dummy");
+        codeGenConfiguration.setUri2PackageNameMap(Collections.singletonMap("http://www.w3schools.com", "test"));
+        codeGenConfiguration.setOutputLocation(outputLocation.getRoot());
+        CodeGenerationUtility.processSchemas(loadSampleSchemaFile(), null, codeGenConfiguration);
+        assertThat(new File(outputLocation.getRoot(), "src/test/Note.java").exists()).isTrue();
+    }
 }