Author: darran.lofthouse(a)jboss.com
Date: 2006-12-06 17:50:47 -0500 (Wed, 06 Dec 2006)
New Revision: 1583
Modified:
branches/dlofthouse/JBWS-1260/src/main/java/org/jboss/ws/tools/WSDLToJava.java
branches/dlofthouse/JBWS-1260/src/test/java/org/jboss/test/ws/tools/jbws1260/JBWS1260TestCase.java
Log:
JBWS-1260 - Completed implementation of source generation for current test cases.
Modified: branches/dlofthouse/JBWS-1260/src/main/java/org/jboss/ws/tools/WSDLToJava.java
===================================================================
---
branches/dlofthouse/JBWS-1260/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2006-12-06
19:15:10 UTC (rev 1582)
+++
branches/dlofthouse/JBWS-1260/src/main/java/org/jboss/ws/tools/WSDLToJava.java 2006-12-06
22:50:47 UTC (rev 1583)
@@ -215,61 +215,81 @@
}
}
- //***************************************************************************
- // PRIVATE METHODS
- //***************************************************************************
-
- private boolean isWrapped()
+ private class WrappedType
{
- return "wrapped".equals(parameterStyle) &&
Constants.DOCUMENT_LITERAL.equals(style);
- }
- private XSElementDeclaration unwrapType(XSTypeDefinition xt)
- {
- if (xt instanceof XSComplexTypeDefinition == false)
- throw new WSException("Tried to unwrap a non-complex type.");
+ public XSTypeDefinition xt;
+ public XSElementDeclaration unwrapped;
+ public String suffix = "";
- XSComplexTypeDefinition wrapper = (XSComplexTypeDefinition)xt;
- XSParticle particle = wrapper.getParticle();
- if (particle != null)
+ public WrappedType(XSTypeDefinition xt)
{
- XSTerm term = particle.getTerm();
+ this.xt = xt;
+ }
- if (term instanceof XSModelGroup == false)
- throw new WSException("Expected model group, could not unwrap");
+ public boolean unwrap()
+ {
+ if (isWrapped() == false)
+ return false;
- XSModelGroup group = (XSModelGroup)term;
+ if (xt instanceof XSComplexTypeDefinition == false)
+ throw new WSException("Tried to unwrap a non-complex type.");
- return unwrapModelGroup(group);
- }
+ XSComplexTypeDefinition wrapper = (XSComplexTypeDefinition)xt;
+ XSParticle particle = wrapper.getParticle();
+ if (particle != null)
+ {
+ XSTerm term = particle.getTerm();
- return null;
- }
+ if (term instanceof XSModelGroup == false)
+ throw new WSException("Expected model group, could not
unwrap");
- private XSElementDeclaration unwrapModelGroup(XSModelGroup group)
- {
- XSElementDeclaration unwrapped = null;
+ XSModelGroup group = (XSModelGroup)term;
- XSObjectList particles = group.getParticles();
- if (particles.getLength() == 1)
+ return unwrapModelGroup(group);
+ }
+
+ return false;
+ }
+
+ private boolean unwrapModelGroup(XSModelGroup group)
{
- XSParticle particle = (XSParticle)particles.item(0);
- XSTerm term = particle.getTerm();
+ XSObjectList particles = group.getParticles();
+ if (particles.getLength() == 1)
+ {
+ XSParticle particle = (XSParticle)particles.item(0);
+ boolean array = particle.getMaxOccursUnbounded() || particle.getMaxOccurs()
> 1;
+ XSTerm term = particle.getTerm();
- if (term instanceof XSModelGroup)
- {
- unwrapped = unwrapModelGroup((XSModelGroup)term);
+ if (term instanceof XSModelGroup)
+ {
+ return unwrapModelGroup((XSModelGroup)term);
+ }
+ else if (term instanceof XSElementDeclaration)
+ {
+ unwrapped = (XSElementDeclaration)term;
+ if (array)
+ {
+ suffix = "[]";
+ }
+ }
+
}
- else if (term instanceof XSElementDeclaration)
- {
- unwrapped = (XSElementDeclaration)term;
- }
+ return unwrapped != null;
}
- return unwrapped;
}
+ //***************************************************************************
+ // PRIVATE METHODS
+ //***************************************************************************
+
+ private boolean isWrapped()
+ {
+ return "wrapped".equals(parameterStyle) &&
Constants.DOCUMENT_LITERAL.equals(style);
+ }
+
private void appendMethods(WSDLInterface intf, StringBuilder buf) throws IOException
{
buf.append(newline);
@@ -398,11 +418,15 @@
XSElementDeclaration element = (XSElementDeclaration)term;
XSTypeDefinition type = element.getTypeDefinition();
- QName xmlName = new QName(element.getNamespace(), element.getName());
- QName xmlType = new QName(element.getTypeDefinition().getNamespace(),
element.getTypeDefinition().getName());
+ String tempContainingElement = containingElement + element.getName();
+
+ QName xmlType = null;
+ if (type.getAnonymous() == false)
+ xmlType = new QName(type.getNamespace(), type.getName());
+
JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
boolean array = particle.getMaxOccursUnbounded() || particle.getMaxOccurs()
> 1;
- generateParameter(buf, null, containingElement, xmlType, xsmodel, type,
array, !element.getNillable());
+ generateParameter(buf, null, tempContainingElement, xmlType, xsmodel, type,
array, !element.getNillable());
String paramName;
if (type.getAnonymous())
@@ -433,7 +457,7 @@
XSParticle particle = wrapper.getParticle();
if (particle == null)
- return false;
+ return true;
XSTerm term = particle.getTerm();
if (term instanceof XSModelGroup == false)
@@ -460,24 +484,7 @@
if (wrapped)
{
- XSElementDeclaration unwrapped = unwrapType(xt);
- if (unwrapped != null)
- {
- xt = unwrapped.getTypeDefinition();
- if (xt.getAnonymous() == false)
- {
- containingElement = unwrapped.getName();
- }
- else
- {
- containingElement = containingElement + unwrapped.getName();
- }
- wrapped = unwrapElementParameters(buf, containingElement, xt);
- }
- else
- {
- wrapped = unwrapElementParameters(buf, containingElement, xt);
- }
+ wrapped = unwrapElementParameters(buf, containingElement, xt);
}
if (wrapped == false)
@@ -504,8 +511,11 @@
if (xt instanceof XSSimpleTypeDefinition)
xmlType = SchemaUtils.handleSimpleType((XSSimpleTypeDefinition)xt);
- Class cl = getJavaType(xmlType, primitive);
+ Class cl = null;
+ if (xmlType != null)
+ cl = getJavaType(xmlType, primitive);
+
if (in != null)
cl = this.checkNeedHolder(in, cl);
if (cl != null)
@@ -515,7 +525,8 @@
else
{
String className;
- if (xt.getAnonymous())
+ // TODO DAL - Check the need to null check.
+ if (xt == null || xt.getAnonymous())
{
className = containingElement;
}
@@ -595,19 +606,21 @@
JBossXSModel xsmodel = WSDLUtils.getSchemaModel(wsdl.getWsdlTypes());
XSTypeDefinition xt = xsmodel.getTypeDefinition(xmlType.getLocalPart(),
xmlType.getNamespaceURI());
- if (isWrapped())
+ WrappedType wt = new WrappedType(xt);
+ if (wt.unwrap())
{
- XSElementDeclaration element = unwrapType(xt);
- if (element != null)
- {
- xt = element.getTypeDefinition();
- containingElement = containingElement + element.getName();
- }
+ XSElementDeclaration element = wt.unwrapped;
+ // TODO DAL - Probably don't need this now.
+ //if (element != null)
+ //{
+ xt = element.getTypeDefinition();
+ containingElement = containingElement + element.getName();
+ //}
}
boolean primitive = true;
WrappedArray wrappedArray = new WrappedArray(xt);
- String arraySuffix = "";
+ String arraySuffix = wt.suffix;
if (wrappedArray.unwrap())
{
xt = wrappedArray.xt;
@@ -621,16 +634,17 @@
Class cls = getJavaType(xmlType, primitive);
- if (xt.getAnonymous()==false)
+ // TODO DAL - Check the real need for the null check.
+ if (xt != null && xt.getAnonymous() == false)
{
- containingElement = xmlType.getLocalPart();
+ containingElement = xmlType.getLocalPart();
}
-
+
if (xt instanceof XSComplexTypeDefinition)
generateJavaSource((XSComplexTypeDefinition)xt, xsmodel, containingElement);
if (cls == null)
- {
+ {
String className = containingElement;
if (className.charAt(0) == '>')
className = className.substring(1);
Modified:
branches/dlofthouse/JBWS-1260/src/test/java/org/jboss/test/ws/tools/jbws1260/JBWS1260TestCase.java
===================================================================
---
branches/dlofthouse/JBWS-1260/src/test/java/org/jboss/test/ws/tools/jbws1260/JBWS1260TestCase.java 2006-12-06
19:15:10 UTC (rev 1582)
+++
branches/dlofthouse/JBWS-1260/src/test/java/org/jboss/test/ws/tools/jbws1260/JBWS1260TestCase.java 2006-12-06
22:50:47 UTC (rev 1583)
@@ -43,18 +43,18 @@
static
{
- //tests.add('A');
- //tests.add('B');
- //tests.add('C');
- //tests.add('D');
- tests.add('E');
- /* tests.add('F');
- tests.add('G');
- tests.add('H');
- tests.add('I');
- tests.add('J');
- tests.add('K');
- tests.add('L');*/
+ tests.add('A');
+ tests.add('B');
+ tests.add('C');
+ tests.add('D');
+ tests.add('E');
+ tests.add('F');
+ tests.add('G');
+ tests.add('H');
+ tests.add('I');
+ tests.add('J');
+ tests.add('K');
+ tests.add('L');
}
/**
@@ -135,41 +135,173 @@
generateScenario('D');
}
+ /**
+ * Test scenario where the element referenced as the message part
+ * references a complex type which contains an anonymous complex
+ * type which contains one element.
+ *
+ * <element name='lookupResponse' type='tns:TelephoneNumber'/>
+ *
+ * <complexType name='TelephoneNumber'>
+ * <sequence>
+ * <element name='Number'>
+ * <complexType>
+ * <sequence>
+ * <element name='number' nillable='true'
type='string'/>
+ * </sequence>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </complexType>
+ */
public void testScenario_E() throws Exception
{
generateScenario('E');
}
+ /**
+ * Test scenario where the element referenced as the message part
+ * references a complex type which contains an anonymout complex
+ * type which contains two elements.
+ *
+ * <element name='lookupResponse' type='tns:TelephoneNumber'/>
+ *
+ * <complexType name='TelephoneNumber'>
+ * <sequence>
+ * <element name='Number'>
+ * <complexType>
+ * <sequence>
+ * <element name='areaCode' nillable='true'
type='string'/>
+ * <element name='number' nillable='true'
type='string'/>
+ * </sequence>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </complexType>
+ *
+ */
public void testScenario_F() throws Exception
{
generateScenario('F');
}
+ /**
+ * Test scenario where the element referenced as the message
+ * parts contains an anonymous complex type which contains
+ * a single element which is an array.
+ *
+ * <element name='lookupResponse'>
+ * <complexType>
+ * <sequence>
+ * <element name='number' nillable='true'
type='string' maxOccurs='unbounded'/>
+ * </sequence>
+ * </complexType>
+ * </element>
+ */
public void testScenario_G() throws Exception
{
generateScenario('G');
}
+ /**
+ * Test scenario where the element referenced as the message
+ * parts references a complex type which contains a single
+ * element which is an array.
+ *
+ * <element name='lookupResponse' type='tns:TelephoneNumber'/>
+ *
+ * <complexType name='TelephoneNumber'>
+ * <sequence>
+ * <element name='number' nillable='true' type='string'
maxOccurs='unbounded'/>
+ * </sequence>
+ * </complexType>
+ *
+ */
public void testScenario_H() throws Exception
{
generateScenario('H');
}
+ /**
+ * Test scenario where the element referenced as the message
+ * parts references a complex type which contains an anonymous
+ * complex type which contains a single element which is an array.
+ *
+ * <element name='lookupResponse' type='tns:TelephoneNumber'/>
+ *
+ * <complexType name='TelephoneNumber'>
+ * <sequence>
+ * <element name='Number'>
+ * <complexType>
+ * <sequence>
+ * <element name='number' nillable='true'
type='string' maxOccurs='unbounded'/>
+ * </sequence>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </complexType>
+ *
+ */
public void testScenario_I() throws Exception
{
generateScenario('I');
}
+ /**
+ * Test scenario where the element referenced as the message
+ * parts contains an anonymous complex type which contains
+ * an empty sequence.
+ *
+ * <element name='lookupResponse'>
+ * <complexType>
+ * <sequence>
+ * </sequence>
+ * </complexType>
+ * </element>
+ *
+ */
public void testScenario_J() throws Exception
{
generateScenario('J');
}
+ /**
+ * Test scenario where the element referenced as the message
+ * parts references a complex type which contains
+ * an empty sequence.
+ *
+ * <element name='lookupResponse' type='tns:TelephoneNumber'/>
+ *
+ * <complexType name='TelephoneNumber'>
+ * <sequence>
+ * </sequence>
+ * </complexType>
+ *
+ */
public void testScenario_K() throws Exception
{
generateScenario('K');
}
+ /**
+ * Test scenario where the element referenced as the message
+ * parts references a complex type which contains an anonymous
+ * complex type which contains an empty sequence.
+ *
+ * <element name='lookupResponse' type='tns:TelephoneNumber'/>
+ *
+ * <complexType name='TelephoneNumber'>
+ * <sequence>
+ * <element name='Number'>
+ * <complexType>
+ * <sequence>
+ * </sequence>
+ * </complexType>
+ * </element>
+ * </sequence>
+ * </complexType>
+ *
+ */
public void testScenario_L() throws Exception
{
generateScenario('L');