Author: sagara
Date: Tue Oct  6 19:17:52 2009
New Revision: 822443

URL: http://svn.apache.org/viewvc?rev=822443&view=rev
Log:
add ErrorHandler inner class for testing.

Modified:
    
webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java

Modified: 
webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java
URL: 
http://svn.apache.org/viewvc/webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java?rev=822443&r1=822442&r2=822443&view=diff
==============================================================================
--- 
webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java
 (original)
+++ 
webservices/woden/trunk/java/woden-om/src/test/java/org/apache/woden/OMWSDLReaderTest.java
 Tue Oct  6 19:17:52 2009
@@ -21,6 +21,8 @@
 import java.io.InputStream;
 import java.net.URI;
 import java.net.URL;
+import java.util.Enumeration;
+import java.util.Hashtable;
 
 import javax.xml.stream.XMLStreamException;
 
@@ -30,7 +32,6 @@
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.woden.tests.TestErrorHandler;
 import org.apache.woden.wsdl20.Description;
 
 public class OMWSDLReaderTest extends TestCase{
@@ -162,4 +163,126 @@
         }
         assertNotNull("The description returned is null.", desc);
     }
+    class TestErrorHandler implements ErrorHandler 
+    {
+      public Hashtable warnings = new Hashtable();
+      public int numWarnings = 0;
+      public Hashtable errors = new Hashtable();
+      public int numErrors = 0;
+      public Hashtable fatalErrors = new Hashtable();
+      public int numFatalErrors = 0;
+
+      /**
+       * Reset the handler. Remove all messages stored in the handler.
+       */
+      public void reset()
+      {
+        warnings.clear();
+        numWarnings = 0;
+        errors.clear();
+        numErrors = 0;
+        fatalErrors.clear();
+        numFatalErrors = 0;
+      }
+      
+      /**
+       * Determine whether an error or fatal error message has been reported.
+       * 
+       * @return True if an error or fatal error message has been reported, 
false otherwise.
+       */
+      public boolean errorMessageHasBeenReported()
+      {
+        if(numErrors + numFatalErrors == 0)
+          return false;
+        return true;
+      }
+      
+      /**
+       * Determine whether any message has been reported (warning, error or 
fatal error).
+       * 
+       * @return True if a message has been reported, false otherwise.
+       */
+      public boolean messageHasBeenReported()
+      {
+        if(numWarnings + numErrors + numFatalErrors == 0)
+          return false;
+        return true;
+      }
+      
+      /**
+       * Get a summary of the message keys. This is used in
+       * reporting the keys of messages that were reported.
+       * 
+       * @return A summary string of the message keys.
+       */
+      public String getSummaryOfMessageKeys()
+      {
+        StringBuffer summary = new StringBuffer();
+        
+        if(numFatalErrors > 0)
+        {
+          summary.append("Fatal Errors: ");
+          Enumeration keys = fatalErrors.keys();
+          while(keys.hasMoreElements())
+          {
+            summary.append(keys.nextElement()).append(" ");
+          }
+          summary.append("\n");
+        }
+        
+        if(numErrors > 0)
+        {
+          summary.append("Errors: ");
+          Enumeration keys = errors.keys();
+          while(keys.hasMoreElements())
+          {
+            summary.append(keys.nextElement()).append(" ");
+          }
+          summary.append("\n");
+        }
+        
+        if(numWarnings > 0)
+        {
+          summary.append("Warnings: ");
+          Enumeration keys = warnings.keys();
+          while(keys.hasMoreElements())
+          {
+            summary.append(keys.nextElement()).append(" ");
+          }
+        }
+        
+        return summary.toString();
+      }
+      
+      /* (non-Javadoc)
+       * @see org.apache.woden.ErrorHandler#warning(org.apache.woden.ErrorInfo)
+       */
+      public void warning(ErrorInfo errorInfo)
+      {
+        warnings.put(errorInfo.getKey(), errorInfo);
+        numWarnings++;
+      }
+
+      /* (non-Javadoc)
+       * @see org.apache.woden.ErrorHandler#error(org.apache.woden.ErrorInfo)
+       */
+      public void error(ErrorInfo errorInfo) 
+      {
+        errors.put(errorInfo.getKey(), errorInfo);
+        numErrors++;
+      }
+
+      /* (non-Javadoc)
+       * @see 
org.apache.woden.ErrorHandler#fatalError(org.apache.woden.ErrorInfo)
+       */
+      public void fatalError(ErrorInfo errorInfo) 
+      {
+        fatalErrors.put(errorInfo.getKey(), errorInfo);
+        numFatalErrors++;
+      }
+      
+      
+
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to