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 sa...@apache.org on 2009/09/01 07:50:51 UTC
svn commit: r809833 [6/10] - in /webservices/woden/trunk/java/woden-tests:
./ src/ src/main/ src/main/resources/ src/main/resources/META-INF/
src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/
src/test/java/org/apache/woden/ src/test...
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPLocationTemplateTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPLocationTemplateTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPLocationTemplateTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPLocationTemplateTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,107 @@
+/**
+ * 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.wsdl20.extensions.http;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Functional verification test of HTTPLocationTemplate.
+ *
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public class HTTPLocationTemplateTest extends TestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(HTTPLocationTemplateTest.class);
+ }
+
+ public void testCtor() throws Exception
+ {
+ HTTPLocationTemplate template;
+
+ //foo, encoded, in query
+ template = new HTTPLocationTemplate("foo", true, true);
+ assertNotNull(template);
+
+ //foo, encoded, in path
+ template = new HTTPLocationTemplate("foo", true, false);
+ assertNotNull(template);
+
+ //foo, raw, in path
+ template = new HTTPLocationTemplate("foo", false, false);
+ assertNotNull(template);
+
+ //foo, raw, in query
+ template = new HTTPLocationTemplate("foo", false, true);
+ assertNotNull(template);
+
+ //TODO tests for null or invalid names
+ }
+
+ public void testGetName() {
+
+ HTTPLocationTemplate template;
+ template = new HTTPLocationTemplate("foo", true, true);
+ assertNotNull(template);
+ assertEquals("Incorrect template name", "foo", template.getName());
+
+ }
+
+ public void testSetGetValue() {
+
+ HTTPLocationTemplate template;
+ template = new HTTPLocationTemplate("foo", true, true);
+
+ String actual = template.getValue();
+ assertNull(actual);
+
+ template.setValue("bar");
+ actual = template.getValue();
+ assertNotNull(actual);
+ assertEquals("Unexpected value", "bar", actual);
+
+ template.setValue(null);
+ actual = template.getValue();
+ assertNull(actual);
+ }
+
+ public void testIsEncoded() {
+
+ HTTPLocationTemplate template;
+
+ template = new HTTPLocationTemplate("foo", true, true);
+ assertTrue(template.isEncoded());
+
+ template = new HTTPLocationTemplate("foo", false, true);
+ assertFalse(template.isEncoded());
+ }
+
+ public void testIsQuery() {
+
+ HTTPLocationTemplate template;
+
+ template = new HTTPLocationTemplate("foo", true, true);
+ assertTrue(template.isQuery());
+
+ template = new HTTPLocationTemplate("foo", true, false);
+ assertFalse(template.isQuery());
+ }
+
+}
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/http/HTTPLocationTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,433 @@
+/**
+ * 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.wsdl20.extensions.http;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.wsdl20.extensions.http.HTTPLocation;
+
+/**
+ * Functional verification test of HTTPLocation.
+ *
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public class HTTPLocationTest extends TestCase
+{
+ public static Test suite()
+ {
+ return new TestSuite(HTTPLocationTest.class);
+ }
+
+ public void testCtor() throws Exception
+ {
+ HTTPLocation loc;
+
+ //empty string
+ loc = new HTTPLocation("");
+ assertNotNull(loc);
+
+ //no curly braces
+ loc = new HTTPLocation("/temperature/");
+ assertNotNull(loc);
+
+ //no curly braces, path and query string
+ loc = new HTTPLocation("/temperature/town?month=Jan&day=01");
+ assertNotNull(loc);
+
+ //one local name
+ loc = new HTTPLocation("/temperature/{town}/");
+ assertNotNull(loc);
+
+ //multiple local names
+ loc = new HTTPLocation("/temperature/{town}/{state}/{country}");
+ assertNotNull(loc);
+
+ //multiple local names, encoded & raw, path & query string
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?month={mth}&date={!dt}");
+ assertNotNull(loc);
+
+ //with double curly braces
+ loc = new HTTPLocation("{{XXX}}/temperature/{town}/{{{state}}}/{country}");
+ assertNotNull(loc);
+
+ //invalid template
+ loc = new HTTPLocation("{{XXX}}/te}mp}erature/{town}/{state}/{coun{try}");
+ assertNotNull(loc);
+
+ }
+
+ public void testGetTemplates_noArg() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ HTTPLocationTemplate[] templates = loc.getTemplates();
+ assertEquals("Incorrect number of templates", 7, templates.length);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ templates = loc.getTemplates();
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/in}valid/abc?{localname}");
+ templates = loc.getTemplates();
+ assertEquals("Location is invalid, so no templates were expected", 0, templates.length);
+ }
+
+ public void testGetTemplatesInPath_noArg() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ HTTPLocationTemplate[] templates = loc.getTemplatesInPath();
+ assertEquals("Incorrect number of templates", 3, templates.length);
+ for(int i=0; i<templates.length; i++) {
+ assertFalse(templates[i].isQuery());
+ }
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ templates = loc.getTemplatesInPath();
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/in}valid/{localname}?abc");
+ templates = loc.getTemplatesInPath();
+ assertEquals("Location is invalid, so no templates were expected", 0, templates.length);
+ }
+
+ public void testGetTemplatesInQuery_noArg() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ HTTPLocationTemplate[] templates = loc.getTemplatesInQuery();
+ assertEquals("Incorrect number of templates", 4, templates.length);
+ for(int i=0; i<templates.length; i++) {
+ assertTrue(templates[i].isQuery());
+ }
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ templates = loc.getTemplatesInQuery();
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/in}valid/abc?{localname}");
+ templates = loc.getTemplatesInQuery();
+ assertEquals("Location is invalid, so no templates were expected", 0, templates.length);
+ }
+
+ public void testGetTemplates_oneArg() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ HTTPLocationTemplate[] templates = loc.getTemplates("town");
+ assertEquals("Incorrect number of templates", 2, templates.length);
+
+ templates = loc.getTemplates("state");
+ assertEquals("Incorrect number of templates", 1, templates.length);
+
+ templates = loc.getTemplates("mth");
+ assertEquals("Incorrect number of templates", 1, templates.length);
+
+ templates = loc.getTemplates("dummy");
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ templates = loc.getTemplates("dummy");
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/in}valid/abc?{localname}");
+ templates = loc.getTemplates("localname");
+ assertEquals("Location is invalid, so no templates were expected", 0, templates.length);
+ }
+
+ public void testGetTemplatesInPath_oneArg() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ HTTPLocationTemplate[] templates = loc.getTemplatesInPath("town");
+ assertEquals("Incorrect number of templates", 2, templates.length);
+ for(int i=0; i<templates.length; i++) {
+ assertFalse(templates[i].isQuery());
+ }
+
+ templates = loc.getTemplatesInPath("country");
+ assertEquals("Incorrect number of templates", 1, templates.length);
+ assertFalse(templates[0].isQuery());
+
+ templates = loc.getTemplatesInPath("dummy");
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ templates = loc.getTemplatesInPath("dummy");
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/in}valid/{localname}?abc");
+ templates = loc.getTemplatesInPath("localname");
+ assertEquals("Location is invalid, so no templates were expected", 0, templates.length);
+ }
+
+ public void testGetTemplatesInQuery_oneArg() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&temp2={tmp}&month={mth}&date={!dt}&place={town}");
+
+ HTTPLocationTemplate[] templates = loc.getTemplatesInQuery("tmp");
+ assertEquals("Incorrect number of templates", 2, templates.length);
+ for(int i=0; i<templates.length; i++) {
+ assertTrue(templates[i].isQuery());
+ }
+
+ templates = loc.getTemplatesInQuery("dt");
+ assertEquals("Incorrect number of templates", 1, templates.length);
+ assertTrue(templates[0].isQuery());
+
+ templates = loc.getTemplatesInQuery("dummy");
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ templates = loc.getTemplatesInQuery("dummy");
+ assertEquals("Unexpected templates", 0, templates.length);
+
+ loc = new HTTPLocation("/in}valid/abc?{localname}");
+ templates = loc.getTemplatesInQuery("localname");
+ assertEquals("Location is invalid, so no templates were expected", 0, templates.length);
+ }
+
+ public void testGetTemplate() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ HTTPLocationTemplate template = loc.getTemplate("town");
+ assertNotNull("expected a template", template);
+
+ //Where multiple templates exist with the same name, this method should return the first.
+ //Check that the template returned is the first (i.e. not the one in the query string).
+ assertFalse(template.isQuery());
+
+
+ template = loc.getTemplate("dt");
+ assertNotNull("expected a template", template);
+
+ template = loc.getTemplate("dummy");
+ assertNull("Unexpected template", template);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ template = loc.getTemplate("dummy");
+ assertNull("Unexpected template", template);
+
+ loc = new HTTPLocation("/in}valid/{localname}");
+ template = loc.getTemplate("localname");
+ assertNull("Location is invalid, so null was expected", template);
+ }
+
+ public void testGetTemplateInPath() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ HTTPLocationTemplate template = loc.getTemplateInPath("town");
+ assertNotNull("expected a template", template);
+ assertFalse(template.isQuery());
+
+ template = loc.getTemplateInPath("state");
+ assertNotNull("expected a template", template);
+
+ template = loc.getTemplateInPath("mth");
+ assertNull("Unexpected template", template);
+
+ template = loc.getTemplateInPath("dummy");
+ assertNull("Unexpected template", template);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ template = loc.getTemplateInPath("dummy");
+ assertNull("Unexpected template", template);
+
+ loc = new HTTPLocation("/in}valid/{localname}?abc");
+ template = loc.getTemplateInPath("localname");
+ assertNull("Location is invalid, so null was expected", template);
+ }
+
+ public void testGetTemplateInQuery() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}&place2={town}");
+
+ HTTPLocationTemplate template = loc.getTemplateInQuery("town");
+ assertNotNull("expected a template", template);
+ assertTrue(template.isQuery());
+
+ template = loc.getTemplateInQuery("dt");
+ assertNotNull("expected a template", template);
+
+ template = loc.getTemplateInQuery("country");
+ assertNull("Unexpected template", template);
+
+ template = loc.getTemplateInQuery("dummy");
+ assertNull("Unexpected template", template);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ template = loc.getTemplateInQuery("dummy");
+ assertNull("Unexpected template", template);
+
+ loc = new HTTPLocation("/in}valid/abc?{localname}");
+ template = loc.getTemplateInQuery("localname");
+ assertNull("Location is invalid, so null was expected", template);
+ }
+
+ public void testGetTemplateNames() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ String[] names = loc.getTemplateNames();
+ assertEquals("Incorrect number of names", 7, names.length);
+ assertEquals("Incorrect order of names", "town", names[0]);
+ assertEquals("Incorrect order of names", "state", names[1]);
+ assertEquals("Incorrect order of names", "country", names[2]);
+ assertEquals("Incorrect order of names", "tmp", names[3]);
+ assertEquals("Incorrect order of names", "mth", names[4]);
+ assertEquals("Incorrect order of names", "dt", names[5]);
+ assertEquals("Incorrect order of names", "town", names[6]);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ names = loc.getTemplateNames();
+ assertEquals("Unexpected template names", 0, names.length);
+
+ loc = new HTTPLocation("/in}valid/{localname}");
+ names = loc.getTemplateNames();
+ assertEquals("Location is invalid, so no template names were expected", 0, names.length);
+ }
+
+ public void testGetTemplateNamesInPath() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}");
+
+ String[] names = loc.getTemplateNamesInPath();
+ assertEquals("Incorrect number of names", 3, names.length);
+ assertEquals("Incorrect order of names", "town", names[0]);
+ assertEquals("Incorrect order of names", "state", names[1]);
+ assertEquals("Incorrect order of names", "country", names[2]);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ names = loc.getTemplateNamesInPath();
+ assertEquals("Unexpected template names", 0, names.length);
+
+ loc = new HTTPLocation("/in}valid/{localname}?abc");
+ names = loc.getTemplateNamesInPath();
+ assertEquals("Location is invalid, so no template names were expected", 0, names.length);
+ }
+
+ public void testGetTemplateNamesInQuery() {
+
+ HTTPLocation loc;
+ loc = new HTTPLocation("/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}&temp2={tmp}");
+
+ String[] names = loc.getTemplateNamesInQuery();
+ assertEquals("Incorrect number of names", 5, names.length);
+ assertEquals("Incorrect order of names", "tmp", names[0]);
+ assertEquals("Incorrect order of names", "mth", names[1]);
+ assertEquals("Incorrect order of names", "dt", names[2]);
+ assertEquals("Incorrect order of names", "town", names[3]);
+ assertEquals("Incorrect order of names", "tmp", names[4]);
+
+ loc = new HTTPLocation("/travel/flight?no=BA6&dep=13.55");
+ names = loc.getTemplateNamesInQuery();
+ assertEquals("Unexpected template names", 0, names.length);
+
+ loc = new HTTPLocation("/in}valid/abc?{localname}");
+ names = loc.getTemplateNamesInQuery();
+ assertEquals("Location is invalid, so no template names were expected", 0, names.length);
+ }
+
+ public void testGetOriginalLocation() {
+
+ String origLoc = "/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}";
+ HTTPLocation loc;
+ loc = new HTTPLocation(origLoc);
+ String returnedLoc = loc.getOriginalLocation();
+ assertEquals("Unexpected location value", origLoc, returnedLoc);
+
+ origLoc = "/travel/flight?no=BA6&dep=13.55";
+ loc = new HTTPLocation(origLoc);
+ returnedLoc = loc.getOriginalLocation();
+ assertEquals("Unexpected location value", origLoc, returnedLoc);
+ }
+
+ public void testGetFormattedLocation() {
+
+ String origLoc = "/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}";
+ HTTPLocation loc;
+ loc = new HTTPLocation(origLoc);
+ HTTPLocationTemplate template;
+ HTTPLocationTemplate[] templates;
+ templates = loc.getTemplates("town");
+ templates[0].setValue("Perth");
+ template = loc.getTemplate("state");
+ template.setValue("WA");
+ template = loc.getTemplate("country");
+ template.setValue("Australia");
+ template = loc.getTemplate("tmp");
+ template.setValue("41.5");
+ template = loc.getTemplate("mth");
+ template.setValue("February");
+ template = loc.getTemplate("dt");
+ template.setValue("28th");
+ templates[1].setValue("Fremantle");
+ String formattedLoc = "/temperature/Perth/WA/Australia?temp=41.5&month=February&date=28th&place=Fremantle";
+ String returnedLoc = loc.getFormattedLocation();
+ assertEquals("Unexpected formatted location value", formattedLoc, returnedLoc);
+
+ origLoc = "/temperature/{town}/{!state}/{country}?temp={tmp}&month={mth}&date={!dt}&place={town}";
+ loc = new HTTPLocation(origLoc);
+ templates = loc.getTemplates("town");
+ //templates[0].setValue("Perth"); //if {town} is not substituted, it will be replaced by empty string
+ template = loc.getTemplate("state");
+ template.setValue("WA");
+ template = loc.getTemplate("country");
+ template.setValue("Australia");
+ template = loc.getTemplate("tmp");
+ template.setValue("41.5");
+ template = loc.getTemplate("mth");
+ template.setValue("February");
+ template = loc.getTemplate("dt");
+ //template.setValue("28th"); //if {!dt} is not substituted, it will be replaced by empty string
+ templates[1].setValue("Fremantle");
+ formattedLoc = "/temperature//WA/Australia?temp=41.5&month=February&date=&place=Fremantle";
+ returnedLoc = loc.getFormattedLocation();
+ assertEquals("Unexpected formatted location value", formattedLoc, returnedLoc);
+
+ origLoc = "/travel/flight?no=BA6&dep=13.55";
+ loc = new HTTPLocation(origLoc);
+ returnedLoc = loc.getFormattedLocation();
+ assertEquals("Unexpected location value", origLoc, returnedLoc);
+
+ origLoc = "{invalid:name}";
+ loc = new HTTPLocation(origLoc);
+ returnedLoc = loc.getFormattedLocation();
+ assertNull("Location is invalid, so null was expected", returnedLoc);
+ }
+
+ public void testToString() {
+ //behaviour same as getFormattedLocation();
+ testGetFormattedLocation();
+ }
+
+}
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingExtensionsTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingExtensionsTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingExtensionsTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingExtensionsTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,156 @@
+/**
+ * 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.wsdl20.extensions.soap;
+
+import java.net.URI;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.Description;
+
+/**
+ * Functional verification test of SoapBindingExtensions.
+ * Checks that the expected API behaviour is supported by the implementation.
+ *
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public class SOAPBindingExtensionsTest extends TestCase
+{
+ private WSDLFactory fFactory = null;
+ private WSDLReader fReader = null;
+ private ErrorHandler fHandler = null;
+ private SOAPBindingExtensions fSoapBindExts = null;
+ private SOAPBindingExtensions fSoapBind2Exts = null;
+
+ private String fWsdlPath = "org/apache/woden/wsdl20/extensions/soap/resources/SOAPBindingExtensions.wsdl";
+
+ public static Test suite()
+ {
+ return new TestSuite(SOAPBindingExtensionsTest.class);
+ }
+
+ protected void setUp() throws Exception
+ {
+ fFactory = WSDLFactory.newInstance();
+ fReader = fFactory.newWSDLReader();
+ fHandler = new TestErrorHandler();
+ fReader.getErrorReporter().setErrorHandler(fHandler);
+
+ URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath);
+ assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".",
+ wsdlURL);
+
+ Description descComp = fReader.readWSDL(wsdlURL.toString());
+ assertNotNull("The reader did not return a WSDL description.", descComp);
+
+ Binding binding = descComp.getBindings()[0];
+ assertNotNull("The Description does not contain a Binding.", binding);
+
+ fSoapBindExts = (SOAPBindingExtensions)binding.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ assertNotNull("The Binding does not contain a SOAPBindingExtensions object.");
+
+ Binding binding2 = descComp.getBindings()[1];
+ assertNotNull("The Description does not contain a second Binding.", binding2);
+
+ fSoapBind2Exts = (SOAPBindingExtensions)binding2.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ assertNotNull("The second Binding does not contain a SOAPBindingExtensions object.");
+ }
+
+ /**
+ * Test that the value for the {soap version} property returned by the <code>getSoapVersion</code> method
+ * matches the expected value parsed from the WSDL.
+ */
+ public void testGetSoapVersion()
+ {
+ String actual = fSoapBindExts.getSoapVersion();
+ assertNotNull("The value for soap version was null", actual);
+ assertEquals("Expected '1.2' for soap version but the actual value was '" + actual + "'.",
+ "1.2",
+ actual);
+ }
+
+ /**
+ * Test that the value for the {soap underlying protocol} property returned by the <code>getSoapUnderlyingProtocol</code> method
+ * matches the expected value parsed from the WSDL.
+ */
+ public void testGetSoapUnderlyingProtocol()
+ {
+ URI actual = fSoapBindExts.getSoapUnderlyingProtocol();
+ assertNotNull("The value for soap underlying protocol was null", actual);
+
+ URI expected = URI.create("http://www.w3.org/2003/05/soap/bindings/HTTP/");
+ assertEquals("Unexpected value for soap underlying protocol.",
+ expected,
+ actual);
+ }
+
+ /**
+ * Test that the value for the {soap mep default} property returned by the <code>getSoapMepDefault</code> method
+ * matches the expected value parsed from the WSDL.
+ */
+ public void testGetSoapMepDefault()
+ {
+ URI actual = fSoapBindExts.getSoapMepDefault();
+ assertNotNull("The value for soap mep default was null", actual);
+
+ URI expected = URI.create("http://www.w3.org/2003/05/soap/mep/request-response");
+ assertEquals("Unexpected value for soap mep default.",
+ expected,
+ actual);
+ }
+
+ /**
+ * Test that the {soap modules} property returned by the <code>getSoapModules</code> method
+ * contains the expected number of SOAPModule objects parsed from the WSDL.
+ */
+ public void testGetSoapModules()
+ {
+ SOAPModule[] actual = fSoapBindExts.getSoapModules();
+ assertEquals("Unexpected number of SOAPModule objects.",
+ 2,
+ actual.length);
+ }
+
+ /**
+ * Test that the {http query parameter separator default} property return by the
+ * <code>getHttpQueryParameterSeparatorDefault</code> method matches the value
+ * parsed from the WSDL or that it defaults to ampersand "&" if omitted from the WSDL.
+ */
+ public void testGetHttpQueryParameterSeparatorDefault()
+ {
+ String actual = fSoapBindExts.getHttpQueryParameterSeparatorDefault();
+ assertNotNull("The value for http query parameter separator default was null", actual);
+ assertEquals("Unexpected value for http query parameter separator default.",
+ "$",
+ actual);
+
+ String actual2 = fSoapBind2Exts.getHttpQueryParameterSeparatorDefault();
+ assertNotNull("The default value for http query parameter separator default was null", actual2);
+ assertEquals("Unexpected default value for http query parameter separator default.",
+ "&",
+ actual2);
+ }
+
+}
\ No newline at end of file
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingFaultExtensionsTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingFaultExtensionsTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingFaultExtensionsTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingFaultExtensionsTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,221 @@
+/**
+ * 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.wsdl20.extensions.soap;
+
+import java.net.URL;
+import java.util.Arrays;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFault;
+import org.apache.woden.wsdl20.Description;
+
+/**
+ * Functional verification test of SoapBindingFaultExtensions.
+ * Checks that the expected API behaviour is supported by the implementation.
+ *
+ * @author John Kaputin (jkaputin@apache.org)
+ */
+public class SOAPBindingFaultExtensionsTest extends TestCase
+{
+ private WSDLFactory fFactory = null;
+ private WSDLReader fReader = null;
+ private ErrorHandler fHandler = null;
+
+ private Binding fBinding = null;
+ private String fWsdlPath = "org/apache/woden/wsdl20/extensions/soap/resources/SOAPBindingFaultExtensions.wsdl";
+
+ public static Test suite()
+ {
+ return new TestSuite(SOAPBindingFaultExtensionsTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fFactory = WSDLFactory.newInstance();
+ fReader = fFactory.newWSDLReader();
+ fHandler = new TestErrorHandler();
+ fReader.getErrorReporter().setErrorHandler(fHandler);
+
+ URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath);
+ assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".",
+ wsdlURL);
+
+ Description descComp = fReader.readWSDL(wsdlURL.toString());
+ assertNotNull("The reader did not return a WSDL description.", descComp);
+
+ fBinding = descComp.getBindings()[0];
+ assertNotNull("The Description does not contain a Binding.", fBinding);
+ assertEquals("The Binding contains an unexpected number of BindingFaults.", 3, fBinding.getBindingFaults().length);
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test that a <code>wsoap:code</code> extension attribute with a value of type xs:QName is represented
+ * in the Component model extensions by the expected QName.
+ */
+ public void testSoapFaultCode_QName()
+ {
+ BindingFault bindFault = fBinding.getBindingFaults()[0];
+ SOAPBindingFaultExtensions soapBindFaultExts =
+ (SOAPBindingFaultExtensions) bindFault.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPFaultCode soapFaultCode = soapBindFaultExts.getSoapFaultCode();
+
+ assertNotNull("The SOAPBindingFaultExtensions did not return a SOAPFaultCode.", soapFaultCode);
+ assertTrue("The SOAPFaultCode does not represent a QName.", soapFaultCode.isQName());
+ assertEquals("The QName represented by the SOAPFaultCode is not the expected one.",
+ new QName("http://www.w3.org/2003/05/soap-envelope","fault1"),
+ soapFaultCode.getQName());
+ }
+
+ /**
+ * Test that a <code>wsoap:code</code> extension attribute with a value of type xs:token "#any" is
+ * represented in the Component model extensions by SOAPFaultCode.ANY.
+ */
+ public void testSoapFaultCode_TokenAny()
+ {
+ BindingFault bindFault = fBinding.getBindingFaults()[1];
+ SOAPBindingFaultExtensions soapBindFaultExts =
+ (SOAPBindingFaultExtensions) bindFault.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPFaultCode soapFaultCode = soapBindFaultExts.getSoapFaultCode();
+
+ assertNotNull("The SOAPBindingFaultExtensions did not return a SOAPFaultCode.", soapFaultCode);
+ assertEquals("The SOAPFaultCode does not represent the xs:token #any.",
+ SOAPFaultCode.ANY,
+ soapFaultCode);
+ }
+
+ /**
+ * Test that if the <code>wsoap:code</code> extension attribute is omitted from the WSDL, the {soap fault code}
+ * property for the corresponding binding fault defaults to token "#any".
+ * This should be represented in the Component model extensions by SOAPFaultCode.ANY.
+ */
+ public void testSoapFaultCode_Default()
+ {
+ BindingFault bindFault = fBinding.getBindingFaults()[2];
+ SOAPBindingFaultExtensions soapBindFaultExts =
+ (SOAPBindingFaultExtensions) bindFault.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPFaultCode soapFaultCode = soapBindFaultExts.getSoapFaultCode();
+
+ assertNotNull("The SOAPBindingFaultExtensions did not return a SOAPFaultCode.", soapFaultCode);
+ assertEquals("The wsoap:code extension attribute was omitted, so SOAPFaultCode.ANY was expected by default.",
+ SOAPFaultCode.ANY,
+ soapFaultCode);
+ }
+
+ /**
+ * Test that a <code>wsoap:subcodes</code> extension attribute with a value of type list of xs:QName is represented
+ * in the Component model extensions by an array of the expected QNames.
+ */
+ public void testSoapFaultSubcodes_QNames()
+ {
+ BindingFault bindFault = fBinding.getBindingFaults()[0];
+ SOAPBindingFaultExtensions soapBindFaultExts =
+ (SOAPBindingFaultExtensions) bindFault.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPFaultSubcodes soapFaultSubcodes = soapBindFaultExts.getSoapFaultSubcodes();
+
+ assertNotNull("The SOAPBindingFaultExtensions did not return a SOAPFaultSubcodes.", soapFaultSubcodes);
+ assertTrue("The SOAPFaultSubcodes does not represent a QName.", soapFaultSubcodes.isQNames());
+ assertTrue("The QNames represented by the SOAPFaultSubcodes are not the expected ones.",
+ Arrays.equals( soapFaultSubcodes.getQNames(),
+ new QName[] {new QName("http://www.w3.org/2003/05/soap-envelope","ABC"),
+ new QName("http://www.w3.org/2003/05/soap-envelope","JKL"),
+ new QName("http://www.w3.org/2003/05/soap-envelope","XYZ")} )
+ );
+ }
+
+ /**
+ * Test that a <code>wsoap:subcodes</code> extension attribute with a value of type xs:token "#any" is
+ * represented in the Component model extensions by SOAPFaultSubcodes.ANY.
+ */
+ public void testSoapFaultSubcodes_TokenAny()
+ {
+ BindingFault bindFault = fBinding.getBindingFaults()[1];
+ SOAPBindingFaultExtensions soapBindFaultExts =
+ (SOAPBindingFaultExtensions) bindFault.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPFaultSubcodes soapFaultSubcodes = soapBindFaultExts.getSoapFaultSubcodes();
+
+ assertNotNull("The SOAPBindingFaultExtensions did not return a SOAPFaultSubcodes.", soapFaultSubcodes);
+ assertEquals("The SOAPFaultSubcodes does not represent the xs:token #any.",
+ SOAPFaultSubcodes.ANY,
+ soapFaultSubcodes);
+ }
+
+ /**
+ * Test that if the <code>wsoap:subcodes</code> extension attribute is omitted from the WSDL, the {soap fault subcodes}
+ * property for the corresponding binding fault defaults to token "#any".
+ * This should be represented in the Component model extensions by SOAPFaultSubcodes.ANY.
+ */
+ public void testSoapFaultSubcodes_Default()
+ {
+ BindingFault bindFault = fBinding.getBindingFaults()[2];
+ SOAPBindingFaultExtensions soapBindFaultExts =
+ (SOAPBindingFaultExtensions) bindFault.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPFaultSubcodes soapFaultSubcodes = soapBindFaultExts.getSoapFaultSubcodes();
+
+ assertNotNull("The SOAPBindingFaultExtensions did not return a SOAPFaultSubcodes.", soapFaultSubcodes);
+ assertEquals("The SOAPFaultSubcodes does not represent the xs:token #any.",
+ SOAPFaultSubcodes.ANY,
+ soapFaultSubcodes);
+ }
+
+ /**
+ * Test that the <code>getSoapModules</code> method returns the expected number of SOAPModule objects
+ * parsed from <wsoap:module> elements within a binding <fault> element.
+ */
+ public void testGetSoapModules()
+ {
+ BindingFault bindFault = fBinding.getBindingFaults()[1];
+ SOAPBindingFaultExtensions soapBindFaultExts =
+ (SOAPBindingFaultExtensions) bindFault.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPModule[] actual = soapBindFaultExts.getSoapModules();
+ assertEquals("Unexpected number of SOAPModule objects.", 3, actual.length);
+ }
+
+ /**
+ * Test that the <code>getSoapHeaders</code> method returns the expected number of SOAPHeaderBlock
+ * objects parsed from <wsoap:header< elements within a binding <fault> element.
+ */
+ public void testGetSoapHeaders()
+ {
+ BindingFault bindFault = fBinding.getBindingFaults()[2];
+ SOAPBindingFaultExtensions soapBindFaultExts =
+ (SOAPBindingFaultExtensions) bindFault.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPHeaderBlock[] actual = soapBindFaultExts.getSoapHeaders();
+ assertEquals("Unexpected number of SOAPHeaderBlock objects.", 2, actual.length);
+ }
+
+}
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingFaultReferenceExtensionsTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingFaultReferenceExtensionsTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingFaultReferenceExtensionsTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingFaultReferenceExtensionsTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,126 @@
+/**
+ * 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.wsdl20.extensions.soap;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingFaultReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.InterfaceFaultReference;
+import org.apache.woden.wsdl20.enumeration.Direction;
+
+/**
+ * Functional verification test of SoapBindingFaultReferenceExtensions.
+ * Checks that the expected API behaviour is supported by the implementation.
+ *
+ * @author jkaputin@apache.org
+ */
+public class SOAPBindingFaultReferenceExtensionsTest extends TestCase
+{
+ private WSDLFactory fFactory = null;
+ private WSDLReader fReader = null;
+ private ErrorHandler fHandler = null;
+
+ private BindingOperation fBindOper = null;
+ private String fWsdlPath = "org/apache/woden/wsdl20/extensions/soap/resources/SOAPBindingFaultReferenceExtensions.wsdl";
+
+ public static Test suite()
+ {
+ return new TestSuite(SOAPBindingFaultReferenceExtensionsTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fFactory = WSDLFactory.newInstance();
+ fReader = fFactory.newWSDLReader();
+ fHandler = new TestErrorHandler();
+ fReader.getErrorReporter().setErrorHandler(fHandler);
+
+ URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath);
+ assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".",
+ wsdlURL);
+
+ Description descComp = fReader.readWSDL(wsdlURL.toString());
+ assertNotNull("The reader did not return a WSDL description.", descComp);
+
+ Binding binding = descComp.getBindings()[0];
+ assertNotNull("The Description does not contain a Binding.", binding);
+ fBindOper = binding.getBindingOperations()[0];
+ assertNotNull("The Binding does not contain a BindingOperation.", fBindOper);
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+ /**
+ * Test that the <code>getSoapModules</code> method returns the expected number of SOAPModule objects
+ * parsed from <wsoap:module> elements within an <infault> element.
+ */
+ public void testGetSoapModules_infault()
+ {
+ BindingFaultReference bindFaultRef = fBindOper.getBindingFaultReferences()[0];
+ assertNotNull("The BindingOperation does not contain a BindingFaultReference.", bindFaultRef);
+
+ InterfaceFaultReference intFaultRef = bindFaultRef.getInterfaceFaultReference();
+ Direction direction = intFaultRef.getDirection();
+ assertTrue("The BindingFaultReference does not represent an <infault> element.", Direction.IN.equals(direction));
+
+ SOAPBindingFaultReferenceExtensions soapBindFaultRefExts =
+ (SOAPBindingFaultReferenceExtensions) bindFaultRef.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPModule[] actual = soapBindFaultRefExts.getSoapModules();
+ assertEquals("Unexpected number of SOAPModule objects.", 2, actual.length);
+ }
+
+ /**
+ * Test that the <code>getSoapModules</code> method returns the expected number of SOAPModule objects
+ * parsed from <wsoap:module> elements within an <outfault> element.
+ */
+ public void testGetSoapModules_outfault()
+ {
+ BindingFaultReference bindFaultRef = fBindOper.getBindingFaultReferences()[1];
+ assertNotNull("The BindingOperation does not contain a second BindingFaultReference.", bindFaultRef);
+
+ InterfaceFaultReference intFaultRef = bindFaultRef.getInterfaceFaultReference();
+ Direction direction = intFaultRef.getDirection();
+ assertTrue("The BindingFaultReference does not represent an <outfault> element.", Direction.OUT.equals(direction));
+
+ SOAPBindingFaultReferenceExtensions soapBindFaultRefExts =
+ (SOAPBindingFaultReferenceExtensions) bindFaultRef.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPModule[] actual = soapBindFaultRefExts.getSoapModules();
+ assertEquals("Unexpected number of SOAPModule objects.", 1, actual.length);
+ }
+
+}
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingMessageReferenceExtensionsTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingMessageReferenceExtensionsTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingMessageReferenceExtensionsTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingMessageReferenceExtensionsTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,156 @@
+/**
+ * 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.wsdl20.extensions.soap;
+
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingMessageReference;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Description;
+import org.apache.woden.wsdl20.enumeration.Direction;
+import org.apache.woden.wsdl20.xml.BindingMessageReferenceElement;
+
+/**
+ * Functional verification test of SoapBindingMessageReferenceExtensions.
+ * Checks that the expected API behaviour is supported by the implementation.
+ *
+ * @author jkaputin@apache.org
+ */
+public class SOAPBindingMessageReferenceExtensionsTest extends TestCase
+{
+ private WSDLFactory fFactory = null;
+ private WSDLReader fReader = null;
+ private ErrorHandler fHandler = null;
+
+ private BindingOperation fBindOper = null;
+ private String fWsdlPath = "org/apache/woden/wsdl20/extensions/soap/resources/SOAPBindingMessageReferenceExtensions.wsdl";
+
+ public static Test suite()
+ {
+ return new TestSuite(SOAPBindingMessageReferenceExtensionsTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fFactory = WSDLFactory.newInstance();
+ fReader = fFactory.newWSDLReader();
+ fHandler = new TestErrorHandler();
+ fReader.getErrorReporter().setErrorHandler(fHandler);
+
+ URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath);
+ assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".",
+ wsdlURL);
+
+ Description descComp = fReader.readWSDL(wsdlURL.toString());
+ assertNotNull("The reader did not return a WSDL description.", descComp);
+
+ Binding binding = descComp.getBindings()[0];
+ assertNotNull("The Description does not contain a Binding.", binding);
+ fBindOper = binding.getBindingOperations()[0];
+ assertNotNull("The Binding does not contain a BindingOperation.", fBindOper);
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+
+ /**
+ * Test that the <code>getSoapModules</code> method returns the expected number of SOAPModule objects
+ * parsed from <wsoap:module> elements within an <input> element.
+ */
+ public void testGetSoapModules_input()
+ {
+ BindingMessageReference bindMsgRef = fBindOper.getBindingMessageReferences()[0];
+ assertNotNull("The BindingOperation does not contain a BindingMessageReference.", bindMsgRef);
+
+ BindingMessageReferenceElement bindMsgRefEl = bindMsgRef.toElement();
+ Direction direction = bindMsgRefEl.getDirection();
+ assertTrue("The BindingMessageReference does not represent an <input> element.", Direction.IN.equals(direction));
+
+ SOAPBindingMessageReferenceExtensions soapBindMsgRefExts =
+ (SOAPBindingMessageReferenceExtensions) bindMsgRef.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPModule[] actual = soapBindMsgRefExts.getSoapModules();
+ assertEquals("Unexpected number of SOAPModule objects.", 2, actual.length);
+ }
+
+ /**
+ * Test that the <code>getSoapModules</code> method returns the expected number of SOAPModule objects
+ * parsed from <wsoap:module> elements within an <output> element.
+ */
+ public void testGetSoapModules_output()
+ {
+ BindingMessageReference bindMsgRef = fBindOper.getBindingMessageReferences()[1];
+ assertNotNull("The BindingOperation does not contain a second BindingMessageReference.", bindMsgRef);
+
+ BindingMessageReferenceElement bindMsgRefEl = bindMsgRef.toElement();
+ Direction direction = bindMsgRefEl.getDirection();
+ assertTrue("The BindingMessageReference does not represent an <output> element.", Direction.OUT.equals(direction));
+
+ SOAPBindingMessageReferenceExtensions soapBindMsgRefExts =
+ (SOAPBindingMessageReferenceExtensions) bindMsgRef.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPModule[] actual = soapBindMsgRefExts.getSoapModules();
+ assertEquals("Unexpected number of SOAPModule objects.", 1, actual.length);
+ }
+
+ /**
+ * Test that the <code>getSoapHeaders</code> method returns the expected number of SOAPHeader objects
+ * parsed from <wsoap:header> elements within an <input> element.
+ */
+ public void testGetSoapHeaders_input()
+ {
+ BindingMessageReference bindMsgRef = fBindOper.getBindingMessageReferences()[0];
+ assertNotNull("The BindingOperation does not contain a BindingMessageReference.", bindMsgRef);
+
+ SOAPBindingMessageReferenceExtensions soapBindMsgRefExts =
+ (SOAPBindingMessageReferenceExtensions) bindMsgRef.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPHeaderBlock[] actual = soapBindMsgRefExts.getSoapHeaders();
+ assertEquals("Unexpected number of SOAPHeaderBlock objects.", 2, actual.length);
+ }
+
+ /**
+ * Test that the <code>getSoapHeaders</code> method returns the expected number of SOAPHeader objects
+ * parsed from <wsoap:header> elements within an <output> element.
+ */
+ public void testGetSoapHeaders_output()
+ {
+ BindingMessageReference bindMsgRef = fBindOper.getBindingMessageReferences()[1];
+ assertNotNull("The BindingOperation does not contain the expected BindingMessageReference.", bindMsgRef);
+
+ SOAPBindingMessageReferenceExtensions soapBindMsgRefExts =
+ (SOAPBindingMessageReferenceExtensions) bindMsgRef.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPHeaderBlock[] actual = soapBindMsgRefExts.getSoapHeaders();
+ assertEquals("Unexpected number of SOAPHeaderBlock objects.", 1, actual.length);
+ }
+
+}
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingOperationExtensionsTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingOperationExtensionsTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingOperationExtensionsTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/extensions/soap/SOAPBindingOperationExtensionsTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,153 @@
+/**
+ * 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.wsdl20.extensions.soap;
+
+import java.net.URI;
+import java.net.URL;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.ErrorHandler;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.tests.TestErrorHandler;
+import org.apache.woden.wsdl20.Binding;
+import org.apache.woden.wsdl20.BindingOperation;
+import org.apache.woden.wsdl20.Description;
+
+/**
+ * Functional verification test of SoapBindingOperationExtensions.
+ * Checks that the expected API behaviour is supported by the implementation.
+ *
+ * @author jkaputin@apache.org
+ */
+public class SOAPBindingOperationExtensionsTest extends TestCase
+{
+ private WSDLFactory fFactory = null;
+ private WSDLReader fReader = null;
+ private ErrorHandler fHandler = null;
+ private BindingOperation fBindOper = null;
+ private BindingOperation fBind2Oper = null;
+
+ private String fWsdlPath = "org/apache/woden/wsdl20/extensions/soap/resources/SOAPBindingOperationExtensions.wsdl";
+
+ public static Test suite()
+ {
+ return new TestSuite(SOAPBindingOperationExtensionsTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fFactory = WSDLFactory.newInstance();
+ fReader = fFactory.newWSDLReader();
+ fHandler = new TestErrorHandler();
+ fReader.getErrorReporter().setErrorHandler(fHandler);
+
+ URL wsdlURL = getClass().getClassLoader().getResource(fWsdlPath);
+ assertNotNull("Failed to find the WSDL document on the classpath using the path: " + fWsdlPath + ".",
+ wsdlURL);
+
+ Description descComp = fReader.readWSDL(wsdlURL.toString());
+ assertNotNull("The reader did not return a WSDL description.", descComp);
+
+ Binding binding = descComp.getBindings()[0];
+ assertNotNull("The Description does not contain a Binding.", binding);
+ fBindOper = binding.getBindingOperations()[0];
+ assertNotNull("The Binding does not a BindingOperation.", fBindOper);
+
+ Binding binding2 = descComp.getBindings()[1];
+ assertNotNull("The Description does not contain a second Binding.", binding2);
+
+ fBind2Oper = binding2.getBindingOperations()[0];
+ assertNotNull("The second Binding does not contain a BindingOperation.");
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ /**
+ * Test that the <code>wsoap:mep</code> extension attribute is represented
+ * in the Component model extensions by the expected URI.
+ */
+ public void testGetSoapMep()
+ {
+ SOAPBindingOperationExtensions soapBindOperExts =
+ (SOAPBindingOperationExtensions) fBindOper.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ URI soapMep = soapBindOperExts.getSoapMep();
+
+ assertNotNull("The SOAPBindingOperationExtensions did not return a value for {soap mep}.", soapMep);
+ assertEquals("Unexpected soap mep URI.", URI.create("urn:mep"), soapMep);
+ }
+
+ /**
+ * Test that the <code>wsoap:action</code> extension attribute is represented
+ * in the Component model extensions by the expected URI.
+ */
+ public void testGetSoapAction()
+ {
+ SOAPBindingOperationExtensions soapBindOperExts =
+ (SOAPBindingOperationExtensions) fBindOper.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ URI soapAction = soapBindOperExts.getSoapAction();
+
+ assertNotNull("The SOAPBindingOperationExtensions did not return a value for {soap action}.", soapAction);
+ assertEquals("Unexpected soap action URI.", URI.create("urn:action"), soapAction);
+ }
+
+ /**
+ * Test that the {soap modules} property returned by the <code>getSoapModules</code> method
+ * contains the expected number of SOAPModule objects parsed from the WSDL.
+ */
+ public void testGetSoapModules()
+ {
+ SOAPBindingOperationExtensions soapBindOperExts =
+ (SOAPBindingOperationExtensions) fBindOper.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ SOAPModule[] actual = soapBindOperExts.getSoapModules();
+ assertEquals("Unexpected number of SOAPModule objects.", 1, actual.length);
+ }
+
+ /**
+ * Test that the {http query parameter separator} property returned by the
+ * <code>getHttpParameterSeparator</code> method method matches the value
+ * parsed from the WSDL or that it defaults to null if omitted from the WSDL.
+ */
+ public void testGetHttpQueryParameterSeparator()
+ {
+ SOAPBindingOperationExtensions soapBindOperExts =
+ (SOAPBindingOperationExtensions) fBindOper.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ String actual = soapBindOperExts.getHttpQueryParameterSeparator();
+
+ assertNotNull("The SOAPBindingOperationExtensions did not return a value for {http query parameter separator}.", actual);
+ assertEquals("Unexpected value for http query parameter separator.", "$", actual);
+
+ SOAPBindingOperationExtensions soapBind2OperExts =
+ (SOAPBindingOperationExtensions) fBind2Oper.getComponentExtensionContext(SOAPConstants.NS_URI_SOAP);
+ String actual2 = soapBind2OperExts.getHttpQueryParameterSeparator();
+
+ assertNull("Non-null value for http query parameter separator.", actual2);
+
+ }
+}
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/fragids/FragmentIdentificationTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/fragids/FragmentIdentificationTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/fragids/FragmentIdentificationTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/fragids/FragmentIdentificationTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,120 @@
+/**
+ * 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.wsdl20.fragids;
+
+import java.net.URL;
+
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.WSDLReader;
+import org.apache.woden.wsdl20.Description;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class FragmentIdentificationTest extends TestCase {
+ private WSDLFactory factory;
+ private WSDLReader reader;
+
+ public static Test suite()
+ {
+ return new TestSuite(FragmentIdentificationTest.class);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ factory = WSDLFactory.newInstance();
+ reader = factory.newWSDLReader();
+ }
+
+ public void testSerialisation(){
+ Description desc = null;
+
+ //Load in a WSDL 2.0 file
+ URL wsdlURL2 = getClass().getClassLoader().getResource("org/apache/woden/wsdl20/fragids/greatH.wsdl");
+
+ try {
+ desc = reader.readWSDL(wsdlURL2.toString());
+ } catch(Exception e) {
+ fail("Failed with unexpected exception: " + e);
+ }
+
+ assertEquals("wsdl.description()", desc.toString());
+ //Elements
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/schemas/resSvc)wsdl.elementDeclaration(ns1:checkAvailability)",
+ desc.getElementDeclaration(new QName("http://greath.example.com/2004/schemas/resSvc","checkAvailability")).toString());
+
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/schemas/resSvc)wsdl.elementDeclaration(ns1:checkAvailabilityResponse)",
+ desc.getElementDeclaration(new QName("http://greath.example.com/2004/schemas/resSvc","checkAvailabilityResponse")).toString());
+
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/schemas/resSvc)wsdl.elementDeclaration(ns1:invalidDataError)",
+ desc.getElementDeclaration(new QName("http://greath.example.com/2004/schemas/resSvc","invalidDataError")).toString());
+
+ //Types
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/schemas/resSvc)wsdl.typeDefinition(ns1:tCheckAvailability)",
+ desc.getTypeDefinition(new QName("http://greath.example.com/2004/schemas/resSvc","tCheckAvailability")).toString());
+
+ //Interface
+ assertEquals("wsdl.interface(reservationInterface)",
+ desc.getInterface(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationInterface")).toString());
+
+ assertEquals("wsdl.interfaceFault(reservationInterface/invalidDataFault)",
+ desc.getInterface(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationInterface")).getInterfaceFault(new QName("http://greath.example.com/2004/wsdl/resSvc", "invalidDataFault")).toString());
+
+ assertEquals("wsdl.interfaceOperation(reservationInterface/opCheckAvailability)",
+ desc.getInterface(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationInterface")).getInterfaceOperation(new QName("http://greath.example.com/2004/wsdl/resSvc", "opCheckAvailability")).toString());
+
+ assertEquals("wsdl.interfaceMessageReference(reservationInterface/opCheckAvailability/In)",
+ desc.getInterface(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationInterface")).getInterfaceOperation(new QName("http://greath.example.com/2004/wsdl/resSvc", "opCheckAvailability")).getInterfaceMessageReferences()[0].toString());
+
+ assertEquals("wsdl.interfaceMessageReference(reservationInterface/opCheckAvailability/Out)",
+ desc.getInterface(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationInterface")).getInterfaceOperation(new QName("http://greath.example.com/2004/wsdl/resSvc", "opCheckAvailability")).getInterfaceMessageReferences()[1].toString());
+
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/wsdl/resSvc)wsdl.interfaceFaultReference(reservationInterface/opCheckAvailability/Out/ns1:invalidDataFault)",
+ desc.getInterface(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationInterface")).getInterfaceOperation(new QName("http://greath.example.com/2004/wsdl/resSvc", "opCheckAvailability", "tns")).getInterfaceFaultReferences()[0].toString());
+
+ //Binding
+ assertEquals("wsdl.binding(reservationSOAPBinding)",
+ desc.getBinding(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationSOAPBinding")).toString());
+
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/wsdl/resSvc)wsdl.bindingFault(reservationSOAPBinding/ns1:invalidDataFault)",
+ desc.getBinding(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationSOAPBinding")).getBindingFaults()[0].toString());
+
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/wsdl/resSvc)wsdl.bindingOperation(reservationSOAPBinding/ns1:opCheckAvailability)",
+ desc.getBinding(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationSOAPBinding")).getBindingOperations()[0].toString());
+
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/wsdl/resSvc)wsdl.bindingMessageReference(reservationSOAPBinding/ns1:opCheckAvailability/In)",
+ desc.getBinding(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationSOAPBinding")).getBindingOperations()[0].getBindingMessageReferences()[0].toString());
+
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/wsdl/resSvc)wsdl.bindingMessageReference(reservationSOAPBinding/ns1:opCheckAvailability/Out)",
+ desc.getBinding(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationSOAPBinding")).getBindingOperations()[0].getBindingMessageReferences()[1].toString());
+
+ assertEquals("xmlns(ns1=http://greath.example.com/2004/wsdl/resSvc)wsdl.bindingFaultReference(reservationSOAPBinding/ns1:opCheckAvailability/Out/ns1:invalidDataFault)",
+ desc.getBinding(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationSOAPBinding")).getBindingOperations()[0].getBindingFaultReferences()[0].toString());
+
+ //Service
+ assertEquals("wsdl.service(reservationService)",
+ desc.getService(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationService")).toString());
+
+ assertEquals("wsdl.endpoint(reservationService/reservationEndpoint)",
+ desc.getService(new QName("http://greath.example.com/2004/wsdl/resSvc", "reservationService")).getEndpoints()[0].toString());
+
+ //TODO add tests for Extensions.
+ }
+}
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingElementTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,206 @@
+/**
+ * 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.wsdl20.xml;
+
+import java.net.URI;
+import java.util.Arrays;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the BindingElement class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingElementTest extends TestCase {
+
+ // create a parent Description to hang the Bindings off
+ private DescriptionElement fDescriptionElement = null;
+ private BindingElement fBindingElement = null;
+ private URI fTypeURI = null;
+ private WSDLFactory fFactory = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(BindingElementTest.class);
+ }
+
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ try {
+ fFactory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ fDescriptionElement = fFactory.newDescription();
+ fBindingElement = fDescriptionElement.addBindingElement();
+ fTypeURI = new URI("http://www.w3.org/0000/00/apacheType");
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Optional attribute ("interface")
+ * - setInterfaceName()
+ * - getInterfaceName()
+ */
+ public void testGetSetInterfaceName()
+ {
+ // check the default
+ QName uri = fBindingElement.getInterfaceName();
+ assertNull("Retrieved BindingElement interface name should be null if none set -", uri);
+
+ fBindingElement.setInterfaceName(new QName("InterfaceName"));
+ uri = fBindingElement.getInterfaceName();
+ assertNotNull(uri);
+ assertEquals("Retrieved BindingElement interface name does not match that set -", "InterfaceName", uri.toString());
+ }
+
+ /* Utility method to obtain the InterfaceElement referenced by the (optional) "interface" attribute
+ * - getInterfaceElement()
+ */
+ public void testGetInterfaceElement()
+ {
+ // check the default:
+ InterfaceElement retrievedInterfaceElement = fBindingElement.getInterfaceElement();
+ assertNull("Retrieved Interface Element should be null if none set -", retrievedInterfaceElement);
+
+ // Create and name an Interface Element
+ DescriptionElement desc = fFactory.newDescription();
+ InterfaceElement interfaceElement = desc.addInterfaceElement();
+ interfaceElement.setName(new NCName("interface1"));
+
+ // Create a binding from the description
+ fBindingElement = desc.addBindingElement();
+
+ // getInterfaceElement() - interface attribute unspecified, but hierarchy in place:
+ retrievedInterfaceElement = fBindingElement.getInterfaceElement();
+ assertNull("Retrieved Interface Element should be null if interface attribute unspecified -", retrievedInterfaceElement);
+
+ // getInterfaceElement() - interface attribute specified, and hierarchy in place:
+ // Set the "interface" attribute to reference the new Interface Element
+ fBindingElement.setInterfaceName(new QName("interface1"));
+ retrievedInterfaceElement = fBindingElement.getInterfaceElement();
+ assertEquals("Retrieved Interface Element was not that expected -", interfaceElement, retrievedInterfaceElement);
+ }
+
+ /*
+ * Mandatory attribute ("name")
+ * - setName()
+ * - getName()
+ */
+ public void testGetSetName()
+ {
+ fBindingElement.setName(new NCName("BindingName"));
+ QName uri = fBindingElement.getName();
+ assertNotNull(uri);
+ assertEquals("Retrieved BindingElement name does not match that set -", "BindingName", uri.toString());
+ }
+
+ /*
+ * Mandatory attribute ("type")
+ * - setType()
+ * - getType()
+ */
+ public void testGetSetType()
+ {
+ fBindingElement.setType(fTypeURI);
+ URI uri = fBindingElement.getType();
+ assertEquals("Retrieved BindingElement type attribute does not match that set -", fTypeURI, uri);
+ }
+
+
+ /*
+ * Optional element ("fault")
+ * - addBindingFaultElement()
+ * - getBindingFaultElements()
+ */
+ public void testAddGetBindingFaultElements()
+ {
+ // check the default:
+ BindingFaultElement[] bfeArray = fBindingElement.getBindingFaultElements();
+ assertNotNull("Expected an array of BindingFaultElements -", bfeArray);
+ assertEquals("Retrieved BindingFaultElement group should be empty if none set -", 0, bfeArray.length);
+
+ // addBindingFaultElement()
+ BindingFaultElement bfe1 = fBindingElement.addBindingFaultElement();
+ BindingFaultElement bfe2 = fBindingElement.addBindingFaultElement();
+ assertNotNull(bfe1);
+ assertNotNull(bfe2);
+
+ // getBindingFaultElements()
+ bfeArray = fBindingElement.getBindingFaultElements();
+ assertNotNull("Expected an array of BindingFaultElements -", bfeArray);
+ assertEquals("Incorrect number of retrieved BindingFaultElements -", 2, bfeArray.length);
+
+ // verify all Fault objects returned
+ List bfeL = Arrays.asList(bfeArray);
+ assertTrue(bfeL.contains(bfe1));
+ assertTrue(bfeL.contains(bfe2));
+ }
+
+ /*
+ * Optional element ("operation")
+ * - addBindingOperationElement()
+ * - getBindingOperationElements()
+ */
+ public void testAddGetBindingOperationElements()
+ {
+ // check the default:
+ BindingOperationElement[] bopArray = fBindingElement.getBindingOperationElements();
+ assertNotNull("Expected an array of BindingOperationElements -", bopArray);
+ assertEquals("Retrieved BindingOperationElement group should be empty if none set -", 0, bopArray.length);
+
+ // addBindingOperationElement()
+ BindingOperationElement bop1 = fBindingElement.addBindingOperationElement();
+ BindingOperationElement bop2 = fBindingElement.addBindingOperationElement();
+ assertNotNull(bop1);
+ assertNotNull(bop2);
+
+ // getBindingOperationElements()
+ bopArray = fBindingElement.getBindingOperationElements();
+ assertNotNull("Expected an array of BindingOperationElements -", bopArray);
+ assertEquals("Incorrect number of retrieved BindingOperationElements -", 2, bopArray.length);
+
+ // verify all Operation objects returned
+ List ifopL = Arrays.asList(bopArray);
+ assertTrue(ifopL.contains(bop1));
+ assertTrue(ifopL.contains(bop2));
+ }
+}
Added: webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java
URL: http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java?rev=809833&view=auto
==============================================================================
--- webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java (added)
+++ webservices/woden/trunk/java/woden-tests/src/test/java/org/apache/woden/wsdl20/xml/BindingFaultElementTest.java Tue Sep 1 05:50:45 2009
@@ -0,0 +1,107 @@
+/**
+ * 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.wsdl20.xml;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.woden.WSDLException;
+import org.apache.woden.WSDLFactory;
+import org.apache.woden.internal.wsdl20.BindingFaultImpl;
+import org.apache.woden.internal.wsdl20.DescriptionImpl;
+import org.apache.woden.types.NCName;
+
+/**
+ * Unit tests for the BindingFaultElement class.
+ *
+ * @author Graham Turrell (gturrell@apache.org)
+ */
+public class BindingFaultElementTest extends TestCase {
+
+ private BindingFaultElement fFault = null;
+
+ public static Test suite()
+ {
+ return new TestSuite(BindingFaultElementTest.class);
+
+ }
+ /*
+ * @see TestCase#setUp()
+ */
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+ fFault = new BindingFaultImpl();
+ }
+
+ /*
+ * @see TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /*
+ * Test that the (Mandatory) BindingFault reference attribute ("ref") can be successfully set and retrieved
+ */
+ public void testSetGetRef()
+ {
+ QName faultRefName = new QName("faultRefName");
+ fFault.setRef(faultRefName);
+ assertEquals("The retrieved BindingFault reference is not that which was set",
+ faultRefName, fFault.getRef());
+ }
+
+ /*
+ * Test that the (Mandatory) InterfaceFault can be successfully retrieved.
+ */
+ public void testGetInterfaceFaultElement()
+ {
+ WSDLFactory factory = null;
+ try {
+ factory = WSDLFactory.newInstance();
+ } catch (WSDLException e) {
+ fail("Can't instantiate the WSDLFactory object.");
+ }
+
+ DescriptionElement descriptionElement = factory.newDescription();
+
+ // Create the BindingElement<->InterfaceElement->InterfaceFaultElement hierarchy
+ BindingElement bindingElement = descriptionElement.addBindingElement();
+ bindingElement.setInterfaceName(new QName("interface1"));
+
+ InterfaceElement interfaceElement = descriptionElement.addInterfaceElement();
+ interfaceElement.setName(new NCName("interface1"));
+
+ InterfaceFaultElement iffElement = interfaceElement.addInterfaceFaultElement();
+ iffElement.setName(new NCName("fault1"));
+
+ // Create the BindingOperationElement->BindingFaultReferenceElement hierarchy
+ BindingOperationElement bopElement = bindingElement.addBindingOperationElement();
+ bopElement.setRef(new QName("operation1"));
+ fFault = bindingElement.addBindingFaultElement();
+ fFault.setRef(new QName("fault1"));
+
+ InterfaceFaultElement retrievedFault = fFault.getInterfaceFaultElement();
+ assertEquals("The retrieved InterfaceFaultElement is not that which was set",
+ iffElement, retrievedFault);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org