Author: jkaputin
Date: Wed Apr 12 09:06:28 2006
New Revision: 393492
URL: http://svn.apache.org/viewcvs?rev=393492&view=rev
Log:
Use TestErrorHandler with the tests that have expected
errors so that the error key can be checked and the
error message suppressed from the test suite output.
Modified:
incubator/woden/java/test/org/apache/woden/xml/IntOrTokenAttrTest.java
incubator/woden/java/test/org/apache/woden/xml/TokenAttrTest.java
Modified: incubator/woden/java/test/org/apache/woden/xml/IntOrTokenAttrTest.java
URL:
http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/xml/IntOrTokenAttrTest.java?rev=393492&r1=393491&r2=393492&view=diff
==============================================================================
--- incubator/woden/java/test/org/apache/woden/xml/IntOrTokenAttrTest.java
(original)
+++ incubator/woden/java/test/org/apache/woden/xml/IntOrTokenAttrTest.java Wed
Apr 12 09:06:28 2006
@@ -21,7 +21,11 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.woden.ErrorInfo;
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.internal.ErrorReporterImpl;
import org.apache.woden.internal.xml.IntOrTokenAnyAttrImpl;
+import org.apache.woden.tests.TestErrorHandler;
import org.w3c.dom.Element;
/**
@@ -32,6 +36,8 @@
*/
public class IntOrTokenAttrTest extends TestCase
{
+ private ErrorReporter reporter;
+ private TestErrorHandler handler;
private Element el = null; //Element arg not used to initialize this attr
private QName qn = new QName("http://wsdl/http","code","whttp");
private IntOrTokenAttr attr = null;
@@ -48,6 +54,9 @@
protected void setUp() throws Exception
{
super.setUp();
+ handler = new TestErrorHandler();
+ reporter = new ErrorReporterImpl();
+ reporter.setErrorHandler(handler);
attr = new IntOrTokenAnyAttrImpl();
}
@@ -57,6 +66,8 @@
protected void tearDown() throws Exception
{
super.tearDown();
+ handler = null;
+ reporter = null;
attr = null;
}
@@ -105,8 +116,8 @@
assertTrue("isInt() should return true", attr.isInt());
assertEquals("Expected getInt() to return 123, but actual value was '"
+ attr.getInt() + "'.",
- new Integer("123"),
- attr.getInt() );
+ new Integer("123"),
+ attr.getInt() );
assertFalse("isToken() should return false", attr.isToken());
assertNull("getToken() should return null", attr.getToken());
}
@@ -114,8 +125,15 @@
public void testInvalidValue() throws Exception
{
String attrVal = "#rubbish";
+ attr.setErrorReporter(reporter); //to check expected error msg
attr.init(el, qn, attrVal);
+ ErrorInfo errInfo = (ErrorInfo)handler.errors.get("WSDL512");
+ assertNotNull("An error should have been reported", errInfo);
+ assertEquals("Error 'WSDL512' expected but error reported was '" +
errInfo.getKey() + "'.",
+ "WSDL512",
+ errInfo.getKey());
+
assertFalse("isValid() should return false", attr.isValid());
assertFalse("isInt() should return false", attr.isInt());
assertFalse("isToken() should return false", attr.isToken());
@@ -126,7 +144,14 @@
public void testNullValue() throws Exception
{
String attrVal = null;
+ attr.setErrorReporter(reporter); //to check expected error msg
attr.init(el, qn, attrVal);
+
+ ErrorInfo errInfo = (ErrorInfo)handler.errors.get("WSDL512");
+ assertNotNull("An error should have been reported", errInfo);
+ assertEquals("Error 'WSDL512' expected but error reported was '" +
errInfo.getKey() + "'.",
+ "WSDL512",
+ errInfo.getKey());
assertFalse("isValid() should return false", attr.isValid());
assertFalse("isInt() should return false", attr.isInt());
Modified: incubator/woden/java/test/org/apache/woden/xml/TokenAttrTest.java
URL:
http://svn.apache.org/viewcvs/incubator/woden/java/test/org/apache/woden/xml/TokenAttrTest.java?rev=393492&r1=393491&r2=393492&view=diff
==============================================================================
--- incubator/woden/java/test/org/apache/woden/xml/TokenAttrTest.java (original)
+++ incubator/woden/java/test/org/apache/woden/xml/TokenAttrTest.java Wed Apr
12 09:06:28 2006
@@ -21,7 +21,11 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.woden.ErrorInfo;
+import org.apache.woden.ErrorReporter;
+import org.apache.woden.internal.ErrorReporterImpl;
import org.apache.woden.internal.xml.TokenAttrImpl;
+import org.apache.woden.tests.TestErrorHandler;
import org.w3c.dom.Element;
/**
@@ -32,6 +36,8 @@
*/
public class TokenAttrTest extends TestCase
{
+ private ErrorReporter reporter;
+ private TestErrorHandler handler;
private Element el = null; //Element arg not used to initialize this attr
private QName qn = new
QName("http://wsdl/http","authenticationType","whttp");;
private TokenAttr attr = null;
@@ -47,14 +53,20 @@
protected void setUp() throws Exception
{
super.setUp();
+ handler = new TestErrorHandler();
+ reporter = new ErrorReporterImpl();
+ reporter.setErrorHandler(handler);
attr = new TokenAttrImpl();
}
/*
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception {
+ protected void tearDown() throws Exception
+ {
super.tearDown();
+ handler = null;
+ reporter = null;
attr = null;
}
@@ -88,7 +100,15 @@
public void testNullValue() throws Exception
{
String attrVal = null;
+ attr.setErrorReporter(reporter); //to check expected error msg
attr.init(el, qn, attrVal);
+
+ ErrorInfo errInfo = (ErrorInfo)handler.errors.get("WSDL508");
+ assertNotNull("An error should have been reported", errInfo);
+ assertEquals("Error 'WSDL508' expected but error reported was '" +
errInfo.getKey() + "'.",
+ "WSDL508",
+ errInfo.getKey());
+
assertNull("Attribute value is not null", attr.getToken());
assertFalse("Attribute value should not be valid", attr.isValid());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]