Author: david.boeren
Date: 2008-06-26 18:02:04 -0400 (Thu, 26 Jun 2008)
New Revision: 7746
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/jbpapp921/
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/jbpapp921/JBPAPP921TestCase.java
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/Models_ServiceIM_ServiceProxyService.java
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/ValidationEvent_test.java
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/test.wsdl
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/wstools-config.xml
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaWriter.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSDLToJava.java
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/client/ServiceCreator.java
Log:
Fix for JBPAPP-921, this time it doesn't break the tests and contains a new test case
for the fix.
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaWriter.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaWriter.java 2008-06-26
21:48:53 UTC (rev 7745)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/JavaWriter.java 2008-06-26
22:02:04 UTC (rev 7746)
@@ -198,7 +198,7 @@
if (needToCreatePackageStructure(location, packageName))
newLoc = utils.createPackage(location.getPath(), packageName);
else newLoc = location;
- String classname = utils.chop(filename, ".java");
+ String classname = utils.chop(ToolsUtils.convertInvalidCharacters(filename),
".java");
File sei = utils.createPhysicalFile(newLoc, classname);
StringBuilder buffer = new StringBuilder();
utils.writeJbossHeader(buffer);
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-06-26
21:48:53 UTC (rev 7745)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2008-06-26
22:02:04 UTC (rev 7746)
@@ -205,7 +205,7 @@
if (namespacePackageMap == null)
namespacePackageMap = new HashMap<String, String>();
String pkg = iter.next();
- namespacePackageMap.put(pkg, map.get(pkg));
+ namespacePackageMap.put(map.get(pkg), pkg);
}
}
@@ -326,6 +326,7 @@
JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
QName faultXMLName = intfFault.getElement();
QName faultXMLType = intfFault.getXmlType();
+
XSElementDeclaration xe =
xsmodel.getElementDeclaration(faultXMLName.getLocalPart(),
faultXMLName.getNamespaceURI());
XSTypeDefinition xt = xe.getTypeDefinition();
if (!xt.getAnonymous())
@@ -337,8 +338,7 @@
if (cl == null)
{
String faultTypeName = (!xt.getAnonymous()) ? faultXMLType.getLocalPart()
: faultXMLName.getLocalPart();
- String packageName = getPackageName(xt.getNamespace());
- buf.append(packageName + "." +
JavaUtils.capitalize(faultTypeName));
+ buf.append(seiPkgName + "." +
JavaUtils.capitalize(faultTypeName));
}
else buf.append(cl.getName());
buf.append(",");
@@ -534,6 +534,7 @@
if (unwrappedElement)
{
buf.append(tempBuf);
+
// We need a wrapper class generated
generateJavaSource(wrapper, WSDLUtils.getSchemaModel(wsdl.getWsdlTypes()),
containingElement);
@@ -638,12 +639,11 @@
className = className.substring(1);
className = ToolsUtils.convertInvalidCharacters(className);
className = utils.firstLetterUpperCase(className);
+ className = seiPkgName + "." + className + arraySuffix;
- String packageName = getPackageName(xt.getNamespace());
- className = packageName + "." + className + arraySuffix;
if (holder)
{
- className = holderWriter.getOrCreateHolder(className,
getLocationForJavaGeneration(packageName));
+ className = holderWriter.getOrCreateHolder(className,
getLocationForJavaGeneration());
}
buf.append(className);
@@ -655,7 +655,7 @@
private void createSEIFile(WSDLInterface intf, File loc) throws IOException
{
- String seiName = getServiceEndpointInterfaceName(intf);
+ String seiName =
ToolsUtils.convertInvalidCharacters(getServiceEndpointInterfaceName(intf));
StringBuilder buf = new StringBuilder();
utils.writeJbossHeader(buf);
@@ -762,8 +762,7 @@
className = className.substring(1);
className = ToolsUtils.convertInvalidCharacters(className);
className = utils.firstLetterUpperCase(className);
- String packageName = getPackageName(xt.getNamespace());
- return packageName + "." + className + arraySuffix;
+ return seiPkgName + "." + className + arraySuffix;
}
if (cls.isArray())
@@ -807,9 +806,9 @@
return paramName;
}
- private File getLocationForJavaGeneration(String packageName)
+ private File getLocationForJavaGeneration()
{
- return new File(this.directoryToGenerate + "/" +
packageName.replace('.', '/'));
+ return new File(this.directoryToGenerate + "/" +
seiPkgName.replace(".", "/"));
}
private void generateJavaSource(XSComplexTypeDefinition xt, JBossXSModel xsmodel,
String containingElement) throws IOException
@@ -819,16 +818,10 @@
private void generateJavaSource(XSComplexTypeDefinition xt, JBossXSModel xsmodel,
String containingElement, boolean exception) throws IOException
{
- XSDTypeToJava xtj = new XSDTypeToJava(namespacePackageMap,
generateSerializableTypes);
+ XSDTypeToJava xtj = new XSDTypeToJava(generateSerializableTypes);
+
xtj.setTypeMapping(this.typeMapping);
- String targetNS = wsdl.getTargetNamespace();
- String tgtNS = xt.getNamespace();
- String packName = getPackageName(tgtNS);
- if(!tgtNS.equals(targetNS))
- {
- File dir = utils.createPackage(this.directoryToGenerate, packName);
- }
- xtj.createJavaFile((XSComplexTypeDefinition)xt, containingElement,
this.directoryToGenerate, packName, xsmodel, exception);
+ xtj.createJavaFile((XSComplexTypeDefinition)xt, containingElement,
getLocationForJavaGeneration(), seiPkgName, xsmodel, exception);
}
public void setParameterStyle(String paramStyle)
@@ -836,19 +829,4 @@
this.parameterStyle = paramStyle;
}
- private String getPackageName(String targetNamespace)
- {
- //Get it from global config
- if (namespacePackageMap != null)
- {
- String pkg = namespacePackageMap.get(targetNamespace);
- if (pkg != null)
- {
- return pkg;
- }
- }
- //return NamespacePackageMapping.getJavaPackageName(targetNamespace);
- //Default behaviour will always generate all classes in the SEI package only
- return seiPkgName;
- }
}
Modified:
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/client/ServiceCreator.java
===================================================================
---
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/client/ServiceCreator.java 2008-06-26
21:48:53 UTC (rev 7745)
+++
stack/native/trunk/modules/core/src/main/java/org/jboss/ws/tools/client/ServiceCreator.java 2008-06-26
22:02:04 UTC (rev 7746)
@@ -33,6 +33,7 @@
import org.jboss.ws.metadata.wsdl.WSDLEndpoint;
import org.jboss.ws.metadata.wsdl.WSDLService;
import org.jboss.ws.metadata.wsdl.WSDLUtils;
+import org.jboss.ws.tools.ToolsUtils;
import org.jboss.ws.tools.interfaces.ServiceCreatorIntf;
import org.jboss.wsf.common.JavaUtils;
@@ -214,6 +215,7 @@
if (wsdl.getInterface(new QName(wsdl.getTargetNamespace(), serviceName)) != null)
serviceName = new
StringBuilder(serviceName).insert(serviceName.lastIndexOf("Service"),
'_').toString();
+ serviceName = ToolsUtils.convertInvalidCharacters(serviceName);
serviceName = JavaUtils.capitalize(serviceName);
StringBuilder buf = new StringBuilder();
@@ -239,13 +241,27 @@
writer.close();
}
+ public static String removeHyphens(final String component)
+ {
+ String result = component;
+ for (int i = 0; i < result.length(); i++)
+ {
+ if (result.charAt(i) == '-')
+ {
+ result = result.replace(result.charAt(i), '_');
+ }
+ }
+
+ return result;
+ }
+
private String generateServiceMethodForWSDLEndpoint(WSDLEndpoint endpt)
{
StringBuilder buf = new StringBuilder(" public ");
QName bindName = endpt.getBinding();
WSDLBinding wbind = wsdl.getBinding(bindName);
- buf.append(getReturnType(wbind)).append(" get");
+ buf.append(removeHyphens(getReturnType(wbind))).append(" get");
buf.append(endpt.getName().getLocalPart()).append("()").append("
throws ServiceException;").append(newLine(1));
return buf.toString();
}
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/jbpapp921/JBPAPP921TestCase.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/jbpapp921/JBPAPP921TestCase.java
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/java/org/jboss/test/ws/tools/jbpapp921/JBPAPP921TestCase.java 2008-06-26
22:02:04 UTC (rev 7746)
@@ -0,0 +1,54 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.ws.tools.jbpapp921;
+
+import java.io.File;
+
+import org.jboss.test.ws.tools.fixture.JBossSourceComparator;
+import org.jboss.test.ws.tools.validation.JaxrpcMappingValidator;
+import org.jboss.ws.tools.WSTools;
+import org.jboss.wsf.test.JBossWSTest;
+
+public class JBPAPP921TestCase extends JBossWSTest
+{
+
+ private static final String resourceDir = "resources/tools/jbpapp921";
+ private static final String toolsDir = "tools/jbpapp921";
+
+ public void testGenerate() throws Exception
+ {
+ String[] args = new String[] { "-dest", toolsDir, "-config",
resourceDir + "/wstools-config.xml" };
+ new WSTools().generate(args);
+ compareSource("Models_ServiceIM_ServiceProxyService.java");
+ compareSource("ValidationEvent_test.java");
+ }
+
+ private static void compareSource(final String fileName) throws Exception
+ {
+ File expected = new File(resourceDir + "/" + fileName);
+ File generated = new File(toolsDir + "/org/jboss/test/ws/jbpapp921/" +
fileName);
+
+ JBossSourceComparator sc = new JBossSourceComparator(expected, generated);
+ sc.validate();
+ sc.validateImports();
+ }
+}
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/Models_ServiceIM_ServiceProxyService.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/Models_ServiceIM_ServiceProxyService.java
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/Models_ServiceIM_ServiceProxyService.java 2008-06-26
22:02:04 UTC (rev 7746)
@@ -0,0 +1,19 @@
+/*
+* JBoss, the OpenSource EJB server
+* Distributable under LGPL license. See terms of license at
gnu.org.
+*/
+
+//Auto Generated by jbossws - Please do not edit!!!
+
+package org.jboss.test.ws.jbpapp921;
+
+
+import javax.xml.rpc.*;
+
+
+public interface Models_ServiceIM_ServiceProxyService extends javax.xml.rpc.Service
+{
+
+ public org.jboss.test.ws.jbpapp921.ValidationEvent_test getvalidationEventPort()
throws ServiceException;
+
+}
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/ValidationEvent_test.java
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/ValidationEvent_test.java
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/ValidationEvent_test.java 2008-06-26
22:02:04 UTC (rev 7746)
@@ -0,0 +1,15 @@
+/*
+ * JBossWS WS-Tools Generated Source
+ *
+ * Generation Date: Thu Jun 26 14:46:54 EDT 2008
+ *
+ * This generated source code represents a derivative work of the input to
+ * the generator that produced it. Consult the input for the copyright and
+ * terms of use that apply to this source code.
+ */
+package org.jboss.test.ws.jbpapp921;
+public interface ValidationEvent_test extends java.rmi.Remote
+{
+
+ public int validateClaim(java.lang.String lifecycleId, java.lang.String claim) throws
java.rmi.RemoteException;
+}
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/test.wsdl
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/test.wsdl
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/test.wsdl 2008-06-26
22:02:04 UTC (rev 7746)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions name="models_ServiceIM_ServiceProxy"
+ targetNamespace="http://org.jboss.test.ws.jbpapp921"
+ xmlns:tns="http://org.jboss.test.ws.jbpapp921"
+
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
+
xmlns="http://schemas.xmlsoap.org/wsdl/">
+ <types>
+ </types>
+ <message name="ValidationEvent_validateClaim">
+ <part name="lifecycleId" type="xsd:string" />
+ <part name="claim" type="xsd:string" />
+ </message>
+ <message name="ValidationEvent_validateClaimResponse">
+ <part name="result" type="xsd:int" />
+ </message>
+ <portType name="validationEvent-test">
+ <operation name="validateClaim"
+ parameterOrder="lifecycleId claim">
+ <input message="tns:ValidationEvent_validateClaim" />
+ <output message="tns:ValidationEvent_validateClaimResponse" />
+ </operation>
+ </portType>
+ <binding name="validationEventBinding"
+ type="tns:validationEvent-test">
+ <soap:binding style="rpc"
+
transport="http://schemas.xmlsoap.org/soap/http" />
+ <operation name="validateClaim">
+ <soap:operation soapAction="" />
+ <input>
+ <soap:body use="literal"
+ namespace="http://org.jboss.test.ws.jbpapp921" />
+ </input>
+ <output>
+ <soap:body use="literal"
+ namespace="http://org.jboss.test.ws.jbpapp921" />
+ </output>
+ </operation>
+ </binding>
+ <service name="models_ServiceIM_ServiceProxy">
+ <port name="validationEventPort"
+ binding="tns:validationEventBinding">
+ <soap:address
+ location="http://localhost:8080/BusinessProcessModeling-ejb/BusinessProcessModeling.ServiceIM.ServiceProxyBean"
/>
+ </port>
+ </service>
+</definitions>
Added:
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/wstools-config.xml
===================================================================
---
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/wstools-config.xml
(rev 0)
+++
stack/native/trunk/modules/testsuite/native-tests/src/test/resources/tools/jbpapp921/wstools-config.xml 2008-06-26
22:02:04 UTC (rev 7746)
@@ -0,0 +1,4 @@
+<configuration>
+ <wsdl-java location="resources/tools/jbpapp921/test.wsdl">
+ </wsdl-java>
+</configuration>
\ No newline at end of file