[jboss-svn-commits] JBL Code SVN: r10114 - labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Mar 10 16:31:41 EST 2007


Author: mark.little at jboss.com
Date: 2007-03-10 16:31:41 -0500 (Sat, 10 Mar 2007)
New Revision: 10114

Added:
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/MockXmlValidatorUnitTest.java
Modified:
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/XmlValidatorUnitTest.java
Log:
http://jira.jboss.com/jira/browse/JBESB-352

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/ConfigurationControlerServiceUnitTest.java	2007-03-10 21:31:41 UTC (rev 10114)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb.listeners.config;
+
+import junit.framework.TestCase;
+
+public class ConfigurationControlerServiceUnitTest extends TestCase
+{
+	public void testService ()
+	{
+		ConfigurationControllerService service = new ConfigurationControllerService();		
+		String conf = service.getConfigurationFile();
+		
+		service.setConfigurationFile(conf);
+		
+		System.setProperty("jboss.server.config.url", "http://foo.bar");
+		
+		try
+		{
+			service.startService();
+		}
+		catch (Exception ex)
+		{
+			ex.printStackTrace();
+			fail();
+		}
+		
+		try
+		{
+			service.stopService();
+		}
+		catch (Exception ex)
+		{
+			fail();
+		}
+	}
+}

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/MockXmlValidatorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/MockXmlValidatorUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/MockXmlValidatorUnitTest.java	2007-03-10 21:31:41 UTC (rev 10114)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated 
+ * by the @authors tag. All rights reserved. 
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors. 
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A 
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
+ * MA  02110-1301, USA.
+ * 
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+
+package org.jboss.soa.esb.listeners.config;
+
+import junit.framework.TestCase;
+
+public class MockXmlValidatorUnitTest extends TestCase
+{
+	public void testMockValidator ()
+	{
+		MockXmlValidatorImpl impl = new MockXmlValidatorImpl();
+		
+		impl.getValidationResults();
+		impl.getXMLDocument();
+		
+		try
+		{
+			impl.validate(null);
+			impl.validate(null, null);
+		}
+		catch (Exception ex)
+		{
+			fail();
+		}
+	}
+}

Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/XmlValidatorUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/XmlValidatorUnitTest.java	2007-03-10 18:53:46 UTC (rev 10113)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/config/XmlValidatorUnitTest.java	2007-03-10 21:31:41 UTC (rev 10114)
@@ -33,10 +33,12 @@
 import junit.framework.JUnit4TestAdapter;
 import junit.framework.TestCase;
 
+import org.jboss.soa.esb.listeners.config.XmlValidatorImpl.XmlErrorHandler;
 import org.jboss.soa.esb.testutils.TestEnvironmentUtil;
 import org.junit.Test;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
+import org.xml.sax.SAXParseException;
 
 import com.sun.org.apache.xml.internal.serialize.OutputFormat;
 import com.sun.org.apache.xml.internal.serialize.XMLSerializer;
@@ -84,7 +86,7 @@
 	}
 	
 	@Test 
-	public void validateTestXml() throws Exception {
+	public void testValidateXml() throws Exception {
 		isValid = xmlValidation.validate(inputSource);
 		if (isValid) {
 			System.err.println(testXml+" is valid");
@@ -103,7 +105,7 @@
 		}
 	}
 	@Test
-	public void validateTestXmlAndSchema() throws Exception {
+	public void testValidateXmlAndSchema() throws Exception {
 		isValid = xmlValidation.validate(inputSource,validationSource);
 		if (isValid) {
 			System.err.println(testXml+" is valid");
@@ -121,6 +123,46 @@
 			}
 		}
 	}
+	
+	public void testValidateXmlAndDefaultSchema() throws Exception
+	{
+		isValid = xmlValidation.validate(inputSource, null);
+		
+		if (isValid)
+		{
+			System.err.println(testXml+" is valid");
+		} 
+		else 
+		{
+			System.err.println(testXml+" is invalid -- see getValidationResults()");
+			Collection<String> validationResults = xmlValidation.getValidationResults();
+
+			if (validationResults.size() == 0) 
+			{
+			} 
+			else 
+			{
+				System.err.println("Validation Results:");
+				Object[] valResults = validationResults.toArray();
+				
+	    		for (int i = 0; i < validationResults.size(); i++) 
+	    		{
+	    			System.err.println(valResults[i].toString());
+	    		}
+			}
+		}
+	}
+	
+	public void testXmlErrorHandler() throws Exception
+	{
+		XmlValidatorImpl foo = new XmlValidatorImpl();
+		XmlValidatorImpl.XmlErrorHandler handler = foo.new XmlErrorHandler();
+		
+		handler.warning(new SAXParseException("foo", null));
+		handler.error(new SAXParseException("foo", null));
+		handler.fatalError(new SAXParseException("foo", null));
+	}
+	
 	@Test
 	public void testGetDocument() throws Exception {
 		Document document = xmlValidation.getXMLDocument();
@@ -151,6 +193,13 @@
 			}
 		}
 	}
+	
+	public void testException () throws Exception
+	{
+		XmlValidatorException ex = new XmlValidatorException("foobar");
+		ex = new XmlValidatorException();
+		ex = new XmlValidatorException("foobar", new Exception());
+	}
 		
 	public static junit.framework.Test suite() {
 		return new JUnit4TestAdapter(XmlValidatorUnitTest.class);




More information about the jboss-svn-commits mailing list