axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject svn commit: r745088 - in /webservices/axis2/branches/java/1_5/modules: codegen/ codegen/test-resources/wsdls/ codegen/test/org/apache/axis2/wsdl/ codegen/test/org/apache/axis2/wsdl/codegen/ codegen/test/org/apache/axis2/wsdl/codegen/schema/ kernel/src/...
Date Tue, 17 Feb 2009 14:10:47 GMT
Author: gdaniels
Date: Tue Feb 17 14:10:47 2009
New Revision: 745088

URL: http://svn.apache.org/viewvc?rev=745088&view=rev
Log:
Add some tests for XML -> Java name conversion.  Unit test the JavaUtils stuff in the kernel
module, and build a WSDL and confirm the generated code looks right in codegen.

Comment out TCP sender from default axis2.xml (TCP receiver is already commented out).

Added:
    webservices/axis2/branches/java/1_5/modules/codegen/build-wsdls.xml
    webservices/axis2/branches/java/1_5/modules/codegen/test-resources/wsdls/
    webservices/axis2/branches/java/1_5/modules/codegen/test-resources/wsdls/Version.wsdl
    webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/XML2JavaMappingTest.java
    webservices/axis2/branches/java/1_5/modules/kernel/test/org/apache/axis2/util/JavaUtilsTests.java
Modified:
    webservices/axis2/branches/java/1_5/modules/codegen/pom.xml
    webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/WSDLServiceBuilderTest.java
    webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/schema/AxisServiceTopElementSchemaGeneratorTest.java
    webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml

Added: webservices/axis2/branches/java/1_5/modules/codegen/build-wsdls.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/codegen/build-wsdls.xml?rev=745088&view=auto
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/codegen/build-wsdls.xml (added)
+++ webservices/axis2/branches/java/1_5/modules/codegen/build-wsdls.xml Tue Feb 17 14:10:47
2009
@@ -0,0 +1,55 @@
+<?xml version="1.0"?>
+
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<project name="itest" basedir=".">
+
+	<target name="wsdl-codegen" unless="test.skip">
+		<!-- Set a property that can be picked up from the ant build.xml's -->
+
+		<echo>Var is ${maven.class.path}</echo>
+
+		<property name="maven.junit.jvmargs" value="" />
+		<path id="maven.dependency.classpath">
+			<path refid="maven.compile.classpath" />
+		</path>
+		<!-- compiling some custom wsdl files -->
+		<property name="wsdl.source.dir" value="test-resources/wsdls" />
+		<property name="wsdl.output.base.dir" value="target/wsdls" />
+		<!-- make the dirs -->
+		<mkdir dir="${wsdl.output.base.dir}" />
+
+		<echo>Compiling Version.wsdl</echo>
+    <delete dir="${wsdl.output.base.dir}/version"/>
+		<mkdir dir="${wsdl.output.base.dir}/version" />
+    <mkdir dir="target/test-classes"/>
+
+		<java fork="yes" classname="org.apache.axis2.wsdl.WSDL2Java" failonerror="yes">
+			<classpath refid="maven.test.classpath" />
+			<classpath location="${compiled.classes.dir}" />
+			<arg line="-ap -o ${wsdl.output.base.dir}/version -d none -s -u -uri test-resources/wsdls/Version.wsdl"
/>
+		</java>
+		<javac fork="yes" destdir="target/test-classes" debug="on">
+			<classpath refid="maven.test.classpath" />
+			<classpath location="${compiled.classes.dir}" />
+			<src path="${wsdl.output.base.dir}/version" />
+		</javac>
+  </target>
+</project>
\ No newline at end of file

Modified: webservices/axis2/branches/java/1_5/modules/codegen/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/codegen/pom.xml?rev=745088&r1=745087&r2=745088&view=diff
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/codegen/pom.xml (original)
+++ webservices/axis2/branches/java/1_5/modules/codegen/pom.xml Tue Feb 17 14:10:47 2009
@@ -33,15 +33,27 @@
     <description>Axis2 Code Generation module</description>
     <dependencies>
         <dependency>
-            <groupId>org.apache.axis2</groupId>
-            <artifactId>axis2-kernel</artifactId>
-            <version>${version}</version>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.axis2</groupId>
-            <artifactId>axis2-adb</artifactId>
-            <version>${version}</version>
+          <groupId>${project.groupId}</groupId>
+          <artifactId>axis2-kernel</artifactId>
+          <version>${project.version}</version>
         </dependency>
+      <dependency>
+        <groupId>${project.groupId}</groupId>
+        <artifactId>axis2-adb</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>${project.groupId}</groupId>
+        <artifactId>axis2-transport-local</artifactId>
+        <version>${transport.local.version}</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>${project.groupId}</groupId>
+        <artifactId>axis2-transport-http</artifactId>
+        <version>${transport.http.version}</version>
+        <scope>test</scope>
+      </dependency>
     </dependencies>
     <build>
         <sourceDirectory>src</sourceDirectory>
@@ -94,31 +106,64 @@
             </testResource>
         </testResources>
         <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <inherited>true</inherited>
+            <configuration>
+              <skip>false</skip>
+              <includes>
+                <include>**/*Test.java</include>
+              </includes>
+            </configuration>
+          </plugin>
+
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-antrun-plugin</artifactId>
                 <executions>
-                    <execution>
-                        <id>process-resources</id>
-                        <phase>process-resources</phase>
-                        <configuration>
-                            <tasks>
-                                <tstamp>
-                                    <format property="build.time" pattern="MMM dd, yyyy
(hh:mm:ss z)" locale="en"/>
-                                </tstamp>
-                                <copy toDir="${basedir}/target/classes/" overwrite="true"
filtering="on">
-                                    <fileset dir="${basedir}/src/" includes="**/*.xsl"/>
-                                    <filterset begintoken="#" endtoken="#">
-                                        <filter token="axisVersion" value="${version}"/>
-                                        <filter token="today" value=" Built on : ${build.time}"/>
-                                    </filterset>
-                                </copy>
-                            </tasks>
-                        </configuration>
-                        <goals>
-                            <goal>run</goal>
-                        </goals>
-                    </execution>
+                  <execution>
+                    <id>generate-test-sources</id>
+                    <phase>generate-test-sources</phase>
+                    <configuration>
+                      <tasks>
+                        <!-- Set a property that can be picked up from the ant build.xml's
-->
+                        <property name="maven.class.path" refid="maven.test.classpath"/>
+                        <echo>Building WSDLs...</echo>
+                        <property name="axis2.home" value="${basedir}/../target"/>
+                        <property name="maven.junit.jvmargs" value=""/>
+                        <path id="maven.dependency.classpath">
+                          <path refid="maven.compile.classpath"/>
+                        </path>
+                        <ant antfile="build-wsdls.xml" inheritall="true" inheritrefs="true"
+                             dir="." target="wsdl-codegen"/>
+                      </tasks>
+                    </configuration>
+                    <goals>
+                      <goal>run</goal>
+                    </goals>
+                  </execution>
+                  <execution>
+                    <id>process-resources</id>
+                    <phase>process-resources</phase>
+                    <configuration>
+                      <tasks>
+                        <tstamp>
+                          <format property="build.time" pattern="MMM dd, yyyy (hh:mm:ss
z)" locale="en"/>
+                        </tstamp>
+                        <copy toDir="${basedir}/target/classes/" overwrite="true" filtering="on">
+                          <fileset dir="${basedir}/src/" includes="**/*.xsl"/>
+                          <filterset begintoken="#" endtoken="#">
+                            <filter token="axisVersion" value="${version}"/>
+                            <filter token="today" value=" Built on : ${build.time}"/>
+                          </filterset>
+                        </copy>
+                      </tasks>
+                    </configuration>
+                    <goals>
+                      <goal>run</goal>
+                    </goals>
+                  </execution>
                 </executions>
             </plugin>
         </plugins>

Added: webservices/axis2/branches/java/1_5/modules/codegen/test-resources/wsdls/Version.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/codegen/test-resources/wsdls/Version.wsdl?rev=745088&view=auto
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/codegen/test-resources/wsdls/Version.wsdl
(added)
+++ webservices/axis2/branches/java/1_5/modules/codegen/test-resources/wsdls/Version.wsdl
Tue Feb 17 14:10:47 2009
@@ -0,0 +1,109 @@
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one
+  ~ or more contributor license agreements. See the NOTICE file
+  ~ distributed with this work for additional information
+  ~ regarding copyright ownership. The ASF licenses this file
+  ~ to you under the Apache License, Version 2.0 (the
+  ~ "License"); you may not use this file except in compliance
+  ~ with the License. You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing,
+  ~ software distributed under the License is distributed on an
+  ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  ~ KIND, either express or implied. See the License for the
+  ~ specific language governing permissions and limitations
+  ~ under the License.
+  -->
+
+<wsdl:definitions xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
+                  xmlns:ns0="http://axisversion.sample/xsd"
+                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
+                  xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
+                  xmlns:ns1="http://org.apache.axis2/xsd"
+                  xmlns:xs="http://www.w3.org/2001/XMLSchema"
+                  xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
+                  xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
+                  targetNamespace="http://axisversion.sample/xsd">
+  <wsdl:types>
+    <xs:schema xmlns:ns="http://axisversion.sample/xsd" attributeFormDefault="qualified"
+               elementFormDefault="unqualified" targetNamespace="http://axisversion.sample/xsd">
+      <xs:element name="ExceptionFault">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element minOccurs="0" name="Exception" nillable="true"
+                        type="xs:anyType"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+      <xs:element name="getVersionResponse">
+        <xs:complexType>
+          <xs:sequence>
+            <xs:element minOccurs="0" name="return" nillable="true" type="xs:string"/>
+          </xs:sequence>
+        </xs:complexType>
+      </xs:element>
+    </xs:schema>
+  </wsdl:types>
+  <wsdl:message name="getVersionRequest"/>
+  <wsdl:message name="getVersionResponse">
+    <wsdl:part name="parameters" element="ns0:getVersionResponse"/>
+  </wsdl:message>
+  <wsdl:message name="getVersionFault">
+    <wsdl:part name="parameters" element="ns0:ExceptionFault"/>
+  </wsdl:message>
+  <wsdl:portType name="VersionPortType">
+    <wsdl:operation name="getVersion">
+      <wsdl:input message="ns0:getVersionRequest" wsaw:Action="urn:getVersion"/>
+      <wsdl:output message="ns0:getVersionResponse" wsaw:Action="urn:getVersionResponse"/>
+      <wsdl:fault message="ns0:getVersionFault" name="getVersionFault"
+                  wsaw:Action="urn:getVersionFault"/>
+    </wsdl:operation>
+
+    <!-- This should turn into "fooBar()" -->
+    <wsdl:operation name="foo-bar">
+      <wsdl:input message="getVersionRequest"/>
+    </wsdl:operation>
+
+    <!-- This should turn into "fooBaR2()" -->
+    <wsdl:operation name="Foo-ba.r2">
+      <wsdl:input message="getVersionRequest"/>
+    </wsdl:operation>
+
+  </wsdl:portType>
+  <wsdl:binding name="VersionSOAP11Binding" type="ns0:VersionPortType">
+    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
+    <wsdl:operation name="getVersion">
+      <soap:operation soapAction="urn:getVersion" style="document"/>
+      <wsdl:input>
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output>
+        <soap:body use="literal"/>
+      </wsdl:output>
+      <wsdl:fault name="getVersionFault">
+        <soap:fault use="literal" name="getVersionFault"/>
+      </wsdl:fault>
+    </wsdl:operation>
+    <wsdl:operation name="foo-bar">
+      <soap:operation soapAction="urn:foo-bar" style="document"/>
+      <wsdl:input>
+        <soap:body use="literal"/>
+      </wsdl:input>
+    </wsdl:operation>
+    <wsdl:operation name="Foo-ba.r2">
+      <soap:operation soapAction="urn:foo-bar" style="document"/>
+      <wsdl:input>
+        <soap:body use="literal"/>
+      </wsdl:input>
+    </wsdl:operation>
+
+  </wsdl:binding>
+  <wsdl:service name="Version">
+    <wsdl:port name="VersionSOAP11port_http" binding="ns0:VersionSOAP11Binding">
+      <soap:address location="http://127.0.0.1:8000/axis2/services/Version"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file

Modified: webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/WSDLServiceBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/WSDLServiceBuilderTest.java?rev=745088&r1=745087&r2=745088&view=diff
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/WSDLServiceBuilderTest.java
(original)
+++ webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/WSDLServiceBuilderTest.java
Tue Feb 17 14:10:47 2009
@@ -55,13 +55,12 @@
         outLocation.mkdirs();
         if (testResourceFile.exists()) {
             File files [] = testResourceFile.listFiles();
-            for (int i = 0; i < files.length; i++) {
-                File file1 = files[i];
+            for (File file1 : files) {
                 if (file1.isFile() && file1.getName().endsWith(".wsdl")) {
                     if (file1.getName().equals("ping-modified.wsdl") ||
-                            file1.getName().equals("ping-unbound.wsdl") ||
-                            file1.getName().equals("wsat.wsdl") ||
-                            file1.getName().equals("no-service.wsdl")) {
+                        file1.getName().equals("ping-unbound.wsdl") ||
+                        file1.getName().equals("wsat.wsdl") ||
+                        file1.getName().equals("no-service.wsdl")) {
                         continue;
                     }
                     try {

Added: webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/XML2JavaMappingTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/XML2JavaMappingTest.java?rev=745088&view=auto
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/XML2JavaMappingTest.java
(added)
+++ webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/XML2JavaMappingTest.java
Tue Feb 17 14:10:47 2009
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.wsdl.codegen;
+
+import junit.framework.TestCase;
+
+public class XML2JavaMappingTest extends TestCase {
+    public void testVersion() throws Exception {
+        Class iface = Class.forName("sample.axisversion.xsd.Version");
+        assertNotNull(iface.getMethod("getVersion"));
+        assertNotNull(iface.getMethod("fooBar"));
+        assertNotNull(iface.getMethod("fooBaR2"));
+        boolean caughtException = false;
+        try {
+            iface.getMethod("foobar2");
+        } catch (NoSuchMethodException e) {
+            caughtException = true;
+        }
+        assertTrue("Didn't catch expected Exception!", caughtException);
+    }
+}

Modified: webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/schema/AxisServiceTopElementSchemaGeneratorTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/schema/AxisServiceTopElementSchemaGeneratorTest.java?rev=745088&r1=745087&r2=745088&view=diff
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/schema/AxisServiceTopElementSchemaGeneratorTest.java
(original)
+++ webservices/axis2/branches/java/1_5/modules/codegen/test/org/apache/axis2/wsdl/codegen/schema/AxisServiceTopElementSchemaGeneratorTest.java
Tue Feb 17 14:10:47 2009
@@ -21,19 +21,16 @@
 
 import junit.framework.TestCase;
 import org.apache.axis2.namespace.Constants;
-import org.apache.axis2.wsdl.codegen.schema.exception.DummySchemaGenerationException;
 
 import javax.xml.namespace.QName;
 import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 
 public class AxisServiceTopElementSchemaGeneratorTest extends TestCase {
 
-    public void testSchemaGeneration(){
+    public void testSchemaGeneration() throws Exception {
 
         AxisServiceTopElementSchemaGenerator schemaGenerator = new AxisServiceTopElementSchemaGenerator(null);
 
@@ -61,19 +58,12 @@
         topElement.setTypeQName(new QName("http://test2.com","testComplexType2"));
         topElements.add(topElement);
 
-
         Map schemaMap = schemaGenerator.getSchemaMap(topElements);
-        try {
-            List xmlSchemaList = schemaGenerator.getXmlSchemaList(schemaMap);
-            org.apache.ws.commons.schema.XmlSchema xmlSchema;
-            for (Iterator iter = xmlSchemaList.iterator();iter.hasNext();){
-                xmlSchema = (org.apache.ws.commons.schema.XmlSchema) iter.next();
-//                xmlSchema.write(System.out);
-            }
-        } catch (DummySchemaGenerationException e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings
| File Templates.
-        }
+        schemaGenerator.getXmlSchemaList(schemaMap);
 
+//        List xmlSchemaList = schemaGenerator.getXmlSchemaList(schemaMap);
+//        for (Object aXmlSchemaList : xmlSchemaList) {
+//            ((org.apache.ws.commons.schema.XmlSchema)aXmlSchemaList).write(System.out);
+//        }
     }
-
 }

Modified: webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml?rev=745088&r1=745087&r2=745088&view=diff
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
(original)
+++ webservices/axis2/branches/java/1_5/modules/kernel/src/org/apache/axis2/deployment/axis2_default.xml
Tue Feb 17 14:10:47 2009
@@ -154,13 +154,13 @@
         <!--uncomment following parameter , and set as you required.-->
         <!--<parameter name="hostname">tcp://myApp.com/ws</parameter>-->
     <!--</transportReceiver>-->
+    <!--<transportSender name="tcp"-->
+                   <!--class="org.apache.axis2.transport.tcp.TCPTransportSender"/>-->
 
     <!-- ================================================= -->
     <!-- Transport Outs -->
     <!-- ================================================= -->
 
-    <transportSender name="tcp"
-                     class="org.apache.axis2.transport.tcp.TCPTransportSender"/>
     <transportSender name="local"
                      class="org.apache.axis2.transport.local.LocalTransportSender"/>
     <transportSender name="http"

Added: webservices/axis2/branches/java/1_5/modules/kernel/test/org/apache/axis2/util/JavaUtilsTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_5/modules/kernel/test/org/apache/axis2/util/JavaUtilsTests.java?rev=745088&view=auto
==============================================================================
--- webservices/axis2/branches/java/1_5/modules/kernel/test/org/apache/axis2/util/JavaUtilsTests.java
(added)
+++ webservices/axis2/branches/java/1_5/modules/kernel/test/org/apache/axis2/util/JavaUtilsTests.java
Tue Feb 17 14:10:47 2009
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2007, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis2.util;
+
+import junit.framework.TestCase;
+
+public class JavaUtilsTests extends TestCase {
+    public void testXMLNameMapping() throws Exception {
+        /* Begin TABLE 20-2 Illustrative Examples from JAXRPC Spec */
+        assertEquals("mixedCaseName", JavaUtils.xmlNameToJavaIdentifier("mixedCaseName"));
+
+        assertEquals("nameWithDashes", JavaUtils.xmlNameToJavaIdentifier("name-with-dashes"));
+
+        assertEquals("name_with_underscore", JavaUtils.xmlNameToJavaIdentifier("name_with_underscore"));
+
+        assertEquals("other_punctChars", JavaUtils.xmlNameToJavaIdentifier("other_punct.chars"));
+
+        assertEquals("answer42", JavaUtils.xmlNameToJavaIdentifier("Answer42"));
+        /* End TABLE 20-2 Illustrative Examples from JAXRPC Spec */
+
+        assertEquals("nameWithDashes",
+                JavaUtils.xmlNameToJavaIdentifier("name-with-dashes"));
+
+        assertEquals("otherPunctChars",
+                JavaUtils.xmlNameToJavaIdentifier("other.punct\u00B7chars"));
+
+        assertEquals("answer42", JavaUtils.xmlNameToJavaIdentifier("Answer42"));
+
+//        assertEquals("\u2160Foo", JavaUtils.xmlNameToJavaIdentifier("\u2160foo"));
+
+        assertEquals("foo", JavaUtils.xmlNameToJavaIdentifier("2foo"));
+
+        //assertEquals("_Foo_", JavaUtils.xmlNameToJavaIdentifier("_foo_"));
+        assertEquals("_foo_", JavaUtils.xmlNameToJavaIdentifier("_foo_"));
+
+        assertEquals("foobar", JavaUtils.xmlNameToJavaIdentifier("--foobar--"));
+
+        assertEquals("foo22Bar", JavaUtils.xmlNameToJavaIdentifier("foo22bar"));
+
+        assertEquals("foo\u2160Bar", JavaUtils.xmlNameToJavaIdentifier("foo\u2160bar"));
+
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("foo-bar"));
+
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("foo.bar"));
+
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("foo:bar"));
+
+        //assertEquals("foo_Bar", JavaUtils.xmlNameToJavaIdentifier("foo_bar"));
+        assertEquals("foo_bar", JavaUtils.xmlNameToJavaIdentifier("foo_bar"));
+
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("foo\u00B7bar"));
+
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("foo\u0387bar"));
+
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("foo\u06DDbar"));
+
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("foo\u06DEbar"));
+
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("FooBar"));
+
+//        assertEquals("FOOBar", JavaUtils.xmlNameToJavaIdentifier("FOOBar"));
+
+        assertEquals("a1BBB", JavaUtils.xmlNameToJavaIdentifier("A1-BBB"));
+
+//        assertEquals("ABBB", JavaUtils.xmlNameToJavaIdentifier("A-BBB"));
+
+//        assertEquals("ACCC", JavaUtils.xmlNameToJavaIdentifier("ACCC"));
+
+
+        // the following cases are ambiguous in JSR-101
+        assertEquals("fooBar", JavaUtils.xmlNameToJavaIdentifier("foo bar"));
+        assertEquals("_1", JavaUtils.xmlNameToJavaIdentifier("-"));
+
+        assertEquals("_abstract", JavaUtils.xmlNameToJavaIdentifier("abstract"));
+    }
+}



Mime
View raw message