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 lm...@apache.org on 2008/03/29 19:33:40 UTC
svn commit: r642577 - in /webservices/woden/branches/woden62:
src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
test/org/apache/woden/internal/wsdl20/assertions/TestDescription1001.java
Author: lmandel
Date: Sat Mar 29 11:33:39 2008
New Revision: 642577
URL: http://svn.apache.org/viewvc?rev=642577&view=rev
Log:
[WODEN-203] Fix for Description1001 throwing exception when checking a host name that does not resolve. New tests added to the test suite for this condition as well.
Modified:
webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/TestDescription1001.java
Modified: webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java?rev=642577&r1=642576&r2=642577&view=diff
==============================================================================
--- webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java (original)
+++ webservices/woden/branches/woden62/src/org/apache/woden/internal/wsdl20/assertions/Description1001.java Sat Mar 29 11:33:39 2008
@@ -16,7 +16,6 @@
*/
package org.apache.woden.internal.wsdl20.assertions;
-import java.io.FileNotFoundException;
import java.net.URI;
import java.net.URL;
@@ -64,21 +63,16 @@
o = url.getContent();
}
if(o == null) {
- wodenCtx.getErrorReporter().reportError(
- new ErrorLocatorImpl(), getId(), new Object[] {tns}, ErrorReporter.SEVERITY_WARNING);
+ throw new Exception();
}
- } catch (FileNotFoundException e1) {
- wodenCtx.getErrorReporter().reportError(
- new ErrorLocatorImpl(), getId(), new Object[] {tns}, ErrorReporter.SEVERITY_WARNING);
-
} catch (WSDLException e2) {
+ // A WSDLException may be thrown due to a problem with the URI resolver so we should report this exception.
throw e2;
} catch (Exception e) {
- // IOException
- // MalformedURLException
- throw new WSDLException(WSDLException.OTHER_ERROR,
- "Fatal error.",
- e);
+ // Any other exception including IOExceptoin, MalformedURLException, UnknownHostException, and
+ // FileNotFoundException means that the namespace was not resolvable.
+ wodenCtx.getErrorReporter().reportError(
+ new ErrorLocatorImpl(), getId(), new Object[] {tns}, ErrorReporter.SEVERITY_WARNING);
}
}
Modified: webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/TestDescription1001.java
URL: http://svn.apache.org/viewvc/webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/TestDescription1001.java?rev=642577&r1=642576&r2=642577&view=diff
==============================================================================
--- webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/TestDescription1001.java (original)
+++ webservices/woden/branches/woden62/test/org/apache/woden/internal/wsdl20/assertions/TestDescription1001.java Sat Mar 29 11:33:39 2008
@@ -65,8 +65,8 @@
}
/**
- * Test that the assertion passes for an interface that
- * extends no other interfaces.
+ * Test that the assertion reports a warning for a namespace
+ * with the urn scheme.
*/
public void testTargetNamespaceSchemeurn() {
DescriptionElement descEl = factory.newDescription();
@@ -78,10 +78,49 @@
fail("Assertion Description1001 threw the following WSDLException for target namespace urn:sample: " + e.toString());
}
if(handler.errorMessageHasBeenReported()) {
- fail("Assertion Description1001 fails incorrectly for an target namespace with the scheme urn.");
+ fail("Assertion Description1001 reports an error instead of a warning for an target namespace with the scheme urn.");
}
else if(!handler.messageHasBeenReported()) {
fail("Assertion Description1001 did not report a warning for a target namespace with the scheme urn.");
+ }
+ }
+
+ /**
+ * Test that the assertion reports a warning for a namespace
+ * with an unknown host http://example.sample.
+ */
+ public void testTargetNamespaceDoesNotResolveUnknownHost() {
+ DescriptionElement descEl = factory.newDescription();
+ descEl.setTargetNamespace(URI.create("http://example.sample"));
+
+ try {
+ assertion.validate(descEl, wodenContext);
+ } catch(WSDLException e){
+ fail("Assertion Description1001 threw the following WSDLException for target namespace http://example.sample, which doesn't resolve: " + e.toString());
+ }
+ if(handler.errorMessageHasBeenReported()) {
+ fail("Assertion Description1001 reports an error instead of a warning for an target namespace that doesn't resolve.");
+ }
+ else if(!handler.messageHasBeenReported()) {
+ fail("Assertion Description1001 did not report a warning for a target namespace that doesn't resolve.");
+ }
+ }
+
+ /**
+ * Test that the assertion reports no warning for a namespace
+ * that resolves such as http://apache.org.
+ */
+ public void testTargetNamespaceResolves() {
+ DescriptionElement descEl = factory.newDescription();
+ descEl.setTargetNamespace(URI.create("http://apache.org"));
+
+ try {
+ assertion.validate(descEl, wodenContext);
+ } catch(WSDLException e){
+ fail("Assertion Description1001 threw the following WSDLException for target namespace http://apache.org, which should resolve: " + e.toString());
+ }
+ if(handler.messageHasBeenReported()) {
+ fail("Assertion Description1001 reports an error or warning for an target namespace that should resolve. Note that this test will fail without network connectivity.");
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org