You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2007/08/30 23:12:20 UTC
svn commit: r571310 - in /incubator/woden/trunk/java:
src/org/apache/woden/internal/ src/org/apache/woden/internal/wsdl20/
src/org/apache/woden/internal/wsdl20/validation/
src/org/apache/woden/types/ src/org/apache/woden/wsdl20/xml/
test/org/apache/wod...
Author: jkaputin
Date: Thu Aug 30 14:12:19 2007
New Revision: 571310
URL: http://svn.apache.org/viewvc?rev=571310&view=rev
Log:
WODEN-162
Introduced a new type QNameTokenUnion to represent
the 'element' attribute of interface fault and
interface message reference.
Added:
incubator/woden/trunk/java/src/org/apache/woden/types/QNameTokenUnion.java (with props)
incubator/woden/trunk/java/test/org/apache/woden/types/QNameTokenUnionTest.java (with props)
Modified:
incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java
incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java
incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidatorTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceFaultTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceMessageReferenceTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java
incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/BaseWSDLReader.java Thu Aug 30 14:12:19 2007
@@ -39,6 +39,7 @@
import org.apache.woden.resolver.URIResolver;
import org.apache.woden.schema.Schema;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.enumeration.Direction;
import org.apache.woden.wsdl20.enumeration.MessageLabel;
import org.apache.woden.wsdl20.extensions.ExtensionDeserializer;
@@ -695,15 +696,24 @@
String element = faultEl.getAttributeValue(Constants.ATTR_ELEMENT);
if(element != null)
{
- try {
- QName qname = faultEl.getQName(element);
- fault.setElementName(qname);
- } catch (WSDLException e) {
- getErrorReporter().reportError(
- new ErrorLocatorImpl(), //TODO line&col nos.
- "WSDL505",
- new Object[] {element, faultEl.getQName()},
- ErrorReporter.SEVERITY_ERROR);
+ if(element.equals(Constants.NMTOKEN_ANY)) {
+ fault.setElement(QNameTokenUnion.ANY);
+ } else if(element.equals(Constants.NMTOKEN_NONE)) {
+ fault.setElement(QNameTokenUnion.NONE);
+ } else if(element.equals(Constants.NMTOKEN_OTHER)) {
+ fault.setElement(QNameTokenUnion.OTHER);
+ } else {
+ //It is not one of the allowed xs:Token values, so it must be an xs:QName
+ try {
+ QName qname = faultEl.getQName(element);
+ fault.setElement(new QNameTokenUnion(qname));
+ } catch (WSDLException e) {
+ getErrorReporter().reportError(
+ new ErrorLocatorImpl(), //TODO line&col nos.
+ "WSDL505",
+ new Object[] {element, faultEl.getQName()},
+ ErrorReporter.SEVERITY_ERROR);
+ }
}
}
@@ -954,19 +964,17 @@
String element = msgRefEl.getAttributeValue(Constants.ATTR_ELEMENT);
if(element != null)
{
- if(element.equals(Constants.NMTOKEN_ANY) ||
- element.equals(Constants.NMTOKEN_NONE) ||
- element.equals(Constants.NMTOKEN_OTHER))
- {
- message.setMessageContentModel(element);
- }
- else
- {
- //element is not #any, #none or #other, so it must be an element qname
- message.setMessageContentModel(Constants.NMTOKEN_ELEMENT);
+ if(element.equals(Constants.NMTOKEN_ANY)) {
+ message.setElement(QNameTokenUnion.ANY);
+ } else if(element.equals(Constants.NMTOKEN_NONE)) {
+ message.setElement(QNameTokenUnion.NONE);
+ } else if(element.equals(Constants.NMTOKEN_OTHER)) {
+ message.setElement(QNameTokenUnion.OTHER);
+ } else {
+ //It is not one of the allowed xs:Token values, so it must be an xs:QName
try {
- QName qname = msgRefEl.getQName(element);
- message.setElementName(qname);
+ QNameTokenUnion qname = new QNameTokenUnion(msgRefEl.getQName(element));
+ message.setElement(qname);
} catch (WSDLException e) {
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
@@ -975,12 +983,6 @@
ErrorReporter.SEVERITY_ERROR);
}
}
- }
- else
- {
- //Per mapping defined in WSDL 2.0 Part 2 spec section 2.5.3,
- //if element attribute not present, message content model is #other
- message.setMessageContentModel(Constants.NMTOKEN_OTHER);
}
parseExtensionAttributes(msgRefEl, InterfaceMessageReferenceElement.class, message, desc);
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java Thu Aug 30 14:12:19 2007
@@ -19,6 +19,7 @@
import javax.xml.namespace.QName;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.Description;
import org.apache.woden.wsdl20.ElementDeclaration;
import org.apache.woden.wsdl20.Interface;
@@ -47,8 +48,7 @@
private NCName fName = null;
//XML Element model data
- private String fElementAttr = null; //value of the 'element' attribute info item
- private QName fElementName = null; //present if 'element' value is of type xs:QName
+ private QNameTokenUnion fElement = null;
/* ************************************************************
* InterfaceFault methods (i.e. WSDL Component model)
@@ -72,26 +72,16 @@
* @see org.apache.woden.wsdl20.InterfaceFault#getMessageContentModel()
*/
public String getMessageContentModel() {
+ String model = Constants.NMTOKEN_OTHER;;
- //this property is derived from the 'element' attribute info item
- String messageContentModel = null;
-
- if(fElementName != null) {
- //the 'element' attribute contains an xs:QName
- messageContentModel = Constants.NMTOKEN_ELEMENT;
- }
- else if(Constants.NMTOKEN_ANY.equals(fElementAttr) ||
- Constants.NMTOKEN_NONE.equals(fElementAttr) ||
- Constants.NMTOKEN_OTHER.equals(fElementAttr) ) {
- messageContentModel = fElementAttr;
- }
- else {
- //'element' does not contain #any, #none, #other or an xs:QNname
- //so it defaults to #other
- messageContentModel = Constants.NMTOKEN_OTHER;
+ if (fElement != null) {
+ if (fElement.isQName()) {
+ model = Constants.NMTOKEN_ELEMENT;
+ } else if(fElement.isToken()) {
+ model = fElement.getToken();
+ }
}
-
- return messageContentModel;
+ return model;
}
/*
@@ -101,7 +91,7 @@
{
Interface interfac = (Interface)getParent();
Description desc = ((InterfaceImpl)interfac).getDescriptionComponent();
- return desc.getElementDeclaration(fElementName);
+ return desc.getElementDeclaration(fElement.getQName());
}
/*
@@ -126,30 +116,32 @@
/*
* @see org.apache.woden.wsdl20.xml.InterfaceFaultElement#setElementName(QName)
*/
- public void setElementName(QName qname)
+ public void setElement(QNameTokenUnion qnameTokenUnion)
{
- fElementName = qname;
+ fElement = qnameTokenUnion;
}
/*
* @see org.apache.woden.wsdl20.xml.InterfaceFaultElement#getElementName()
*/
- public QName getElementName()
+ public QNameTokenUnion getElement()
{
- return fElementName;
+ return fElement;
}
/*
* @see org.apache.woden.wsdl20.xml.InterfaceFaultElement#getElement()
*/
- public XmlSchemaElement getElement()
+ public XmlSchemaElement getXmlSchemaElement()
{
XmlSchemaElement xse = null;
- InterfaceElement interfac = (InterfaceElement)getParentElement();
- DescriptionElement desc = (DescriptionElement)interfac.getParentElement();
- TypesElement types = desc.getTypesElement();
- if(types != null) {
- xse = ((TypesImpl)types).getElementDeclaration(fElementName);
+ if (fElement.isQName()) {
+ InterfaceElement interfac = (InterfaceElement)getParentElement();
+ DescriptionElement desc = (DescriptionElement)interfac.getParentElement();
+ TypesElement types = desc.getTypesElement();
+ if(types != null) {
+ xse = ((TypesImpl)types).getElementDeclaration(fElement.getQName());
+ }
}
return xse;
}
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/InterfaceMessageReferenceImpl.java Thu Aug 30 14:12:19 2007
@@ -16,15 +16,16 @@
*/
package org.apache.woden.internal.wsdl20;
-import javax.xml.namespace.QName;
-
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.Description;
import org.apache.woden.wsdl20.ElementDeclaration;
import org.apache.woden.wsdl20.Interface;
import org.apache.woden.wsdl20.InterfaceMessageReference;
import org.apache.woden.wsdl20.InterfaceOperation;
import org.apache.woden.wsdl20.enumeration.Direction;
+import org.apache.woden.wsdl20.fragids.FragmentIdentifier;
+import org.apache.woden.wsdl20.fragids.InterfaceMessageReferencePart;
import org.apache.woden.wsdl20.xml.DescriptionElement;
import org.apache.woden.wsdl20.xml.InterfaceElement;
import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
@@ -32,9 +33,6 @@
import org.apache.woden.wsdl20.xml.TypesElement;
import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.woden.wsdl20.fragids.FragmentIdentifier;
-import org.apache.woden.wsdl20.fragids.InterfaceMessageReferencePart;
-
/**
* This class represents the <input> and <output>
* child elements of interface operation.
@@ -48,11 +46,7 @@
//WSDL Component model data
private NCName fMessageLabel = null;
private Direction fDirection = null;
- private String fMessageContentModel = null;
-
- //XML Element model data
- private QName fElementName = null;
-
+ private QNameTokenUnion fElement = null;
/* ************************************************************
* InterfaceMessageReference methods (the WSDL Component model)
@@ -76,10 +70,18 @@
/* (non-Javadoc)
* @see org.apache.woden.wsdl20.InterfaceMessageReference#getMessageContentModel()
- * @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#getMessageContentModel()
*/
public String getMessageContentModel() {
- return fMessageContentModel;
+ String model = Constants.NMTOKEN_OTHER;;
+
+ if (fElement != null) {
+ if (fElement.isQName()) {
+ model = Constants.NMTOKEN_ELEMENT;
+ } else if(fElement.isToken()) {
+ model = fElement.getToken();
+ }
+ }
+ return model;
}
/* (non-Javadoc)
@@ -87,10 +89,14 @@
*/
public ElementDeclaration getElementDeclaration()
{
- InterfaceOperation oper = (InterfaceOperation)getParent();
- Interface interfac = (Interface)oper.getParent();
- Description desc = ((InterfaceImpl)interfac).getDescriptionComponent();
- ElementDeclaration elemDecl = desc.getElementDeclaration(fElementName);
+ ElementDeclaration elemDecl = null;
+
+ if(fElement != null) {
+ InterfaceOperation oper = (InterfaceOperation)getParent();
+ Interface interfac = (Interface)oper.getParent();
+ Description desc = ((InterfaceImpl)interfac).getDescriptionComponent();
+ elemDecl = desc.getElementDeclaration(fElement.getQName());
+ }
return elemDecl;
}
@@ -113,40 +119,33 @@
}
/* (non-Javadoc)
- * @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#setMessageContentModel(java.lang.String)
- */
- public void setMessageContentModel(String nmToken) {
- fMessageContentModel = nmToken;
- }
-
- /* (non-Javadoc)
* @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#setElementName(javax.xml.namespace.QName)
*/
- public void setElementName(QName element) {
- fElementName = element;
+ public void setElement(QNameTokenUnion element) {
+ fElement = element;
}
/* (non-Javadoc)
* @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#getElementName()
*/
- public QName getElementName() {
- return fElementName;
+ public QNameTokenUnion getElement() {
+ return fElement;
}
/* (non-Javadoc)
* @see org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement#getElement()
*/
- public XmlSchemaElement getElement()
+ public XmlSchemaElement getXmlSchemaElement()
{
XmlSchemaElement xse = null;
- if(Constants.NMTOKEN_ELEMENT.equals(fMessageContentModel))
+ if(fElement != null && fElement.isQName())
{
InterfaceOperationElement oper = (InterfaceOperationElement)getParentElement();
InterfaceElement interfac = (InterfaceElement)oper.getParentElement();
DescriptionElement desc = (DescriptionElement)interfac.getParentElement();
TypesElement types = desc.getTypesElement();
if(types != null) {
- xse = ((TypesImpl)types).getElementDeclaration(fElementName);
+ xse = ((TypesImpl)types).getElementDeclaration(fElement.getQName());
}
}
return xse;
Modified: incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/validation/WSDLDocumentValidator.java Thu Aug 30 14:12:19 2007
@@ -179,7 +179,7 @@
for(int j = 0; j < numFaultElements; j++)
{
InterfaceFaultElement faultElement = faultElements[j];
- if(!testAssertionSchema1066(descElement, faultElement.getElementName(), errorReporter))
+ if(!testAssertionSchema1066(descElement, faultElement.getElement().getQName(), errorReporter))
isValid = false;
}
return isValid;
Added: incubator/woden/trunk/java/src/org/apache/woden/types/QNameTokenUnion.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/types/QNameTokenUnion.java?rev=571310&view=auto
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/types/QNameTokenUnion.java (added)
+++ incubator/woden/trunk/java/src/org/apache/woden/types/QNameTokenUnion.java Thu Aug 30 14:12:19 2007
@@ -0,0 +1,97 @@
+/**
+ * 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.
+ */
+package org.apache.woden.types;
+
+import javax.xml.namespace.QName;
+
+/**
+ * This class represents the data type "Union of xs:QName and xs:Token"
+ * where the token values are #any, #none, or #other.
+ *
+ * @author Dan Harvey, danharvey42@gmail.com
+ *
+ */
+public class QNameTokenUnion {
+ private final QName qname;
+ private final String token;
+ public static final QNameTokenUnion ANY = new QNameTokenUnion("#any");
+ public static final QNameTokenUnion NONE = new QNameTokenUnion("#none");
+ public static final QNameTokenUnion OTHER = new QNameTokenUnion("#other");
+
+ /*
+ * Constructs a QNameTokenUnion as a 'token' type with the specified token value.
+ * This constructor has been declared private so that it cannot be used to specify
+ * arbitrary tokens. It is used only to create an enumeration of static variables
+ * representing the token types #any, #none and #other.
+ */
+ private QNameTokenUnion(String token) {
+ this.token = token.intern();
+ this.qname = null;
+ }
+
+ /**
+ * Constructs a QNameTokenUnion as a 'QName' type with the specified qname value.
+ * The qname parameter must not be null.
+ *
+ * @param qname the QName to set as its value.
+ * @throws NullPointerException if qname is null
+ */
+ public QNameTokenUnion(QName qname) {
+ if (qname != null) {
+ this.qname = qname;
+ this.token = null;
+ } else {
+ throw new NullPointerException("QName=null");
+ }
+ }
+
+ /**
+ * Returns the QName if it exists otherwise null.
+ *
+ * @return a QName if it exists otherwise null.
+ */
+ public QName getQName() {
+ return qname;
+ }
+
+ /**
+ * Returns the token value if it exists otherwise null.
+ *
+ * @return a String value of the token if it exists otherwise null.
+ */
+ public String getToken() {
+ return token;
+ }
+
+ /**
+ * Returns True if a QName exists, otherwise it returns False;
+ *
+ * @return a boolean representing if this has a QName value.
+ */
+ public boolean isQName() {
+ return qname != null;
+ }
+
+ /**
+ * Returns True is a token value exists, otherwise it returns False.
+ *
+ * @return a boolean representing if this has a token value.
+ */
+ public boolean isToken() {
+ return token != null;
+ }
+}
Propchange: incubator/woden/trunk/java/src/org/apache/woden/types/QNameTokenUnion.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java Thu Aug 30 14:12:19 2007
@@ -19,6 +19,7 @@
import javax.xml.namespace.QName;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.ws.commons.schema.XmlSchemaElement;
/**
@@ -47,24 +48,24 @@
public QName getName();
/**
- * Specify the name of the global schema element declaration referred to by this
+ * Specify the union of the xs:token and xs:QName of the global schema element declaration referred to by this
* InterfaceFaultElement.
* The specified QName corresponds to the <code>element</code> attribute of the interface
* <fault> element.
*
- * @param elementName the QName of the element declaration
+ * @param elementName the QNameTokenUnion of the element declaration
*/
- public void setElementName(QName elementName);
+ public void setElement(QNameTokenUnion elementName);
/**
- * Return the name of the global schema element declaration referred to by this
+ * Return the union of the xs:token and xs:QName of the global schema element declaration referred to by this
* InterfaceFaultElement.
* This corresponds to the <code>element</code> attribute of the interface
* <fault> element.
*
- * @return the QName of the element declaration
+ * @return the QNameTokenUnion of the element declaration
*/
- public QName getElementName();
+ public QNameTokenUnion getElement();
/**
* Return the XmlSchemaElement representing the global schema element declaration
@@ -78,6 +79,6 @@
*
* @return the XmlSchemaElement
*/
- public XmlSchemaElement getElement();
+ public XmlSchemaElement getXmlSchemaElement();
}
Modified: incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java (original)
+++ incubator/woden/trunk/java/src/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElement.java Thu Aug 30 14:12:19 2007
@@ -19,6 +19,7 @@
import javax.xml.namespace.QName;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.enumeration.Direction;
import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -54,37 +55,24 @@
public NCName getMessageLabel();
/**
- * @deprecated This is a property of the component model, not the infoset, so it is deprecated in M7
- * and will be removed for M8 (WODEN-136)
- */
- public void setMessageContentModel(String nmToken);
-
-
- /**
- * @deprecated This is a property of the component model, not the infoset, so it is deprecated in M7
- * and will be removed for M8 (WODEN-136)
- */
- public String getMessageContentModel();
-
- /**
- * Specify the name of the global schema element declaration referred to by this
+ * Specify the union of the xs:token and xs:QName of the global schema element declaration referred to by this
* InterfaceMessageReferenceElement.
- * The specified QName corresponds to the <code>element</code> attribute of the interface
+ * The specified QNameTokenEnum corresponds to the <code>element</code> attribute of the interface
* operation <input> or <output> element.
*
- * @param elementName the QName of the element declaration
+ * @param element the QNameTokenEnum of the element declaration.
*/
- public void setElementName(QName elementName);
+ public void setElement(QNameTokenUnion element);
/**
- * Return the name of the global schema element declaration referred to by this
+ * Return the union of the xs:token and xs:QName of the global schema element declaration referred to by this
* InterfaceMessageReferenceElement.
* This corresponds to the <code>element</code> attribute of the interface
* operation <input> or <output> element.
*
- * @return the QName of the element declaration
+ * @return the QNameTokenEnum of the element declaration
*/
- public QName getElementName();
+ public QNameTokenUnion getElement();
/**
* Return the XmlSchemaElement representing the global schema element declaration
@@ -98,7 +86,7 @@
*
* @return the XmlSchemaElement
*/
- public XmlSchemaElement getElement();
+ public XmlSchemaElement getXmlSchemaElement();
/**
* Set the message direction using the specified enumerated type, Direction,
Modified: incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidatorTest.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidatorTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/internal/wsdl20/validation/WSDLComponentValidatorTest.java Thu Aug 30 14:12:19 2007
@@ -42,6 +42,7 @@
import org.apache.woden.internal.wsdl20.extensions.PopulatedExtensionRegistry;
import org.apache.woden.tests.TestErrorHandler;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.Binding;
import org.apache.woden.wsdl20.BindingFault;
import org.apache.woden.wsdl20.BindingFaultReference;
@@ -400,7 +401,7 @@
/**
* Test that the testAssertionInterfaceMessageReference1028 method returns
* true if the message content model is #any or #none and the element
- * declartion is empty, false otherwise.
+ * declaration is empty, false otherwise.
*/
public void testTestAssertionInterfaceMessageReference1028()
{
@@ -425,7 +426,7 @@
InterfaceOperationElement oper = interfac.addInterfaceOperationElement();
InterfaceMessageReferenceElement interfaceMessageReference = oper.addInterfaceMessageReferenceElement();
- interfaceMessageReference.setMessageContentModel(Constants.NMTOKEN_ANY);
+ interfaceMessageReference.setElement(QNameTokenUnion.ANY);
descComp.getInterfaces(); //init Interface's ref to its Description
@@ -451,7 +452,7 @@
InterfaceOperationElement oper = interfac.addInterfaceOperationElement();
InterfaceMessageReferenceElement interfaceMessageReference = oper.addInterfaceMessageReferenceElement();
- interfaceMessageReference.setMessageContentModel(Constants.NMTOKEN_NONE);
+ interfaceMessageReference.setElement(QNameTokenUnion.NONE);
descComp.getInterfaces(); //init Interface's ref to its Description
@@ -465,6 +466,9 @@
fail("There was a problem running the test assertion method " + e);
}
+ /*
+ * These tests are no longer valid as there is no way to setup the element model with false properties with the QNameTokenUnion type.
+ *
// Test that the method returns false if the message content model is #any and the element declaration is not empty.
try
{
@@ -477,8 +481,8 @@
InterfaceOperationElement oper = interfac.addInterfaceOperationElement();
InterfaceMessageReferenceElement interfaceMessageReference = oper.addInterfaceMessageReferenceElement();
- interfaceMessageReference.setMessageContentModel(Constants.NMTOKEN_ANY);
- interfaceMessageReference.setElementName(name1);
+ interfaceMessageReference.setElement(new QNameTokenUnion(Constants.NMTOKEN_ANY));
+ interfaceMessageReference.setElement(new QNameTokenUnion(name1));
descComp.getInterfaces(); //init Interface's ref to its Description
@@ -503,8 +507,8 @@
InterfaceOperationElement oper = interfac.addInterfaceOperationElement();
InterfaceMessageReferenceElement interfaceMessageReference = oper.addInterfaceMessageReferenceElement();
- interfaceMessageReference.setMessageContentModel(Constants.NMTOKEN_NONE);
- interfaceMessageReference.setElementName(name1);
+ interfaceMessageReference.setElement(new QNameTokenUnion(Constants.NMTOKEN_NONE));
+ interfaceMessageReference.setElement(new QNameTokenUnion(name1));
descEl.toComponent().getInterfaces(); //init Interface's ref to its Description
@@ -517,7 +521,7 @@
{
fail("There was a problem running the test assertion method " + e);
}
-
+ */
// Test that the method returns true if the message content model is #other and the element declaration is not empty.
try
{
@@ -529,8 +533,8 @@
InterfaceOperationElement oper = interfac.addInterfaceOperationElement();
InterfaceMessageReferenceElement interfaceMessageReference = oper.addInterfaceMessageReferenceElement();
- interfaceMessageReference.setMessageContentModel(Constants.NMTOKEN_OTHER);
- interfaceMessageReference.setElementName(name1);
+ interfaceMessageReference.setElement(QNameTokenUnion.OTHER);
+ interfaceMessageReference.setElement(new QNameTokenUnion(name1));
descEl.toComponent().getInterfaces(); //init Interface's ref to its Description
@@ -543,7 +547,10 @@
{
fail("There was a problem running the test assertion method " + e);
}
-
+
+ /*
+ * These tests are no longer valid as there is no way to setup the element model with false properties with the QNameTokenUnion type.
+ *
// Test that the method returns true if the message content model is #element and the element declaration is not empty.
try
{
@@ -555,8 +562,8 @@
InterfaceOperationElement oper = interfac.addInterfaceOperationElement();
InterfaceMessageReferenceElement interfaceMessageReference = oper.addInterfaceMessageReferenceElement();
- interfaceMessageReference.setMessageContentModel(Constants.NMTOKEN_ELEMENT);
- interfaceMessageReference.setElementName(name1);
+ interfaceMessageReference.setElement(new QNameTokenUnion(Constants.NMTOKEN_ELEMENT));
+ interfaceMessageReference.setElement(new QNameTokenUnion(name1));
descEl.toComponent().getInterfaces(); //init Interface's ref to its Description
@@ -569,6 +576,7 @@
{
fail("There was a problem running the test assertion method " + e);
}
+ */
}
/**
Added: incubator/woden/trunk/java/test/org/apache/woden/types/QNameTokenUnionTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/types/QNameTokenUnionTest.java?rev=571310&view=auto
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/types/QNameTokenUnionTest.java (added)
+++ incubator/woden/trunk/java/test/org/apache/woden/types/QNameTokenUnionTest.java Thu Aug 30 14:12:19 2007
@@ -0,0 +1,90 @@
+/**
+ * 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.
+ */
+package org.apache.woden.types;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import javax.xml.namespace.QName;
+
+/**
+ * This class tests the three possible ways to construct a QNameTokenUnion and the functions for each.
+ *
+ * @author Dan Harvey, danharvey42@gmail.com
+ *
+ */
+public class QNameTokenUnionTest extends TestCase {
+
+
+ public static Test suite()
+ {
+ return new TestSuite(QNameTokenUnionTest.class);
+ }
+
+ public void testQNameTokenUnionString() {
+ //Test three possible token types.
+ //#any token
+ QNameTokenUnion union = QNameTokenUnion.ANY;
+ assertFalse("A QNameTokenUnion with token #any should return false for isQName()", union.isQName());
+ assertTrue("A QNameTokenUnion with token #any should return true for isToken()", union.isToken());
+ assertNull("A QNameTokenUnion with token #any should return null for getQName()", union.getQName());
+ assertTrue("A QNameTokenUnion with token #any should return #any for getToken()", union.getToken().equals("#any"));
+
+ //#none token
+ union = QNameTokenUnion.NONE;
+ assertFalse("A QNameTokenUnion with token #none should return false for isQName()", union.isQName());
+ assertTrue("A QNameTokenUnion with token #none should return true for isToken()", union.isToken());
+ assertNull("A QNameTokenUnion with token #none should return null for getQName()", union.getQName());
+ assertTrue("A QNameTokenUnion with token #none should return #none for getToken()", union.getToken().equals("#none"));
+
+ //#other token
+ union = QNameTokenUnion.OTHER;
+ assertFalse("A QNameTokenUnion with token #other should return false for isQName()", union.isQName());
+ assertTrue("A QNameTokenUnion with token #other should return true for isToken()", union.isToken());
+ assertNull("A QNameTokenUnion with token #other should return null for getQName()", union.getQName());
+ assertTrue("A QNameTokenUnion woth token #other should return #other for getToken()", union.getToken().equals("#other"));
+
+ }
+
+ public void testQNameTokenUnionQName() {
+ QNameTokenUnion union = null;
+
+ //Construct with a QName.
+ boolean notThrownException = true;
+ try {
+ union = new QNameTokenUnion(new QName("org.apache.woden"));
+ } catch (NullPointerException e) {
+ notThrownException = false;
+ }
+ assertTrue("A QNameTokenUnion with a valid QName should not throw a NullPointerException when constructed", notThrownException);
+ assertTrue("The QName returned a different QName value to that which was set.", union.getQName().equals(new QName("org.apache.woden")));
+ assertNull("A QNameTokenUnion with a valid QName should return null for getToken()", union.getToken());
+ assertTrue("A QNameTokenUnion with a valid QName should return true for isQName()", union.isQName());
+ assertFalse("A QNameTokenUnion with a valid QName should return false for isToken()", union.isToken());
+
+ //Construct with a null QName.
+ boolean thrownException = false;
+ try {
+ QName qname = null;
+ union = new QNameTokenUnion(qname);
+ } catch (NullPointerException e) {
+ thrownException = true;
+ }
+ assertTrue("A QNameTokenUnion with a null QName argument should throw an NullPointerException when constructed", thrownException);
+ }
+
+}
Propchange: incubator/woden/trunk/java/test/org/apache/woden/types/QNameTokenUnionTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceFaultTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceFaultTest.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceFaultTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceFaultTest.java Thu Aug 30 14:12:19 2007
@@ -16,6 +16,8 @@
*/
package org.apache.woden.wsdl20;
+import java.net.URI;
+
import javax.xml.namespace.QName;
import junit.framework.Test;
@@ -27,6 +29,7 @@
import org.apache.woden.internal.wsdl20.DescriptionImpl;
import org.apache.woden.internal.wsdl20.ElementDeclarationImpl;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.xml.DescriptionElement;
import org.apache.woden.wsdl20.xml.InterfaceElement;
import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
@@ -45,6 +48,7 @@
private InterfaceElement fInterfaceElement = null;
private final String FAULT_NAME = "faultName";
private final String INTF_NAME = "interfaceName";
+ private final String TNS = "http://example.org";
public static Test suite()
{
@@ -64,14 +68,15 @@
fail("Can't instantiate the WSDLFactory object.");
}
fDescriptionElement = factory.newDescription();
+ fDescriptionElement.setTargetNamespace(URI.create(TNS));
fInterfaceElement = fDescriptionElement.addInterfaceElement();
fInterfaceElement.setName(new NCName(INTF_NAME));
fFaultElement = fInterfaceElement.addInterfaceFaultElement();
fFaultElement.setName(new NCName(FAULT_NAME));
- fFaultElement.setElementName(new QName(FAULT_NAME));
+ fFaultElement.setElement(new QNameTokenUnion(new QName(FAULT_NAME)));
fDescription = fDescriptionElement.toComponent();
- Interface iface = fDescription.getInterface(new QName(INTF_NAME));
- fFault = iface.getInterfaceFault(new QName(FAULT_NAME));
+ Interface iface = fDescription.getInterface(new QName(TNS,INTF_NAME));
+ fFault = iface.getInterfaceFault(new QName(TNS,FAULT_NAME));
}
/*
@@ -97,7 +102,7 @@
ed.setName(new QName(FAULT_NAME));
((DescriptionImpl)fDescriptionElement).addElementDeclaration(ed);
fDescription = fDescriptionElement.toComponent();
- fFault = fDescription.getInterface(new QName(INTF_NAME)).getInterfaceFault(new QName(FAULT_NAME));
+ fFault = fDescription.getInterface(new QName(TNS,INTF_NAME)).getInterfaceFault(new QName(TNS,FAULT_NAME));
assertEquals("The retrieved Element Declaration is not that which was set",
ed, fFault.getElementDeclaration());
}
@@ -107,14 +112,14 @@
*/
public void testGetName()
{
- QName faultName = new QName(FAULT_NAME);
- NCName faultNCName = new NCName(FAULT_NAME);
- fFaultElement.setName(faultNCName);
+ QName faultName = new QName(TNS, FAULT_NAME);
fDescription = fDescriptionElement.toComponent();
- fFault = fDescription.getInterface(new QName(INTF_NAME)).getInterfaceFault(new QName(FAULT_NAME));
- assertEquals("The retrieved Interface Fault name is not that which was set",
+ fFault = fDescription.getInterface(new QName(TNS, INTF_NAME)).getInterfaceFault(new QName(TNS, FAULT_NAME));
+ assertEquals("The retrieved fault name is not that which was set",
faultName, fFault.getName());
}
+
+ //TODO WODEN-162, need to create testGetMessageContentModel() method.
/*
* toElement()
Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceMessageReferenceTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceMessageReferenceTest.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceMessageReferenceTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/InterfaceMessageReferenceTest.java Thu Aug 30 14:12:19 2007
@@ -16,14 +16,24 @@
*/
package org.apache.woden.wsdl20;
+import java.net.URI;
+
+import javax.xml.namespace.QName;
+
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
-import org.apache.woden.internal.wsdl20.InterfaceMessageReferenceImpl;
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.Constants;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.enumeration.Direction;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
+import org.apache.woden.wsdl20.xml.InterfaceElement;
import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
@@ -34,24 +44,41 @@
*/
public class InterfaceMessageReferenceTest extends TestCase {
+ private DescriptionElement fDescriptionElement = null;
+ private InterfaceElement fInterfaceElement = null;
+ private InterfaceOperationElement fInterfaceOperationElement = null;
private InterfaceMessageReferenceElement fMessageReferenceElement = null;
private InterfaceMessageReference fMessageReferenceComp = null;
- private final String CONTENT_MODEL = "contentModel";
+ private final String TNS = "http://example.org";
+ private final String INTF_NAME = "interfaceName";
+ private final String OPER_NAME = "operationName";
public static Test suite()
{
return new TestSuite(InterfaceMessageReferenceTest.class);
}
- /*
+
+ /*
* @see TestCase#setUp()
*/
protected void setUp() throws Exception
{
- super.setUp();
- fMessageReferenceElement = new InterfaceMessageReferenceImpl();
- fMessageReferenceElement.setDirection(Direction.OUT);
- fMessageReferenceElement.setMessageContentModel(CONTENT_MODEL);
- fMessageReferenceComp = (InterfaceMessageReference) fMessageReferenceElement;
+ super.setUp();
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+ fDescriptionElement = factory.newDescription();
+ fDescriptionElement.setTargetNamespace(URI.create(TNS));
+ fInterfaceElement = fDescriptionElement.addInterfaceElement();
+ fInterfaceElement.setName(new NCName(INTF_NAME));
+ fInterfaceOperationElement = fInterfaceElement.addInterfaceOperationElement();
+ fInterfaceOperationElement.setName(new NCName(OPER_NAME));
+ fMessageReferenceElement = fInterfaceOperationElement.addInterfaceMessageReferenceElement();
+ //fMessageReferenceElement.setElement(QNameTokenUnion.OTHER);
+ //fMessageReferenceComp = (InterfaceMessageReference) fMessageReferenceElement;
}
/*
@@ -67,8 +94,11 @@
*/
public void testGetDirection()
{
- assertEquals("The retrieved FaultReference direction is not that which was set",
- Direction.OUT, fMessageReferenceElement.getDirection());
+ fMessageReferenceElement.setDirection(Direction.OUT);
+ Description desc = fDescriptionElement.toComponent();
+ InterfaceMessageReference msgRef = desc.getInterfaces()[0].getInterfaceOperations()[0].getInterfaceMessageReferences()[0];
+ assertEquals("The retrieved direction is not that which was set",
+ Direction.OUT, msgRef.getDirection());
}
/*
@@ -78,8 +108,10 @@
{
NCName messageRefNCName = new NCName("messageRefName");
fMessageReferenceElement.setMessageLabel(messageRefNCName);
- assertEquals("The retrieved Element name is not that which was set",
- messageRefNCName, fMessageReferenceComp.getMessageLabel());
+ Description desc = fDescriptionElement.toComponent();
+ InterfaceMessageReference msgRef = desc.getInterfaces()[0].getInterfaceOperations()[0].getInterfaceMessageReferences()[0];
+ assertEquals("The retrieved message label is not that which was set",
+ messageRefNCName, msgRef.getMessageLabel());
}
/*
@@ -87,15 +119,35 @@
*/
public void testGetMessageContentModel()
{
- assertEquals("The retrieved Message Content Model is not that which was set",
- CONTENT_MODEL, fMessageReferenceComp.getMessageContentModel());
+ Description desc = fDescriptionElement.toComponent();
+ InterfaceMessageReference msgRef = desc.getInterfaces()[0].getInterfaceOperations()[0].getInterfaceMessageReferences()[0];
+
+ fMessageReferenceElement.setElement(QNameTokenUnion.ANY);
+ assertEquals("The retrieved Message Content Model is not #any",
+ Constants.NMTOKEN_ANY, msgRef.getMessageContentModel());
+
+ fMessageReferenceElement.setElement(QNameTokenUnion.NONE);
+ assertEquals("The retrieved Message Content Model is not #none",
+ Constants.NMTOKEN_NONE, msgRef.getMessageContentModel());
+
+ fMessageReferenceElement.setElement(QNameTokenUnion.OTHER);
+ assertEquals("The retrieved Message Content Model is not #other",
+ Constants.NMTOKEN_OTHER, msgRef.getMessageContentModel());
+
+ fMessageReferenceElement.setElement(new QNameTokenUnion(new QName("elementName")));
+ assertEquals("The retrieved Message Content Model is not #element",
+ Constants.NMTOKEN_ELEMENT, msgRef.getMessageContentModel());
}
+
+ //TODO WODEN-162, testGetElementDeclaration()
/*
- * toElement() - get element decalaration
+ * toElement() - test that the infoset element view of this component can be retreived
*/
public void testToElement()
{
- assertEquals(fMessageReferenceElement, fMessageReferenceComp.toElement());
+ Description desc = fDescriptionElement.toComponent();
+ InterfaceMessageReference msgRef = desc.getInterfaces()[0].getInterfaceOperations()[0].getInterfaceMessageReferences()[0];
+ assertEquals(fMessageReferenceElement, msgRef.toElement());
}
}
Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceFaultElementTest.java Thu Aug 30 14:12:19 2007
@@ -16,6 +16,8 @@
*/
package org.apache.woden.wsdl20.xml;
+import java.net.URI;
+
import javax.xml.namespace.QName;
import junit.framework.Test;
@@ -25,8 +27,11 @@
import org.apache.woden.WSDLException;
import org.apache.woden.WSDLFactory;
import org.apache.woden.internal.wsdl20.DescriptionImpl;
-import org.apache.woden.internal.wsdl20.InterfaceFaultImpl;
+import org.apache.woden.internal.wsdl20.ElementDeclarationImpl;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
+import org.apache.woden.wsdl20.ElementDeclaration;
+import org.apache.ws.commons.schema.XmlSchemaElement;
/**
* Unit tests for the InterfaceFaultElement class.
@@ -35,7 +40,12 @@
*/
public class InterfaceFaultElementTest extends TestCase {
- private InterfaceFaultElement fFault;
+ private DescriptionElement fDescriptionElement = null;
+ private InterfaceElement fInterfaceElement = null;
+ private InterfaceFaultElement fFaultElement;
+ private final String TNS = "http://example.org";
+ private final String INTF_NAME = "interfaceName";
+ private final String FAULT_NAME = "faultName";
public static Test suite()
{
@@ -51,34 +61,90 @@
fail("Can't instantiate the WSDLFactory object.");
}
- DescriptionElement desc = factory.newDescription();
- fFault = (desc.addInterfaceElement()).addInterfaceFaultElement();
+ fDescriptionElement = factory.newDescription();
+ fDescriptionElement.setTargetNamespace(URI.create(TNS));
+ fInterfaceElement = fDescriptionElement.addInterfaceElement();
+ fInterfaceElement.setName(new NCName(INTF_NAME));
+ fFaultElement = fInterfaceElement.addInterfaceFaultElement();
}
/*
- * Test that an (optional) ElementName QName can be successfully set and retrieved
- */
- public void testSetGetElementName()
- {
- // Default case
- assertNull("The retrieved Element name when unset should be null", fFault.getElementName());
-
- QName elementName = new QName("elementName");
- fFault.setElementName(elementName);
- assertEquals("The retrieved Element name is not that which was set",
- elementName, fFault.getElementName());
- }
-
- /*
* Test that a (Mandatory) Name QName can be successfully set and retrieved
*/
public void testSetGetName()
{
- QName faultName = new QName("faultName");
- NCName faultNCName = new NCName("faultName");
- fFault.setName(faultNCName);
- assertEquals("The retrieved Element name is not that which was set",
- faultName, fFault.getName());
+ QName faultName = new QName(TNS, FAULT_NAME);
+ NCName faultNCName = new NCName(FAULT_NAME);
+ fFaultElement.setName(faultNCName);
+ assertEquals("The retrieved fault name is not that which was set",
+ faultName, fFaultElement.getName());
}
+
+ /*
+ * Test that the optional attribute ("element") can be successfully set and retrieved
+ */
+ public void testSetGetElement()
+ {
+ //test with type qname.
+ QNameTokenUnion element = new QNameTokenUnion(new QName("ElementName"));
+ fFaultElement.setElement(element);
+ assertEquals("The retrieved 'element' attribute is not that which was set",
+ element, fFaultElement.getElement());
+
+ //test with type token.
+ QNameTokenUnion token = QNameTokenUnion.ANY;
+ fFaultElement.setElement(token);
+ assertEquals("The retrieved 'element' attribute is not that which was set",
+ token, fFaultElement.getElement());
+ }
+
+ /*
+ * Test that the optional schema element declaration can be successfully retrieved if
+ * the QNameTokenUnion is of type qname and if it is of type token, that there is no
+ * element declaration returned.
+ */
+ public void testGetXmlSchemaElement()
+ {
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ // Create the DescriptionElement->InterfaceElement->InterfaceOperationElement->InterfaceMessageReferenceElement hierarchy
+ DescriptionElement descriptionElement = factory.newDescription();
+ InterfaceElement interfaceElement = descriptionElement.addInterfaceElement();
+ InterfaceOperationElement interfaceOperationElement = interfaceElement.addInterfaceOperationElement();
+
+ // create the InterfaceMessageReferenceElement to test
+ InterfaceMessageReferenceElement messageReference = interfaceOperationElement.addInterfaceMessageReferenceElement();
+
+ // Default case:
+ XmlSchemaElement retrievedElement = messageReference.getXmlSchemaElement();
+ assertNull("Unset Element Declaration should return null", retrievedElement);
+
+ // populated case 1 - (with Message Content Model set to #ANY or #NONE).
+ ElementDeclaration ed = new ElementDeclarationImpl();
+ ((DescriptionImpl)descriptionElement).addElementDeclaration(ed);
+ messageReference.setElement(QNameTokenUnion.NONE);
+
+ descriptionElement.toComponent();
+
+ retrievedElement = messageReference.getXmlSchemaElement();
+ assertNull("The retrieved Element Declation should return null when message content model is #NONE",
+ retrievedElement);
+
+ messageReference.setElement(QNameTokenUnion.ANY);
+ descriptionElement.toComponent();
+ retrievedElement = messageReference.getXmlSchemaElement();
+ assertNull("The retrieved Element Declaration should return null when message content model is #ANY",
+ retrievedElement);
+
+ /* TODO WODEN-162, need a test that adds an xml schema to the TypesElement, then
+ * refers to a schema element via the 'element' attribute, then calls
+ * getXmlSchemaElement to retrieve it.
+ */
+ }
}
Modified: incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java
URL: http://svn.apache.org/viewvc/incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java?rev=571310&r1=571309&r2=571310&view=diff
==============================================================================
--- incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java (original)
+++ incubator/woden/trunk/java/test/org/apache/woden/wsdl20/xml/InterfaceMessageReferenceElementTest.java Thu Aug 30 14:12:19 2007
@@ -31,6 +31,7 @@
import org.apache.woden.internal.wsdl20.ElementDeclarationImpl;
import org.apache.woden.internal.wsdl20.InterfaceMessageReferenceImpl;
import org.apache.woden.types.NCName;
+import org.apache.woden.types.QNameTokenUnion;
import org.apache.woden.wsdl20.ElementDeclaration;
import org.apache.woden.wsdl20.enumeration.Direction;
import org.apache.ws.commons.schema.XmlSchemaElement;
@@ -44,7 +45,7 @@
*/
public class InterfaceMessageReferenceElementTest extends TestCase {
- private InterfaceMessageReferenceElement fMessageReference = null;
+ private InterfaceMessageReferenceElement fMessageReferenceElement = null;
private URI fNamespace = null;
public static Test suite()
@@ -58,7 +59,7 @@
protected void setUp() throws Exception
{
super.setUp();
- fMessageReference = new InterfaceMessageReferenceImpl();
+ fMessageReferenceElement = new InterfaceMessageReferenceImpl();
fNamespace = new URI("http://apache.org/testns");
}
@@ -76,11 +77,11 @@
public void testSetGetDirection()
{
// Default case
- assertNull("The retrieved Direction when unset should be null", fMessageReference.getDirection());
+ assertNull("The retrieved Direction when unset should be null", fMessageReferenceElement.getDirection());
- fMessageReference.setDirection(Direction.OUT);
+ fMessageReferenceElement.setDirection(Direction.OUT);
assertEquals("The retrieved MessageReference direction is not that which was set",
- Direction.OUT, fMessageReference.getDirection());
+ Direction.OUT, fMessageReferenceElement.getDirection());
}
/*
@@ -89,42 +90,38 @@
public void testSetGetMessageLabel()
{
NCName messageRefNCName = new NCName("messageRefName");
- fMessageReference.setMessageLabel(messageRefNCName);
+ fMessageReferenceElement.setMessageLabel(messageRefNCName);
assertEquals("The retrieved messageLabel is not that which was set",
- messageRefNCName, fMessageReference.getMessageLabel());
+ messageRefNCName, fMessageReferenceElement.getMessageLabel());
}
- /*
- * Test that the (Mandatory) Message Content Model property can be successfully set and retrieved
- */
- public void testSetGetMessageContentModel()
- {
- fMessageReference.setMessageContentModel("contentModel");
- assertEquals("The retrieved Message Content Model is not that which was set",
- "contentModel", fMessageReference.getMessageContentModel());
- }
-
-
/*
- * Test that the (Mandatory) Element Name attribute ("element") can be successfully set and retrieved
+ * Test that the optional attribute ("element") can be successfully set and retrieved
*/
- public void testSetGetElementName()
+ public void testSetGetElement()
{
- QName elementName = new QName("ElementName");
- fMessageReference.setElementName(elementName);
- assertEquals("The retrieved Element Name attribute is not that which was set",
- elementName, fMessageReference.getElementName());
+ //test with type qname.
+ QNameTokenUnion element = new QNameTokenUnion(new QName("ElementName"));
+ fMessageReferenceElement.setElement(element);
+ assertEquals("The retrieved 'element' attribute is not that which was set",
+ element, fMessageReferenceElement.getElement());
+
+ //test with type token.
+ QNameTokenUnion token = QNameTokenUnion.ANY;
+ fMessageReferenceElement.setElement(token);
+ assertEquals("The retrieved 'element' attribute is not that which was set",
+ token, fMessageReferenceElement.getElement());
}
/*
- * Test that the (Optional) Element Declaration property can be successfully retrieved.
- * The element reference is to an Element Declaration associated with a TypeDef below the ancestor Description,
- * of the name set in setElementName().
+ * Test that the optional schema element declaration can be successfully retrieved if
+ * the QNameTokenUnion is of type qname and if it is of type token, that there is no
+ * element declaration returned.
*
* TODO Need to check model structure for XmlSchema
*/
- public void testGetElement()
+ public void testGetXmlSchemaElement()
{
WSDLFactory factory = null;
try {
@@ -142,27 +139,25 @@
InterfaceMessageReferenceElement messageReference = interfaceOperationElement.addInterfaceMessageReferenceElement();
// Default case:
- XmlSchemaElement retrievedElement = messageReference.getElement();
+ XmlSchemaElement retrievedElement = messageReference.getXmlSchemaElement();
assertNull("Unset Element Declaration should return null", retrievedElement);
// populated case 1 - (with Message Content Model set to #ANY or #NONE).
- ElementDeclaration ed = new ElementDeclarationImpl();
- ((DescriptionImpl)descriptionElement).addElementDeclaration(ed);
- messageReference.setMessageContentModel(Constants.NMTOKEN_NONE);
-
- descriptionElement.toComponent();
-
- retrievedElement = messageReference.getElement();
+ messageReference.setElement(QNameTokenUnion.NONE);
+ retrievedElement = messageReference.getXmlSchemaElement();
assertNull("The retrieved Element Declation should return null when message content model is #NONE",
retrievedElement);
- messageReference.setMessageContentModel(Constants.NMTOKEN_ANY);
- descriptionElement.toComponent();
- retrievedElement = messageReference.getElement();
+ messageReference.setElement(QNameTokenUnion.ANY);
+ retrievedElement = messageReference.getXmlSchemaElement();
assertNull("The retrieved Element Declaration should return null when message content model is #ANY",
retrievedElement);
- /* TODO following populated case (with Message Content Model set) requires XmlSchema "element" field to be set.
+ /* TODO WODEN-162, need a test that adds an xml schema to the TypesElement, then
+ * refers to a schema element via the 'element' attribute, then calls
+ * getXmlSchemaElement to retrieve it.
+ *
+ * following populated case (with Message Content Model set) requires XmlSchema "element" field to be set.
* (probably via org.apache.ws.commons.schema.SchemaBuilder.handleXmlSchemaElement())
*/
/*
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org