[cvs] expresso commit by rimovm: Continued moving of test suites to
separate
JCorporate Ltd
jcorp at jcorp2.servlets.net
Fri Nov 12 08:17:56 PST 2004
Log Message:
-----------
Continued moving of test suites to separate directory.
Modified Files:
--------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/controller:
XMLController.java
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core:
ExpressoTestSuite.java
Added Files:
-----------
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/controller/tests:
BlockTests.java
ControllerResponseTests.java
InputTests.java
OutputTests.java
TestSecureIfSetController.java
TransitionTests.java
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/dataobjects/jdbc/tests:
DownloadMimeTypeJoin.xml
JoinedObjectTest.java
LobFieldTest.java
TestJoinedDigesterBean.java
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/dataobjects/test:
Test1ExpressoServices.xml
TestDataTransferObject.java
TestLog4jConfig.xml
TestPersistenceManager.java
log4j.dtd
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/db/tests:
DBConnectionPoolStressThread.java
DBConnectionPoolTest.java
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/logging/tests:
LogManagerTests.java
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/misc/tests:
Base64Test.java
CookieBase64Test.java
CookieTests.java
FileUtilTests.java
HexEncoderTest.java
TestDateTime.java
TestXmlDocTypeFilter.java
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/ext/tests:
DBObjStressTest.java
RetrieveThroughputTest.java
StressTestObject.java
StressTestSchema.java
StressThread.java
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/digester/test:
SampleConfig.xml
TestComponentMetadataConfig.java
TestExpressoServicesConfig.java
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/management/test:
Test1ExpressoServices.xml
TestLog4jConfig.xml
TestServiceWriter.java
log4j.dtd
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test:
Test1ExpressoServices.xml
Test2ExpressoServices.xml
TestComponent.java
TestComponentMetadata.xml
TestComponentSystem.java
TestLog4jConfig.xml
TestRuntimeInitServlet.java
log4j.dtd
expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/util/test:
FastStringBufferTest.java
TestLocatorUtils.java
Removed Files:
-------------
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/tests:
BlockTests.java
ControllerResponseTests.java
InputTests.java
OutputTests.java
TestSecureIfSetController.java
TransitionTests.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/tests:
DownloadMimeTypeJoin.xml
JoinedObjectTest.java
LobFieldTest.java
TestJoinedDigesterBean.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/test:
Test1ExpressoServices.xml
TestDataTransferObject.java
TestLog4jConfig.xml
TestPersistenceManager.java
log4j.dtd
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/tests:
DBConnectionPoolStressThread.java
DBConnectionPoolTest.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/logging/tests:
LogManagerTests.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests:
Base64Test.java
CookieBase64Test.java
CookieTests.java
FastStringBufferTest.java
FileUtilTests.java
HexEncoderTest.java
TestDateTime.java
TestXmlDocTypeFilter.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/tests:
DBObjStressTest.java
RetrieveThroughputTest.java
StressTestObject.java
StressTestSchema.java
StressThread.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/digester/test:
SampleConfig.xml
TestComponentMetadataConfig.java
TestExpressoServicesConfig.java
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/management/test:
Test1ExpressoServices.xml
TestLog4jConfig.xml
TestServiceWriter.java
log4j.dtd
expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/test:
Test1ExpressoServices.xml
Test2ExpressoServices.xml
TestComponent.java
TestComponentMetadata.xml
TestComponentSystem.java
TestLog4jConfig.xml
TestRuntimeInitServlet.java
log4j.dtd
Revision Data
-------------
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/management/test/log4j.dtd
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- Authors: Chris Taylor, Ceki Gulcu. -->
+
+<!-- Version: 1.2 -->
+
+<!-- A configuration element consists of optional renderer
+elements,appender elements, categories and an optional root
+element. -->
+
+<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?,
+ categoryFactory?)>
+
+<!-- The "threshold" attribute takes a level value such that all -->
+<!-- logging statements with a level equal or below this value are -->
+<!-- disabled. -->
+
+<!-- Setting the "debug" or "configDebug" attributes enable the printing -->
+<!-- of internal log4j logging statements. -->
+
+<!-- By default, debug attribute is "null", meaning that we not touch -->
+<!-- internal log4j logging settings. -->
+
+
+<!ATTLIST log4j:configuration
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ threshold (all|debug|info|warn|error|fatal|off|null) "null"
+ debug (true|false|null) "null"
+>
+
+<!-- renderer elements allow the user to customize the conversion of -->
+<!-- message objects to String. -->
+
+<!ELEMENT renderer EMPTY>
+<!ATTLIST renderer
+ renderedClass CDATA #REQUIRED
+ renderingClass CDATA #REQUIRED
+>
+
+<!-- Appenders must have a name and a class. -->
+<!-- Appenders may contain an error handler, a layout, optional parameters -->
+<!-- and filters. They may also reference (or include) other appenders. -->
+<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
+<!ATTLIST appender
+ name ID #REQUIRED
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT layout (param*)>
+<!ATTLIST layout
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT filter (param*)>
+<!ATTLIST filter
+ class CDATA #REQUIRED
+>
+
+<!-- ErrorHandlers can be of any class. They can admit any number of -->
+<!-- parameters. -->
+
+<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)>
+<!ATTLIST errorHandler
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT root-ref EMPTY>
+
+<!ELEMENT logger-ref EMPTY>
+<!ATTLIST logger-ref
+ ref IDREF #REQUIRED
+>
+
+<!ELEMENT param EMPTY>
+<!ATTLIST param
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
+>
+
+
+<!-- The priority class is org.apache.log4j.Level by default -->
+<!ELEMENT priority (param*)>
+<!ATTLIST priority
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+<!-- The level class is org.apache.log4j.Level by default -->
+<!ELEMENT level (param*)>
+<!ATTLIST level
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named category. -->
+<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
+<!ATTLIST category
+ class CDATA #IMPLIED
+ name CDATA #REQUIRED
+ additivity (true|false) "true"
+>
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named logger. -->
+<!ELEMENT logger (level?,appender-ref*)>
+<!ATTLIST logger
+ name ID #REQUIRED
+ additivity (true|false) "true"
+>
+
+
+<!ELEMENT categoryFactory (param*)>
+<!ATTLIST categoryFactory
+ class CDATA #REQUIRED>
+
+<!ELEMENT appender-ref EMPTY>
+<!ATTLIST appender-ref
+ ref IDREF #REQUIRED
+>
+
+<!-- If no priority element is specified, then the configurator MUST not -->
+<!-- touch the priority of root. -->
+<!-- The root category always exists and cannot be subclassed. -->
+<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
+
+
+<!-- ==================================================================== -->
+<!-- A logging event -->
+<!-- ==================================================================== -->
+<!ELEMENT log4j:eventSet (log4j:event*)>
+<!ATTLIST log4j:eventSet
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ version (1.1|1.2) "1.2"
+ includesLocationInfo (true|false) "true"
+>
+
+
+
+<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?,
+ log4j:locationInfo?) >
+
+<!-- The timestamp format is application dependent. -->
+<!ATTLIST log4j:event
+ category CDATA #REQUIRED
+ priority CDATA #REQUIRED
+ thread CDATA #REQUIRED
+ timestamp CDATA #REQUIRED
+>
+
+<!ELEMENT log4j:message (#PCDATA)>
+<!ELEMENT log4j:NDC (#PCDATA)>
+
+<!ELEMENT log4j:throwable (#PCDATA)>
+
+<!ELEMENT log4j:locationInfo EMPTY>
+<!ATTLIST log4j:locationInfo
+ class CDATA #REQUIRED
+ method CDATA #REQUIRED
+ file CDATA #REQUIRED
+ line CDATA #REQUIRED
+>
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/management/test/TestServiceWriter.java
@@ -0,0 +1,146 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.kernel.management.test;
+
+import com.jcorporate.expresso.kernel.RootContainerInterface;
+import com.jcorporate.expresso.kernel.SystemFactory;
+import com.jcorporate.expresso.kernel.exception.ConfigurationException;
+import com.jcorporate.expresso.kernel.management.DefaultServiceWriter;
+import junit.framework.TestCase;
+
+import java.io.File;
+
+/** JUnitTest case for class: com.jcorporate.expresso.kernel.management.XercesServiceWriter */
+public class TestServiceWriter extends TestCase {
+
+ public TestServiceWriter(String _name) {
+ super(_name);
+ }
+
+ RootContainerInterface globalContainer = null;
+
+ /** setUp method for test case */
+ protected void setUp() {
+ try {
+ globalContainer = SystemFactory.buildExpressoComponentSystem(
+ this.getClass().getResource("Test1ExpressoServices.xml"),
+ this.getClass().getResource("TestLog4jConfig.xml"),
+ "D:/Expresso/log");
+ } catch (ConfigurationException ex) {
+ ex.printStackTrace();
+ throw new IllegalStateException("Error setting up test case: " + ex.getMessage());
+ }
+
+ }
+
+ /** tearDown method for test case */
+ protected void tearDown() {
+ globalContainer.destroy();
+ globalContainer = null;
+ System.gc();
+ System.runFinalization();
+ }
+
+ public void testXercesSaveConfiguration() {
+ runTestSaveConfig(com.jcorporate.expresso.kernel.management.XercesDOMWriter.class.getName());
+ }
+
+ public void testTRAXSaveConfiguration() {
+ runTestSaveConfig(com.jcorporate.expresso.kernel.management.TraxDOMWriter.class.getName());
+ }
+
+ protected void runTestSaveConfig(String domWriterClass) {
+ try {
+ DefaultServiceWriter sw = new DefaultServiceWriter();
+ sw.setDomWriterClass(domWriterClass);
+
+ sw.writeServicesFile(globalContainer, "d:/expresso/log/testOut.xml");
+
+ File f = new File("d:/expresso/log/testOut.xml");
+ if (f == null) {
+ fail("testOut.xml wasn't created");
+ }
+
+ RootContainerInterface testContainer =
+ SystemFactory.buildExpressoComponentSystem(f.toURL(),
+ this.getClass().getResource("TestLog4jConfig.xml"),
+ "D:/Expresso/log");
+
+ assertTrue("Test containers should be equal",
+ testContainer.getExpressoServicesConfig().equals(globalContainer.getExpressoServicesConfig()));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Exception thrown during test: " + ex.getMessage());
+ }
+
+ }
+
+
+ /** Executes the test case */
+ public static void main(String[] argv) {
+ String[] testCaseList = {TestServiceWriter.class.getName()};
+ junit.textui.TestRunner.main(testCaseList);
+ }
+}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/management/test/TestLog4jConfig.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.Out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m\n"/>
+ </layout>
+ </appender>
+ <root>
+ <priority value="info"/>
+ <appender-ref ref="console"/>
+ </root>
+</log4j:configuration>
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/management/test/Test1ExpressoServices.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE expresso-services PUBLIC "-//Jcorporate Ltd//DTD Expresso Services Configuration 5.1//EN" "http://www.jcorporate.com/dtds/expresso-services_5_1.dtd">
+<expresso-services>
+ <mapped-property name="setupValues" key="test1" value="abcdefg"/>
+ <mapped-property name="setupValues" key="who you gonna call?" value="knees time!"/>
+ <component name="default" class-name="com.jcorporate.expresso.kernel.DataContext">
+ <property name="contextName" value="default"/>
+ <property name="hasSetupTables" value="true"/>
+ <property name="securityContext" value=""/>
+ <property name="contextDescription" value="A Sample Default Database"/>
+ <mapped-property name="setupValue" key="test1" value="Test Setup Value"/>
+ <component name="TestComponent" class-name="com.jcorporate.expresso.kernel.test.TestComponent">
+ <property name="property1" value="Abcdefg"/>
+ <property name="property2" value="true"/>
+ </component>
+ </component>
+</expresso-services>
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/misc/tests/TestDateTime.java
@@ -0,0 +1,264 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.misc.tests;
+
+import com.jcorporate.expresso.core.misc.DateTime;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import com.jcorporate.expresso.services.test.TestSystemInitializer;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import java.util.Calendar;
+import java.util.Date;
+
+/**
+ * <p>Test case to verify DateTime utility class</p>
+ * <p>Copyright: Copyright (c) 2001-2002</p>
+ * <p>Company: JCorporate Ltd.</p>
+ * @author Tommy Grovnes
+ * @version $Revision: 1.1 $ on $Date: 2004/11/12 16:17:23 $
+ */
+public class TestDateTime extends ExpressoTestCase {
+
+ String myContext = TestSystemInitializer.getTestContext();
+
+ public TestDateTime(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TestDateTime.class);
+ }
+
+ public static void checkOKDate(String testName, String result) {
+ assertTrue("Not null Return ", (result != null));
+ assertTrue("Greater Than Zero Length Return ", (result.length() > 0));
+ System.out.println(testName + " : result " + result);
+ }
+
+ public static void checkNullDate(String testName, String result) {
+ assertTrue("Is Null Return ", (result == null));
+ System.out.println(testName + " : result " + result);
+ }
+
+ public void testGoodDate() throws Exception {
+
+ int year = 1969;
+ int month = 4;
+ int day = 22;
+ int hour = 13;
+ int min = 14;
+ int sec = 15;
+ Date date = new Date();
+ Calendar aCalendar = Calendar.getInstance();
+ aCalendar.set(year, month, day, hour, min, sec);
+
+ System.out.println("=======================================");
+ System.out.println("testGoodDate\n");
+ System.out.println("year = " + year);
+ System.out.println("month = " + month);
+ System.out.println("day = " + day);
+ System.out.println("hour = " + hour);
+ System.out.println("min = " + min);
+ System.out.println("sec = " + sec);
+ System.out.println("date = " + date);
+ System.out.println("");
+
+ checkOKDate("getDateString()", DateTime.getDateString());
+ checkOKDate("getDateTimeForDB()", DateTime.getDateTimeForDB());
+ checkOKDate("getDateTimeForDB(myContext)",
+ DateTime.getDateTimeForDB(myContext));
+ checkOKDate("getDateTimeForDB(year, month, day, hour, min, sec, myContext)",
+ DateTime.getDateTimeForDB(year, month, day, hour, min, sec, myContext));
+ checkOKDate("getDateTimeForDB(date, myContext)",
+ DateTime.getDateTimeForDB(date, myContext));
+// checkOKDate("getDateString(aCalendar)",
+// DateTime.getDateString(aCalendar));
+ checkOKDate("getDateTimeForDB(year, month, day, hour, min, sec)",
+ DateTime.getDateTimeForDB(year, month, day, hour, min, sec));
+ checkOKDate("getDateTimeForDB(date)",
+ DateTime.getDateTimeForDB(date));
+ checkOKDate("getDateTimeString()",
+ DateTime.getDateTimeString());
+ checkOKDate("getDateTimeString(date)",
+ DateTime.getDateTimeString(date));
+ checkOKDate("getTimeForDB()", DateTime.getTimeForDB());
+ checkOKDate("getTimeForDB(hour, min, sec)",
+ DateTime.getTimeForDB(hour, min, sec));
+ checkOKDate("getTimeForDB(date)", DateTime.getTimeForDB(date));
+ checkOKDate("getTimeForDB(date, myContext)",
+ DateTime.getTimeForDB(date, myContext));
+ checkOKDate("getDateForDB()", DateTime.getDateForDB());
+ checkOKDate("getDateForDB(year, month, day)",
+ DateTime.getDateForDB(year, month, day));
+ checkOKDate("getDateForDB(date)", DateTime.getDateForDB(date));
+ checkOKDate("getDateForDB(date, myContext)",
+ DateTime.getDateForDB(date, myContext));
+ }
+
+ public void testNullDate() throws Exception {
+
+ Date date = null;
+
+ System.out.println("=======================================");
+ System.out.println("testNullDate\n");
+
+ checkNullDate("getDateTimeForDB(date, myContext)",
+ DateTime.getDateTimeForDB(date, myContext));
+ checkNullDate("getDateTimeForDB(date)",
+ DateTime.getDateTimeForDB(date));
+ checkNullDate("getDateTimeString(date)",
+ DateTime.getDateTimeString(date));
+ checkNullDate("getTimeForDB(date)",
+ DateTime.getTimeForDB(date));
+ checkNullDate("getTimeForDB(date, myContext)",
+ DateTime.getTimeForDB(date, myContext));
+ checkNullDate("getDateForDB(date)",
+ DateTime.getDateForDB(date));
+ checkNullDate("getDateForDB(date, myContext)",
+ DateTime.getDateForDB(date, myContext));
+
+ }
+
+ public void testBadDate1() throws Exception {
+
+ int year = -1;
+ int month = -1;
+ int day = -1;
+ int hour = -1;
+ int min = -1;
+ int sec = -1;
+ Calendar aCalendar = Calendar.getInstance();
+ aCalendar.set(year, month, day, hour, min, sec);
+
+ System.out.println("=======================================");
+ System.out.println("testBadDate\n");
+ System.out.println("year = " + year);
+ System.out.println("month = " + month);
+ System.out.println("day = " + day);
+ System.out.println("hour = " + hour);
+ System.out.println("min = " + min);
+ System.out.println("sec = " + sec);
+ System.out.println("");
+
+ System.out.println("getDateTimeForDB(year, month, day, hour, min, sec, myContext) : result "
+ + DateTime.getDateTimeForDB(year, month, day, hour, min, sec, myContext));
+// System.out.println("getDateString(aCalendar) : result "
+// + DateTime.getDateString(aCalendar));
+ System.out.println("getDateTimeForDB(year, month, day, hour, min, sec) : result "
+ + DateTime.getDateTimeForDB(year, month, day, hour, min, sec));
+ System.out.println("getTimeForDB(hour, min, sec) : result "
+ + DateTime.getTimeForDB(hour, min, sec));
+ System.out.println("getDateForDB(year, month, day) : result "
+ + DateTime.getDateForDB(year, month, day));
+
+ }
+
+ public void testBadDate2() throws Exception {
+
+ int year = 99999;
+ int month = 99;
+ int day = 99;
+ int hour = 99;
+ int min = 99;
+ int sec = 99;
+ Calendar aCalendar = Calendar.getInstance();
+ aCalendar.set(year, month, day, hour, min, sec);
+
+ System.out.println("=======================================");
+ System.out.println("testBadDate2\n");
+ System.out.println("year = " + year);
+ System.out.println("month = " + month);
+ System.out.println("day = " + day);
+ System.out.println("hour = " + hour);
+ System.out.println("min = " + min);
+ System.out.println("sec = " + sec);
+ System.out.println("");
+
+ System.out.println("getDateTimeForDB(year, month, day, hour, min, sec," +
+ " myContext) : result "
+ + DateTime.getDateTimeForDB(year, month,
+ day, hour, min, sec, myContext));
+// System.out.println("getDateString(aCalendar) : result " +
+// DateTime.getDateString(aCalendar));
+ System.out.println("getDateTimeForDB(year, month, day, hour, min, sec) : result " +
+ DateTime.getDateTimeForDB(year, month, day,
+ hour, min, sec));
+ System.out.println("getTimeForDB(hour, min, sec) : result " +
+ DateTime.getTimeForDB(hour, min, sec));
+ System.out.println("getDateForDB(year, month, day) : result " +
+ DateTime.getDateForDB(year, month, day));
+ }
+
+
+ public static void main(String args[])
+ throws Exception {
+ TestRunner.run(suite());
+ }
+
+}
+
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/misc/tests/TestXmlDocTypeFilter.java
@@ -0,0 +1,157 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.misc.tests;
+
+import com.jcorporate.expresso.core.misc.ConfigManager;
+import com.jcorporate.expresso.core.misc.XmlDocTypeFilter;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+import org.xml.sax.InputSource;
+
+import java.io.FileInputStream;
+
+
+/**
+ * Unit test for XMLDocTypeFilter class
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ $Date: 2004/11/12 16:17:23 $
+ */
+public class TestXmlDocTypeFilter
+ extends ExpressoTestCase {
+ public TestXmlDocTypeFilter(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+
+ String configDir = null;
+ XmlDocTypeFilter testClass = null;
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static junit.framework.Test suite()
+ throws Exception {
+ return new TestSuite(TestXmlDocTypeFilter.class);
+ }
+
+ public void setUp() {
+ configDir = ConfigManager.getConfigDir();
+ assertTrue("configDir != null",
+ (configDir != null && configDir.length() > 0));
+
+ testClass = new XmlDocTypeFilter();
+ }
+
+ public void testParseExpressoConfig()
+ throws Exception {
+ String fileName = configDir + "/expresso-config.xml";
+ FileInputStream fis = new FileInputStream(fileName);
+ InputSource inputSource = new InputSource(fis);
+ assertTrue("Proper Expresso Config Doctype",
+ testClass.isProperDocType("expresso-config", inputSource) == true);
+ fis.close();
+ fis = new FileInputStream(fileName);
+ inputSource = new InputSource(fis);
+ assertTrue("Testing Wrong Expresso Config Doctype",
+ testClass.isProperDocType("expresso-config-WRONG",
+ inputSource) == false);
+ }
+
+ public void testParseStrutsConfig()
+ throws Exception {
+ String fileName = configDir + "/struts-config.xml";
+ FileInputStream fis = new FileInputStream(fileName);
+ InputSource inputSource = new InputSource(fis);
+ assertTrue("Proper Struts Config Doctype",
+ testClass.isProperDocType("struts-config", inputSource) == true);
+ fis.close();
+ fis = new FileInputStream(fileName);
+ inputSource = new InputSource(fis);
+ assertTrue("Testing Wrong Struts Config Doctype",
+ testClass.isProperDocType("struts-config-WRONG",
+ inputSource) == false);
+ }
+
+ public void testParseLoggingConfig()
+ throws Exception {
+ String fileName = configDir + "/expressoLogging.xml";
+ FileInputStream fis = new FileInputStream(fileName);
+ InputSource inputSource = new InputSource(fis);
+ assertTrue("Proper Log4j Configuration Doctype",
+ testClass.isProperDocType("log4j:configuration",
+ inputSource) == true);
+ fis.close();
+ fis = new FileInputStream(fileName);
+ inputSource = new InputSource(fis);
+ assertTrue("Testing Wrong Log4j Config Doctype",
+ testClass.isProperDocType("log4j:configuration-WRONG",
+ inputSource) == false);
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/misc/tests/HexEncoderTest.java
@@ -0,0 +1,161 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.misc.tests;
+
+import com.jcorporate.expresso.core.misc.HexEncoder;
+import com.jcorporate.expresso.services.test.CommandLineParser;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Tests The HexEncoder Class. A Class that will take binary numbers and
+ * product a Hexadecimal output.
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ on $Date: 2004/11/12 16:17:23 $
+ */
+public class HexEncoderTest
+ extends ExpressoTestCase {
+ public HexEncoderTest(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ CommandLineParser.parseCommandLine(args);
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite() {
+ return new TestSuite(HexEncoderTest.class);
+ }
+
+ /**
+ * Tests to make sure both arrays are equal values.
+ *
+ * @param array1[]
+ * @param array2[]
+ * @return true if array1 and array2 have equal values contained in them.
+ */
+ private static boolean arraysAreEqual(byte[] array1, byte[] array2) {
+ if (array1.length != array2.length) {
+ return false;
+ }
+
+ int len = array1.length;
+
+ for (int i = 0; i < len; i++) {
+ if (array1[i] != array2[i]) {
+ return false;
+ }
+ }
+
+ return true;
+ } /* arraysAreEqual(byte, byte) */
+
+ /**
+ * This test case makes sure that various byte values get properly
+ * encoded and decoded back.
+ * @throws Exception if an error occurs during encode/decode process
+ */
+ public void testHexEncode()
+ throws Exception {
+ byte[][] testArray = {
+ {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {5, 6, 7, 8, 9, 0, 35, 62, 33},
+ {(byte) 0x0A, (byte) 0xFF, (byte) 0xCA, (byte) 0xB1, (byte) 0x00, (byte) 0x42}
+ };
+
+ for (int i = 0; i < testArray.length; i++) {
+ byte[] test = testArray[i];
+ String encoded = HexEncoder.encode(test);
+ byte[] decoded = HexEncoder.decode(encoded);
+ assertTrue("Arrays Must Be Equal: i=" + i,
+ arraysAreEqual(test, decoded));
+ }
+ }
+
+ /**
+ * This test makes sure that IllegalArgumentExceptions are thrown if
+ * invalid inputs are given to the system.
+ */
+ public void testBadInputs()
+ throws Exception {
+ String[] breakDecode = {"ABA", "", "ABCDEFHLKAMABACD"};
+
+ for (int i = 0; i < breakDecode.length; i++) {
+ try {
+ byte[] decoded = HexEncoder.decode(breakDecode[i]);
+ fail("Didn't handle bad input " + breakDecode[i]);
+ } catch (IllegalArgumentException ex) {
+ }
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/misc/tests/CookieBase64Test.java
@@ -0,0 +1,137 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.misc.tests;
+
+import com.jcorporate.expresso.core.misc.CookieBase64;
+import com.jcorporate.expresso.services.test.CommandLineParser;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Unit tests for Base64-ish encoding for cookies
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ $Date: 2004/11/12 16:17:23 $
+ */
+public class CookieBase64Test
+ extends ExpressoTestCase {
+ final String[] testString = {
+ "a", "ab", "abc", "abcd", "abcde", "ABC", "ABCDE", "abcdef", "abcdefg",
+ "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@",
+ "#$%^&*()_+1234567890<>,.:\"\\"
+ };
+ final byte[] test3 = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 120, 54, -125, 30, (byte) 0xFF
+ };
+
+ public CookieBase64Test(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ CommandLineParser.parseCommandLine(args);
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite()
+ throws Exception {
+ return new TestSuite(CookieBase64Test.class);
+ }
+
+ /**
+ * Tests the proprietary non-padding Base64 scheme. (No ='s at the end)
+ */
+ public void testCookieBase64() {
+ int i;
+
+ for (i = 0; i < testString.length; i++) {
+ String arrayPartEncode = CookieBase64.encodeNoPadding(
+ testString[i].getBytes());
+ String arrayPartDecode = new String(CookieBase64.decodeNoPadding(
+ arrayPartEncode));
+ assertTrue("CookieBase64 Test: Test Data " + testString[i],
+ arrayPartDecode.equals(testString[i]));
+ assertTrue("Greater Than Zero Length Return " + testString[i],
+ arrayPartEncode.length() > 0);
+ assertTrue("No Padding", arrayPartEncode.indexOf('=') == -1);
+ }
+
+ //Test3
+ String encode3 = CookieBase64.encodeNoPadding(test3);
+ byte[] decode3 = CookieBase64.decodeNoPadding(encode3);
+
+ for (i = 0; i < decode3.length; i++) {
+ assertTrue("Binary Input Data i=" + Integer.toString(i),
+ test3[i] == decode3[i]);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/misc/tests/FileUtilTests.java
@@ -0,0 +1,150 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+package com.jcorporate.expresso.core.misc.tests;
+
+import com.jcorporate.expresso.core.misc.FileUtil;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+
+/**
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: </p>
+ * <p>Company: </p>
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ on $Date: 2004/11/12 16:17:23 $
+ */
+
+public class FileUtilTests extends ExpressoTestCase
+{
+
+
+
+ public FileUtilTests(String name) throws Exception
+ {
+ super(name);
+ }
+
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite() {
+ return new TestSuite(FileUtilTests.class);
+ }
+
+ /**
+ * Tests the file extension parser to make sure it's grabbing the right
+ * values.
+ */
+ public void testFileExtensions() {
+ String result = FileUtil.getExtension("abc");
+ assertTrue("".equals(result));
+
+ result = FileUtil.getExtension("abc.d");
+ assertTrue("d".equals(result));
+
+ result = FileUtil.getExtension("abc.d.efg");
+ assertTrue("efg".equals(result));
+
+ }
+
+ /**
+ * Tests to make sure path parsing is correct.
+ */
+ public void testGetPath() {
+ String test = "/tmp/usr/abcd/abcdefg.jkh";
+ String result = FileUtil.getPath(test);
+ assertTrue("/tmp/usr/abcd".equals(result));
+
+ test = "c:\\windows\\test\\krnl386.exe";
+ result = FileUtil.getPath(test);
+ assertTrue("c:\\windows\\test".equals(result));
+
+ }
+
+ /**
+ * Tests the getBase
+ */
+ public void testGetBase() {
+ String test = "/tmp/usr/abcd/abcdefg.jkh";
+ String result = FileUtil.getBase(test);
+ assertTrue("abcdefg".equals(result));
+
+ test = "c:\\windows\\test\\krnl386.exe";
+ result = FileUtil.getBase(test);
+ assertTrue("krnl386".equals(result));
+
+
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/misc/tests/Base64Test.java
@@ -0,0 +1,163 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.misc.tests;
+
+import com.jcorporate.expresso.core.misc.Base64;
+import com.jcorporate.expresso.services.test.CommandLineParser;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+
+
+/**
+ * Unit tests for the Base64 encoding class
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ $Date: 2004/11/12 16:17:23 $
+ */
+public class Base64Test
+ extends ExpressoTestCase {
+ final String[] testString = {
+ "a", "ab", "abc", "abcd", "abcde", "ABC", "ABCDE", "abcdef", "abcdefg",
+ "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@",
+ "#$%^&*()_+1234567890<>,.:\"\\"
+ };
+ final byte[] test3 = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 120, 54, -125, 30, (byte) 0xFF
+ };
+
+ public Base64Test(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ CommandLineParser.parseCommandLine(args);
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite() {
+ return new TestSuite(Base64Test.class);
+ }
+
+ /**
+ * Tests a normal base64 operation.
+ */
+ public void testBase64WithPadding() {
+ int i;
+
+ for (i = 0; i < testString.length; i++) {
+ String arrayPartEncode = Base64.encode(testString[i].getBytes());
+ String arrayPartDecode = new String(Base64.decode(arrayPartEncode));
+ assertTrue("Base64 Test: Test Data " + testString[i],
+ arrayPartDecode.equals(testString[i]));
+ assertTrue("Greater Than Zero Length Return " + testString[i],
+ arrayPartEncode.length() > 0);
+ }
+
+ //Test3
+ String encode3 = Base64.encode(test3);
+ byte[] decode3 = Base64.decode(encode3);
+
+ for (i = 0; i < decode3.length; i++) {
+ assertTrue("Binary Input Data i=" + Integer.toString(i),
+ test3[i] == decode3[i]);
+ }
+ }
+
+ /**
+ * Tests the proprietary non-padding Base64 scheme. (No ='s at the end)
+ */
+ public void testBase64NoPadding() {
+ int i;
+
+ for (i = 0; i < testString.length; i++) {
+ String arrayPartEncode = Base64.encodeNoPadding(
+ testString[i].getBytes());
+ String arrayPartDecode = new String(Base64.decodeNoPadding(
+ arrayPartEncode));
+ assertTrue("Base64 Test: Test Data " + testString[i],
+ arrayPartDecode.equals(testString[i]));
+ assertTrue("Greater Than Zero Length Return " + testString[i],
+ arrayPartEncode.length() > 0);
+ assertTrue("No Padding", arrayPartEncode.indexOf('=') == -1);
+ }
+
+ //Test3
+ String encode3 = Base64.encodeNoPadding(test3);
+ byte[] decode3 = Base64.decodeNoPadding(encode3);
+ assertTrue("Greater Than Zero Length Return [binary]",
+ decode3.length > 0);
+
+ for (i = 0; i < decode3.length; i++) {
+ assertTrue("Binary Input Data i=" + Integer.toString(i),
+ test3[i] == decode3[i]);
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/misc/tests/CookieTests.java
@@ -0,0 +1,160 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.misc.tests;
+
+import com.jcorporate.expresso.core.misc.CookieUtil;
+import com.jcorporate.expresso.core.security.CryptoManager;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+import com.jcorporate.expresso.services.test.TestSystemInitializer;
+
+
+/**
+ * Tests cookie encryption
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ $Date: 2004/11/12 16:17:23 $
+ */
+public class CookieTests
+ extends ExpressoTestCase {
+ boolean usingStrongCrypto;
+
+ public CookieTests(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ TestSystemInitializer.setUp();
+ //Set the system properties we need
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public static junit.framework.Test suite()
+ throws Exception {
+ return new TestSuite(CookieTests.class);
+ }
+
+ /**
+ * Make sure we put back the CryptoManager into the condition we found it.
+ * @throws Exception upon error
+ */
+ public void setUp()
+ throws Exception {
+ usingStrongCrypto = CryptoManager.getInstance().isUsingStrongCrypto();
+ }
+
+ public void tearDown()
+ throws Exception {
+ CryptoManager.getInstance().loadClasses(usingStrongCrypto);
+ }
+
+ /**
+ * Test given the various crypto manager classes being loaded
+ * @todo: We need to validate that there are no illegal URL characters
+ * in the encoded cookies
+ * @throws Exception upon error
+ */
+ public void testCookieEncryption()
+ throws Exception {
+ CryptoManager cm = CryptoManager.getInstance();
+
+ //Test Strong Encryption
+ cm.loadClasses(true);
+
+ //Quirk - Make the Empty String the last case no matter how many
+ //others you add into test array
+ String[] testArray = {
+ "abcdefghijklmnopqrstuvwxyz",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+", "abc", "rimo\n",
+ "rimo\b\r\0", "rimovm01", "9123123456789", "^\"\\...//?.<>", ""
+ };
+ int i;
+
+ for (i = 0; i < testArray.length; i++) {
+ String encode = CookieUtil.cookieEncode(testArray[i]);
+ String decode = CookieUtil.cookieDecode(encode);
+
+ if (i < testArray.length - 1) {
+ assertTrue("Greater Than Zero Length Return " + testArray[i],
+ encode.length() > 0);
+ }
+
+ assertTrue("testEncryptionMode: testArray[i]",
+ decode.equals(testArray[i]));
+ }
+
+ // Test With Weak Encryption Installed
+ cm.loadClasses(false);
+
+ for (i = 0; i < testArray.length; i++) {
+ String encode = CookieUtil.cookieEncode(testArray[i]);
+ String decode = CookieUtil.cookieDecode(encode);
+ assertTrue("testEncryptionMode: testArray[i]",
+ decode.equals(testArray[i]));
+ }
+ }
+}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/logging/tests/LogManagerTests.java
@@ -0,0 +1,113 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.logging.tests;
+
+import org.apache.log4j.Logger;
+
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+
+
+/**
+ * Unit test case for LogManager
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ on $Date: 2004/11/12 16:17:23 $
+ * @since Expresso 5.0
+ */
+public class LogManagerTests
+ extends ExpressoTestCase {
+
+ /**
+ * Basic constructor - initializes the underlying Expresso configuration
+ * system.
+ * @param name The Test Name
+ */
+ public LogManagerTests(String name)
+ throws Exception {
+ super(name);
+ }
+
+ /**
+ * Tests the logging system for potential Exceptions.
+ * @todo Automate this so we can verify that logging is automatically
+ * working
+ * @throws Exception if an error occurs while testing logging.
+ */
+ public void testLogging()
+ throws Exception {
+
+ Logger c = Logger.getLogger("com.jcorporate.expresso");
+ c.info("Testing a Log to root output");
+ c.error("This one though should actually print");
+ c = Logger.getLogger("com.jcorporate.expresso.core");
+ c.error("This is a test error message");
+ c.info("This is a test info message");
+ c.warn("This is a test warning");
+ c = Logger.getLogger("com.jcorporate.expresso.services");
+ c.error("This is a test error message");
+ c.info("This is a test info message");
+ c.warn("This is a test warning");
+
+ }
+}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/digester/test/TestComponentMetadataConfig.java
@@ -0,0 +1,138 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+package com.jcorporate.expresso.kernel.digester.test;
+
+import com.jcorporate.expresso.kernel.digester.ComponentMetadataConfig;
+import com.jcorporate.expresso.kernel.metadata.ComponentMetadata;
+import com.jcorporate.expresso.kernel.metadata.ControllerData;
+import com.jcorporate.expresso.kernel.metadata.DBObjectData;
+import com.jcorporate.expresso.kernel.metadata.JobData;
+import com.jcorporate.expresso.kernel.metadata.ReportData;
+import com.jcorporate.expresso.kernel.metadata.SchemaData;
+import junit.framework.TestCase;
+
+import java.util.List;
+
+/** JUnitTest case for class: com.jcorporate.expresso.kernel.digester.ComponentMetadataConfig */
+public class TestComponentMetadataConfig extends TestCase {
+
+ public TestComponentMetadataConfig(String _name) {
+ super(_name);
+ }
+
+ /** test for method loadComponentMetadata(..) */
+ public void testLoadComponentMetadata() {
+ ComponentMetadataConfig esc;
+ try {
+ esc = new ComponentMetadataConfig();
+ esc.loadComponentMetadata("/com/jcorporate/expresso/kernel/digester/test/SampleConfig.xml");
+ } catch (Exception ex) {
+ fail("Error attempting to digest services file");
+ return;
+ }
+
+ ComponentMetadata metadata = esc.getMetadata();
+ assertTrue("Must have metadata", metadata != null);
+ assertTrue("Must have a valid name", metadata.getName().equals("test"));
+ assertTrue("Must have a valid version", metadata.getVersionNumber().equals("1.2.3"));
+ assertTrue("Must have a valid description", metadata.getDescription().equals("Test Component"));
+ assertTrue("Must have valid message bundle path",
+ metadata.getMessageBundle()
+ .equals("/com/jcorporate/expresso/core/Messages.properties"));
+ SchemaData sd = metadata.getSchemaData();
+ assertTrue("Must have a Schema metadata", sd != null);
+ List list = sd.getControllers();
+ assertTrue("Must have controllers", list != null && list.size() == 1);
+ assertTrue("First controller is DBMaint", ((ControllerData) list.get(0))
+ .getClassName().equals(
+ "com.jcorporate.expresso.services.controller.DBMaint"));
+ list = sd.getDataObjects();
+ assertTrue("Must have data objects",list != null && list.size() == 1);
+ assertTrue("First data object is MimeTypes", ((DBObjectData) list.get(0))
+ .getClassName().equals("com.jcorporate.expresso.services.dbobj.MimeTypes"));
+ list = sd.getJobs();
+ assertTrue("Must have jobs", list != null && list.size() == 1);
+ assertTrue("First job is test jobs",((JobData) list.get(0)).
+ getClassName().equals("com.jcorporate.expresso.services.job.TestJob"));
+ list = sd.getReports();
+ assertTrue("Must have reports",list != null && list.size() == 1);
+ assertTrue("First report is test report", ((ReportData) list.get(0)).
+ getClassName().equals("com.jcorporate.expresso.ext.report.TestReport"));
+
+ List nested = metadata.getChildren();
+ assertTrue("Must have child components",nested != null && nested.size() == 1);
+ ComponentMetadata oneNested = (ComponentMetadata) nested.get(0);
+ assertTrue("Checking nested component description", oneNested.getDescription().equals("Sample Nested Do Nothing Component"));
+ assertTrue("Checking nested component name", oneNested.getName().equals("nested1"));
+ assertTrue("Checking nested component version number",oneNested.getVersionNumber().equals("4.5.6"));
+ }
+
+ /** Executes the test case
+ * @param argv the command line arguments
+ */
+ public static void main(String[] argv) {
+ String[] testCaseList = {TestComponentMetadataConfig.class.getName()};
+ junit.textui.TestRunner.main(testCaseList);
+ }
+}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/digester/test/TestExpressoServicesConfig.java
@@ -0,0 +1,122 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+package com.jcorporate.expresso.kernel.digester.test;
+
+import com.jcorporate.expresso.kernel.digester.ComponentConfig;
+import com.jcorporate.expresso.kernel.digester.ExpressoServicesConfig;
+import junit.framework.TestCase;
+
+/** JUnitTest case for class: com.jcorporate.expresso.kernel.digester.ExpressoServicesConfig */
+public class TestExpressoServicesConfig extends TestCase {
+
+ public TestExpressoServicesConfig(String _name) {
+ super(_name);
+ }
+
+ /** setUp method for test case */
+ protected void setUp() {
+ }
+
+ /** tearDown method for test case */
+ protected void tearDown() {
+ }
+
+ /** test for method loadExpressoServices(..) */
+ public void testLoadExpressoServices() {
+ try {
+ ExpressoServicesConfig esc = new ExpressoServicesConfig();
+ esc.setExpressoServicesFile(com.jcorporate.expresso.kernel.test
+ .TestComponentSystem.class.getResource("Test1ExpressoServices.xml"));
+ esc.loadExpressoServices();
+ } catch (Exception ex) {
+ fail("Error attempting to digest services file");
+ }
+ }
+
+ /** test for method setExpressoServicesFile(..) */
+ public void testExpressoServicesFileContents() {
+ try {
+ ExpressoServicesConfig esc = new ExpressoServicesConfig();
+ esc.setExpressoServicesFile(com.jcorporate.expresso.kernel.test.TestComponentSystem.class.getResource("Test1ExpressoServices.xml"));
+ esc.loadExpressoServices();
+ ComponentConfig root = esc.getRootConfig();
+ assertTrue(root != null);
+ assertTrue("Must have some child components got null instead", root.getChildComponents() != null);
+ assertTrue("Should have one child component. Got " + root.getChildComponents().size() + " instead.",
+ root.getChildComponents().size() == 1);
+ assertTrue("Should have four properties. Got " + ((ComponentConfig) root.getChildComponents().get(0)).getProperties().size() + " instead"
+ , ((ComponentConfig) root.getChildComponents().get(0)).getProperties().size() == 4);
+ } catch (Exception ex) {
+ fail("Error attempting to digest services file");
+ }
+ }
+
+ /** Executes the test case
+ * @param argv The command line arguments
+ * */
+ public static void main(String[] argv) {
+ String[] testCaseList = {TestExpressoServicesConfig.class.getName()};
+ junit.textui.TestRunner.main(testCaseList);
+ }
+}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/digester/test/SampleConfig.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<component-metadata name="test">
+ <description>Test Component</description>
+ <version-info>
+ <major-version>1</major-version>
+ <minor-version>2</minor-version>
+ <micro-version>3</micro-version>
+ </version-info>
+ <message-bundle>/com/jcorporate/expresso/core/Messages.properties</message-bundle>
+ <property-list>
+ <!-- value= default value. -->
+ <property name="testProperty" value="true" type="java.lang.Boolean" description="A simple property" access="readwrite"/>
+ <property name="testDropdown" value="ab" type="java.lang.String" description="A dropdown property" access="readwrite">
+ <property-valid-value name="a" value="A value"/>
+ <property-valid-value name="ab" value="AB value"/>
+ <property-valid-value name="abc" value="ABC value"/>
+ <property-valid-value name="abcd" value="ABCD value"/>
+ <property-valid-value name="abcde" value="ABCDE value"/>
+ </property>
+<!-- Not supported yet
+ <array-property name="" type="" description="" access="">
+ <array-property-value value=""/>
+ </array-property>
+ <mapped-property name="" description="" access="">
+ <mapped-value key="" type="" value=""/>
+ </mapped-property>
+-->
+ </property-list>
+ <method-list>
+ <method name="getDataObjects" return-type="java.util.List" description="Retrieve all embedded DBObjects">
+ <method-arg name="list" type="java.lang.Integer"/>
+ </method>
+ </method-list>
+ <schema>
+ <struts-config location=""/>
+ <dbobject>
+ <classname name="com.jcorporate.expresso.services.dbobj.MimeTypes"/>
+ </dbobject>
+ <controller>
+ <classname name="com.jcorporate.expresso.services.controller.DBMaint"/>
+ </controller>
+ <job>
+ <classname name="com.jcorporate.expresso.services.job.TestJob"/>
+ </job>
+ <report>
+ <classname name="com.jcorporate.expresso.ext.report.TestReport"/>
+ </report>
+ </schema>
+ <embedded-components>
+ <component-metadata name="nested1">
+ <description>Sample Nested Do Nothing Component</description>
+ <version-info>
+ <major-version>4</major-version>
+ <minor-version>5</minor-version>
+ <micro-version>6</micro-version>
+ </version-info>
+ </component-metadata>
+ </embedded-components>
+</component-metadata>
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/ext/tests/DBObjStressTest.java
@@ -0,0 +1,208 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.ext.tests;
+
+import com.jcorporate.expresso.core.db.DBException;
+import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
+import com.jcorporate.expresso.core.misc.ConfigManager;
+import com.jcorporate.expresso.core.misc.ConfigurationException;
+import com.jcorporate.expresso.kernel.ConsoleInstallLog;
+import com.jcorporate.expresso.kernel.InstallLog;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import com.jcorporate.expresso.services.test.SchemaCreator;
+import com.jcorporate.expresso.services.test.TestSystemInitializer;
+import junit.framework.TestSuite;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+
+/**
+ * Stress Test for 5019 DBObjects
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ $Date: 2004/11/12 16:17:23 $
+ */
+public class DBObjStressTest
+ extends ExpressoTestCase {
+ static final int NUM_THREADS = 1;
+ static final int NUM_ITERATIONS = 10;
+ private long startTime = 0;
+ private ArrayList threadList = new ArrayList(NUM_THREADS);
+
+ public DBObjStressTest(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Define the suite of tests that verify each function of the cache
+ *
+ * @return
+ */
+ public static junit.framework.Test suite() {
+ TestSuite suite = new TestSuite(DBObjStressTest.class);
+
+ return suite;
+ } /* suite() */
+
+
+ public void testStressDBObjects() {
+ System.out.println("Starting testStressDBObjects()");
+
+ for (int i = 0; i < NUM_THREADS; i++) {
+ StressThread st = new StressThread(NUM_ITERATIONS,
+ SecuredDBObject.SYSTEM_ACCOUNT);
+ threadList.add(st);
+ st.start();
+ }
+
+ boolean successfullOperation = true;
+
+ for (Iterator i = threadList.iterator(); i.hasNext();) {
+ System.out.println("Waiting for thread");
+
+ StressThread st = (StressThread) i.next();
+
+ try {
+ if (st.isAlive()) {
+ st.join();
+ }
+ } catch (InterruptedException ie) {
+ }
+
+ assertTrue("Thread is dead", !st.isAlive());
+ successfullOperation &= st.getSuccess();
+ }
+
+ assertTrue("All Threads Successfull", successfullOperation == true);
+
+ try {
+ StressTestObject sto = new StressTestObject(SecuredDBObject.SYSTEM_ACCOUNT);
+ sto.setDataContext(TestSystemInitializer.getTestContext());
+ assertTrue("Check all records deleted", sto.count() == 0);
+ } catch (DBException dbe) {
+ dbe.printStackTrace();
+ fail("Caught DBException trying to count records. " +
+ dbe.getMessage());
+ }
+ }
+
+ /**
+ * Sets up the fixture, for example, open a network connection.
+ * This method is called before a test is executed.
+ *
+ * @throws Exception
+ */
+ protected void setUp()
+ throws Exception {
+ TestSystemInitializer.setUp();
+ try {
+ ConfigManager.getContext(TestSystemInitializer.getTestContext());
+ } catch (ConfigurationException ce) {
+ fail("There is no 'test' db/context set up - cannot run db object tests without a test context");
+ }
+
+ InstallLog installLog = new ConsoleInstallLog();
+
+ StressTestSchema ts = new StressTestSchema();
+ SchemaCreator.ensureSchemaExists(new com.jcorporate.expresso.core.ExpressoSchema(), installLog);
+ SchemaCreator.ensureSchemaExists(ts, installLog);
+ startTime = new java.util.Date().getTime();
+ } /* setUp() */
+
+
+ /**
+ * Tears down the fixture, for example, close a network connection.
+ * This method is called after a test is executed.
+ *
+ * @throws Exception
+ */
+ protected void tearDown()
+ throws Exception {
+ long endTime = new java.util.Date().getTime();
+ System.out.println("Current Threading Tests Took: " +
+ Long.toString(endTime - startTime) + " ms.");
+
+ //This test should be run alone... destroy things when we're done.
+ ConfigManager.destroy();
+
+ // try {
+ // StressTestSchema ts = new StressTestSchema();
+ // SchemaDeleter.deleteSchema("test", ts);
+ // } catch (DBException de) {
+ // log.error(de);
+ // fail("Unable to clean up test object tables");
+ // }
+ } /* tearDown() */
+
+
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/ext/tests/RetrieveThroughputTest.java
@@ -0,0 +1,167 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.ext.tests;
+
+import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
+import com.jcorporate.expresso.core.misc.ConfigManager;
+import com.jcorporate.expresso.core.misc.ConfigurationException;
+import com.jcorporate.expresso.services.dbobj.DefaultUserInfo;
+import com.jcorporate.expresso.services.dbobj.MimeTypes;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import com.jcorporate.expresso.services.test.TestSystemInitializer;
+import junit.framework.TestSuite;
+
+/**
+ * <p>Title: </p>
+ * <p>Description: </p>
+ * <p>Copyright: </p>
+ * <p>Company: </p>
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ on $Date: 2004/11/12 16:17:23 $
+ */
+
+public class RetrieveThroughputTest extends ExpressoTestCase {
+ static final int NUM_ITERATIONS = 1000;
+ private long startTime = 0;
+
+
+ public RetrieveThroughputTest(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Define the suite of tests that verify each function of the cache
+ *
+ * @return
+ */
+ public static junit.framework.Test suite() {
+ TestSuite suite = new TestSuite(RetrieveThroughputTest.class);
+
+ return suite;
+ } /* suite() */
+
+ /**
+ * Sets up the fixture, for example, open a network connection.
+ * This method is called before a test is executed.
+ *
+ * @throws Exception
+ */
+ protected void setUp()
+ throws Exception {
+ TestSystemInitializer.setUp();
+ try {
+ ConfigManager.getContext(TestSystemInitializer.getTestContext());
+ } catch (ConfigurationException ce) {
+ fail("There is no 'test' db/context set up - cannot run db object tests without a test context");
+ }
+
+// StressTestSchema ts = new StressTestSchema();
+// SchemaCreator.ensureSchemaExists(new com.jcorporate.expresso.core.ExpressoSchema());
+// SchemaCreator.ensureSchemaExists(ts);
+ startTime = new java.util.Date().getTime();
+ } /* setUp() */
+
+ public void testRetrieve() {
+ try {
+ MimeTypes mt = new MimeTypes(SecuredDBObject.SYSTEM_ACCOUNT);
+ mt.setDataContext(TestSystemInitializer.getTestContext());
+ mt.setField(MimeTypes.FLD_MIMENUMBER,1);
+ mt.retrieve();
+ startTime = System.currentTimeMillis();
+ for (int i=0; i < NUM_ITERATIONS; i++) {
+ mt.retrieve();
+ }
+ long endTime = System.currentTimeMillis();
+ System.out.println("Throughput for retrieving MimeTypes was: " + (endTime - startTime) / NUM_ITERATIONS + " ms per retrieval");
+
+
+
+ DefaultUserInfo dui = new DefaultUserInfo(SecuredDBObject.SYSTEM_ACCOUNT);
+ dui.setDataContext(TestSystemInitializer.getTestContext());
+ dui.setField(DefaultUserInfo.EXPUID,3);
+ dui.retrieve();
+ startTime = System.currentTimeMillis();
+ for (int i=0; i < NUM_ITERATIONS; i++) {
+ dui.retrieve();
+ }
+ endTime = System.currentTimeMillis();
+ System.out.println("Throughput for retrieving DefaultUserInfo was: " + (endTime - startTime) / NUM_ITERATIONS + " ms per retrieval");
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("Exception caught while testing");
+ }
+
+ }
+
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/ext/tests/StressThread.java
@@ -0,0 +1,202 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.ext.tests;
+
+import com.jcorporate.expresso.core.db.DBException;
+import com.jcorporate.expresso.services.test.TestSystemInitializer;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import com.jcorporate.expresso.core.registry.ExpressoThread;
+
+
+/**
+ * Thread that stresses DBObjects.
+ * <p>
+ * Assumption - to simulate real life stuff, we're gonna
+ * assume that reads to updates have a ratio of 4 to 1
+ * </p>
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ $Date: 2004/11/12 16:17:23 $
+ */
+public class StressThread
+ extends ExpressoThread {
+ static final int NUM_RECORDS = 60;
+ ArrayList myIds = new ArrayList(NUM_RECORDS);
+ int numLoops;
+ int userUid;
+ boolean success = true;
+ int maxID = 0;
+
+ public StressThread(int loops, int uid) {
+ numLoops = loops;
+ userUid = uid;
+ }
+
+ public boolean getSuccess() {
+ return success;
+ }
+
+ public void run() {
+ super.run();
+ try {
+ for (int i = 0; i < numLoops; i++) {
+ addTestObjects();
+ System.gc();
+ retrieveTestObjects();
+ System.gc();
+ updateTestObjects();
+ System.gc();
+ searchAndRetrieveTestObjects();
+ System.gc();
+ deleteTestObjects();
+ }
+ } catch (DBException dbe) {
+ success = false;
+ System.out.println(dbe.getMessage());
+ dbe.printStackTrace();
+ }
+ }
+
+ protected void addTestObjects()
+ throws DBException {
+ StressTestObject sto = new StressTestObject(userUid);
+ sto.setDataContext(TestSystemInitializer.getTestContext());
+ sto.setField("SomeData", "abcdefg");
+ sto.setField("SomeMoreData", "hijklmnop");
+
+ for (int i = 0; i < NUM_RECORDS; i++) {
+ sto.add();
+ myIds.add(sto.getField("RecordID"));
+ }
+
+ maxID = Integer.parseInt(sto.getField("RecordID"));
+ }
+
+ /**
+ * Performs a repeated retrieve and update for each object
+ */
+ protected void updateTestObjects()
+ throws DBException {
+ StressTestObject sto = new StressTestObject(userUid);
+ sto.setDataContext(TestSystemInitializer.getTestContext());
+
+ for (Iterator i = myIds.iterator(); i.hasNext();) {
+ sto.setField("RecordID", (String) i.next());
+ sto.retrieve();
+ sto.setField("SomeData", "oser");
+ sto.setField("SomeMoreData", "good morning vietnam");
+ sto.update();
+ }
+ }
+
+ /**
+ * Does a batch of searchAndRetrieve Lists grabbing only the first 50 records.
+ */
+ protected void searchAndRetrieveTestObjects()
+ throws DBException {
+ StressTestObject sto = new StressTestObject(userUid);
+ sto.setDataContext(TestSystemInitializer.getTestContext());
+ sto.setMaxRecords(25);
+
+ for (int i = 0; i < 20; i++) {
+ ArrayList al = sto.searchAndRetrieveList();
+
+ if (al.size() == 0) {
+ throw new DBException("ArrayList was empty");
+ }
+ }
+ }
+
+ protected void retrieveTestObjects()
+ throws DBException {
+ StressTestObject sto = new StressTestObject(userUid);
+ sto.setDataContext(TestSystemInitializer.getTestContext());
+
+ for (int j = 0; j < 5; j++) {
+ for (Iterator i = myIds.iterator(); i.hasNext();) {
+ sto.clear();
+ sto.setField("RecordID", (String) i.next());
+ sto.retrieve();
+ }
+ }
+ }
+
+ protected void deleteTestObjects()
+ throws DBException {
+ StressTestObject sto = new StressTestObject(userUid);
+ sto.setDataContext(TestSystemInitializer.getTestContext());
+
+ for (Iterator i = myIds.iterator(); i.hasNext();) {
+ sto.setField("RecordID", (String) i.next());
+
+ if (sto.find()) {
+ sto.delete();
+ }
+ }
+
+ myIds = new ArrayList(NUM_RECORDS);
+ }
+}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/ext/tests/StressTestSchema.java
@@ -0,0 +1,102 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.ext.tests;
+
+import com.jcorporate.expresso.core.db.DBException;
+import com.jcorporate.expresso.core.dbobj.Schema;
+
+
+/**
+ * Schema for stress testing
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ $Date: 2004/11/12 16:17:23 $
+ */
+public class StressTestSchema
+ extends Schema {
+ public StressTestSchema()
+ throws DBException {
+ super();
+
+ try {
+
+ /* Database objects */
+ addDBObject(com.jcorporate.expresso.ext.tests.StressTestObject.class);
+ } catch (Exception e) {
+ throw new DBException(e);
+ }
+ }
+
+ public String getDefaultDescription() {
+ return "Stress Test Schema";
+ }
+
+ public String getDefaultComponentCode() {
+ return "stressTest";
+ }
+
+ public String getMessageBundlePath() {
+ return "/";
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/ext/tests/StressTestObject.java
@@ -0,0 +1,158 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.ext.tests;
+
+import com.jcorporate.expresso.core.controller.ControllerRequest;
+import com.jcorporate.expresso.core.db.DBConnection;
+import com.jcorporate.expresso.core.db.DBException;
+import com.jcorporate.expresso.core.dbobj.DBObject;
+import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
+
+
+/**
+ * An actual Stess test DBObject
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ $Date: 2004/11/12 16:17:23 $
+ */
+public class StressTestObject
+ extends SecuredDBObject {
+
+ /**
+ * @see com.jcorporate.expresso.core.dbobj.SecuredDBObject#SecuredDBObject
+ *
+ * @throws DBException
+ */
+ public StressTestObject()
+ throws DBException {
+ super();
+ } /* UserDBObj() */
+
+ /**
+ * Constructor
+ * Creation date: (8/9/00 5:44:22 PM)
+ * @author
+ *
+ * @param dbConnection com.jcorporate.expresso.core.db.DBConnection
+ * @throws DBException
+ */
+ public StressTestObject(DBConnection dbConnection)
+ throws DBException {
+ super(dbConnection);
+ } /* UserDBObj(DBConnection) */
+
+ /**
+ *
+ */
+ public StressTestObject(int uid)
+ throws DBException {
+ super(uid);
+ }
+
+ /**
+ * For using DBObjects within Controllers. Initializes based upon the current
+ * user and the requested db. [Of course this can be modified later]
+ *
+ * @param request - The controller request handed to you by the framework.
+ */
+ public StressTestObject(ControllerRequest request)
+ throws DBException {
+ super(request);
+ }
+
+ public DBObject getThisDBObj()
+ throws com.jcorporate.expresso.core.db.DBException {
+ return (DBObject) new StressTestObject();
+ }
+
+ /**
+ * Overrides add() by autoincrementing the rewards ID, and also setting the
+ * dateJoinedField()
+ */
+ public synchronized void add()
+ throws com.jcorporate.expresso.core.db.DBException {
+ setField("UpdateCount", "0");
+ super.add();
+ }
+
+ public synchronized void update()
+ throws com.jcorporate.expresso.core.db.DBException {
+ int fieldCount = this.getFieldInt("UpdateCount");
+ fieldCount++;
+ this.setField("UpdateCount", Integer.toString(fieldCount));
+ super.update();
+ }
+
+ protected void setupFields()
+ throws com.jcorporate.expresso.core.db.DBException {
+ setTargetTable("EXPRESSOSTRESS");
+ setDescription("Expresso Stress Test Table");
+ setCharset("ISO-8859-1");
+ addField("RecordID", "auto-inc", 0, false, "Record ID Number");
+ addField("UpdateCount", "int", 0, false, "Update Count");
+ addField("SomeData", "varchar", 256, false, "Some Random Data");
+ addField("SomeMoreData", "varchar", 256, false, "Some More RandomData");
+ addKey("RecordID");
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/util/test/FastStringBufferTest.java
@@ -0,0 +1,220 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.kernel.util.test;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import com.jcorporate.expresso.kernel.util.FastStringBuffer;
+
+/**
+ * Unit Test for FastStringBuffer
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ on $Date: 2004/11/12 16:17:23 $
+ */
+
+public class FastStringBufferTest
+ extends TestCase {
+
+
+ public FastStringBufferTest(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ junit.textui.TestRunner.run(suite());
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ * @return instantiated TestSuite
+ */
+ public static junit.framework.Test suite() {
+ return new TestSuite(FastStringBufferTest.class);
+ }
+
+ /**
+ * Tests basic append and clear to make sure it's working.
+ */
+ public void testFastStringBuffer() {
+ final String testValue = "abcdefghijklmnop";
+ try {
+ FastStringBuffer testBuffer = new FastStringBuffer(256);
+ for (int j = 0; j < 100; j++) {
+ assertTrue("Fresh FastStringBuffer should have zero length", testBuffer.length() == 0);
+ assertTrue("Fresh FastStringBuffer should have empty string", "".equals(testBuffer.toString()));
+
+ testBuffer.append(testValue);
+ assertTrue("Must have proper value in test buffer.", testValue.equals(testBuffer.toString()));
+ testBuffer.clear();
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Error performaing testFastStringBufferPool(): " + ex.getMessage());
+ }
+
+
+ }
+
+
+ /**
+ * Similar to above test, but we get the FastStringBuffer from the FastStringBuffer
+ * pool instead
+ */
+ public void testFastStringBufferPool() {
+ final String testValue = "abcdefghijklmnop";
+
+ try {
+ for (int j = 0; j < 100; j++) {
+ FastStringBuffer testBuffer = FastStringBuffer.getInstance();
+ try {
+ assertTrue("Must receive non-null testBuffer from Pool", testBuffer != null);
+ assertTrue("Buffer from pool must have 1k capacity", testBuffer.capacity() == 1024);
+ assertTrue("Fresh value from the pool should have zero length", testBuffer.length() == 0);
+ assertTrue("Fresh value from the pool should have empty string", "".equals(testBuffer.toString()));
+
+ testBuffer.append(testValue);
+ String resultValue = testBuffer.toString();
+ assertTrue("Must have proper value in test buffer. Got '" + resultValue + "' instead", testValue.equals(resultValue));
+ } finally {
+ testBuffer.release();
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Error performaing testFastStringBufferPool(): " + ex.getMessage());
+ }
+ }
+
+ public void testFastStringBufferPoolWithOverlap() {
+ final String testValue = "abcdefghijklmnop";
+
+ try {
+ for (int j = 0; j < 100; j++) {
+ FastStringBuffer overlapBuffer = FastStringBuffer.getInstance();
+ FastStringBuffer testBuffer = FastStringBuffer.getInstance();
+ try {
+ assertTrue("Must receive non-null testBuffer from Pool", testBuffer != null);
+ overLapFastStringBuffer();
+ assertTrue("Buffer from pool must have 1k capacity", testBuffer.capacity() == 1024);
+ overLapFastStringBuffer();
+ assertTrue("Fresh value from the pool should have zero length", testBuffer.length() == 0);
+ overLapFastStringBuffer();
+ assertTrue("Fresh value from the pool should have empty string", "".equals(testBuffer.toString()));
+ overLapFastStringBuffer();
+
+ testBuffer.append(testValue);
+ String resultValue = testBuffer.toString();
+ assertTrue("Must have proper value in test buffer. Got '" + resultValue + "' instead", testValue.equals(resultValue));
+ overLapFastStringBuffer();
+ } finally {
+ overlapBuffer.release();
+ testBuffer.release();
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Error performaing testFastStringBufferPool(): " + ex.getMessage());
+ }
+ }
+
+ private void overLapFastStringBuffer() {
+ FastStringBuffer fsb = FastStringBuffer.getInstance();
+ fsb.append("WHERE MIMETYPES = 2");
+ fsb.append("AND WHOKNOW'S WHAT = 4");
+ fsb.toString();
+ fsb.release();
+ }
+
+
+ public void testFastStringBufferPoolWithOverflow() {
+// final String testValue ="abcdefghijklmnop";
+
+ try {
+ for (int j = 0; j < 100; j++) {
+ FastStringBuffer testBuffer = FastStringBuffer.getInstance();
+ try {
+ assertTrue("Must receive non-null testBuffer from Pool", testBuffer != null);
+ assertTrue("Buffer from pool must have 1k capacity j=" + j + " got " + testBuffer.capacity() + " instead.", testBuffer.capacity() == 1024);
+ assertTrue("Fresh value from the pool should have zero length", testBuffer.length() == 0);
+ assertTrue("Fresh value from the pool should have empty string", "".equals(testBuffer.toString()));
+ for (int i = 0; i < 2048; i++) {
+ testBuffer.append("a");
+ }
+ assertTrue("Must have proper length in test buffer got " + testBuffer.length() + " instead", testBuffer.length() == 2048);
+ } finally {
+ testBuffer.release();
+ }
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Error performaing testFastStringBufferPool(): " + ex.getMessage());
+ }
+
+ }
+}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/util/test/TestLocatorUtils.java
@@ -0,0 +1,302 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.kernel.util.test;
+
+import com.jcorporate.expresso.kernel.Containable;
+import com.jcorporate.expresso.kernel.ExpressoComponent;
+import com.jcorporate.expresso.kernel.RootContainerInterface;
+import com.jcorporate.expresso.kernel.SystemFactory;
+import com.jcorporate.expresso.kernel.digester.ComponentConfig;
+import com.jcorporate.expresso.kernel.exception.ConfigurationException;
+import com.jcorporate.expresso.kernel.metadata.ComponentMetadata;
+import com.jcorporate.expresso.kernel.util.LocatorUtils;
+import com.jcorporate.expresso.services.test.TestSystemInitializer;
+import junit.framework.TestCase;
+
+/** JUnitTest case for class: com.jcorporate.expresso.kernel.util.LocatorUtils */
+public class TestLocatorUtils extends TestCase {
+
+ public TestLocatorUtils(String _name) {
+ super(_name);
+ }
+
+ RootContainerInterface globalContainer = null;
+
+ /** setUp method for test case */
+ protected void setUp() {
+ try {
+ globalContainer = SystemFactory.buildExpressoComponentSystem(
+ this.getClass().getResource("/com/jcorporate/expresso/kernel/management/test/Test1ExpressoServices.xml"),
+ this.getClass().getResource("/com/jcorporate/expresso/kernel/management/test/TestLog4jConfig.xml"),
+ TestSystemInitializer.getLogDirectory());
+ } catch (ConfigurationException ex) {
+ ex.printStackTrace();
+ fail("Unable to set up test case: " + ex.getMessage());
+ }
+
+
+ }
+
+ /** tearDown method for test case */
+ protected void tearDown() {
+ globalContainer.destroy();
+ globalContainer = null;
+ System.gc();
+ System.runFinalization();
+ }
+
+ /** test for method locateComponent(..) */
+ public void testLocateComponent() {
+ try {
+ //
+ //Basic tests
+ //
+ LocatorUtils lu = new LocatorUtils((ExpressoComponent) globalContainer);
+ ExpressoComponent test = lu.locateComponent("");
+ assertTrue("Root component must not be null", test != null);
+ assertTrue("Test should be the same as the global container", test == globalContainer);
+
+ test = lu.locateComponent("default");
+ assertTrue("Test component must be named default", "default".equals(test.getMetaData().getName()));
+ assertTrue("Test component must be a component container", test instanceof Containable);
+
+ test = lu.locateComponent("default.TestComponent");
+ assertTrue("Test component must be named TestComponent",
+ "TestComponent".equals(test.getMetaData().getName()));
+
+ //
+ //Now test to make sure that LocatorUtils properly finds the root
+ //given being dumped anywhere on the tree.
+ //
+ lu = new LocatorUtils(test);
+
+ test = lu.locateComponent("");
+ assertTrue("Root component must not be null", test != null);
+ assertTrue("Test should be the same as the global container", test == globalContainer);
+
+ test = lu.locateComponent("default");
+ assertTrue("Test component must be named default", "default".equals(test.getMetaData().getName()));
+ assertTrue("Test component must be a component container", test instanceof Containable);
+
+ test = lu.locateComponent("default.TestComponent");
+ assertTrue("Test component must be named TestComponent",
+ "TestComponent".equals(test.getMetaData().getName()));
+
+ //
+ //Now test bad input
+ //
+ try {
+ test = lu.locateComponent("abcdkefjj");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateComponent("default..TestComponent");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateComponent(".default.TestComponent");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateComponent("default.ancdkiekel/");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Error locating components " + ex.getMessage());
+ }
+
+ }
+
+ /** test for method locateConfiguration(..) */
+ public void testLocateConfiguration() {
+ LocatorUtils lu = new LocatorUtils((ExpressoComponent) globalContainer);
+ ComponentConfig test = lu.locateConfiguration("");
+ assertTrue("Root component must not be null", test != null);
+
+ test = lu.locateConfiguration("default");
+ assertTrue("Test component must be named default", "default".equals(test.getName()));
+
+ test = lu.locateConfiguration("default.TestComponent");
+ assertTrue("Test component must be named TestComponent",
+ "TestComponent".equals(test.getName()));
+
+ //
+ //Now test bad input
+ //
+ try {
+ test = lu.locateConfiguration("abcdkefjj");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateConfiguration("default..TestComponent");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateConfiguration(".default.TestComponent");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateConfiguration("default.ancdkiekel/");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ }
+
+ /** test for method locateMetadata(..) */
+ public void testLocateMetadata() {
+ LocatorUtils lu = new LocatorUtils((ExpressoComponent) globalContainer);
+ ComponentMetadata test = lu.locateMetadata("");
+ assertTrue("Root component must not be null", test != null);
+
+ test = lu.locateMetadata("default");
+ assertTrue("Test component must be named default", "default".equals(test.getName()));
+
+ test = lu.locateMetadata("default.TestComponent");
+ assertTrue("Test component must be named TestComponent",
+ "TestComponent".equals(test.getName()));
+
+ //
+ //Now test bad input
+ //
+ try {
+ test = lu.locateMetadata("abcdkefjj");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateMetadata("default..TestComponent");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateMetadata(".default.TestComponent");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+ try {
+ test = lu.locateMetadata("default.ancdkiekel/");
+ fail("Should have thrown an exception upon bad input");
+ } catch (IllegalArgumentException ex) {
+
+ }
+
+
+ }
+
+ /**
+ * Test to make sure components on the tree are getting correct paths
+ * back.
+ */
+ public void testCreatePath() {
+ LocatorUtils lu = new LocatorUtils((ExpressoComponent) globalContainer);
+ ExpressoComponent test = lu.locateComponent("");
+ assertTrue("Root component must not be null", test != null);
+ assertTrue("".equals(lu.getPath(test)));
+
+ test = lu.locateComponent("default");
+ assertTrue("default component must not be null", test != null);
+ assertTrue("default".equals(lu.getPath(test)));
+
+ test = lu.locateComponent("default.TestComponent");
+ assertTrue("default.TestComponent must not be null", test != null);
+ assertTrue("default.TestComponent".equals(lu.getPath(test)));
+
+ }
+
+ /** Executes the test case */
+ public static void main(String[] argv) {
+ String[] testCaseList = {TestLocatorUtils.class.getName()};
+ junit.textui.TestRunner.main(testCaseList);
+ }
+}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/tests/OutputTests.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.controller.tests;
-
-import com.jcorporate.expresso.core.controller.Output;
-import com.jcorporate.expresso.core.misc.StringDOMParser;
-import com.jcorporate.expresso.kernel.util.FastStringBuffer;
-import com.jcorporate.expresso.services.test.CommandLineParser;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-import org.w3c.dom.Document;
-
-
-/**
- * Unit test case for testing com.jcorporate.expresso.core.controller.Output
- * objects.
- * @author Michael Rimov
- * @version $Revision: 1.9 $
- */
-public class OutputTests
- extends ExpressoTestCase {
- Output o = null;
- StringDOMParser parser = null;
- static final String outputName = "Test Output";
- static final String outputContent = "This is a test output description";
- static final String escapedOutputContent = "This & That \" And \" something else too;";
- static final int outputDisplayLength = 30;
-
- public OutputTests(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- CommandLineParser.parseCommandLine(args);
- junit.textui.TestRunner.run(suite());
- }
-
- public void setUp()
- throws Exception {
- o = new Output(outputName, outputContent);
- o.setDisplayLength(outputDisplayLength);
- o.setAlignment("left");
- parser = new StringDOMParser();
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(OutputTests.class);
- }
-
- /**
- * Helper function to set up the parser and parse the XML returned
- * from the Output
- */
- private Document getXMLDoc()
- throws Exception {
- FastStringBuffer fsb = new FastStringBuffer(128);
- String result = o.toXML(fsb).toString();
- System.out.println("\nOutput Before Serialization:");
- System.out.println(result);
-
- Document d = parser.parseString(result);
-
- if (d == null) {
- fail("Output returned mal-formed XML document");
- }
-
- return d;
- }
-
- /**
- * Helper to rebuild the Output from XML
- */
- private Output getOutput(Document d)
- throws Exception {
- Output anotherOutput = (Output) Output.fromXML(d);
- FastStringBuffer fsb = new FastStringBuffer(128);
- System.out.println("\nOutput After De-Serialization:");
- System.out.println(anotherOutput.toXML(fsb).toString());
-
- return anotherOutput;
- }
-
- /**
- * Test basic Output->XML->Output Serialization
- */
- public void testXML()
- throws Exception {
- Document d = getXMLDoc();
- Output newOutput = getOutput(d);
- assertTrue("getOutput returned null", newOutput != null);
- assertTrue("Proper Display Length", newOutput.getDisplayLength() == 30);
- assertTrue("Proper Name", newOutput.getName().equals(outputName));
- assertTrue("Proper Content",
- newOutput.getContent().equals(outputContent));
- }
-
- /**
- * Test Output->Xml->Output with special characters in the content.
- */
- public void testXmlWithSpecialCharacters()
- throws Exception {
- o.setContent(escapedOutputContent);
-
- Document d = getXMLDoc();
- Output newOutput = getOutput(d);
- assertTrue("getOutput returned null", newOutput != null);
- assertTrue("Proper Display Length", newOutput.getDisplayLength() == 30);
- assertTrue("Proper Name", newOutput.getName().equals(outputName));
- assertTrue("Proper Content",
- newOutput.getContent().equals(escapedOutputContent));
- }
-
- /**
- * Same as testXML, but test with nested Outputs
- */
- public void testXMLWithNestedOutput()
- throws Exception {
- Output nested = new Output("nested1", "label1");
- o.addNested(nested);
- nested = new Output("nested2", "label2");
- o.addNested(nested);
-
- Document d = getXMLDoc();
- Output newOutput = getOutput(d);
- assertTrue("getOutput returned null", newOutput != null);
- assertTrue("Proper Display Length", newOutput.getDisplayLength() == 30);
- assertTrue("Proper Name", newOutput.getName().equals(outputName));
- assertTrue("Proper Content",
- newOutput.getContent().equals(outputContent));
- nested = (Output) newOutput.getNested("nested1");
- assertTrue("Got nested 1", nested != null);
- assertTrue("Proper Nested 1 Content",
- nested.getContent().equals("label1"));
- nested = (Output) newOutput.getNested("nested2");
- assertTrue("Got nested 2", nested != null);
- assertTrue("Proper Nested 2 Content",
- nested.getContent().equals("label2"));
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/tests/TransitionTests.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.controller.tests;
-
-import com.jcorporate.expresso.core.controller.Transition;
-import com.jcorporate.expresso.core.misc.StringDOMParser;
-import com.jcorporate.expresso.kernel.util.FastStringBuffer;
-import com.jcorporate.expresso.services.test.CommandLineParser;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-import org.w3c.dom.Document;
-
-
-/**
- * Unit test case for testing com.jcorporate.expresso.core.controller.Transition
- * objects.
- * @author Michael Rimov
- * @version $Revision: 1.9 $
- */
-public class TransitionTests
- extends ExpressoTestCase {
- Transition t = null;
- StringDOMParser parser = null;
- static final String transitionName = "Test Transition";
- static final String transitionLabel = "Click Here To Continue";
- static final String transitionController = "com.jcorporate.expresso.services.controller.DBMaint";
-
- public TransitionTests(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- CommandLineParser.parseCommandLine(args);
- junit.textui.TestRunner.run(suite());
- }
-
- public void setUp()
- throws Exception {
- t = new Transition(transitionName, transitionLabel,
- transitionController);
- t.addParam("a", "b");
- t.addParam("c", "d");
- parser = new StringDOMParser();
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(TransitionTests.class);
- }
-
- /**
- * Helper function to set up the parser and parse the XML returned
- * from the Transition
- */
- private Document getXMLDoc()
- throws Exception {
- FastStringBuffer fsb = new FastStringBuffer(128);
- String result = t.toXML(fsb).toString();
- System.out.println("\nTransition Before Serialization:");
- System.out.println(result);
-
- Document d = parser.parseString(result);
-
- if (d == null) {
- fail("Transition returned mal-formed XML document");
- }
-
- return d;
- }
-
- /**
- * Helper to rebuild the Transition from XML
- */
- private Transition getTransition(Document d)
- throws Exception {
- Transition anotherTransition = (Transition) Transition.fromXML(d);
- FastStringBuffer fsb = new FastStringBuffer(128);
- System.out.println("\nTransition After De-Serialization:");
- System.out.println(anotherTransition.toXML(fsb).toString());
-
- return anotherTransition;
- }
-
- /**
- * Test basic Transition->XML->Transition Serialization
- */
- public void testXML()
- throws Exception {
- Document d = getXMLDoc();
- Transition newTransition = getTransition(d);
- assertTrue("getTransition returned null", newTransition != null);
- assertTrue("Proper Name",
- newTransition.getName().equals(transitionName));
- assertTrue("Proper Controller",
- newTransition.getControllerObject().equals(
- transitionController));
- assertTrue("Proper Parameter a",
- newTransition.getParam("a").equals("b"));
- assertTrue("Proper Parameter c",
- newTransition.getParam("c").equals("d"));
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/tests/BlockTests.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.controller.tests;
-
-import com.jcorporate.expresso.core.controller.Block;
-import com.jcorporate.expresso.core.controller.Input;
-import com.jcorporate.expresso.core.controller.Output;
-import com.jcorporate.expresso.core.controller.Transition;
-import com.jcorporate.expresso.core.misc.StringDOMParser;
-import com.jcorporate.expresso.kernel.util.FastStringBuffer;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-import org.w3c.dom.Document;
-
-
-/**
- * Unit test for com.jcorporate.expresso.core.controller.Block objects.
- * @author Michael Rimov
- * @version $Revision: 1.9 $
- */
-public class BlockTests
- extends ExpressoTestCase {
- Block b = null;
- StringDOMParser parser = null;
- static final String BlockName = "TestBlock";
- static final String outputName = "Output1";
- static final String outputContent = "Sample Content";
- static final String inputName1 = "Input1";
- static final String inputLabel1 = "Enter Your Name";
- static final String inputName2 = "Input2";
- static final String inputLabel2 = "Enter Your Login Name";
- static final String transitionName = "Transition1";
- static final String transitionLabel = "Click Here To Continue";
- static final String transitionController = "com.jcorporate.expresso.services.controller.DBMaint";
- static final String block2Name = "Block 2";
-
- public BlockTests(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- }
-
- public void setUp()
- throws Exception {
- b = new Block(BlockName);
-
- Input i = new Input(inputName1, inputLabel1);
- b.add(i);
- i = new Input(inputName2, inputLabel2);
- b.add(i);
-
- Output o = new Output(outputName, outputContent);
- b.add(o);
-
- Transition t = new Transition(transitionName, transitionLabel,
- transitionController);
- b.add(t);
-
- Block b2 = new Block(block2Name);
- b.add(b2);
- parser = new StringDOMParser();
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(BlockTests.class);
- }
-
- /**
- * Helper function to set up the parser and parse the XML returned
- * from the Block
- */
- private Document getXMLDoc(Block block)
- throws Exception {
- FastStringBuffer fsb = new FastStringBuffer(128);
- String result = block.toXML(fsb).toString();
- System.out.println("\nBlock Before Serialization:");
- System.out.println(result);
-
- Document d = parser.parseString(result);
-
- if (d == null) {
- fail("Block returned mal-formed XML document");
- }
-
- return d;
- }
-
- /**
- * Helper to rebuild the Block from XML
- */
- private Block getBlock(Document d)
- throws Exception {
- try {
- Block anotherBlock = (Block) Block.fromXML(d);
- FastStringBuffer fsb = new FastStringBuffer(128);
- System.out.println("\nBlock After De-Serialization:");
- System.out.println(anotherBlock.toXML(fsb).toString());
-
- return anotherBlock;
- } catch (NullPointerException npe) {
- npe.printStackTrace();
- fail("Null Pointer Exception: " + npe);
-
- return null;
- }
- }
-
- /**
- * Tests a very simple block XML Serialization
- */
- public void testSimpleXML()
- throws Exception {
- Block simpleBlock = new Block(BlockName);
- Document d = getXMLDoc(simpleBlock);
- Block newBlock = getBlock(d);
- assertTrue("getBlock returned null", newBlock != null);
- assertTrue("Proper Name", newBlock.getName().equals(BlockName));
- }
-
- /**
- * Test basic Block->XML->Block Serialization
- */
- public void testXML()
- throws Exception {
- Document d = getXMLDoc(b);
- Block newBlock = getBlock(d);
- assertTrue("getBlock returned null", newBlock != null);
- assertTrue("Proper Name", newBlock.getName().equals(BlockName));
-
- try {
- Input i;
- Output o;
- Transition t;
- Block b2;
- i = (Input) newBlock.getContent(inputName1);
- assertTrue("i != null for " + inputName1, i != null);
- assertTrue("i.getLabel() == " + inputLabel1,
- i.getLabel().equals(inputLabel1));
- i = (Input) newBlock.getContent(inputName2);
- assertTrue("i != null for " + inputName2, i != null);
- assertTrue("i.getLabel() == " + inputLabel2,
- i.getLabel().equals(inputLabel2));
- o = (Output) newBlock.getContent(outputName);
- assertTrue("o != null for " + outputName, o != null);
- assertTrue("o.getContent() == " + outputContent,
- o.getContent().equals(outputContent));
- t = (Transition) newBlock.getContent(transitionName);
- assertTrue("t != null for " + transitionName, t != null);
- assertTrue("t.getControllerObject() == " + transitionController,
- t.getControllerObject().equals(transitionController));
- assertTrue("t.getLabel() == " + transitionLabel,
- t.getLabel().equals(transitionLabel));
- b2 = (Block) newBlock.getContent(block2Name);
- assertTrue("b2 != null for " + block2Name, b2 != null);
- } catch (ClassCastException cce) {
- cce.printStackTrace();
- fail("Class Cast Exception: " + cce.getMessage());
- }
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/tests/InputTests.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.controller.tests;
-
-import com.jcorporate.expresso.core.controller.Input;
-import com.jcorporate.expresso.core.dbobj.ValidValue;
-import com.jcorporate.expresso.core.misc.StringDOMParser;
-import com.jcorporate.expresso.kernel.util.FastStringBuffer;
-import com.jcorporate.expresso.services.test.CommandLineParser;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-import org.w3c.dom.Document;
-
-import java.util.Enumeration;
-import java.util.Vector;
-
-
-/**
- * Unit test case for testing com.jcorporate.expresso.core.controller.Input
- * objects.
- * @author Michael Rimov
- * @version $Revision: 1.10 $
- */
-public class InputTests
- extends ExpressoTestCase {
- Input i = null;
- StringDOMParser parser = null;
-
- public InputTests(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- CommandLineParser.parseCommandLine(args);
- junit.textui.TestRunner.run(suite());
- }
-
- public void setUp()
- throws Exception {
- i = new Input("Test Input", "This is a test Input");
- i.setLookup("com.jcorporate.expresso.services.dbobj.MimeTypes");
- i.setDescription("This is a test input description");
- i.setDisplayLength(30);
- i.setType("boolean");
- i.setAttribute("checkbox", "");
- parser = new StringDOMParser();
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(InputTests.class);
- }
-
- /**
- * Helper function to set up the parser and parse the XML returned
- * from the input
- */
- private Document getXMLDoc()
- throws Exception {
- FastStringBuffer fsb = new FastStringBuffer(128);
- String result = i.toXML(fsb).toString();
- System.out.println("\nInput Before Serialization:");
- System.out.println(result);
-
- Document d = parser.parseString(result);
-
- if (d == null) {
- fail("Input returned mal-formed XML document");
- }
-
- return d;
- }
-
- /**
- * Helper to rebuild the input from XML
- */
- private Input getInput(Document d)
- throws Exception {
- Input anotherI = (Input) Input.fromXML(d);
-
- // System.out.println("\nInput After De-Serialization:");
- // System.out.println(anotherI.toXML(fsb).toString());
- return anotherI;
- }
-
- /**
- * Test basic Input->XML->Input Serialization
- */
- public void testXML()
- throws Exception {
- Document d = getXMLDoc();
- Input newInput = getInput(d);
- assertTrue("getInput returned null", newInput != null);
- assertTrue("Proper Display Length", newInput.getDisplayLength() == 30);
- assertTrue("Proper Lookup",
- newInput.getLookup().equals("com.jcorporate.expresso.services.dbobj.MimeTypes"));
- assertTrue("Proper Name", newInput.getName().equals("Test Input"));
- assertTrue("Proper Description",
- newInput.getDescription().equals("This is a test input description"));
- assertTrue("Proper Label",
- newInput.getLabel().equals("This is a test Input"));
- assertTrue("Proper Type", newInput.getType().equals("boolean"));
- assertTrue("Checkbox Attribute Exists",
- newInput.getAttribute("checkbox") != null);
- }
-
- /**
- * Same as testXML, but test MultiValues too
- */
- public void testXMLMultiValues()
- throws Exception {
- i.addValidValue("one", "One Value");
- i.addValidValue("two", "Two Values");
- i.addValidValue("three", "Three Values");
- i.setType("C");
-
- Document d = getXMLDoc();
- Input newInput = getInput(d);
- assertTrue("getInput returned null", newInput != null);
- assertTrue("Proper Display Length", newInput.getDisplayLength() == 30);
- assertTrue("Proper Lookup",
- newInput.getLookup().equals("com.jcorporate.expresso.services.dbobj.MimeTypes"));
- assertTrue("Proper Name", newInput.getName().equals("Test Input"));
- assertTrue("Proper Description",
- newInput.getDescription().equals("This is a test input description"));
- assertTrue("Proper Label",
- newInput.getLabel().equals("This is a test Input"));
- assertTrue("Proper Type", newInput.getType().equals("C"));
- assertTrue("Checkbox Attribute Exists",
- newInput.getAttribute("checkbox") != null);
-
- //Now check valid values
- Vector v = newInput.getValidValues();
- assertTrue("Returned Vector of valid values",
- (v != null && !v.isEmpty()));
- assertTrue("Returned proper number of valid values", v.size() == 3);
-
- for (Enumeration e = v.elements(); e.hasMoreElements();) {
- ValidValue vv = (ValidValue) e.nextElement();
- assertTrue("Valid Value != null", vv != null);
-
- String value = vv.getValue();
- String description = vv.getDescription();
-
- if (value.equals("one")) {
- assertTrue("Proper Description for one",
- description.equals("One Value"));
- } else if (value.equals("two")) {
- assertTrue("Proper Description for two",
- description.equals("Two Values"));
- } else if (value.equals("three")) {
- assertTrue("Proper Description for three",
- description.equals("Three Values"));
- } else {
- fail("Got invalid valid value: " + value);
- }
- }
- }
-
- /**
- * Same as testXML, but test with nested inputs
- */
- public void testXMLWithNestedInput()
- throws Exception {
- Input nested = new Input("nested1", "label1");
- i.addNested(nested);
- nested = new Input("nested2", "label2");
- i.addNested(nested);
-
- Document d = getXMLDoc();
- Input newInput = getInput(d);
- assertTrue("getInput returned null", newInput != null);
- assertTrue("Proper Display Length", newInput.getDisplayLength() == 30);
- assertTrue("Proper Lookup",
- newInput.getLookup().equals("com.jcorporate.expresso.services.dbobj.MimeTypes"));
- assertTrue("Proper Name", newInput.getName().equals("Test Input"));
- assertTrue("Proper Description",
- newInput.getDescription().equals("This is a test input description"));
- assertTrue("Proper Label",
- newInput.getLabel().equals("This is a test Input"));
- assertTrue("Proper Type", newInput.getType().equals("boolean"));
- assertTrue("Checkbox Attribute Exists",
- newInput.getAttribute("checkbox") != null);
- nested = (Input) newInput.getNested("nested1");
- assertTrue("Got nested 1", nested != null);
- assertTrue("Proper Nested 1 Label", nested.getLabel().equals("label1"));
- nested = (Input) newInput.getNested("nested2");
- assertTrue("Got nested 2", nested != null);
- assertTrue("Proper Nested 2 Label", nested.getLabel().equals("label2"));
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/tests/ControllerResponseTests.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.controller.tests;
-
-import com.jcorporate.expresso.core.controller.Block;
-import com.jcorporate.expresso.core.controller.ControllerException;
-import com.jcorporate.expresso.core.controller.ControllerRequest;
-import com.jcorporate.expresso.core.controller.ControllerResponse;
-import com.jcorporate.expresso.core.controller.Input;
-import com.jcorporate.expresso.core.controller.Output;
-import com.jcorporate.expresso.core.controller.Transition;
-import com.jcorporate.expresso.core.controller.session.SimplePersistentSession;
-import com.jcorporate.expresso.core.misc.StringDOMParser;
-import com.jcorporate.expresso.services.test.CommandLineParser;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-import org.w3c.dom.Document;
-
-import java.io.IOException;
-
-
-/**
- * Unit test case for testing com.jcorporate.expresso.core.controller.ControllerResponse
- * objects.
- * @author Michael Rimov
- * @version $Revision: 1.10 $
- * @since Expresso 5.0
- */
-public class ControllerResponseTests
- extends ExpressoTestCase {
- ControllerResponse cr = null;
- StringDOMParser parser = null;
- static final String controllerName = "com.jcorporate.expresso.services.controller.DBMaint";
- static final String responseTitle = "Sample Response";
- static final String responseStyle = "xml??";
- static final String BlockName = "TestBlock";
- static final String outputName = "Output1";
- static final String outputContent = "Sample Content";
- static final String inputName1 = "Input1";
- static final String inputLabel1 = "Enter Your Name";
- static final String inputName2 = "Input2";
- static final String inputLabel2 = "Enter Your Login Name";
- static final String transitionName = "Transition1";
- static final String transitionLabel = "Click Here To Continue";
- static final String transitionController = "com.jcorporate.expresso.services.controller.DBMaint";
- static final String block2Name = "Block 2";
-
- public ControllerResponseTests(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- CommandLineParser.parseCommandLine(args);
- junit.textui.TestRunner.run(suite());
- }
-
- public void setUp()
- throws Exception {
-
-
- cr = new ControllerResponse();
- cr.setTitle(responseTitle);
- cr.setControllerClass(controllerName);
- cr.setStyle(responseStyle);
- SimplePersistentSession session = new SimplePersistentSession();
- ControllerRequest request = new ControllerRequest();
- request.setUid(3);
- request.setSession(session);
- cr.setRequest(request);
-
- Block b = new Block(BlockName);
- Input i = new Input(inputName1, inputLabel1);
- b.add(i);
- i = new Input(inputName2, inputLabel2);
- b.add(i);
-
- Output o = new Output(outputName, outputContent);
- b.add(o);
-
- Transition t = new Transition(transitionName, transitionLabel,
- transitionController);
- b.add(t);
- cr.addBlock(b);
-
- Block b2 = new Block(block2Name);
- cr.addBlock(b2);
-
- //
- //Yes, the data is already in the blocks, but this way we can
- //test the block retrieval and Input/Output/Transition Cache
- //
- cr.addInput(i);
- cr.addOutput(o);
- cr.addTransition(t);
- parser = new StringDOMParser();
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(ControllerResponseTests.class);
- }
-
- /**
- * Helper function to set up the parser and parse the XML returned
- * from the Output
- */
- private Document getXMLDoc()
- throws Exception {
- String result = cr.toXML();
-
- // System.out.println("\nController Response Before Serialization:");
- // System.out.println(result);
- Document d = parser.parseString(result);
-
- if (d == null) {
- fail("ControllerResponse returned mal-formed XML document");
- }
-
- return d;
- }
-
- /**
- * Helper to rebuild the Output from XML
- */
- private ControllerResponse getControllerResponse(Document d)
- throws Exception {
- ControllerResponse cr1 = ControllerResponse.fromXML(d);
- System.out.println("\nController Response After De-Serialization:");
- System.out.println(cr1.toXML());
-
- return cr1;
- }
-
- /**
- * Test basic ControllerReponse->XML->ControllerResponse Serialization
- * Note, that the serialization of the nested blocks is only determined
- * to make sure that the blocks exist in the Controller Element. The
- * well-formdness of the blocks/input/ouputs/transitions is left to their
- * respective test cases
- */
- public void testXML()
- throws Exception {
- try {
- Document d = getXMLDoc();
- ControllerResponse cr1 = getControllerResponse(d);
- assertTrue("cr1 returned null", cr1 != null);
- assertTrue("Block 1 Exists", cr1.getBlock(BlockName) != null);
- assertTrue("Block 2 Exists", cr1.getBlock(block2Name) != null);
- assertTrue("Proper Controller Name",
- cr1.getControllerClass().equals(controllerName));
- assertTrue("Proper Style", cr1.getStyle().equals(responseStyle));
- assertTrue("Proper Title", cr1.getTitle().equals(responseTitle));
- assertTrue("Input 2 Exists", cr1.getInput(inputName2) != null);
- assertTrue("Output 1 Exists", cr1.getOutput(outputName) != null);
- assertTrue("Transition 1 Exists",
- cr1.getTransition(transitionName) != null);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception: " + ex.getMessage());
- }
- }
-
- public void testSerialization() {
- try {
- ControllerResponse response = new ControllerResponse();
- ControllerRequest request = new ControllerRequest();
- response.setRequest(request);
- request.setDataContext("default");
- request.setSession(new com.jcorporate.expresso.core.controller.session.SimplePersistentSession());
- java.io.ByteArrayOutputStream bos = new java.io.
- ByteArrayOutputStream();
- java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(bos);
- oos.writeObject(response);
- oos.flush();
- oos.close();
- java.io.ByteArrayInputStream bis = new java.io.ByteArrayInputStream(bos.toByteArray());
- java.io.ObjectInputStream ois = new java.io.ObjectInputStream(bis);
- response = (ControllerResponse)ois.readObject();
-
-
- }
- catch (IOException ex) {
- ex.printStackTrace();
- fail("IO Exception testing serialization " + ex.getMessage());
- } catch (ClassNotFoundException ex) {
- ex.printStackTrace();
- fail("ClassNotFoundException testing serialization " + ex.getMessage());
-
- } catch (ControllerException ex) {
- ex.printStackTrace();
- fail("ClassNotFoundException testing serialization " + ex.getMessage());
- }
-
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/controller/tests/TestSecureIfSetController.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.controller.tests;
-
-import com.jcorporate.expresso.core.controller.SecureIfSetController;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-
-/** JUnitTest case for class: com.jcorporate.expresso.core.controller.SecureIfSetController */
-public class TestSecureIfSetController extends ExpressoTestCase {
-
- public TestSecureIfSetController(String _name) throws Exception {
- super(_name);
- }
-
- /** setUp method for test case */
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- /** tearDown method for test case */
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /** test for method isDBConnectionAvailable(..) */
- public void testIsDBConnectionAvailable() {
- SecureIfSetController sf = new TestSecureIfSetController.TestController();
- boolean result = sf.isDBConnectionAvailable("default");
- assertTrue("default connection should be available", result == true);
-
- result = sf.isDBConnectionAvailable("abitkghaigkhksksm,,,,s");
- assertTrue("nonsense connection should NOT be available", result == false);
-
- }
-
- /** Executes the test case */
- public static void main(String[] argv) {
- String[] testCaseList = {TestSecureIfSetController.class.getName()};
- junit.textui.TestRunner.main(testCaseList);
- }
-
- class TestController extends SecureIfSetController {
- TestController() {
- super();
- }
-
- }
-}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test/log4j.dtd
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<!-- Authors: Chris Taylor, Ceki Gulcu. -->
+
+<!-- Version: 1.2 -->
+
+<!-- A configuration element consists of optional renderer
+elements,appender elements, categories and an optional root
+element. -->
+
+<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?,
+ categoryFactory?)>
+
+<!-- The "threshold" attribute takes a level value such that all -->
+<!-- logging statements with a level equal or below this value are -->
+<!-- disabled. -->
+
+<!-- Setting the "debug" or "configDebug" attributes enable the printing -->
+<!-- of internal log4j logging statements. -->
+
+<!-- By default, debug attribute is "null", meaning that we not touch -->
+<!-- internal log4j logging settings. -->
+
+
+<!ATTLIST log4j:configuration
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ threshold (all|debug|info|warn|error|fatal|off|null) "null"
+ debug (true|false|null) "null"
+>
+
+<!-- renderer elements allow the user to customize the conversion of -->
+<!-- message objects to String. -->
+
+<!ELEMENT renderer EMPTY>
+<!ATTLIST renderer
+ renderedClass CDATA #REQUIRED
+ renderingClass CDATA #REQUIRED
+>
+
+<!-- Appenders must have a name and a class. -->
+<!-- Appenders may contain an error handler, a layout, optional parameters -->
+<!-- and filters. They may also reference (or include) other appenders. -->
+<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
+<!ATTLIST appender
+ name ID #REQUIRED
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT layout (param*)>
+<!ATTLIST layout
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT filter (param*)>
+<!ATTLIST filter
+ class CDATA #REQUIRED
+>
+
+<!-- ErrorHandlers can be of any class. They can admit any number of -->
+<!-- parameters. -->
+
+<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)>
+<!ATTLIST errorHandler
+ class CDATA #REQUIRED
+>
+
+<!ELEMENT root-ref EMPTY>
+
+<!ELEMENT logger-ref EMPTY>
+<!ATTLIST logger-ref
+ ref IDREF #REQUIRED
+>
+
+<!ELEMENT param EMPTY>
+<!ATTLIST param
+ name CDATA #REQUIRED
+ value CDATA #REQUIRED
+>
+
+
+<!-- The priority class is org.apache.log4j.Level by default -->
+<!ELEMENT priority (param*)>
+<!ATTLIST priority
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+<!-- The level class is org.apache.log4j.Level by default -->
+<!ELEMENT level (param*)>
+<!ATTLIST level
+ class CDATA #IMPLIED
+ value CDATA #REQUIRED
+>
+
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named category. -->
+<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
+<!ATTLIST category
+ class CDATA #IMPLIED
+ name CDATA #REQUIRED
+ additivity (true|false) "true"
+>
+
+<!-- If no level element is specified, then the configurator MUST not -->
+<!-- touch the level of the named logger. -->
+<!ELEMENT logger (level?,appender-ref*)>
+<!ATTLIST logger
+ name ID #REQUIRED
+ additivity (true|false) "true"
+>
+
+
+<!ELEMENT categoryFactory (param*)>
+<!ATTLIST categoryFactory
+ class CDATA #REQUIRED>
+
+<!ELEMENT appender-ref EMPTY>
+<!ATTLIST appender-ref
+ ref IDREF #REQUIRED
+>
+
+<!-- If no priority element is specified, then the configurator MUST not -->
+<!-- touch the priority of root. -->
+<!-- The root category always exists and cannot be subclassed. -->
+<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
+
+
+<!-- ==================================================================== -->
+<!-- A logging event -->
+<!-- ==================================================================== -->
+<!ELEMENT log4j:eventSet (log4j:event*)>
+<!ATTLIST log4j:eventSet
+ xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
+ version (1.1|1.2) "1.2"
+ includesLocationInfo (true|false) "true"
+>
+
+
+
+<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?,
+ log4j:locationInfo?) >
+
+<!-- The timestamp format is application dependent. -->
+<!ATTLIST log4j:event
+ category CDATA #REQUIRED
+ priority CDATA #REQUIRED
+ thread CDATA #REQUIRED
+ timestamp CDATA #REQUIRED
+>
+
+<!ELEMENT log4j:message (#PCDATA)>
+<!ELEMENT log4j:NDC (#PCDATA)>
+
+<!ELEMENT log4j:throwable (#PCDATA)>
+
+<!ELEMENT log4j:locationInfo EMPTY>
+<!ATTLIST log4j:locationInfo
+ class CDATA #REQUIRED
+ method CDATA #REQUIRED
+ file CDATA #REQUIRED
+ line CDATA #REQUIRED
+>
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test/TestComponentMetadata.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE component-metadata PUBLIC "-//Jcorporate Ltd//DTD Expresso Component Metadata Configuration 5.1//EN" "http://www.jcorporate.com/dtds/expresso-metadata_5_1.dtd">
+<component-metadata name="TestComponent1">
+ <description>A Test Component For Demonstration Purposes</description>
+ <version-info>
+ <major-version>4</major-version>
+ <minor-version>0</minor-version>
+ <micro-version>0</micro-version>
+ </version-info>
+ <property-list>
+ <property name="property1" value="123" type="java.lang.String" description="Property 1" access="rw"/>
+ <property name="property2" value="true" type="java.lang.Boolean" description="Boolean Property #2" access="readwrite"/>
+ </property-list>
+ <method-list>
+ <method name="doSomething" return-type="void" description="Do Something">
+ <method-arg name="param1" type="java.lang.String"/>
+ <method-arg name="param2" type="java.lang.Class"/>
+ </method>
+ </method-list>
+</component-metadata>
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test/TestComponent.java
@@ -0,0 +1,130 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+package com.jcorporate.expresso.kernel.test;
+
+import com.jcorporate.expresso.kernel.ComponentBase;
+import com.jcorporate.expresso.kernel.ComponentLifecycle;
+import com.jcorporate.expresso.kernel.Configuration;
+import com.jcorporate.expresso.kernel.exception.ConfigurationException;
+import org.apache.log4j.Logger;
+
+import java.net.URL;
+
+/**
+ * A Component for unit testing
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ on $Date: 2004/11/12 16:17:23 $
+ */
+
+public class TestComponent extends ComponentBase implements ComponentLifecycle {
+ Logger log = Logger.getLogger(TestComponent.class);
+
+ String property1 = null;
+ Boolean property2 = null;
+
+ public TestComponent() {
+ }
+
+ public URL getMetadataLocation() {
+ return this.getClass().getResource("TestComponentMetadata.xml");
+ }
+
+ public void initialize() {
+ log.info("Received Initialize Event");
+ }
+
+ public void configure(Configuration newConfig) throws ConfigurationException {
+ log.info("Received Configure Event");
+ }
+
+ public void reconfigure(Configuration newConfig) throws ConfigurationException {
+ log.info("Received Reconfigure Event");
+ property1 = (String) newConfig.get("property1");
+ property2 = (Boolean) newConfig.get("property2");
+ }
+
+ public void destroy() {
+ log.info("Received Destroy Event");
+ }
+
+ public void doSomething(String param1, Class param2) {
+ log.info("doSomething command invoked.");
+ }
+
+ public String getProperty1() {
+ return property1;
+ }
+
+ public Boolean getProperty2() {
+ return property2;
+ }
+
+ public void setProperty1(String property1) {
+ this.property1 = property1;
+ }
+
+ public void setProperty2(Boolean property2) {
+ this.property2 = property2;
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test/Test2ExpressoServices.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE expresso-services PUBLIC "-//Jcorporate Ltd//DTD Expresso Services Configuration 5.1//EN" "../expresso-services_5_1.dtd">
+<expresso-services name="sampleRuntime">
+ <mapped-property name="setupValue" key="test1" value="abcdefg"/>
+ <mapped-property name="setupValue" key="who you gonna call?" value="knees time!"/>
+ <component name="default" class-name="com.jcorporate.expresso.kernel.DataContext">
+ <property name="contextName" value="default"/>
+ <property name="hasSetupTables" value="true"/>
+ <property name="securityContext" value=""/>
+ <property name="contextDescription" value="A Sample Default Database"/>
+ <mapped-property name="setupValue" key="test1" value="Test Setup Value"/>
+ <component name="TestComponent" class-name="com.jcorporate.expresso.kernel.test.TestComponent">
+ <property name="property1" value="Abcdefg"/>
+ <property name="property2" value="true"/>
+ </component>
+ </component>
+</expresso-services>
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test/TestRuntimeInitServlet.java
@@ -0,0 +1,124 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+package com.jcorporate.expresso.kernel.test;
+
+import com.jcorporate.expresso.kernel.RootContainerInterface;
+import com.jcorporate.expresso.kernel.SystemFactory;
+import com.jcorporate.expresso.kernel.exception.ConfigurationException;
+import junit.framework.TestCase;
+
+/** JUnitTest case for class: com.jcorporate.expresso.kernel.RuntimeInitServlet */
+public class TestRuntimeInitServlet extends TestCase {
+
+ static RootContainerInterface globalContainer = null;
+
+ public TestRuntimeInitServlet(String _name) {
+ super(_name);
+ }
+
+ /** setUp method for test case */
+ protected void setUp() {
+ }
+
+ /** tearDown method for test case */
+ protected void tearDown() {
+ }
+
+ /** test for method init(..) */
+ public void testInit() {
+ try {
+ try {
+ globalContainer = SystemFactory.buildExpressoComponentSystem(
+ "D:/Expresso/devConfig/expresso-services.xml", null, "D:/Expresso/log");
+ fail("Call should have thrown IllegalArgumentException");
+ } catch (IllegalArgumentException iae) {
+
+ }
+
+ globalContainer = SystemFactory.buildExpressoComponentSystem(
+ "D:/Expresso/devConfig/expresso-services.xml",
+ "D:/expresso/devConfig/expressoLogging.xml",
+ "D:/Expresso/log");
+
+ assertTrue(globalContainer != null);
+ } catch (ConfigurationException ex) {
+ ex.printStackTrace();
+ fail("Error configing root container");
+ }
+ }
+
+ /** test for method destroy(..) */
+ public void testDestroy() {
+ if (globalContainer != null) {
+ globalContainer.destroy();
+ globalContainer = null;
+ }
+ }
+
+ /** Executes the test case */
+ public static void main(String[] argv) {
+ String[] testCaseList = {TestRuntimeInitServlet.class.getName()};
+ junit.textui.TestRunner.main(testCaseList);
+ }
+}
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test/TestLog4jConfig.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.Out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m\n"/>
+ </layout>
+ </appender>
+ <category name="com.jcorporate.expresso.kernel.digester">
+ <priority value="debug"/>
+ </category>
+ <root>
+ <priority value="info"/>
+ <appender-ref ref="console"/>
+ </root>
+</log4j:configuration>
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test/TestComponentSystem.java
@@ -0,0 +1,224 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+package com.jcorporate.expresso.kernel.test;
+
+import com.jcorporate.expresso.kernel.DataContext;
+import com.jcorporate.expresso.kernel.RootContainerInterface;
+import com.jcorporate.expresso.kernel.SystemFactory;
+import com.jcorporate.expresso.kernel.management.ExpressoRuntimeMap;
+import junit.framework.TestCase;
+
+/**
+ * Unit tests for the whole component system
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $ on $Date: 2004/11/12 16:17:23 $
+ */
+
+public class TestComponentSystem extends TestCase {
+
+ public TestComponentSystem(String _name) {
+ super(_name);
+ }
+
+ /** setUp method for test case */
+ protected void setUp() {
+ }
+
+ /** tearDown method for test case */
+ protected void tearDown() {
+ }
+
+ public void testInitRoot() {
+ RootContainerInterface globalContainer = null;
+ try {
+ globalContainer = SystemFactory.buildExpressoComponentSystem(
+ this.getClass().getResource("Test1ExpressoServices.xml"),
+ this.getClass().getResource("TestLog4jConfig.xml"),
+ System.getProperty("junit.argv.logDir", "/d:/expresso/log"));
+
+ assertTrue(globalContainer != null);
+ assertTrue(globalContainer.getExpressoServicesConfig() != null);
+ assertTrue(globalContainer.getContainerImplementation() != null);
+ assertTrue(globalContainer.getSetupValues() != null);
+ assertTrue("abcdefg".equals(globalContainer.getSetupValue("test1")));
+ assertTrue(globalContainer.getLogManager() != null);
+ assertTrue(globalContainer.getParent() == null);
+ assertTrue(globalContainer.getMetaData() != null);
+ assertTrue(globalContainer.getExpressoServicesConfig() != null);
+ globalContainer.destroy();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Caught Exception constructing Global Container");
+ }
+
+ }
+
+
+ public void testInit() {
+ RootContainerInterface globalContainer = null;
+ try {
+ globalContainer = SystemFactory.buildExpressoComponentSystem(
+ this.getClass().getResource("Test1ExpressoServices.xml"),
+ this.getClass().getResource("TestLog4jConfig.xml"),
+ "D:/Expresso/log");
+
+
+ DataContext dc = (DataContext) globalContainer.locateComponent("default");
+ assertTrue("DataContext should be non-null", dc != null);
+ assertTrue("DataContext should have setup tables"
+ , dc.getHasSetupTables().booleanValue() == true);
+
+ assertTrue("Security Context should be the default database",
+ dc.getSecurityContext().equals("default"));
+
+ assertTrue("Should have correct description as set by services.xml"
+ , dc.getContextDescription().equals("A Sample Default Database"));
+
+ assertTrue("Should have correct test setup value: got " + dc.getSetupValue("test1") + "instead",
+ "Test Setup Value".equals(dc.getSetupValue("test1")));
+
+ TestComponent tc = (TestComponent) dc.locateComponent("TestComponent");
+ assertTrue("Test Component must not be null", tc != null);
+
+
+ globalContainer.destroy();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Caught Exception constructing Global Container");
+ }
+
+ }
+
+ /**
+ * This, unfortunately, is a visual 'joke' in that you should see a warning
+ * message about having to GC a Rootcontainer interface when it should
+ * have been explicitly destroyed.
+ */
+ public void testGC() {
+ RootContainerInterface globalContainer = null;
+ try {
+ globalContainer = SystemFactory.buildExpressoComponentSystem(
+ this.getClass().getResource("Test1ExpressoServices.xml"),
+ this.getClass().getResource("TestLog4jConfig.xml"),
+ "D:/Expresso/log");
+
+ assertTrue(globalContainer != null);
+ globalContainer = null;
+ ExpressoRuntimeMap.unregisterRuntime(null);
+ System.gc();
+ System.runFinalization();
+
+ assertTrue(ExpressoRuntimeMap.getDefaultRuntime() == null);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Caught Exception constructing Global Container");
+ }
+
+ }
+
+ /**
+ * This test case actually tests the management class ExpressoRuntimeMap
+ * by initializing several containers and making sure that the ExpressoRuntime
+ * map seems to be keeping track of them properly.
+ */
+ public void testMultipleInits() {
+ RootContainerInterface globalContainer = null;
+
+ try {
+ globalContainer = SystemFactory.buildExpressoComponentSystem(
+ this.getClass().getResource("Test1ExpressoServices.xml"),
+ this.getClass().getResource("TestLog4jConfig.xml"),
+ "D:/Expresso/log");
+
+ RootContainerInterface testContainer = SystemFactory.buildExpressoComponentSystem(
+ this.getClass().getResource("Test2ExpressoServices.xml"),
+ this.getClass().getResource("TestLog4jConfig.xml"),
+ "D:/Expresso/log");
+
+ RootContainerInterface retrievedContainer = ExpressoRuntimeMap.getDefaultRuntime();
+ assertTrue("Retrieved container should be the global test container",
+ retrievedContainer == globalContainer);
+
+ retrievedContainer = ExpressoRuntimeMap.getRuntime("sampleRuntime");
+ assertTrue(retrievedContainer != null);
+ assertTrue("Retrieved container should be the second created container",
+ retrievedContainer == testContainer);
+
+ testContainer.destroy();
+ retrievedContainer = ExpressoRuntimeMap.getRuntime("sampleRuntime");
+ assertTrue("sampleRuntime should no longer exist", retrievedContainer == null);
+ globalContainer.destroy();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Caught Exception constructing Containers");
+ }
+ }
+
+
+ /** Executes the test case */
+ public static void main(String[] argv) {
+ String[] testCaseList = {TestComponentSystem.class.getName()};
+ junit.textui.TestRunner.main(testCaseList);
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/kernel/test/Test1ExpressoServices.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE expresso-services PUBLIC "-//Jcorporate Ltd//DTD Expresso Services Configuration 5.1//EN" "../expresso-services_5_1.dtd">
+<expresso-services>
+ <mapped-property name="setupValue" key="test1" value="abcdefg"/>
+ <mapped-property name="setupValue" key="who you gonna call?" value="knees time!"/>
+ <component name="default" class-name="com.jcorporate.expresso.kernel.DataContext">
+ <property name="contextName" value="default"/>
+ <property name="hasSetupTables" value="true"/>
+ <property name="securityContext" value=""/>
+ <property name="contextDescription" value="A Sample Default Database"/>
+ <mapped-property name="setupValue" key="test1" value="Test Setup Value"/>
+ <component name="TestComponent" class-name="com.jcorporate.expresso.kernel.test.TestComponent">
+ <property name="property1" value="Abcdefg"/>
+ <property name="property2" value="true"/>
+ </component>
+ </component>
+</expresso-services>
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE dataobject-join PUBLIC "-//Jcorporate Ltd//DTD Expresso DataObject Join 5.1//EN" "http://www.jcorporate.com/dtds/jdbc-join_5_1.dtd">
-<!--
-Sample join that shows a three way join with DownloadLog, DownloadFiles, and MimeTypes
--->
-<dataobject-join description="Download Log View">
- <dataobject className="com.jcorporate.expresso.ext.dbobj.DownloadLog" alias="DownloadLog"/>
- <dataobject className="com.jcorporate.expresso.ext.dbobj.DownloadFiles" alias="DownloadFiles"/>
- <dataobject className="com.jcorporate.expresso.services.dbobj.MimeTypes" alias="MimeTypes"/>
- <distinct distinctJoin="true"/>
- <!-- Although we don't mind folks browsing, we don't want them adding based upon this join -->
- <permissions add="false" read="true" update="true" delete="true"/>
- <relations>
- <foreign-key local-alias-ref="DownloadLog" local-alias-key="FileNumber" foreign-alias-ref="DownloadFiles" foreign-alias-key="FileNumber"/>
- <foreign-key local-alias-ref="DownloadFiles" local-alias-key="MimeNumber" foreign-alias-ref="MimeTypes" foreign-alias-key="MimeNumber"/>
- <!--
- <foreign-key local-alias-ref="DownloadLog" local-alias-key="ExpUid" foreign-alias-ref="Users" foreign-alias-key="ExpUid"/>
--->
- </relations>
-</dataobject-join>
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/tests/TestJoinedDigesterBean.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.dataobjects.jdbc.tests;
-
-import com.jcorporate.expresso.core.dataobjects.jdbc.JoinedDigesterBean;
-import junit.framework.TestCase;
-import org.apache.commons.digester.Digester;
-
-import java.net.URL;
-import java.util.List;
-
-/** JUnitTest case for class: com.jcorporate.expresso.core.dataobjects.jdbc.JoinedDigesterBean */
-public class TestJoinedDigesterBean extends TestCase {
-
- private static final String TEST_FILE = "/com/jcorporate/" +
- "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml";
-
- public TestJoinedDigesterBean(String _name) {
- super(_name);
- }
-
- /** test for method buildDigester(..) */
- public void testBuildDigester() {
- try {
- JoinedDigesterBean bean = new JoinedDigesterBean();
- Digester d = bean.buildDigester();
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Error building digester");
- }
- }
-
-
- /** test for method digest(..) */
- public void testDigest() {
- JoinedDigesterBean bean = new JoinedDigesterBean();
- Digester d = bean.buildDigester();
- URL file = TestJoinedDigesterBean.class.getResource(TEST_FILE);
-
- if (file == null) {
- throw new IllegalArgumentException("Error getting Test join xml file");
- }
-
- try {
- bean.digest(d, file);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Error digesting data");
- }
- runDataIntegrityTest(bean);
-
- }
-
-
- /** test for method loadJoinData(..) */
- public void testLoadJoinData() {
- JoinedDigesterBean bean = new JoinedDigesterBean();
- URL file = TestJoinedDigesterBean.class.getResource(TEST_FILE);
-
- if (file == null) {
- throw new IllegalArgumentException("Error getting Test join xml file");
- }
-
- try {
- bean.loadJoinData(file);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Error digesting data");
- }
-
- runDataIntegrityTest(bean);
- }
-
- private void runDataIntegrityTest(JoinedDigesterBean theBean) {
- assertTrue("Download Log View".equals(theBean.getDescription()));
- assertTrue(theBean.isDistinct() == false);
- List dataobjects = theBean.getDataObjects();
- List relations = theBean.getRelations();
-
- assertTrue("dataobjects should not be null", dataobjects != null);
- assertTrue("relations should not be null", relations != null);
-
- assertTrue("dataobjects should have elements", dataobjects.size() > 0);
- assertTrue("relations should have elements", relations.size() > 0);
- }
-
- /** Executes the test case */
- public static void main(String[] argv) {
- String[] testCaseList = {TestJoinedDigesterBean.class.getName()};
- junit.textui.TestRunner.main(testCaseList);
- }
-}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/tests/LobFieldTest.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-package com.jcorporate.expresso.core.dataobjects.jdbc.tests;
-
-import com.jcorporate.expresso.core.dataobjects.jdbc.LobField;
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.core.db.TableCreator;
-import com.jcorporate.expresso.core.dbobj.tests.Test1;
-import com.jcorporate.expresso.core.dbobj.tests.Test2;
-import com.jcorporate.expresso.core.dbobj.tests.TestSchema;
-import com.jcorporate.expresso.core.misc.ConfigManager;
-import com.jcorporate.expresso.core.misc.ConfigurationException;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.apache.log4j.Logger;
-
-import java.sql.Blob;
-import java.util.Enumeration;
-import java.util.Vector;
-
-/**
- * Unit test cases for testing the LobField class.
- * @author Michael Rimov
- * @version $Revision: 1.6 $ on $Date: 2004/09/29 06:20:16 $
- * @since Expresso 5.1
- */
-
-public class LobFieldTest extends TestCase {
-
- private static Logger log = Logger.getLogger(LobFieldTest.class);
-
- /**
- * Constructs a test case with the given name.
- *
- *@param name The name of the test case
- */
- public LobFieldTest(String name) {
- super(name);
- } /* DBObjectTest(String) */
-
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- ConfigManager.destroy();
- }
-
- /**
- * Sets up the fixture, for example, open a network connection.
- * This method is called before a test is executed.
- *
- * @throws Exception
- */
- public void setUp()
- throws Exception {
- TestSystemInitializer.setUp();
-
- try {
- ConfigManager.getContext(TestSystemInitializer.getTestContext());
- } catch (ConfigurationException ce) {
- fail("Specified context to test:" + TestSystemInitializer.getTestContext() + " but couldn't find that context");
- }
-
- TestSchema ts = new TestSchema();
- Vector v = TableCreator.getInstance().createAsNeeded(ts, TestSystemInitializer.getTestContext());
-
- for (Enumeration ev = v.elements(); ev.hasMoreElements();) {
- log.info((String) ev.nextElement());
- }
-
- Test1 test1List = new Test1();
- test1List.setDataContext(TestSystemInitializer.getTestContext());
- test1List.deleteAll();
-
- } /* setUp() */
-
-
- /**
- * Tears down the fixture, for example, close a network connection.
- * This method is called after a test is executed.
- *
- * @throws Exception
- */
- public void tearDown()
- throws Exception {
- try {
-
- /* Clean out the test tables */
- Test1 test1List = new Test1();
- test1List.setDataContext(TestSystemInitializer.getTestContext());
- test1List.deleteAll();
-
- Test2 test2List = new Test2();
- test2List.setDataContext(TestSystemInitializer.getTestContext());
- test2List.deleteAll();
-
- } catch (DBException de) {
- de.printStackTrace();
- log.error(de);
- }
- } /* tearDown() */
-
-
- /**
- * Define the suite of tests that verify each function of the cache
- *
- * @return an instantiated test suite
- */
- public static Test suite() {
- TestSuite suite = new TestSuite(LobFieldTest.class);
-
- return suite;
- } /* suite() */
-
-
- /**
- * This test demonstrates/tests the basic functionality for binary-based
- * data fields. You must use the saveBinaryField as a separate method rather
- * than setField.
- */
- public void testBLOBSupport() {
- LobField lf = new LobField();
- final Integer testInt = new Integer(-3544);
- final String testKey = "1";
- try {
- java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(128);
- java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(bos);
- oos.writeObject(testInt);
- byte buffer[] = bos.toByteArray();
- java.io.ByteArrayInputStream bis = new java.io.ByteArrayInputStream(buffer);
-
-
- Test1 oneTest = new Test1();
- oneTest.setDataContext(TestSystemInitializer.getTestContext());
- oneTest.setField("TestKey", testKey);
- oneTest.add();
-
- lf.setCriteria(oneTest);
- lf.saveBlob("BlobTest", bis, buffer.length);
-
- java.io.InputStream is = lf.getBlobStream("BlobTest");
-
- assertTrue("Blob Input stream data must not be null", is != null);
-
- java.io.ObjectInputStream ois = new java.io.ObjectInputStream(is);
- Object o = ois.readObject();
- assertTrue("Read object must not be null", o != null);
- assertTrue("Read object must be of type java.lang.Integer", o instanceof Integer);
- Integer i = (Integer) o;
- assertTrue("Binary field data must be equal to original data. Got " + i.intValue() +
- " instead of " + testInt.intValue(), i.intValue() == testInt.intValue());
-
-
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Caught exception testing BLOB Support: " + t.getMessage());
- } finally {
- lf.close();
- }
- }
-
- /**
- * Test Blob support with a larger quantitiy of data
- *
- * (Originally needed because Oracle Blob's work with standard jdbc operations for small sizes (~ <4K), but
- * not with larger sizes)
- */
- public void testBLOBSupportLargeData() {
- LobField lf = new LobField();
- final Integer testInt = new Integer(-3544);
- Integer[] testIntArray = new Integer[1000];
- final String testKey = "1";
- try {
- for (int i=0; i<1000; i++) {
- testIntArray[i] = testInt;
- }
-
- java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(128000);
- java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(bos);
- oos.writeObject(testIntArray);
- byte buffer[] = bos.toByteArray();
- java.io.ByteArrayInputStream bis = new java.io.ByteArrayInputStream(buffer);
-
-
- Test1 oneTest = new Test1();
- oneTest.setDataContext(TestSystemInitializer.getTestContext());
- oneTest.setField("TestKey", testKey);
- oneTest.add();
-
- lf.setCriteria(oneTest);
- lf.saveBlob("BlobTest", bis, buffer.length);
-
- java.io.InputStream is = lf.getBlobStream("BlobTest");
-
- assertTrue("Blob Input stream data must not be null", is != null);
-
- java.io.ObjectInputStream ois = new java.io.ObjectInputStream(is);
- Object o = ois.readObject();
- assertTrue("Read object must not be null", o != null);
- assertTrue("Read object must be of type java.lang.Integer[]", o instanceof Integer[]);
- Integer[] i = (Integer[]) o;
-
- boolean objectsEqual = true;
- for (int j=0; j<i.length; j++) {
- if (i[j].intValue() != testIntArray[j].intValue()) {
- objectsEqual = false;
- break;
- }
- }
- assertTrue("Binary field data must be equal to original data.", objectsEqual);
-
-
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Caught exception testing BLOB Support: " + t.getMessage());
- } finally {
- lf.close();
- }
- }
-
- /**
- * Test Blob support with a larger quantitiy of data
- *
- * Specifically, this test tests the LobField.saveBlob(String, Blob) method
- */
- public void testBLOBSupportLargeData2() {
- LobField lf = new LobField();
- LobField lf2 = new LobField();
- final Integer testInt = new Integer(-3544);
- Integer[] testIntArray = new Integer[1000];
- final String testKey = "1";
- final String testKey2 = "2";
- try {
- for (int i=0; i<1000; i++) {
- testIntArray[i] = testInt;
- }
-
- java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream(100000);
- java.io.ObjectOutputStream oos = new java.io.ObjectOutputStream(bos);
- oos.writeObject(testIntArray);
- byte buffer[] = bos.toByteArray();
- java.io.ByteArrayInputStream bis = new java.io.ByteArrayInputStream(buffer);
-
- Test1 oneTest = new Test1();
- oneTest.setDataContext(TestSystemInitializer.getTestContext());
- oneTest.setField("TestKey", testKey);
- oneTest.add();
-
- lf.setCriteria(oneTest);
- lf.saveBlob("BlobTest", bis, buffer.length);
-
- Blob blob = lf.getBlob("BlobTest");
- Test1 oneTest2 = new Test1();
- oneTest2.setDataContext(TestSystemInitializer.getTestContext());
- oneTest2.setField("TestKey", testKey2);
- oneTest2.add();
- lf2.setCriteria(oneTest2);
- lf2.saveBlob("BlobTest", blob);
-
- java.io.InputStream is = lf2.getBlobStream("BlobTest");
-
- assertTrue("Blob Input stream data must not be null", is != null);
-
- java.io.ObjectInputStream ois = new java.io.ObjectInputStream(is);
- Object o = ois.readObject();
- assertTrue("Read object must not be null", o != null);
- assertTrue("Read object must be of type java.lang.Integer[]", o instanceof Integer[]);
- Integer[] i = (Integer[]) o;
-
- boolean objectsEqual = true;
- for (int j=0; j<i.length; j++) {
- if (i[j].intValue() != testIntArray[j].intValue()) {
- objectsEqual = false;
- break;
- }
- }
- assertTrue("Binary field data must be equal to original data.", objectsEqual);
-
-
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Caught exception testing BLOB Support: " + t.getMessage());
- } finally {
- lf.close();
- }
- }
-
- /**
- * This test demonstrates/tests the basic functionality for Text-based
- * data fields. You set and retrieve the text data as usual and the
- * underlying framework saves/retrieves the CLOB field when you want it.
- */
- public void testCLOBSupport() {
- final String testString = "LONG Character Update Test";
- final String testKey = "1";
- LobField lf = new LobField();
- try {
- Test1 oneTest = new Test1();
- oneTest.setDataContext(TestSystemInitializer.getTestContext());
- oneTest.setField("TestKey", testKey);
- oneTest.add();
-
- lf.setCriteria(oneTest);
- java.io.InputStream is = lf.getBlobStream("BlobTest");
- assertTrue("BLOB Stream should be null", is == null);
-
- lf.saveClob("ClobTest", testString);
- String fieldData = lf.getClobString("ClobTest");
-
- assertTrue("CLOB Field data must not be null", fieldData != null);
-
- assertTrue("CLOB field data must be equal to the original data. Got "
- + fieldData + " instead", testString.equals(fieldData));
-
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Caught exception testing CLOB Support: " + t.getMessage());
- } finally {
- lf.close();
- }
- }
-
- /**
- * This test makes sure that the LOB Field support doesn't crash if field
- * values are null.
- */
- public void testNullSupport() {
- final String testString = "LONG Character Update Test";
- final String testKey = "1";
- LobField lf = new LobField();
- try {
- Test1 oneTest = new Test1();
- oneTest.setDataContext(TestSystemInitializer.getTestContext());
- oneTest.setField("TestKey", testKey);
- oneTest.add();
-
- lf.setCriteria(oneTest);
- lf.saveClob("ClobTest", (String) null);
- String fieldData = lf.getClobString("ClobTest");
- assertTrue("Field data should be null", fieldData == null);
-
- } catch (Throwable t) {
- t.printStackTrace();
- fail("Caught exception testing Null Support: " + t.getMessage());
- } finally {
- lf.close();
- }
-
- }
-
-
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/jdbc/tests/JoinedObjectTest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.dataobjects.jdbc.tests;
-
-import java.util.ArrayList;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import com.jcorporate.expresso.core.dataobjects.DataException;
-import com.jcorporate.expresso.core.dataobjects.Securable;
-import com.jcorporate.expresso.core.dataobjects.jdbc.JoinedDataObject;
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.core.misc.ConfigManager;
-import com.jcorporate.expresso.core.misc.ConfigurationException;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-
-
-/**
- * <p>
- * DBObjectTest.java</p>
- * <p>Copyright 1999, 2000, 2001 Jcorporate Ltd.</p>
- * A test case to verify the functions of DBObject. You can also use this
- * test as
- */
-public class JoinedObjectTest
- extends TestCase {
-
-
- /**
- * Constructs a test case with the given name.
- *
- *@param name The name of the test case
- */
- public JoinedObjectTest(String name) {
- super(name);
- } /* DBObjectTest(String) */
-
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- ConfigManager.destroy();
- }
-
- /**
- * Sets up the fixture, for example, open a network connection.
- * This method is called before a test is executed.
- *
- * @throws Exception
- */
- public void setUp()
- throws Exception {
- TestSystemInitializer.setUp();
-
- try {
- ConfigManager.getContext(TestSystemInitializer.getTestContext());
- } catch (ConfigurationException ce) {
- fail("Specified context to test:" + TestSystemInitializer.getTestContext() + " but couldn't find that context");
- }
-
- } /* setUp() */
-
-
- /**
- * Tears down the fixture, for example, close a network connection.
- * This method is called after a test is executed.
- *
- * @throws Exception
- */
- public void tearDown()
- throws Exception {
-
- } /* tearDown() */
-
-
- /**
- * Define the suite of tests that verify each function of the cache
- *
- * @return an instantiated test suite
- */
- public static Test suite() {
- TestSuite suite = new TestSuite(JoinedObjectTest.class);
-
- return suite;
- } /* suite() */
-
- public void testCount() {
- try {
- JoinedDataObject testJoin = new JoinedDataObject();
- testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT);
- testJoin.setDefinitionName("/com/jcorporate/" +
- "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml");
- testJoin.set("DownloadLog.LogEntry","1");
- int number = testJoin.count();
- System.out.println("Received count result of : " + number);
-
- JoinedDataObject emptyCount = new JoinedDataObject();
- emptyCount.setRequestingUid(Securable.SYSTEM_ACCOUNT);
- emptyCount.setDefinitionName("/com/jcorporate/" +
- "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml");
- number = emptyCount.count();
- System.out.println("Received count result of : " + number);
-
-
- }
- catch (DataException ex) {
- ex.printStackTrace();
- fail("Error testing Joined DataObject");
- } catch (DBException ex) {
- ex.printStackTrace();
- fail("Caught DBException testing Joined DataObject");
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception testing Joined DataObject");
- }
-
- }
-
-
-
- /**
- * Test to make sure that calling clear doesn't break anything.
- */
- public void testClear() {
- try {
- JoinedDataObject testJoin = new JoinedDataObject();
- testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT);
- testJoin.setDefinitionName("/com/jcorporate/" +
- "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml");
- testJoin.set("DownloadLog.LogEntry","1");
- int number = testJoin.count();
- System.out.println("Received count result of : " + number);
-
- testJoin.clear();
- testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT);
- testJoin.setDefinitionName("/com/jcorporate/" +
- "expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml");
- number = testJoin.count();
- System.out.println("Received count result of : " + number);
-
-
- }
- catch (DataException ex) {
- ex.printStackTrace();
- fail("Error testing Joined DataObject");
- } catch (DBException ex) {
- ex.printStackTrace();
- fail("Caught DBException testing Joined DataObject");
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception testing Joined DataObject");
- }
-
- }
-
- /**
- * Tries a database object join on search and retrieve.
- */
- public void testSearchAndRetrieveList() {
- try {
- JoinedDataObject testJoin = new JoinedDataObject();
- testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT);
- testJoin.setDefinitionName("/com/jcorporate/expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml");
- testJoin.set("DownloadLog.LogEntry","1");
- ArrayList al = testJoin.searchAndRetrieveList();
- System.out.println("Received result of : " + al.size() + " records");
- }
- catch (DataException ex) {
- ex.printStackTrace();
- fail("Error testing Joined DataObject");
- } catch (DBException ex) {
- ex.printStackTrace();
- fail("Caught DBException testing Joined DataObject");
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception testing Joined DataObject");
- }
-
- }
-
- public void testOrderBy() {
- try {
- JoinedDataObject testJoin = new JoinedDataObject();
- testJoin.setRequestingUid(Securable.SYSTEM_ACCOUNT);
- testJoin.setDefinitionName("/com/jcorporate/expresso/core/dataobjects/jdbc/tests/DownloadMimeTypeJoin.xml");
- testJoin.set("DownloadLog.LogEntry","1");
- ArrayList al = testJoin.searchAndRetrieveList("MimeTypes.MimeNumber DESC");
- System.out.println("Received result of : " + al.size() + " records");
- al = testJoin.searchAndRetrieveList("MimeTypes.MimeNumber");
- System.out.println("Received result of : " + al.size() + " records");
- al = testJoin.searchAndRetrieveList("Users.ExpUid DESC|MimeTypes.MimeNumber ASC");
- System.out.println("Received result of : " + al.size() + " records");
- }
- catch (DataException ex) {
- ex.printStackTrace();
- fail("Error testing Joined DataObject");
- } catch (DBException ex) {
- ex.printStackTrace();
- fail("Caught DBException testing Joined DataObject");
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception testing Joined DataObject");
- }
-
- }
-
-
- /**
- * Tests the setter and getter values of the dataobject.
- */
- public void testGetSet() {
-
- }
-}
-/* DBObjectTest */
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/test/log4j.dtd
+++ /dev/null
@@ -1,163 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!-- Authors: Chris Taylor, Ceki Gulcu. -->
-
-<!-- Version: 1.2 -->
-
-<!-- A configuration element consists of optional renderer
-elements,appender elements, categories and an optional root
-element. -->
-
-<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?,
- categoryFactory?)>
-
-<!-- The "threshold" attribute takes a level value such that all -->
-<!-- logging statements with a level equal or below this value are -->
-<!-- disabled. -->
-
-<!-- Setting the "debug" or "configDebug" attributes enable the printing -->
-<!-- of internal log4j logging statements. -->
-
-<!-- By default, debug attribute is "null", meaning that we not touch -->
-<!-- internal log4j logging settings. -->
-
-
-<!ATTLIST log4j:configuration
- xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
- threshold (all|debug|info|warn|error|fatal|off|null) "null"
- debug (true|false|null) "null"
->
-
-<!-- renderer elements allow the user to customize the conversion of -->
-<!-- message objects to String. -->
-
-<!ELEMENT renderer EMPTY>
-<!ATTLIST renderer
- renderedClass CDATA #REQUIRED
- renderingClass CDATA #REQUIRED
->
-
-<!-- Appenders must have a name and a class. -->
-<!-- Appenders may contain an error handler, a layout, optional parameters -->
-<!-- and filters. They may also reference (or include) other appenders. -->
-<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
-<!ATTLIST appender
- name ID #REQUIRED
- class CDATA #REQUIRED
->
-
-<!ELEMENT layout (param*)>
-<!ATTLIST layout
- class CDATA #REQUIRED
->
-
-<!ELEMENT filter (param*)>
-<!ATTLIST filter
- class CDATA #REQUIRED
->
-
-<!-- ErrorHandlers can be of any class. They can admit any number of -->
-<!-- parameters. -->
-
-<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)>
-<!ATTLIST errorHandler
- class CDATA #REQUIRED
->
-
-<!ELEMENT root-ref EMPTY>
-
-<!ELEMENT logger-ref EMPTY>
-<!ATTLIST logger-ref
- ref IDREF #REQUIRED
->
-
-<!ELEMENT param EMPTY>
-<!ATTLIST param
- name CDATA #REQUIRED
- value CDATA #REQUIRED
->
-
-
-<!-- The priority class is org.apache.log4j.Level by default -->
-<!ELEMENT priority (param*)>
-<!ATTLIST priority
- class CDATA #IMPLIED
- value CDATA #REQUIRED
->
-
-<!-- The level class is org.apache.log4j.Level by default -->
-<!ELEMENT level (param*)>
-<!ATTLIST level
- class CDATA #IMPLIED
- value CDATA #REQUIRED
->
-
-
-<!-- If no level element is specified, then the configurator MUST not -->
-<!-- touch the level of the named category. -->
-<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
-<!ATTLIST category
- class CDATA #IMPLIED
- name CDATA #REQUIRED
- additivity (true|false) "true"
->
-
-<!-- If no level element is specified, then the configurator MUST not -->
-<!-- touch the level of the named logger. -->
-<!ELEMENT logger (level?,appender-ref*)>
-<!ATTLIST logger
- name ID #REQUIRED
- additivity (true|false) "true"
->
-
-
-<!ELEMENT categoryFactory (param*)>
-<!ATTLIST categoryFactory
- class CDATA #REQUIRED>
-
-<!ELEMENT appender-ref EMPTY>
-<!ATTLIST appender-ref
- ref IDREF #REQUIRED
->
-
-<!-- If no priority element is specified, then the configurator MUST not -->
-<!-- touch the priority of root. -->
-<!-- The root category always exists and cannot be subclassed. -->
-<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
-
-
-<!-- ==================================================================== -->
-<!-- A logging event -->
-<!-- ==================================================================== -->
-<!ELEMENT log4j:eventSet (log4j:event*)>
-<!ATTLIST log4j:eventSet
- xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
- version (1.1|1.2) "1.2"
- includesLocationInfo (true|false) "true"
->
-
-
-
-<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?,
- log4j:locationInfo?) >
-
-<!-- The timestamp format is application dependent. -->
-<!ATTLIST log4j:event
- category CDATA #REQUIRED
- priority CDATA #REQUIRED
- thread CDATA #REQUIRED
- timestamp CDATA #REQUIRED
->
-
-<!ELEMENT log4j:message (#PCDATA)>
-<!ELEMENT log4j:NDC (#PCDATA)>
-
-<!ELEMENT log4j:throwable (#PCDATA)>
-
-<!ELEMENT log4j:locationInfo EMPTY>
-<!ATTLIST log4j:locationInfo
- class CDATA #REQUIRED
- method CDATA #REQUIRED
- file CDATA #REQUIRED
- line CDATA #REQUIRED
->
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/test/TestPersistenceManager.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-package com.jcorporate.expresso.core.dataobjects.test;
-
-import com.jcorporate.expresso.core.dataobjects.PersistenceManager;
-import com.jcorporate.expresso.core.db.DBConfig;
-import com.jcorporate.expresso.core.db.TypeMapper;
-import com.jcorporate.expresso.core.misc.SystemMacros;
-import com.jcorporate.expresso.kernel.DataContext;
-import com.jcorporate.expresso.kernel.RootContainerInterface;
-import com.jcorporate.expresso.kernel.SystemFactory;
-import com.jcorporate.expresso.kernel.util.LocatorUtils;
-import junit.framework.TestCase;
-
-/** JUnitTest case for class: com.jcorporate.expresso.core.dataobjects.PersistenceManager */
-public class TestPersistenceManager extends TestCase {
-
-
- public TestPersistenceManager(String _name) {
- super(_name);
- }
-
- RootContainerInterface globalContainer = null;
-
- /** setUp method for test case */
- protected void setUp() {
- SystemMacros.getInstance()
- .setWebAppDir(System.getProperty("junit.argv.webAppDir", ""));
-
- try {
- globalContainer = SystemFactory.buildExpressoComponentSystem(
- this.getClass().getResource("Test1ExpressoServices.xml"),
- this.getClass().getResource("TestLog4jConfig.xml"),
- System.getProperty("junit.argv.logDir", "/d:/expresso/log"));
- } catch (Exception e) {
- e.printStackTrace();
- fail("Caught Exception setting up test case");
- }
- }
-
- /** tearDown method for test case */
- protected void tearDown() {
- globalContainer.destroy();
- }
-
- /** test for method initialize(..) */
- public void testInitialize() {
- try {
- DataContext dc = (DataContext) globalContainer.locateComponent("default");
- assertTrue("DataContext should be non-null", dc != null);
- assertTrue("DataContext should have setup tables"
- , dc.getHasSetupTables().booleanValue() == true);
-
- LocatorUtils lc = new LocatorUtils(globalContainer);
- PersistenceManager manager = (PersistenceManager) lc.locateComponent("default.PersistenceManager");
- assertTrue("PersistenceManager should exist", manager != null);
-
- DBConfig config = (DBConfig) lc.locateComponent("default.PersistenceManager.DBConfig");
- assertTrue("DBConfig should exist", config != null);
-
- TypeMapper mapper = (TypeMapper) lc.locateComponent("default.PersistenceManager.TypeMapper");
- assertTrue("TypeMapper should exist", mapper != null);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception constructing Global Container");
- }
-
-
- }
-
-
- /** test for method getTypeMapper(..) */
- public void testGetTypeMapper() {
- try {
- LocatorUtils lc = new LocatorUtils(globalContainer);
- PersistenceManager manager = (PersistenceManager) lc.locateComponent("default.PersistenceManager");
- assertTrue("PersistenceManager should exist", manager != null);
- assertTrue("TypeMapper must not be null", manager.getTypeMapper() != null);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception constructing Global Container");
- }
-
- }
-
- /** test for method getDataContext(..) */
- public void testGetDataContext() {
- try {
- LocatorUtils lc = new LocatorUtils(globalContainer);
- PersistenceManager manager = (PersistenceManager) lc.locateComponent("default.PersistenceManager");
- assertTrue("PersistenceManager should exist", manager != null);
- assertTrue("default".equals(manager.getDataContext()));
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception constructing Global Container");
- }
- }
-
- /** test for method getConfigName(..) */
- public void testGetConfigName() {
- try {
- LocatorUtils lc = new LocatorUtils(globalContainer);
- PersistenceManager manager = (PersistenceManager) lc.locateComponent("default.PersistenceManager");
- assertTrue("PersistenceManager should exist", manager != null);
- assertTrue("hypersonic.xml".equals(manager.getConfigName()));
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception constructing Global Container");
- }
- }
-
- /** test for method getDataURL(..) */
- public void testGetDataURL() {
- try {
- LocatorUtils lc = new LocatorUtils(globalContainer);
- PersistenceManager manager = (PersistenceManager) lc.locateComponent("default.PersistenceManager");
- assertTrue("PersistenceManager should exist", manager != null);
- assertTrue("jdbc:hsqldb:%web-app%WEB-INF/db/default/default"
- .equals(manager.getDataURL()));
-
- assertTrue(manager.getDBConfig().getCurrentConfig().getUrl() != null);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception constructing Global Container");
- }
-
- }
-
-
- /** test for method getUserName(..) */
- public void testGetUserName() {
- try {
- LocatorUtils lc = new LocatorUtils(globalContainer);
- PersistenceManager manager = (PersistenceManager) lc.locateComponent("default.PersistenceManager");
- assertTrue("PersistenceManager should exist", manager != null);
- assertTrue("sa".equals(manager.getUserName()));
- assertTrue("sa".equals(manager.getDBConfig().getCurrentConfig().getLogin()));
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception constructing Global Container");
- }
- }
-
-
- /** test for method getPassword(..) */
- public void testGetPassword() {
- try {
- LocatorUtils lc = new LocatorUtils(globalContainer);
- PersistenceManager manager = (PersistenceManager) lc.locateComponent("default.PersistenceManager");
- assertTrue("PersistenceManager should exist", manager != null);
- assertTrue("".equals(manager.getPassword()));
- assertTrue("".equals(manager.getDBConfig().getCurrentConfig().getPassword()));
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Caught Exception constructing Global Container");
- }
- }
-
- /** Executes the test case */
- public static void main(String[] argv) {
- String[] testCaseList = {TestPersistenceManager.class.getName()};
- junit.textui.TestRunner.main(testCaseList);
- }
-}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/test/TestLog4jConfig.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.Out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m\n"/>
- </layout>
- </appender>
- <category name="com.jcorporate.expresso.kernel.digester">
- <priority value="debug"/>
- </category>
- <root>
- <priority value="info"/>
- <appender-ref ref="console"/>
- </root>
-</log4j:configuration>
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/test/Test1ExpressoServices.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE expresso-services PUBLIC "-//Jcorporate Ltd//DTD Expresso Services Configuration 5.1//EN" "http://www.jcorporate.com/dtds/expresso-services_5_1.dtd">
-<expresso-services>
- <component name="default" class-name="com.jcorporate.expresso.kernel.DataContext">
- <property name="contextName" value="default"/>
- <property name="hasSetupTables" value="true"/>
- <property name="securityContext" value=""/>
- <property name="contextDescription" value="A Sample Default Database"/>
- <component name="PersistenceManager" class-name="com.jcorporate.expresso.core.dataobjects.PersistenceManager">
- <property name="UserName" value="sa"/>
- <property name="Password" value=""/>
- <property name="DataURL" value="jdbc:hsqldb:%web-app%WEB-INF/db/default/default"/>
- <property name="ConfigName" value="hypersonic.xml"/>
- <component name="DBConfig" class-name="com.jcorporate.expresso.core.db.DBConfig"/>
- <component name="TypeMapper" class-name="com.jcorporate.expresso.core.db.TypeMapper"/>
- <!-- Commented out since JNDIConfig is not getting used by this persistence engine.
- <component name="JNDIConfig" class-name="com.jcorporate.expresso.core.db.config.JNDIConfig"/>
- -->
- </component>
- </component>
-</expresso-services>
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/dataobjects/test/TestDataTransferObject.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.dataobjects.test;
-
-import com.jcorporate.expresso.core.dataobjects.*;
-import com.jcorporate.expresso.core.db.*;
-import com.jcorporate.expresso.core.dbobj.*;
-import com.jcorporate.expresso.services.dbobj.MimeTypes;
-import com.jcorporate.expresso.services.test.*;
-import junit.framework.*;
-import java.io.*;
-import java.util.*;
-
-
-/**
- * Tests various aspects of the DataTransferObject
- *
- * @author Michael Rimov
- * @version 1.0
- */
-public class TestDataTransferObject extends ExpressoTestCase
-{
- DataTransferObject dataTransferObject = null;
- MimeTypes mt = null;
-
- /**
- * Creates a new TestDataTransferObject object.
- *
- * @param testName The name of the test
- *
- * @throws Exception Upon initialization error
- */
- public TestDataTransferObject(String testName) throws Exception
- {
- super(testName);
- }
-
- /**
- * A main function to allow testing of this class only
- *
- * @param args Unused
- *
- * @throws Exception If an error occurs during testing
- */
- public static void main(String[] args) throws Exception
- {
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Constructs the test suite
- *
- * @return An instantiated Junit test suite
- *
- * @throws Exception Upon error
- */
- public static junit.framework.Test suite() throws Exception
- {
- return new TestSuite(TestDataTransferObject.class);
- }
-
- /**
- * Checks the data transfer object by verifying that the values
- * set in the data object are consistent with those that appear in the data
- * transfer object
- */
- public void testDTOValues()
- {
- try {
- DataTransferObject dto = mt.getDataTransferObject();
- assertTrue(TestSystemInitializer.getTestContext().equals(dto.getDataContext()));
- assertTrue(MimeTypes.class.getName().equals(dto.getObjectClassName()));
-
- Map fields = dto.getTableFields();
- checkFields(fields);
- } catch (DBException ex) {
- ex.printStackTrace();
- fail("Exception testing field values");
- }
- }
-
-
- /**
- * Performs similar test to testDTOValues except that the data transfer object
- * is serialized to memory, deserialized, and the values in the deserialized
- * data transfer object are checked against the original data object.
- */
- public void testDTOSerialization()
- {
- try {
- DataTransferObject dto = mt.getDataTransferObject();
- assertTrue(TestSystemInitializer.getTestContext().equals(dto.getDataContext()));
- assertTrue(MimeTypes.class.getName().equals(dto.getObjectClassName()));
-
- DataTransferObject dto2 = runThroughSerializerTransfer(dto);
-
- Map fields = dto.getTableFields();
- checkFields(fields);
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Exception testing field values");
- }
- }
-
-
- /**
- * Sets up the test suite by creating a mime type data object.
- *
- * @throws Exception upon setup error
- */
- protected void setUp() throws Exception
- {
- super.setUp();
- dataTransferObject = new DataTransferObject();
- mt = new MimeTypes(SecuredDBObject.SYSTEM_ACCOUNT);
- mt.setDataContext(TestSystemInitializer.getTestContext());
- mt.setField(MimeTypes.FLD_MIMENUMBER, 1);
- mt.setField(MimeTypes.FLD_DESCRIPTION, "Image File");
- mt.setField(MimeTypes.FLD_FILE_EXTENSIONS, ".jpg,.png,.gif");
- }
-
- /**
- * Checks to make sure field values are consistent
- *
- * @param fields
- */
- protected void checkFields(Map fields)
- {
- assertTrue(fields.containsKey(MimeTypes.FLD_MIMENUMBER));
- assertTrue(fields.containsKey(MimeTypes.FLD_DESCRIPTION));
- assertTrue(fields.containsKey(MimeTypes.FLD_FILE_EXTENSIONS));
-
- assertTrue("1".equals(fields.get(MimeTypes.FLD_MIMENUMBER)));
- assertTrue("Image File".equals(fields.get(MimeTypes.FLD_DESCRIPTION)));
- assertTrue(".jpg,.png,.gif".equals(fields.get(MimeTypes.FLD_FILE_EXTENSIONS)));
- }
-
- /**
- * Serializes a test object to memory, a serializes into a new object
- * and returns that new object
- *
- * @param testObject The object to serialize
- * @return The deserialized object
- * @throws java.io.IOException Upon I/O error
- * @throws java.lang.ClassNotFoundException If one of the sub classes could not be found
- */
- protected DataTransferObject runThroughSerializerTransfer(DataTransferObject testObject)
- throws java.io.IOException, java.lang.ClassNotFoundException
- {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(bos);
- oos.writeObject(testObject);
-
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- ObjectInputStream ois = new ObjectInputStream(bis);
-
- DataTransferObject dto2 = (DataTransferObject) ois.readObject();
-
- return dto2;
- }
-
- /**
- * Run when every test completes
- *
- * @throws Exception upon error
- */
- protected void tearDown() throws Exception
- {
- dataTransferObject = null;
- mt = null;
- super.tearDown();
- }
-}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/tests/DBConnectionPoolTest.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.db.tests;
-
-import com.jcorporate.expresso.core.db.DBConnection;
-import com.jcorporate.expresso.core.db.DBConnectionPool;
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.core.db.exception.PoolFullException;
-import com.jcorporate.expresso.core.misc.DateTime;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-import junit.framework.TestSuite;
-
-
-/**
- * Unit test for the DBConnectionPool
- * @author Michael Rimov
- * @version $Revision: 1.8 $ on $Date: 2003/10/27 19:10:32 $
- */
-
-public class DBConnectionPoolTest extends ExpressoTestCase {
- static final int NUM_STRESS_THREADS = 60;
- static final int NUM_ITERATIONS = 20;
-
- /**
- * Default testing constructor
- * @param testName the Test Name
- * @throws java.lang.Exception
- */
- public DBConnectionPoolTest(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
- junit.textui.TestRunner.run(suite());
- }
-
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(DBConnectionPoolTest.class);
- }
-
- public void tearDown() {
- try {
- DBConnectionPool.getInstance(TestSystemInitializer.getTestContext()).disconnectAll();
- } catch (DBException ex) {
- }
- }
-
- /**
- * Tests to make sure basic connection pool capabilities are there.
- */
- public void testConnectionPool() {
- try {
- System.out.println("\nBegin connection pool tests:" +
- DateTime.getDateTimeString());
-
- DBConnectionPool myPool = DBConnectionPool.getInstance(TestSystemInitializer.getTestContext());
- int maxConnections = myPool.getMaxConnections();
- DBConnection connections[] = new DBConnection[maxConnections];
- System.out.println("Maximum connections in the pool is: " + maxConnections);
-
- for (int i = 0; i <= 5000; i++) {
- for (int j = 0; j < maxConnections; j++) {
- connections[j] = myPool.getConnection("Test " + j);
- }
-
- for (int j = 0; j < maxConnections; j++) {
- myPool.release(connections[j]);
- }
- }
-
- System.out.println("End connection pool tests:" +
- DateTime.getDateTimeString());
- } catch (DBException ex) {
- ex.printStackTrace();
- fail("Caught an exception attempting DBConnectionPool Test " + ex.getMessage());
- }
-
- }
-
- /**
- * This test attempts to check to make sure the new DBConnection.release()
- * method is working.
- */
- public void testNewRelease() {
- try {
- System.out.println("\nBegin new connection pool tests:" +
- DateTime.getDateTimeString());
-
- DBConnectionPool myPool = DBConnectionPool.getInstance(TestSystemInitializer.getTestContext());
- int maxConnections = myPool.getMaxConnections();
- DBConnection connections[] = new DBConnection[maxConnections];
- System.out.println("Maximum connections in the pool is: " + maxConnections);
-
- for (int i = 0; i <= 100; i++) {
- for (int j = 0; j < maxConnections; j++) {
- connections[j] = myPool.getConnection("Test " + j);
- connections[j].execute("SELECT COUNT(*) FROM CONTROLLERSECURITY");
- }
-
-
- for (int j = 0; j < maxConnections; j++) {
- myPool.release(connections[j]);
- }
- }
-
- System.out.println("End new connection pool tests:" +
- DateTime.getDateTimeString());
- } catch (DBException ex) {
- ex.printStackTrace();
- fail("Caught an exception attempting DBConnectionPool Test " + ex.getMessage());
- }
-
- }
-
- /**
- * In this test, we try to create the maximum number of connections and then
- * attempt to allocate one more. It should throw an exception or return
- * a connection.
- */
- public void testFullPool() {
- try {
- DBConnectionPool myPool = DBConnectionPool.getInstance(TestSystemInitializer.getTestContext());
- int maxConnections = myPool.getMaxConnections();
- DBConnection connections[] = new DBConnection[maxConnections];
- System.out.println("Maximum connections in the pool is: " + maxConnections);
-
- for (int j = 0; j < maxConnections; j++) {
- connections[j] = myPool.getConnection("Test " + j);
- }
-
- try {
- DBConnection breakConnection = myPool.getConnection("Breaking Connection");
- fail("The last connection SHOULD have thrown an exception");
- } catch(DBException dbe) {
- assertTrue("Must receive a PoolFullException",
- dbe instanceof PoolFullException);
- }
-
- for (int j=0; j < maxConnections;j++) {
- myPool.release(connections[j]);
- }
- }
- catch (DBException ex) {
- ex.printStackTrace();
- fail("Caught an exception attempting DBConnectionPool Test " + ex.getMessage());
- }
- }
-
- /**
- * Generates lots of threads that bang away on the connection pool attempting to
- * get it to die.
- */
- public void testConnectionPoolStressTest() {
- DBConnectionPoolStressThread theThreads[] = new DBConnectionPoolStressThread[NUM_STRESS_THREADS];
-
- for (int i = 0; i < NUM_STRESS_THREADS; i++) {
- theThreads[i] = new DBConnectionPoolStressThread("DBConnectionPool Thread " + i);
- }
-
- for (int i = 0; i < NUM_STRESS_THREADS; i++) {
- theThreads[i].start();
- }
-
- for (int i = 0; i < NUM_STRESS_THREADS; i++) {
- try {
- theThreads[i].join();
- } catch (InterruptedException ex) {
- }
- }
-
- boolean failures = false;
- for (int i = 0; i < NUM_STRESS_THREADS; i++) {
- System.out.println("Status for thread: " + theThreads[i].getName() +
- " number of pool fulls: " + theThreads[i].getNumPoolFulls() +
- " errors: " + theThreads[i].getErrors());
-
- if (theThreads[i].getErrors() != null) {
- failures = true;
- }
- }
-
- assertTrue("There were failures.", failures == false);
-
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/db/tests/DBConnectionPoolStressThread.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.db.tests;
-
-import com.jcorporate.expresso.core.db.DBConnection;
-import com.jcorporate.expresso.core.db.DBConnectionPool;
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.core.db.exception.PoolFullException;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-
-/**
- * Unit test to stress the DBConnectionPool
- * @author Michael Rimov
- * @version $Revision: 1.8 $ on $Date: 2004/09/22 05:29:16 $
- */
-
-public class DBConnectionPoolStressThread extends java.lang.Thread {
- protected String errorMessage = null;
- int numPoolFulls = 0;
-
-
- public DBConnectionPoolStressThread() {
- }
-
- public DBConnectionPoolStressThread(String threadName) {
- super(threadName);
- }
-
- public String getErrors() {
- return errorMessage;
- }
-
- public int getNumPoolFulls() {
- return numPoolFulls;
- }
-
- public void run() {
- try {
- DBConnectionPool myPool = DBConnectionPool.getInstance(TestSystemInitializer.getTestContext());
- /**@todo Override this java.lang.Thread method*/
- for (int i = 0; i < DBConnectionPoolTest.NUM_ITERATIONS; i++) {
- if (!this.isInterrupted()) {
- try {
- DBConnection oneConnection = myPool.getConnection();
- if (oneConnection == null) {
- errorMessage = "Received null connection from the connection pool.";
- }
- synchronized (this) {
- try {
- sleep(new java.util.Random().nextInt(50));
- } catch (InterruptedException ex) {
- }
- }
- oneConnection.release();
-// myPool.release(oneConnection);
- } catch (PoolFullException pfe) {
- numPoolFulls++;
- //We're ok, that's what we're trying to stress here.
- }
- } else {
- numPoolFulls++;
- break;
- }
- }
- } catch (DBException ex) {
- ex.printStackTrace();
- errorMessage = ex.getMessage();
- return;
- }
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/logging/tests/LogManagerTests.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.logging.tests;
-
-import org.apache.log4j.Logger;
-
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-
-
-/**
- * Unit test case for LogManager
- * @author Michael Rimov
- * @version $Revision: 1.11 $ on $Date: 2004/10/25 00:07:12 $
- * @since Expresso 5.0
- */
-public class LogManagerTests
- extends ExpressoTestCase {
-
- /**
- * Basic constructor - initializes the underlying Expresso configuration
- * system.
- */
- public LogManagerTests(String name)
- throws Exception {
- super(name);
- }
-
- /**
- * Tests the logging system for potential Exceptions.
- * @todo Automate this so we can verify that logging is automatically
- * working
- * @throws Exception if an error occurs while testing logging.
- */
- public void testLogging()
- throws Exception {
-
- Logger c = Logger.getLogger("com.jcorporate.expresso");
- c.info("Testing a Log to root output");
- c.error("This one though should actually print");
- c = Logger.getLogger("com.jcorporate.expresso.core");
- c.error("This is a test error message");
- c.info("This is a test info message");
- c.warn("This is a test warning");
- c = Logger.getLogger("com.jcorporate.expresso.services");
- c.error("This is a test error message");
- c.info("This is a test info message");
- c.warn("This is a test warning");
-
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests/TestDateTime.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.misc.tests;
-
-import com.jcorporate.expresso.core.misc.DateTime;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-import java.util.Calendar;
-import java.util.Date;
-
-/**
- * <p>Test case to verify DateTime utility class</p>
- * <p>Copyright: Copyright (c) 2001-2002</p>
- * <p>Company: JCorporate Ltd.</p>
- * @author Tommy Grovnes
- * @version $Revision: 1.6 $ on $Date: 2004/10/25 02:37:15 $
- */
-public class TestDateTime extends ExpressoTestCase {
-
- String myContext = TestSystemInitializer.getTestContext();
-
- public TestDateTime(String testName)
- throws Exception {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(TestDateTime.class);
- }
-
- public static void checkOKDate(String testName, String result) {
- assertTrue("Not null Return ", (result != null));
- assertTrue("Greater Than Zero Length Return ", (result.length() > 0));
- System.out.println(testName + " : result " + result);
- }
-
- public static void checkNullDate(String testName, String result) {
- assertTrue("Is Null Return ", (result == null));
- System.out.println(testName + " : result " + result);
- }
-
- public void testGoodDate() throws Exception {
-
- int year = 1969;
- int month = 4;
- int day = 22;
- int hour = 13;
- int min = 14;
- int sec = 15;
- Date date = new Date();
- Calendar aCalendar = Calendar.getInstance();
- aCalendar.set(year, month, day, hour, min, sec);
-
- System.out.println("=======================================");
- System.out.println("testGoodDate\n");
- System.out.println("year = " + year);
- System.out.println("month = " + month);
- System.out.println("day = " + day);
- System.out.println("hour = " + hour);
- System.out.println("min = " + min);
- System.out.println("sec = " + sec);
- System.out.println("date = " + date);
- System.out.println("");
-
- checkOKDate("getDateString()", DateTime.getDateString());
- checkOKDate("getDateTimeForDB()", DateTime.getDateTimeForDB());
- checkOKDate("getDateTimeForDB(myContext)",
- DateTime.getDateTimeForDB(myContext));
- checkOKDate("getDateTimeForDB(year, month, day, hour, min, sec, myContext)",
- DateTime.getDateTimeForDB(year, month, day, hour, min, sec, myContext));
- checkOKDate("getDateTimeForDB(date, myContext)",
- DateTime.getDateTimeForDB(date, myContext));
-// checkOKDate("getDateString(aCalendar)",
-// DateTime.getDateString(aCalendar));
- checkOKDate("getDateTimeForDB(year, month, day, hour, min, sec)",
- DateTime.getDateTimeForDB(year, month, day, hour, min, sec));
- checkOKDate("getDateTimeForDB(date)",
- DateTime.getDateTimeForDB(date));
- checkOKDate("getDateTimeString()",
- DateTime.getDateTimeString());
- checkOKDate("getDateTimeString(date)",
- DateTime.getDateTimeString(date));
- checkOKDate("getTimeForDB()", DateTime.getTimeForDB());
- checkOKDate("getTimeForDB(hour, min, sec)",
- DateTime.getTimeForDB(hour, min, sec));
- checkOKDate("getTimeForDB(date)", DateTime.getTimeForDB(date));
- checkOKDate("getTimeForDB(date, myContext)",
- DateTime.getTimeForDB(date, myContext));
- checkOKDate("getDateForDB()", DateTime.getDateForDB());
- checkOKDate("getDateForDB(year, month, day)",
- DateTime.getDateForDB(year, month, day));
- checkOKDate("getDateForDB(date)", DateTime.getDateForDB(date));
- checkOKDate("getDateForDB(date, myContext)",
- DateTime.getDateForDB(date, myContext));
- }
-
- public void testNullDate() throws Exception {
-
- Date date = null;
-
- System.out.println("=======================================");
- System.out.println("testNullDate\n");
-
- checkNullDate("getDateTimeForDB(date, myContext)",
- DateTime.getDateTimeForDB(date, myContext));
- checkNullDate("getDateTimeForDB(date)",
- DateTime.getDateTimeForDB(date));
- checkNullDate("getDateTimeString(date)",
- DateTime.getDateTimeString(date));
- checkNullDate("getTimeForDB(date)",
- DateTime.getTimeForDB(date));
- checkNullDate("getTimeForDB(date, myContext)",
- DateTime.getTimeForDB(date, myContext));
- checkNullDate("getDateForDB(date)",
- DateTime.getDateForDB(date));
- checkNullDate("getDateForDB(date, myContext)",
- DateTime.getDateForDB(date, myContext));
-
- }
-
- public void testBadDate1() throws Exception {
-
- int year = -1;
- int month = -1;
- int day = -1;
- int hour = -1;
- int min = -1;
- int sec = -1;
- Calendar aCalendar = Calendar.getInstance();
- aCalendar.set(year, month, day, hour, min, sec);
-
- System.out.println("=======================================");
- System.out.println("testBadDate\n");
- System.out.println("year = " + year);
- System.out.println("month = " + month);
- System.out.println("day = " + day);
- System.out.println("hour = " + hour);
- System.out.println("min = " + min);
- System.out.println("sec = " + sec);
- System.out.println("");
-
- System.out.println("getDateTimeForDB(year, month, day, hour, min, sec, myContext) : result "
- + DateTime.getDateTimeForDB(year, month, day, hour, min, sec, myContext));
-// System.out.println("getDateString(aCalendar) : result "
-// + DateTime.getDateString(aCalendar));
- System.out.println("getDateTimeForDB(year, month, day, hour, min, sec) : result "
- + DateTime.getDateTimeForDB(year, month, day, hour, min, sec));
- System.out.println("getTimeForDB(hour, min, sec) : result "
- + DateTime.getTimeForDB(hour, min, sec));
- System.out.println("getDateForDB(year, month, day) : result "
- + DateTime.getDateForDB(year, month, day));
-
- }
-
- public void testBadDate2() throws Exception {
-
- int year = 99999;
- int month = 99;
- int day = 99;
- int hour = 99;
- int min = 99;
- int sec = 99;
- Calendar aCalendar = Calendar.getInstance();
- aCalendar.set(year, month, day, hour, min, sec);
-
- System.out.println("=======================================");
- System.out.println("testBadDate2\n");
- System.out.println("year = " + year);
- System.out.println("month = " + month);
- System.out.println("day = " + day);
- System.out.println("hour = " + hour);
- System.out.println("min = " + min);
- System.out.println("sec = " + sec);
- System.out.println("");
-
- System.out.println("getDateTimeForDB(year, month, day, hour, min, sec," +
- " myContext) : result "
- + DateTime.getDateTimeForDB(year, month,
- day, hour, min, sec, myContext));
-// System.out.println("getDateString(aCalendar) : result " +
-// DateTime.getDateString(aCalendar));
- System.out.println("getDateTimeForDB(year, month, day, hour, min, sec) : result " +
- DateTime.getDateTimeForDB(year, month, day,
- hour, min, sec));
- System.out.println("getTimeForDB(hour, min, sec) : result " +
- DateTime.getTimeForDB(hour, min, sec));
- System.out.println("getDateForDB(year, month, day) : result " +
- DateTime.getDateForDB(year, month, day));
- }
-
-
- public static void main(String args[])
- throws Exception {
- TestRunner.run(suite());
- }
-
-}
-
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests/TestXmlDocTypeFilter.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.misc.tests;
-
-import com.jcorporate.expresso.core.misc.ConfigManager;
-import com.jcorporate.expresso.core.misc.XmlDocTypeFilter;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-import org.xml.sax.InputSource;
-
-import java.io.FileInputStream;
-
-
-/**
- * Unit test for XMLDocTypeFilter class
- * @author Michael Rimov
- * @version $Revision: 1.7 $ $Date: 2004/10/29 00:14:15 $
- */
-public class TestXmlDocTypeFilter
- extends ExpressoTestCase {
- public TestXmlDocTypeFilter(String testName)
- throws Exception {
- super(testName);
- }
-
-
- String configDir = null;
- XmlDocTypeFilter testClass = null;
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- }
-
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(TestXmlDocTypeFilter.class);
- }
-
- public void setUp() {
- configDir = ConfigManager.getConfigDir();
- assertTrue("configDir != null",
- (configDir != null && configDir.length() > 0));
-
- testClass = new XmlDocTypeFilter();
- }
-
- public void testParseExpressoConfig()
- throws Exception {
- String fileName = configDir + "/expresso-config.xml";
- FileInputStream fis = new FileInputStream(fileName);
- InputSource inputSource = new InputSource(fis);
- assertTrue("Proper Expresso Config Doctype",
- testClass.isProperDocType("expresso-config", inputSource) == true);
- fis.close();
- fis = new FileInputStream(fileName);
- inputSource = new InputSource(fis);
- assertTrue("Testing Wrong Expresso Config Doctype",
- testClass.isProperDocType("expresso-config-WRONG",
- inputSource) == false);
- }
-
- public void testParseStrutsConfig()
- throws Exception {
- String fileName = configDir + "/struts-config.xml";
- FileInputStream fis = new FileInputStream(fileName);
- InputSource inputSource = new InputSource(fis);
- assertTrue("Proper Struts Config Doctype",
- testClass.isProperDocType("struts-config", inputSource) == true);
- fis.close();
- fis = new FileInputStream(fileName);
- inputSource = new InputSource(fis);
- assertTrue("Testing Wrong Struts Config Doctype",
- testClass.isProperDocType("struts-config-WRONG",
- inputSource) == false);
- }
-
- public void testParseLoggingConfig()
- throws Exception {
- String fileName = configDir + "/expressoLogging.xml";
- FileInputStream fis = new FileInputStream(fileName);
- InputSource inputSource = new InputSource(fis);
- assertTrue("Proper Log4j Configuration Doctype",
- testClass.isProperDocType("log4j:configuration",
- inputSource) == true);
- fis.close();
- fis = new FileInputStream(fileName);
- inputSource = new InputSource(fis);
- assertTrue("Testing Wrong Log4j Config Doctype",
- testClass.isProperDocType("log4j:configuration-WRONG",
- inputSource) == false);
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests/HexEncoderTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.misc.tests;
-
-import com.jcorporate.expresso.core.misc.HexEncoder;
-import com.jcorporate.expresso.services.test.CommandLineParser;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-
-
-/**
- * Tests The HexEncoder Class. A Class that will take binary numbers and
- * product a Hexadecimal output.
- * @author Michael Rimov
- * @version $Revision: 1.6 $ on $Date: 2003/06/03 06:12:15 $
- */
-public class HexEncoderTest
- extends ExpressoTestCase {
- public HexEncoderTest(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- CommandLineParser.parseCommandLine(args);
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite() {
- return new TestSuite(HexEncoderTest.class);
- }
-
- /**
- * Tests to make sure both arrays are equal values.
- *
- * @param array1[]
- * @param array2[]
- * @return true if array1 and array2 have equal values contained in them.
- */
- private static boolean arraysAreEqual(byte[] array1, byte[] array2) {
- if (array1.length != array2.length) {
- return false;
- }
-
- int len = array1.length;
-
- for (int i = 0; i < len; i++) {
- if (array1[i] != array2[i]) {
- return false;
- }
- }
-
- return true;
- } /* arraysAreEqual(byte, byte) */
-
- /**
- * This test case makes sure that various byte values get properly
- * encoded and decoded back.
- * @throws Exception if an error occurs during encode/decode process
- */
- public void testHexEncode()
- throws Exception {
- byte[][] testArray = {
- {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}, {5, 6, 7, 8, 9, 0, 35, 62, 33},
- {(byte) 0x0A, (byte) 0xFF, (byte) 0xCA, (byte) 0xB1, (byte) 0x00, (byte) 0x42}
- };
-
- for (int i = 0; i < testArray.length; i++) {
- byte[] test = testArray[i];
- String encoded = HexEncoder.encode(test);
- byte[] decoded = HexEncoder.decode(encoded);
- assertTrue("Arrays Must Be Equal: i=" + i,
- arraysAreEqual(test, decoded));
- }
- }
-
- /**
- * This test makes sure that IllegalArgumentExceptions are thrown if
- * invalid inputs are given to the system.
- */
- public void testBadInputs()
- throws Exception {
- String[] breakDecode = {"ABA", "", "ABCDEFHLKAMABACD"};
-
- for (int i = 0; i < breakDecode.length; i++) {
- try {
- byte[] decoded = HexEncoder.decode(breakDecode[i]);
- fail("Didn't handle bad input " + breakDecode[i]);
- } catch (IllegalArgumentException ex) {
- }
- }
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests/FastStringBufferTest.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.misc.tests;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import com.jcorporate.expresso.kernel.util.FastStringBuffer;
-
-/**
- * Unit Test for FastStringBuffer
- * @author Michael Rimov
- * @version $Revision: 1.6 $ on $Date: 2004/03/01 08:11:38 $
- */
-
-public class FastStringBufferTest
- extends TestCase {
-
-
- public FastStringBufferTest(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- * @return instantiated TestSuite
- */
- public static junit.framework.Test suite() {
- return new TestSuite(FastStringBufferTest.class);
- }
-
- /**
- * Tests basic append and clear to make sure it's working.
- */
- public void testFastStringBuffer() {
- final String testValue = "abcdefghijklmnop";
- try {
- FastStringBuffer testBuffer = new FastStringBuffer(256);
- for (int j = 0; j < 100; j++) {
- assertTrue("Fresh FastStringBuffer should have zero length", testBuffer.length() == 0);
- assertTrue("Fresh FastStringBuffer should have empty string", "".equals(testBuffer.toString()));
-
- testBuffer.append(testValue);
- assertTrue("Must have proper value in test buffer.", testValue.equals(testBuffer.toString()));
- testBuffer.clear();
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Error performaing testFastStringBufferPool(): " + ex.getMessage());
- }
-
-
- }
-
-
- /**
- * Similar to above test, but we get the FastStringBuffer from the FastStringBuffer
- * pool instead
- */
- public void testFastStringBufferPool() {
- final String testValue = "abcdefghijklmnop";
-
- try {
- for (int j = 0; j < 100; j++) {
- FastStringBuffer testBuffer = FastStringBuffer.getInstance();
- try {
- assertTrue("Must receive non-null testBuffer from Pool", testBuffer != null);
- assertTrue("Buffer from pool must have 1k capacity", testBuffer.capacity() == 1024);
- assertTrue("Fresh value from the pool should have zero length", testBuffer.length() == 0);
- assertTrue("Fresh value from the pool should have empty string", "".equals(testBuffer.toString()));
-
- testBuffer.append(testValue);
- String resultValue = testBuffer.toString();
- assertTrue("Must have proper value in test buffer. Got '" + resultValue + "' instead", testValue.equals(resultValue));
- } finally {
- testBuffer.release();
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Error performaing testFastStringBufferPool(): " + ex.getMessage());
- }
- }
-
- public void testFastStringBufferPoolWithOverlap() {
- final String testValue = "abcdefghijklmnop";
-
- try {
- for (int j = 0; j < 100; j++) {
- FastStringBuffer overlapBuffer = FastStringBuffer.getInstance();
- FastStringBuffer testBuffer = FastStringBuffer.getInstance();
- try {
- assertTrue("Must receive non-null testBuffer from Pool", testBuffer != null);
- overLapFastStringBuffer();
- assertTrue("Buffer from pool must have 1k capacity", testBuffer.capacity() == 1024);
- overLapFastStringBuffer();
- assertTrue("Fresh value from the pool should have zero length", testBuffer.length() == 0);
- overLapFastStringBuffer();
- assertTrue("Fresh value from the pool should have empty string", "".equals(testBuffer.toString()));
- overLapFastStringBuffer();
-
- testBuffer.append(testValue);
- String resultValue = testBuffer.toString();
- assertTrue("Must have proper value in test buffer. Got '" + resultValue + "' instead", testValue.equals(resultValue));
- overLapFastStringBuffer();
- } finally {
- overlapBuffer.release();
- testBuffer.release();
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Error performaing testFastStringBufferPool(): " + ex.getMessage());
- }
- }
-
- private void overLapFastStringBuffer() {
- FastStringBuffer fsb = FastStringBuffer.getInstance();
- fsb.append("WHERE MIMETYPES = 2");
- fsb.append("AND WHOKNOW'S WHAT = 4");
- fsb.toString();
- fsb.release();
- }
-
-
- public void testFastStringBufferPoolWithOverflow() {
-// final String testValue ="abcdefghijklmnop";
-
- try {
- for (int j = 0; j < 100; j++) {
- FastStringBuffer testBuffer = FastStringBuffer.getInstance();
- try {
- assertTrue("Must receive non-null testBuffer from Pool", testBuffer != null);
- assertTrue("Buffer from pool must have 1k capacity j=" + j + " got " + testBuffer.capacity() + " instead.", testBuffer.capacity() == 1024);
- assertTrue("Fresh value from the pool should have zero length", testBuffer.length() == 0);
- assertTrue("Fresh value from the pool should have empty string", "".equals(testBuffer.toString()));
- for (int i = 0; i < 2048; i++) {
- testBuffer.append("a");
- }
- assertTrue("Must have proper length in test buffer got " + testBuffer.length() + " instead", testBuffer.length() == 2048);
- } finally {
- testBuffer.release();
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Error performaing testFastStringBufferPool(): " + ex.getMessage());
- }
-
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests/CookieBase64Test.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.misc.tests;
-
-import com.jcorporate.expresso.core.misc.CookieBase64;
-import com.jcorporate.expresso.services.test.CommandLineParser;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-
-
-/**
- * Unit tests for Base64-ish encoding for cookies
- * @author Michael Rimov
- * @version $Revision: 1.6 $ $Date: 2003/06/03 06:12:15 $
- */
-public class CookieBase64Test
- extends ExpressoTestCase {
- final String[] testString = {
- "a", "ab", "abc", "abcd", "abcde", "ABC", "ABCDE", "abcdef", "abcdefg",
- "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@",
- "#$%^&*()_+1234567890<>,.:\"\\"
- };
- final byte[] test3 = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 120, 54, -125, 30, (byte) 0xFF
- };
-
- public CookieBase64Test(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- CommandLineParser.parseCommandLine(args);
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(CookieBase64Test.class);
- }
-
- /**
- * Tests the proprietary non-padding Base64 scheme. (No ='s at the end)
- */
- public void testCookieBase64() {
- int i;
-
- for (i = 0; i < testString.length; i++) {
- String arrayPartEncode = CookieBase64.encodeNoPadding(
- testString[i].getBytes());
- String arrayPartDecode = new String(CookieBase64.decodeNoPadding(
- arrayPartEncode));
- assertTrue("CookieBase64 Test: Test Data " + testString[i],
- arrayPartDecode.equals(testString[i]));
- assertTrue("Greater Than Zero Length Return " + testString[i],
- arrayPartEncode.length() > 0);
- assertTrue("No Padding", arrayPartEncode.indexOf('=') == -1);
- }
-
- //Test3
- String encode3 = CookieBase64.encodeNoPadding(test3);
- byte[] decode3 = CookieBase64.decodeNoPadding(encode3);
-
- for (i = 0; i < decode3.length; i++) {
- assertTrue("Binary Input Data i=" + Integer.toString(i),
- test3[i] == decode3[i]);
- }
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests/FileUtilTests.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-package com.jcorporate.expresso.core.misc.tests;
-
-import com.jcorporate.expresso.core.misc.FileUtil;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-
-/**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: </p>
- * <p>Company: </p>
- * @author Michael Rimov
- * @version $Revision: 1.2 $ on $Date: 2004/02/11 06:14:07 $
- */
-
-public class FileUtilTests extends ExpressoTestCase
-{
-
-
-
- public FileUtilTests(String name) throws Exception
- {
- super(name);
- }
-
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite() {
- return new TestSuite(FileUtilTests.class);
- }
-
- /**
- * Tests the file extension parser to make sure it's grabbing the right
- * values.
- */
- public void testFileExtensions() {
- String result = FileUtil.getExtension("abc");
- assertTrue("".equals(result));
-
- result = FileUtil.getExtension("abc.d");
- assertTrue("d".equals(result));
-
- result = FileUtil.getExtension("abc.d.efg");
- assertTrue("efg".equals(result));
-
- }
-
- /**
- * Tests to make sure path parsing is correct.
- */
- public void testGetPath() {
- String test = "/tmp/usr/abcd/abcdefg.jkh";
- String result = FileUtil.getPath(test);
- assertTrue("/tmp/usr/abcd".equals(result));
-
- test = "c:\\windows\\test\\krnl386.exe";
- result = FileUtil.getPath(test);
- assertTrue("c:\\windows\\test".equals(result));
-
- }
-
- /**
- * Tests the getBase
- */
- public void testGetBase() {
- String test = "/tmp/usr/abcd/abcdefg.jkh";
- String result = FileUtil.getBase(test);
- assertTrue("abcdefg".equals(result));
-
- test = "c:\\windows\\test\\krnl386.exe";
- result = FileUtil.getBase(test);
- assertTrue("krnl386".equals(result));
-
-
- }
-
-
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests/Base64Test.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.misc.tests;
-
-import com.jcorporate.expresso.core.misc.Base64;
-import com.jcorporate.expresso.services.test.CommandLineParser;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-
-
-/**
- * Unit tests for the Base64 encoding class
- * @author Michael Rimov
- * @version $Revision: 1.6 $ $Date: 2003/06/03 06:12:15 $
- */
-public class Base64Test
- extends ExpressoTestCase {
- final String[] testString = {
- "a", "ab", "abc", "abcd", "abcde", "ABC", "ABCDE", "abcdef", "abcdefg",
- "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@",
- "#$%^&*()_+1234567890<>,.:\"\\"
- };
- final byte[] test3 = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, -1, 120, 54, -125, 30, (byte) 0xFF
- };
-
- public Base64Test(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- CommandLineParser.parseCommandLine(args);
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Filler Function to conform to log4j test suites.
- */
- public static junit.framework.Test suite() {
- return new TestSuite(Base64Test.class);
- }
-
- /**
- * Tests a normal base64 operation.
- */
- public void testBase64WithPadding() {
- int i;
-
- for (i = 0; i < testString.length; i++) {
- String arrayPartEncode = Base64.encode(testString[i].getBytes());
- String arrayPartDecode = new String(Base64.decode(arrayPartEncode));
- assertTrue("Base64 Test: Test Data " + testString[i],
- arrayPartDecode.equals(testString[i]));
- assertTrue("Greater Than Zero Length Return " + testString[i],
- arrayPartEncode.length() > 0);
- }
-
- //Test3
- String encode3 = Base64.encode(test3);
- byte[] decode3 = Base64.decode(encode3);
-
- for (i = 0; i < decode3.length; i++) {
- assertTrue("Binary Input Data i=" + Integer.toString(i),
- test3[i] == decode3[i]);
- }
- }
-
- /**
- * Tests the proprietary non-padding Base64 scheme. (No ='s at the end)
- */
- public void testBase64NoPadding() {
- int i;
-
- for (i = 0; i < testString.length; i++) {
- String arrayPartEncode = Base64.encodeNoPadding(
- testString[i].getBytes());
- String arrayPartDecode = new String(Base64.decodeNoPadding(
- arrayPartEncode));
- assertTrue("Base64 Test: Test Data " + testString[i],
- arrayPartDecode.equals(testString[i]));
- assertTrue("Greater Than Zero Length Return " + testString[i],
- arrayPartEncode.length() > 0);
- assertTrue("No Padding", arrayPartEncode.indexOf('=') == -1);
- }
-
- //Test3
- String encode3 = Base64.encodeNoPadding(test3);
- byte[] decode3 = Base64.decodeNoPadding(encode3);
- assertTrue("Greater Than Zero Length Return [binary]",
- decode3.length > 0);
-
- for (i = 0; i < decode3.length; i++) {
- assertTrue("Binary Input Data i=" + Integer.toString(i),
- test3[i] == decode3[i]);
- }
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/core/misc/tests/CookieTests.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.core.misc.tests;
-
-import com.jcorporate.expresso.core.misc.CookieUtil;
-import com.jcorporate.expresso.core.security.CryptoManager;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import junit.framework.TestSuite;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-
-
-/**
- * Tests cookie encryption
- * @author Michael Rimov
- * @version $Revision: 1.7 $ $Date: 2004/10/18 17:42:19 $
- */
-public class CookieTests
- extends ExpressoTestCase {
- boolean usingStrongCrypto;
-
- public CookieTests(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- TestSystemInitializer.setUp();
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- }
-
- public static junit.framework.Test suite()
- throws Exception {
- return new TestSuite(CookieTests.class);
- }
-
- /**
- * Make sure we put back the CryptoManager into the condition we found it.
- * @throws Exception upon error
- */
- public void setUp()
- throws Exception {
- usingStrongCrypto = CryptoManager.getInstance().isUsingStrongCrypto();
- }
-
- public void tearDown()
- throws Exception {
- CryptoManager.getInstance().loadClasses(usingStrongCrypto);
- }
-
- /**
- * Test given the various crypto manager classes being loaded
- * @todo: We need to validate that there are no illegal URL characters
- * in the encoded cookies
- * @throws Exception upon error
- */
- public void testCookieEncryption()
- throws Exception {
- CryptoManager cm = CryptoManager.getInstance();
-
- //Test Strong Encryption
- cm.loadClasses(true);
-
- //Quirk - Make the Empty String the last case no matter how many
- //others you add into test array
- String[] testArray = {
- "abcdefghijklmnopqrstuvwxyz",
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#$%^&*()_+", "abc", "rimo\n",
- "rimo\b\r\0", "rimovm01", "9123123456789", "^\"\\...//?.<>", ""
- };
- int i;
-
- for (i = 0; i < testArray.length; i++) {
- String encode = CookieUtil.cookieEncode(testArray[i]);
- String decode = CookieUtil.cookieDecode(encode);
-
- if (i < testArray.length - 1) {
- assertTrue("Greater Than Zero Length Return " + testArray[i],
- encode.length() > 0);
- }
-
- assertTrue("testEncryptionMode: testArray[i]",
- decode.equals(testArray[i]));
- }
-
- // Test With Weak Encryption Installed
- cm.loadClasses(false);
-
- for (i = 0; i < testArray.length; i++) {
- String encode = CookieUtil.cookieEncode(testArray[i]);
- String decode = CookieUtil.cookieDecode(encode);
- assertTrue("testEncryptionMode: testArray[i]",
- decode.equals(testArray[i]));
- }
- }
-}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/tests/DBObjStressTest.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.ext.tests;
-
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
-import com.jcorporate.expresso.core.misc.ConfigManager;
-import com.jcorporate.expresso.core.misc.ConfigurationException;
-import com.jcorporate.expresso.kernel.ConsoleInstallLog;
-import com.jcorporate.expresso.kernel.InstallLog;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import com.jcorporate.expresso.services.test.SchemaCreator;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-import junit.framework.TestSuite;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-
-/**
- * Stress Test for 5019 DBObjects
- * @author Michael Rimov
- * @version $Revision: 1.13 $ $Date: 2004/10/24 23:57:39 $
- */
-public class DBObjStressTest
- extends ExpressoTestCase {
- static final int NUM_THREADS = 1;
- static final int NUM_ITERATIONS = 10;
- private long startTime = 0;
- private ArrayList threadList = new ArrayList(NUM_THREADS);
-
- public DBObjStressTest(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Define the suite of tests that verify each function of the cache
- *
- * @return
- */
- public static junit.framework.Test suite() {
- TestSuite suite = new TestSuite(DBObjStressTest.class);
-
- return suite;
- } /* suite() */
-
-
- public void testStressDBObjects() {
- System.out.println("Starting testStressDBObjects()");
-
- for (int i = 0; i < NUM_THREADS; i++) {
- StressThread st = new StressThread(NUM_ITERATIONS,
- SecuredDBObject.SYSTEM_ACCOUNT);
- threadList.add(st);
- st.start();
- }
-
- boolean successfullOperation = true;
-
- for (Iterator i = threadList.iterator(); i.hasNext();) {
- System.out.println("Waiting for thread");
-
- StressThread st = (StressThread) i.next();
-
- try {
- if (st.isAlive()) {
- st.join();
- }
- } catch (InterruptedException ie) {
- }
-
- assertTrue("Thread is dead", !st.isAlive());
- successfullOperation &= st.getSuccess();
- }
-
- assertTrue("All Threads Successfull", successfullOperation == true);
-
- try {
- StressTestObject sto = new StressTestObject(SecuredDBObject.SYSTEM_ACCOUNT);
- sto.setDataContext(TestSystemInitializer.getTestContext());
- assertTrue("Check all records deleted", sto.count() == 0);
- } catch (DBException dbe) {
- dbe.printStackTrace();
- fail("Caught DBException trying to count records. " +
- dbe.getMessage());
- }
- }
-
- /**
- * Sets up the fixture, for example, open a network connection.
- * This method is called before a test is executed.
- *
- * @throws Exception
- */
- protected void setUp()
- throws Exception {
- TestSystemInitializer.setUp();
- try {
- ConfigManager.getContext(TestSystemInitializer.getTestContext());
- } catch (ConfigurationException ce) {
- fail("There is no 'test' db/context set up - cannot run db object tests without a test context");
- }
-
- InstallLog installLog = new ConsoleInstallLog();
-
- StressTestSchema ts = new StressTestSchema();
- SchemaCreator.ensureSchemaExists(new com.jcorporate.expresso.core.ExpressoSchema(), installLog);
- SchemaCreator.ensureSchemaExists(ts, installLog);
- startTime = new java.util.Date().getTime();
- } /* setUp() */
-
-
- /**
- * Tears down the fixture, for example, close a network connection.
- * This method is called after a test is executed.
- *
- * @throws Exception
- */
- protected void tearDown()
- throws Exception {
- long endTime = new java.util.Date().getTime();
- System.out.println("Current Threading Tests Took: " +
- Long.toString(endTime - startTime) + " ms.");
-
- //This test should be run alone... destroy things when we're done.
- ConfigManager.destroy();
-
- // try {
- // StressTestSchema ts = new StressTestSchema();
- // SchemaDeleter.deleteSchema("test", ts);
- // } catch (DBException de) {
- // log.error(de);
- // fail("Unable to clean up test object tables");
- // }
- } /* tearDown() */
-
-
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/tests/RetrieveThroughputTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.ext.tests;
-
-import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
-import com.jcorporate.expresso.core.misc.ConfigManager;
-import com.jcorporate.expresso.core.misc.ConfigurationException;
-import com.jcorporate.expresso.services.dbobj.DefaultUserInfo;
-import com.jcorporate.expresso.services.dbobj.MimeTypes;
-import com.jcorporate.expresso.services.test.ExpressoTestCase;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-import junit.framework.TestSuite;
-
-/**
- * <p>Title: </p>
- * <p>Description: </p>
- * <p>Copyright: </p>
- * <p>Company: </p>
- * @author Michael Rimov
- * @version $Revision: 1.4 $ on $Date: 2004/10/24 23:57:39 $
- */
-
-public class RetrieveThroughputTest extends ExpressoTestCase {
- static final int NUM_ITERATIONS = 1000;
- private long startTime = 0;
-
-
- public RetrieveThroughputTest(String testName)
- throws Exception {
- super(testName);
- }
-
- public static void main(String[] args)
- throws Exception {
-
- //Set the system properties we need
- junit.textui.TestRunner.run(suite());
- }
-
- /**
- * Define the suite of tests that verify each function of the cache
- *
- * @return
- */
- public static junit.framework.Test suite() {
- TestSuite suite = new TestSuite(RetrieveThroughputTest.class);
-
- return suite;
- } /* suite() */
-
- /**
- * Sets up the fixture, for example, open a network connection.
- * This method is called before a test is executed.
- *
- * @throws Exception
- */
- protected void setUp()
- throws Exception {
- TestSystemInitializer.setUp();
- try {
- ConfigManager.getContext(TestSystemInitializer.getTestContext());
- } catch (ConfigurationException ce) {
- fail("There is no 'test' db/context set up - cannot run db object tests without a test context");
- }
-
-// StressTestSchema ts = new StressTestSchema();
-// SchemaCreator.ensureSchemaExists(new com.jcorporate.expresso.core.ExpressoSchema());
-// SchemaCreator.ensureSchemaExists(ts);
- startTime = new java.util.Date().getTime();
- } /* setUp() */
-
- public void testRetrieve() {
- try {
- MimeTypes mt = new MimeTypes(SecuredDBObject.SYSTEM_ACCOUNT);
- mt.setDataContext(TestSystemInitializer.getTestContext());
- mt.setField(MimeTypes.FLD_MIMENUMBER,1);
- mt.retrieve();
- startTime = System.currentTimeMillis();
- for (int i=0; i < NUM_ITERATIONS; i++) {
- mt.retrieve();
- }
- long endTime = System.currentTimeMillis();
- System.out.println("Throughput for retrieving MimeTypes was: " + (endTime - startTime) / NUM_ITERATIONS + " ms per retrieval");
-
-
-
- DefaultUserInfo dui = new DefaultUserInfo(SecuredDBObject.SYSTEM_ACCOUNT);
- dui.setDataContext(TestSystemInitializer.getTestContext());
- dui.setField(DefaultUserInfo.EXPUID,3);
- dui.retrieve();
- startTime = System.currentTimeMillis();
- for (int i=0; i < NUM_ITERATIONS; i++) {
- dui.retrieve();
- }
- endTime = System.currentTimeMillis();
- System.out.println("Throughput for retrieving DefaultUserInfo was: " + (endTime - startTime) / NUM_ITERATIONS + " ms per retrieval");
-
- } catch (Exception e) {
- e.printStackTrace();
- fail("Exception caught while testing");
- }
-
- }
-
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/tests/StressThread.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.ext.tests;
-
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.services.test.TestSystemInitializer;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import com.jcorporate.expresso.core.registry.ExpressoThread;
-
-
-/**
- * Thread that stresses DBObjects.
- * <p>
- * Assumption - to simulate real life stuff, we're gonna
- * assume that reads to updates have a ratio of 4 to 1
- * </p>
- * @author Michael Rimov
- * @version $Revision: 1.10 $ $Date: 2004/11/09 15:19:20 $
- */
-public class StressThread
- extends ExpressoThread {
- static final int NUM_RECORDS = 60;
- ArrayList myIds = new ArrayList(NUM_RECORDS);
- int numLoops;
- int userUid;
- boolean success = true;
- int maxID = 0;
-
- public StressThread(int loops, int uid) {
- numLoops = loops;
- userUid = uid;
- }
-
- public boolean getSuccess() {
- return success;
- }
-
- public void run() {
- super.run();
- try {
- for (int i = 0; i < numLoops; i++) {
- addTestObjects();
- System.gc();
- retrieveTestObjects();
- System.gc();
- updateTestObjects();
- System.gc();
- searchAndRetrieveTestObjects();
- System.gc();
- deleteTestObjects();
- }
- } catch (DBException dbe) {
- success = false;
- System.out.println(dbe.getMessage());
- dbe.printStackTrace();
- }
- }
-
- protected void addTestObjects()
- throws DBException {
- StressTestObject sto = new StressTestObject(userUid);
- sto.setDataContext(TestSystemInitializer.getTestContext());
- sto.setField("SomeData", "abcdefg");
- sto.setField("SomeMoreData", "hijklmnop");
-
- for (int i = 0; i < NUM_RECORDS; i++) {
- sto.add();
- myIds.add(sto.getField("RecordID"));
- }
-
- maxID = Integer.parseInt(sto.getField("RecordID"));
- }
-
- /**
- * Performs a repeated retrieve and update for each object
- */
- protected void updateTestObjects()
- throws DBException {
- StressTestObject sto = new StressTestObject(userUid);
- sto.setDataContext(TestSystemInitializer.getTestContext());
-
- for (Iterator i = myIds.iterator(); i.hasNext();) {
- sto.setField("RecordID", (String) i.next());
- sto.retrieve();
- sto.setField("SomeData", "oser");
- sto.setField("SomeMoreData", "good morning vietnam");
- sto.update();
- }
- }
-
- /**
- * Does a batch of searchAndRetrieve Lists grabbing only the first 50 records.
- */
- protected void searchAndRetrieveTestObjects()
- throws DBException {
- StressTestObject sto = new StressTestObject(userUid);
- sto.setDataContext(TestSystemInitializer.getTestContext());
- sto.setMaxRecords(25);
-
- for (int i = 0; i < 20; i++) {
- ArrayList al = sto.searchAndRetrieveList();
-
- if (al.size() == 0) {
- throw new DBException("ArrayList was empty");
- }
- }
- }
-
- protected void retrieveTestObjects()
- throws DBException {
- StressTestObject sto = new StressTestObject(userUid);
- sto.setDataContext(TestSystemInitializer.getTestContext());
-
- for (int j = 0; j < 5; j++) {
- for (Iterator i = myIds.iterator(); i.hasNext();) {
- sto.clear();
- sto.setField("RecordID", (String) i.next());
- sto.retrieve();
- }
- }
- }
-
- protected void deleteTestObjects()
- throws DBException {
- StressTestObject sto = new StressTestObject(userUid);
- sto.setDataContext(TestSystemInitializer.getTestContext());
-
- for (Iterator i = myIds.iterator(); i.hasNext();) {
- sto.setField("RecordID", (String) i.next());
-
- if (sto.find()) {
- sto.delete();
- }
- }
-
- myIds = new ArrayList(NUM_RECORDS);
- }
-}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/tests/StressTestSchema.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.ext.tests;
-
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.core.dbobj.Schema;
-
-
-/**
- * Schema for stress testing
- * @author Michael Rimov
- * @version $Revision: 1.6 $ $Date: 2003/06/03 06:12:20 $
- */
-public class StressTestSchema
- extends Schema {
- public StressTestSchema()
- throws DBException {
- super();
-
- try {
-
- /* Database objects */
- addDBObject(com.jcorporate.expresso.ext.tests.StressTestObject.class);
- } catch (Exception e) {
- throw new DBException(e);
- }
- }
-
- public String getDefaultDescription() {
- return "Stress Test Schema";
- }
-
- public String getDefaultComponentCode() {
- return "stressTest";
- }
-
- public String getMessageBundlePath() {
- return "/";
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/tests/StressTestObject.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.ext.tests;
-
-import com.jcorporate.expresso.core.controller.ControllerRequest;
-import com.jcorporate.expresso.core.db.DBConnection;
-import com.jcorporate.expresso.core.db.DBException;
-import com.jcorporate.expresso.core.dbobj.DBObject;
-import com.jcorporate.expresso.core.dbobj.SecuredDBObject;
-
-
-/**
- * An actual Stess test DBObject
- * @author Michael Rimov
- * @version $Revision: 1.9 $ $Date: 2004/10/24 23:57:39 $
- */
-public class StressTestObject
- extends SecuredDBObject {
-
- /**
- * @see com.jcorporate.expresso.core.dbobj.SecuredDBObject#SecuredDBObject
- *
- * @throws DBException
- */
- public StressTestObject()
- throws DBException {
- super();
- } /* UserDBObj() */
-
- /**
- * Constructor
- * Creation date: (8/9/00 5:44:22 PM)
- * @author
- *
- * @param dbConnection com.jcorporate.expresso.core.db.DBConnection
- * @throws DBException
- */
- public StressTestObject(DBConnection dbConnection)
- throws DBException {
- super(dbConnection);
- } /* UserDBObj(DBConnection) */
-
- /**
- *
- */
- public StressTestObject(int uid)
- throws DBException {
- super(uid);
- }
-
- /**
- * For using DBObjects within Controllers. Initializes based upon the current
- * user and the requested db. [Of course this can be modified later]
- *
- * @param request - The controller request handed to you by the framework.
- */
- public StressTestObject(ControllerRequest request)
- throws DBException {
- super(request);
- }
-
- public DBObject getThisDBObj()
- throws com.jcorporate.expresso.core.db.DBException {
- return (DBObject) new StressTestObject();
- }
-
- /**
- * Overrides add() by autoincrementing the rewards ID, and also setting the
- * dateJoinedField()
- */
- public synchronized void add()
- throws com.jcorporate.expresso.core.db.DBException {
- setField("UpdateCount", "0");
- super.add();
- }
-
- public synchronized void update()
- throws com.jcorporate.expresso.core.db.DBException {
- int fieldCount = this.getFieldInt("UpdateCount");
- fieldCount++;
- this.setField("UpdateCount", Integer.toString(fieldCount));
- super.update();
- }
-
- protected void setupFields()
- throws com.jcorporate.expresso.core.db.DBException {
- setTargetTable("EXPRESSOSTRESS");
- setDescription("Expresso Stress Test Table");
- setCharset("ISO-8859-1");
- addField("RecordID", "auto-inc", 0, false, "Record ID Number");
- addField("UpdateCount", "int", 0, false, "Update Count");
- addField("SomeData", "varchar", 256, false, "Some Random Data");
- addField("SomeMoreData", "varchar", 256, false, "Some More RandomData");
- addKey("RecordID");
- }
-}
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/digester/test/TestComponentMetadataConfig.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-package com.jcorporate.expresso.kernel.digester.test;
-
-import com.jcorporate.expresso.kernel.digester.ComponentMetadataConfig;
-import com.jcorporate.expresso.kernel.metadata.ComponentMetadata;
-import com.jcorporate.expresso.kernel.metadata.ControllerData;
-import com.jcorporate.expresso.kernel.metadata.DBObjectData;
-import com.jcorporate.expresso.kernel.metadata.JobData;
-import com.jcorporate.expresso.kernel.metadata.ReportData;
-import com.jcorporate.expresso.kernel.metadata.SchemaData;
-import junit.framework.TestCase;
-
-import java.util.List;
-
-/** JUnitTest case for class: com.jcorporate.expresso.kernel.digester.ComponentMetadataConfig */
-public class TestComponentMetadataConfig extends TestCase {
-
- public TestComponentMetadataConfig(String _name) {
- super(_name);
- }
-
- /** test for method loadComponentMetadata(..) */
- public void testLoadComponentMetadata() {
- ComponentMetadataConfig esc;
- try {
- esc = new ComponentMetadataConfig();
- esc.loadComponentMetadata("/com/jcorporate/expresso/kernel/digester/test/SampleConfig.xml");
- } catch (Exception ex) {
- fail("Error attempting to digest services file");
- return;
- }
-
- ComponentMetadata metadata = esc.getMetadata();
- assertTrue("Must have metadata", metadata != null);
- assertTrue("Must have a valid name", metadata.getName().equals("test"));
- assertTrue("Must have a valid version", metadata.getVersionNumber().equals("1.2.3"));
- assertTrue("Must have a valid description", metadata.getDescription().equals("Test Component"));
- assertTrue("Must have valid message bundle path",
- metadata.getMessageBundle()
- .equals("/com/jcorporate/expresso/core/Messages.properties"));
- SchemaData sd = metadata.getSchemaData();
- assertTrue("Must have a Schema metadata", sd != null);
- List list = sd.getControllers();
- assertTrue("Must have controllers", list != null && list.size() == 1);
- assertTrue("First controller is DBMaint", ((ControllerData) list.get(0))
- .getClassName().equals(
- "com.jcorporate.expresso.services.controller.DBMaint"));
- list = sd.getDataObjects();
- assertTrue("Must have data objects",list != null && list.size() == 1);
- assertTrue("First data object is MimeTypes", ((DBObjectData) list.get(0))
- .getClassName().equals("com.jcorporate.expresso.services.dbobj.MimeTypes"));
- list = sd.getJobs();
- assertTrue("Must have jobs", list != null && list.size() == 1);
- assertTrue("First job is test jobs",((JobData) list.get(0)).
- getClassName().equals("com.jcorporate.expresso.services.job.TestJob"));
- list = sd.getReports();
- assertTrue("Must have reports",list != null && list.size() == 1);
- assertTrue("First report is test report", ((ReportData) list.get(0)).
- getClassName().equals("com.jcorporate.expresso.ext.report.TestReport"));
-
- List nested = metadata.getChildren();
- assertTrue("Must have child components",nested != null && nested.size() == 1);
- ComponentMetadata oneNested = (ComponentMetadata) nested.get(0);
- assertTrue("Checking nested component description", oneNested.getDescription().equals("Sample Nested Do Nothing Component"));
- assertTrue("Checking nested component name", oneNested.getName().equals("nested1"));
- assertTrue("Checking nested component version number",oneNested.getVersionNumber().equals("4.5.6"));
- }
-
- /** Executes the test case
- * @param argv the command line arguments
- */
- public static void main(String[] argv) {
- String[] testCaseList = {TestComponentMetadataConfig.class.getName()};
- junit.textui.TestRunner.main(testCaseList);
- }
-}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/digester/test/TestExpressoServicesConfig.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2003 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-package com.jcorporate.expresso.kernel.digester.test;
-
-import com.jcorporate.expresso.kernel.digester.ComponentConfig;
-import com.jcorporate.expresso.kernel.digester.ExpressoServicesConfig;
-import junit.framework.TestCase;
-
-/** JUnitTest case for class: com.jcorporate.expresso.kernel.digester.ExpressoServicesConfig */
-public class TestExpressoServicesConfig extends TestCase {
-
- public TestExpressoServicesConfig(String _name) {
- super(_name);
- }
-
- /** setUp method for test case */
- protected void setUp() {
- }
-
- /** tearDown method for test case */
- protected void tearDown() {
- }
-
- /** test for method loadExpressoServices(..) */
- public void testLoadExpressoServices() {
- try {
- ExpressoServicesConfig esc = new ExpressoServicesConfig();
- esc.setExpressoServicesFile(com.jcorporate.expresso.kernel.test
- .TestComponentSystem.class.getResource("Test1ExpressoServices.xml"));
- esc.loadExpressoServices();
- } catch (Exception ex) {
- fail("Error attempting to digest services file");
- }
- }
-
- /** test for method setExpressoServicesFile(..) */
- public void testExpressoServicesFileContents() {
- try {
- ExpressoServicesConfig esc = new ExpressoServicesConfig();
- esc.setExpressoServicesFile(com.jcorporate.expresso.kernel.test.TestComponentSystem.class.getResource("Test1ExpressoServices.xml"));
- esc.loadExpressoServices();
- ComponentConfig root = esc.getRootConfig();
- assertTrue(root != null);
- assertTrue("Must have some child components got null instead", root.getChildComponents() != null);
- assertTrue("Should have one child component. Got " + root.getChildComponents().size() + " instead.",
- root.getChildComponents().size() == 1);
- assertTrue("Should have four properties. Got " + ((ComponentConfig) root.getChildComponents().get(0)).getProperties().size() + " instead"
- , ((ComponentConfig) root.getChildComponents().get(0)).getProperties().size() == 4);
- } catch (Exception ex) {
- fail("Error attempting to digest services file");
- }
- }
-
- /** Executes the test case
- * @param argv The command line arguments
- * */
- public static void main(String[] argv) {
- String[] testCaseList = {TestExpressoServicesConfig.class.getName()};
- junit.textui.TestRunner.main(testCaseList);
- }
-}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/digester/test/SampleConfig.xml
+++ /dev/null
@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<component-metadata name="test">
- <description>Test Component</description>
- <version-info>
- <major-version>1</major-version>
- <minor-version>2</minor-version>
- <micro-version>3</micro-version>
- </version-info>
- <message-bundle>/com/jcorporate/expresso/core/Messages.properties</message-bundle>
- <property-list>
- <!-- value= default value. -->
- <property name="testProperty" value="true" type="java.lang.Boolean" description="A simple property" access="readwrite"/>
- <property name="testDropdown" value="ab" type="java.lang.String" description="A dropdown property" access="readwrite">
- <property-valid-value name="a" value="A value"/>
- <property-valid-value name="ab" value="AB value"/>
- <property-valid-value name="abc" value="ABC value"/>
- <property-valid-value name="abcd" value="ABCD value"/>
- <property-valid-value name="abcde" value="ABCDE value"/>
- </property>
-<!-- Not supported yet
- <array-property name="" type="" description="" access="">
- <array-property-value value=""/>
- </array-property>
- <mapped-property name="" description="" access="">
- <mapped-value key="" type="" value=""/>
- </mapped-property>
--->
- </property-list>
- <method-list>
- <method name="getDataObjects" return-type="java.util.List" description="Retrieve all embedded DBObjects">
- <method-arg name="list" type="java.lang.Integer"/>
- </method>
- </method-list>
- <schema>
- <struts-config location=""/>
- <dbobject>
- <classname name="com.jcorporate.expresso.services.dbobj.MimeTypes"/>
- </dbobject>
- <controller>
- <classname name="com.jcorporate.expresso.services.controller.DBMaint"/>
- </controller>
- <job>
- <classname name="com.jcorporate.expresso.services.job.TestJob"/>
- </job>
- <report>
- <classname name="com.jcorporate.expresso.ext.report.TestReport"/>
- </report>
- </schema>
- <embedded-components>
- <component-metadata name="nested1">
- <description>Sample Nested Do Nothing Component</description>
- <version-info>
- <major-version>4</major-version>
- <minor-version>5</minor-version>
- <micro-version>6</micro-version>
- </version-info>
- </component-metadata>
- </embedded-components>
-</component-metadata>
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/management/test/log4j.dtd
+++ /dev/null
@@ -1,163 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-
-<!-- Authors: Chris Taylor, Ceki Gulcu. -->
-
-<!-- Version: 1.2 -->
-
-<!-- A configuration element consists of optional renderer
-elements,appender elements, categories and an optional root
-element. -->
-
-<!ELEMENT log4j:configuration (renderer*, appender*,(category|logger)*,root?,
- categoryFactory?)>
-
-<!-- The "threshold" attribute takes a level value such that all -->
-<!-- logging statements with a level equal or below this value are -->
-<!-- disabled. -->
-
-<!-- Setting the "debug" or "configDebug" attributes enable the printing -->
-<!-- of internal log4j logging statements. -->
-
-<!-- By default, debug attribute is "null", meaning that we not touch -->
-<!-- internal log4j logging settings. -->
-
-
-<!ATTLIST log4j:configuration
- xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
- threshold (all|debug|info|warn|error|fatal|off|null) "null"
- debug (true|false|null) "null"
->
-
-<!-- renderer elements allow the user to customize the conversion of -->
-<!-- message objects to String. -->
-
-<!ELEMENT renderer EMPTY>
-<!ATTLIST renderer
- renderedClass CDATA #REQUIRED
- renderingClass CDATA #REQUIRED
->
-
-<!-- Appenders must have a name and a class. -->
-<!-- Appenders may contain an error handler, a layout, optional parameters -->
-<!-- and filters. They may also reference (or include) other appenders. -->
-<!ELEMENT appender (errorHandler?, param*, layout?, filter*, appender-ref*)>
-<!ATTLIST appender
- name ID #REQUIRED
- class CDATA #REQUIRED
->
-
-<!ELEMENT layout (param*)>
-<!ATTLIST layout
- class CDATA #REQUIRED
->
-
-<!ELEMENT filter (param*)>
-<!ATTLIST filter
- class CDATA #REQUIRED
->
-
-<!-- ErrorHandlers can be of any class. They can admit any number of -->
-<!-- parameters. -->
-
-<!ELEMENT errorHandler (param*, root-ref?, logger-ref*, appender-ref?)>
-<!ATTLIST errorHandler
- class CDATA #REQUIRED
->
-
-<!ELEMENT root-ref EMPTY>
-
-<!ELEMENT logger-ref EMPTY>
-<!ATTLIST logger-ref
- ref IDREF #REQUIRED
->
-
-<!ELEMENT param EMPTY>
-<!ATTLIST param
- name CDATA #REQUIRED
- value CDATA #REQUIRED
->
-
-
-<!-- The priority class is org.apache.log4j.Level by default -->
-<!ELEMENT priority (param*)>
-<!ATTLIST priority
- class CDATA #IMPLIED
- value CDATA #REQUIRED
->
-
-<!-- The level class is org.apache.log4j.Level by default -->
-<!ELEMENT level (param*)>
-<!ATTLIST level
- class CDATA #IMPLIED
- value CDATA #REQUIRED
->
-
-
-<!-- If no level element is specified, then the configurator MUST not -->
-<!-- touch the level of the named category. -->
-<!ELEMENT category (param*,(priority|level)?,appender-ref*)>
-<!ATTLIST category
- class CDATA #IMPLIED
- name CDATA #REQUIRED
- additivity (true|false) "true"
->
-
-<!-- If no level element is specified, then the configurator MUST not -->
-<!-- touch the level of the named logger. -->
-<!ELEMENT logger (level?,appender-ref*)>
-<!ATTLIST logger
- name ID #REQUIRED
- additivity (true|false) "true"
->
-
-
-<!ELEMENT categoryFactory (param*)>
-<!ATTLIST categoryFactory
- class CDATA #REQUIRED>
-
-<!ELEMENT appender-ref EMPTY>
-<!ATTLIST appender-ref
- ref IDREF #REQUIRED
->
-
-<!-- If no priority element is specified, then the configurator MUST not -->
-<!-- touch the priority of root. -->
-<!-- The root category always exists and cannot be subclassed. -->
-<!ELEMENT root (param*, (priority|level)?, appender-ref*)>
-
-
-<!-- ==================================================================== -->
-<!-- A logging event -->
-<!-- ==================================================================== -->
-<!ELEMENT log4j:eventSet (log4j:event*)>
-<!ATTLIST log4j:eventSet
- xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
- version (1.1|1.2) "1.2"
- includesLocationInfo (true|false) "true"
->
-
-
-
-<!ELEMENT log4j:event (log4j:message, log4j:NDC?, log4j:throwable?,
- log4j:locationInfo?) >
-
-<!-- The timestamp format is application dependent. -->
-<!ATTLIST log4j:event
- category CDATA #REQUIRED
- priority CDATA #REQUIRED
- thread CDATA #REQUIRED
- timestamp CDATA #REQUIRED
->
-
-<!ELEMENT log4j:message (#PCDATA)>
-<!ELEMENT log4j:NDC (#PCDATA)>
-
-<!ELEMENT log4j:throwable (#PCDATA)>
-
-<!ELEMENT log4j:locationInfo EMPTY>
-<!ATTLIST log4j:locationInfo
- class CDATA #REQUIRED
- method CDATA #REQUIRED
- file CDATA #REQUIRED
- line CDATA #REQUIRED
->
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/management/test/TestServiceWriter.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/* ====================================================================
- * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
- *
- * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in
- * the documentation and/or other materials provided with the
- * distribution.
- *
- * 3. The end-user documentation included with the redistribution,
- * if any, must include the following acknowledgment:
- * "This product includes software developed by Jcorporate Ltd.
- * (http://www.jcorporate.com/)."
- * Alternately, this acknowledgment may appear in the software itself,
- * if and wherever such third-party acknowledgments normally appear.
- *
- * 4. "Jcorporate" and product names such as "Expresso" must
- * not be used to endorse or promote products derived from this
- * software without prior written permission. For written permission,
- * please contact info at jcorporate.com.
- *
- * 5. Products derived from this software may not be called "Expresso",
- * or other Jcorporate product names; nor may "Expresso" or other
- * Jcorporate product names appear in their name, without prior
- * written permission of Jcorporate Ltd.
- *
- * 6. No product derived from this software may compete in the same
- * market space, i.e. framework, without prior written permission
- * of Jcorporate Ltd. For written permission, please contact
- * partners at jcorporate.com.
- *
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
- * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Jcorporate Ltd. Contributions back
- * to the project(s) are encouraged when you make modifications.
- * Please send them to support at jcorporate.com. For more information
- * on Jcorporate Ltd. and its products, please see
- * <http://www.jcorporate.com/>.
- *
- * Portions of this software are based upon other open source
- * products and are subject to their respective licenses.
- */
-
-package com.jcorporate.expresso.kernel.management.test;
-
-import com.jcorporate.expresso.kernel.RootContainerInterface;
-import com.jcorporate.expresso.kernel.SystemFactory;
-import com.jcorporate.expresso.kernel.exception.ConfigurationException;
-import com.jcorporate.expresso.kernel.management.DefaultServiceWriter;
-import junit.framework.TestCase;
-
-import java.io.File;
-
-/** JUnitTest case for class: com.jcorporate.expresso.kernel.management.XercesServiceWriter */
-public class TestServiceWriter extends TestCase {
-
- public TestServiceWriter(String _name) {
- super(_name);
- }
-
- RootContainerInterface globalContainer = null;
-
- /** setUp method for test case */
- protected void setUp() {
- try {
- globalContainer = SystemFactory.buildExpressoComponentSystem(
- this.getClass().getResource("Test1ExpressoServices.xml"),
- this.getClass().getResource("TestLog4jConfig.xml"),
- "D:/Expresso/log");
- } catch (ConfigurationException ex) {
- ex.printStackTrace();
- throw new IllegalStateException("Error setting up test case: " + ex.getMessage());
- }
-
- }
-
- /** tearDown method for test case */
- protected void tearDown() {
- globalContainer.destroy();
- globalContainer = null;
- System.gc();
- System.runFinalization();
- }
-
- public void testXercesSaveConfiguration() {
- runTestSaveConfig(com.jcorporate.expresso.kernel.management.XercesDOMWriter.class.getName());
- }
-
- public void testTRAXSaveConfiguration() {
- runTestSaveConfig(com.jcorporate.expresso.kernel.management.TraxDOMWriter.class.getName());
- }
-
- protected void runTestSaveConfig(String domWriterClass) {
- try {
- DefaultServiceWriter sw = new DefaultServiceWriter();
- sw.setDomWriterClass(domWriterClass);
-
- sw.writeServicesFile(globalContainer, "d:/expresso/log/testOut.xml");
-
- File f = new File("d:/expresso/log/testOut.xml");
- if (f == null) {
- fail("testOut.xml wasn't created");
- }
-
- RootContainerInterface testContainer =
- SystemFactory.buildExpressoComponentSystem(f.toURL(),
- this.getClass().getResource("TestLog4jConfig.xml"),
- "D:/Expresso/log");
-
- assertTrue("Test containers should be equal",
- testContainer.getExpressoServicesConfig().equals(globalContainer.getExpressoServicesConfig()));
- } catch (Exception ex) {
- ex.printStackTrace();
- fail("Exception thrown during test: " + ex.getMessage());
- }
-
- }
-
-
- /** Executes the test case */
- public static void main(String[] argv) {
- String[] testCaseList = {TestServiceWriter.class.getName()};
- junit.textui.TestRunner.main(testCaseList);
- }
-}
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/management/test/TestLog4jConfig.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
- <appender name="console" class="org.apache.log4j.ConsoleAppender">
- <param name="Target" value="System.Out"/>
- <layout class="org.apache.log4j.PatternLayout">
- <param name="ConversionPattern" value="%d %-5p [%t] %C{2} (%F:%L) - %m\n"/>
- </layout>
- </appender>
- <root>
- <priority value="info"/>
- <appender-ref ref="console"/>
- </root>
-</log4j:configuration>
\ No newline at end of file
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/kernel/management/test/Test1ExpressoServices.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE expresso-services PUBLIC "-//Jcorporate Ltd//DTD Expresso Services Configuration 5.1//EN" "http://www.jcorporate.com/dtds/expresso-services_5_1.dtd">
-<expresso-services>
- <mapped-property name="setupValues" key="test1" value="abcdefg"/>
- <mapped-property name="setupValues" key="who you gonna call?" value="knees time!"/>
- <component name="default" class-name="com.jcorporate.expresso.kernel.DataContext">
- <property name="contextName" value="default"/>
- <property name="hasSetupTables" value="true"/>
- <property name="securityContext" value=""/>
- <property name="contextDescription" value="A Sample Default Database"/>
- <mapped-property name="setupValue" key="test1" value="Test Setup Value"/>
- <component name="TestComponent" class-name="com.jcorporate.expresso.kernel.test.TestComponent">
- <property name="property1" value="Abcdefg"/>
- <property name="property2" value="true"/>
- </component>
- </component>
-</expresso-services>
Index: XMLController.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/controller/XMLController.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/controller/XMLController.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/controller/XMLController.java -u -r1.15 -r1.16
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/controller/XMLController.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/ext/xml/controller/XMLController.java
@@ -105,6 +105,7 @@
*/
public class XMLController
extends DBController {
+
private static Logger log = Logger.getLogger(XMLController.class);
/**
@@ -158,7 +159,10 @@
/**
*
- *
+ * @param req The <code>ControllerRequest</code> object given
+ * to us by the framework.
+ * @param res The <code>ControllerResponse</code> object to populate
+ * with Inputs/Outputs and Blocks.
* @throws ControllerException
*/
private void doFileExportState(ControllerRequest req,
@@ -227,7 +231,10 @@
/**
*
- *
+ * @param req The <code>ControllerRequest</code> object given
+ * to us by the framework.
+ * @param res The <code>ControllerResponse</code> object to populate
+ * with Inputs/Outputs and Blocks.
* @throws ControllerException
*/
private void doFileImportState(ControllerRequest req,
@@ -259,7 +266,8 @@
/**
*
- *
+ * @param req The <code>ControllerRequest</code> object given
+ * to us by the framework.
* @throws ControllerException
*/
private void doImportState(ControllerRequest req)
@@ -283,6 +291,7 @@
/**
*
+ * @param dbObjName The Object to load.
* @throws ControllerException
* @return A Schema object instantiated from the class named by the
* 'SchemaClass' parameter
@@ -311,7 +320,7 @@
/**
* Instantiate & return the schema class given in the current parameter
*
- * @param schemaName
+ * @param schemaName the class-name of the schema to load.
* @throws ControllerException
* @return A Schema object instantiated from the class named by the
* 'SchemaClass' parameter
@@ -335,14 +344,17 @@
* @return java.lang.String The Title of the controller
*/
public String getTitle() {
- return ("Database Object XML Import/Export");
+ return "Database Object XML Import/Export";
} /* getTitle() */
/**
- *
- *
- * @param newState
- * @throws ControllerException
+ * Old-Style State switching method.
+ * @param req The <code>ControllerRequest</code> object given
+ * to us by the framework.
+ * @param newState the new state to transition into.
+ * @throws ControllerException upon error.
+ * @throws NonHandleableException upon fatal error.
+ * @return ControllerResponse.
*/
public ControllerResponse newState(String newState, ControllerRequest req)
throws ControllerException,
@@ -383,7 +395,10 @@
/**
*
- *
+ * @param req The <code>ControllerRequest</code> object given
+ * to us by the framework.
+ * @param res The <code>ControllerResponse</code> object to populate
+ * with Inputs/Outputs and Blocks.
* @throws ControllerException
*/
private void promptFileExportState(ControllerRequest req,
@@ -414,7 +429,8 @@
/**
*
- *
+ * @param res The <code>ControllerResponse</code> object to populate
+ * with Inputs/Outputs and Blocks.
* @throws ControllerException
*/
private void promptFileImportState(ControllerResponse res)
@@ -434,7 +450,8 @@
/**
*
- *
+ * @param res The <code>ControllerResponse</code> object to populate
+ * with Inputs/Outputs and Blocks.
* @throws ControllerException
*/
private void promptImportState(ControllerResponse res)
@@ -456,6 +473,14 @@
} /* promptImportState() */
+ /**
+ *
+ * @param req The <code>ControllerRequest</code> object given
+ * to us by the framework.
+ * @param res The <code>ControllerResponse</code> object to populate
+ * with Inputs/Outputs and Blocks.
+ * @throws ControllerException
+ */
private void promptForSchema(ControllerRequest req, ControllerResponse res)
throws ControllerException {
log.debug("Begin state promptForSchema");
Index: ExpressoTestSuite.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/ExpressoTestSuite.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -Lexpresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/ExpressoTestSuite.java -Lexpresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/ExpressoTestSuite.java -u -r1.2 -r1.3
--- expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/ExpressoTestSuite.java
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/ExpressoTestSuite.java
@@ -110,6 +110,8 @@
ts.addTestSuite(com.jcorporate.expresso.kernel.digester.test.TestComponentMetadataConfig.class);
ts.addTestSuite(com.jcorporate.expresso.kernel.digester.test.TestExpressoServicesConfig.class);
ts.addTestSuite(com.jcorporate.expresso.kernel.util.test.TestLocatorUtils.class);
+ ts.addTestSuite(com.jcorporate.expresso.kernel.util.test.FastStringBufferTest.class);
+
ts.addTestSuite(com.jcorporate.expresso.core.security.filters.FilterTreeTest.class);
ts.addTestSuite(com.jcorporate.expresso.core.db.tests.DBConnectionPoolTest.class);
ts.addTestSuite(com.jcorporate.expresso.core.controller.tests.InputTests.class);
@@ -125,7 +127,6 @@
ts.addTestSuite(com.jcorporate.expresso.core.misc.tests.Base64Test.class);
ts.addTestSuite(com.jcorporate.expresso.core.misc.tests.HexEncoderTest.class);
ts.addTestSuite(com.jcorporate.expresso.core.misc.tests.CookieBase64Test.class);
- ts.addTestSuite(com.jcorporate.expresso.core.misc.tests.FastStringBufferTest.class);
ts.addTestSuite(com.jcorporate.expresso.core.misc.tests.FileUtilTests.class);
ts.addTestSuite(com.jcorporate.expresso.core.logging.tests.LogManagerTests.class);
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/controller/tests/OutputTests.java
@@ -0,0 +1,209 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.controller.tests;
+
+import com.jcorporate.expresso.core.controller.Output;
+import com.jcorporate.expresso.core.misc.StringDOMParser;
+import com.jcorporate.expresso.kernel.util.FastStringBuffer;
+import com.jcorporate.expresso.services.test.CommandLineParser;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+import org.w3c.dom.Document;
+
+
+/**
+ * Unit test case for testing com.jcorporate.expresso.core.controller.Output
+ * objects.
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $
+ */
+public class OutputTests
+ extends ExpressoTestCase {
+ Output o = null;
+ StringDOMParser parser = null;
+ static final String outputName = "Test Output";
+ static final String outputContent = "This is a test output description";
+ static final String escapedOutputContent = "This & That \" And \" something else too;";
+ static final int outputDisplayLength = 30;
+
+ public OutputTests(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ CommandLineParser.parseCommandLine(args);
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void setUp()
+ throws Exception {
+ o = new Output(outputName, outputContent);
+ o.setDisplayLength(outputDisplayLength);
+ o.setAlignment("left");
+ parser = new StringDOMParser();
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite()
+ throws Exception {
+ return new TestSuite(OutputTests.class);
+ }
+
+ /**
+ * Helper function to set up the parser and parse the XML returned
+ * from the Output
+ */
+ private Document getXMLDoc()
+ throws Exception {
+ FastStringBuffer fsb = new FastStringBuffer(128);
+ String result = o.toXML(fsb).toString();
+ System.out.println("\nOutput Before Serialization:");
+ System.out.println(result);
+
+ Document d = parser.parseString(result);
+
+ if (d == null) {
+ fail("Output returned mal-formed XML document");
+ }
+
+ return d;
+ }
+
+ /**
+ * Helper to rebuild the Output from XML
+ */
+ private Output getOutput(Document d)
+ throws Exception {
+ Output anotherOutput = (Output) Output.fromXML(d);
+ FastStringBuffer fsb = new FastStringBuffer(128);
+ System.out.println("\nOutput After De-Serialization:");
+ System.out.println(anotherOutput.toXML(fsb).toString());
+
+ return anotherOutput;
+ }
+
+ /**
+ * Test basic Output->XML->Output Serialization
+ */
+ public void testXML()
+ throws Exception {
+ Document d = getXMLDoc();
+ Output newOutput = getOutput(d);
+ assertTrue("getOutput returned null", newOutput != null);
+ assertTrue("Proper Display Length", newOutput.getDisplayLength() == 30);
+ assertTrue("Proper Name", newOutput.getName().equals(outputName));
+ assertTrue("Proper Content",
+ newOutput.getContent().equals(outputContent));
+ }
+
+ /**
+ * Test Output->Xml->Output with special characters in the content.
+ */
+ public void testXmlWithSpecialCharacters()
+ throws Exception {
+ o.setContent(escapedOutputContent);
+
+ Document d = getXMLDoc();
+ Output newOutput = getOutput(d);
+ assertTrue("getOutput returned null", newOutput != null);
+ assertTrue("Proper Display Length", newOutput.getDisplayLength() == 30);
+ assertTrue("Proper Name", newOutput.getName().equals(outputName));
+ assertTrue("Proper Content",
+ newOutput.getContent().equals(escapedOutputContent));
+ }
+
+ /**
+ * Same as testXML, but test with nested Outputs
+ */
+ public void testXMLWithNestedOutput()
+ throws Exception {
+ Output nested = new Output("nested1", "label1");
+ o.addNested(nested);
+ nested = new Output("nested2", "label2");
+ o.addNested(nested);
+
+ Document d = getXMLDoc();
+ Output newOutput = getOutput(d);
+ assertTrue("getOutput returned null", newOutput != null);
+ assertTrue("Proper Display Length", newOutput.getDisplayLength() == 30);
+ assertTrue("Proper Name", newOutput.getName().equals(outputName));
+ assertTrue("Proper Content",
+ newOutput.getContent().equals(outputContent));
+ nested = (Output) newOutput.getNested("nested1");
+ assertTrue("Got nested 1", nested != null);
+ assertTrue("Proper Nested 1 Content",
+ nested.getContent().equals("label1"));
+ nested = (Output) newOutput.getNested("nested2");
+ assertTrue("Got nested 2", nested != null);
+ assertTrue("Proper Nested 2 Content",
+ nested.getContent().equals("label2"));
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/controller/tests/TransitionTests.java
@@ -0,0 +1,171 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.controller.tests;
+
+import com.jcorporate.expresso.core.controller.Transition;
+import com.jcorporate.expresso.core.misc.StringDOMParser;
+import com.jcorporate.expresso.kernel.util.FastStringBuffer;
+import com.jcorporate.expresso.services.test.CommandLineParser;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+import org.w3c.dom.Document;
+
+
+/**
+ * Unit test case for testing com.jcorporate.expresso.core.controller.Transition
+ * objects.
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $
+ */
+public class TransitionTests
+ extends ExpressoTestCase {
+ Transition t = null;
+ StringDOMParser parser = null;
+ static final String transitionName = "Test Transition";
+ static final String transitionLabel = "Click Here To Continue";
+ static final String transitionController = "com.jcorporate.expresso.services.controller.DBMaint";
+
+ public TransitionTests(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ CommandLineParser.parseCommandLine(args);
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void setUp()
+ throws Exception {
+ t = new Transition(transitionName, transitionLabel,
+ transitionController);
+ t.addParam("a", "b");
+ t.addParam("c", "d");
+ parser = new StringDOMParser();
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite()
+ throws Exception {
+ return new TestSuite(TransitionTests.class);
+ }
+
+ /**
+ * Helper function to set up the parser and parse the XML returned
+ * from the Transition
+ */
+ private Document getXMLDoc()
+ throws Exception {
+ FastStringBuffer fsb = new FastStringBuffer(128);
+ String result = t.toXML(fsb).toString();
+ System.out.println("\nTransition Before Serialization:");
+ System.out.println(result);
+
+ Document d = parser.parseString(result);
+
+ if (d == null) {
+ fail("Transition returned mal-formed XML document");
+ }
+
+ return d;
+ }
+
+ /**
+ * Helper to rebuild the Transition from XML
+ */
+ private Transition getTransition(Document d)
+ throws Exception {
+ Transition anotherTransition = (Transition) Transition.fromXML(d);
+ FastStringBuffer fsb = new FastStringBuffer(128);
+ System.out.println("\nTransition After De-Serialization:");
+ System.out.println(anotherTransition.toXML(fsb).toString());
+
+ return anotherTransition;
+ }
+
+ /**
+ * Test basic Transition->XML->Transition Serialization
+ */
+ public void testXML()
+ throws Exception {
+ Document d = getXMLDoc();
+ Transition newTransition = getTransition(d);
+ assertTrue("getTransition returned null", newTransition != null);
+ assertTrue("Proper Name",
+ newTransition.getName().equals(transitionName));
+ assertTrue("Proper Controller",
+ newTransition.getControllerObject().equals(
+ transitionController));
+ assertTrue("Proper Parameter a",
+ newTransition.getParam("a").equals("b"));
+ assertTrue("Proper Parameter c",
+ newTransition.getParam("c").equals("d"));
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/controller/tests/BlockTests.java
@@ -0,0 +1,232 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.controller.tests;
+
+import com.jcorporate.expresso.core.controller.Block;
+import com.jcorporate.expresso.core.controller.Input;
+import com.jcorporate.expresso.core.controller.Output;
+import com.jcorporate.expresso.core.controller.Transition;
+import com.jcorporate.expresso.core.misc.StringDOMParser;
+import com.jcorporate.expresso.kernel.util.FastStringBuffer;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+import org.w3c.dom.Document;
+
+
+/**
+ * Unit test for com.jcorporate.expresso.core.controller.Block objects.
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $
+ */
+public class BlockTests
+ extends ExpressoTestCase {
+ Block b = null;
+ StringDOMParser parser = null;
+ static final String BlockName = "TestBlock";
+ static final String outputName = "Output1";
+ static final String outputContent = "Sample Content";
+ static final String inputName1 = "Input1";
+ static final String inputLabel1 = "Enter Your Name";
+ static final String inputName2 = "Input2";
+ static final String inputLabel2 = "Enter Your Login Name";
+ static final String transitionName = "Transition1";
+ static final String transitionLabel = "Click Here To Continue";
+ static final String transitionController = "com.jcorporate.expresso.services.controller.DBMaint";
+ static final String block2Name = "Block 2";
+
+ public BlockTests(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void setUp()
+ throws Exception {
+ b = new Block(BlockName);
+
+ Input i = new Input(inputName1, inputLabel1);
+ b.add(i);
+ i = new Input(inputName2, inputLabel2);
+ b.add(i);
+
+ Output o = new Output(outputName, outputContent);
+ b.add(o);
+
+ Transition t = new Transition(transitionName, transitionLabel,
+ transitionController);
+ b.add(t);
+
+ Block b2 = new Block(block2Name);
+ b.add(b2);
+ parser = new StringDOMParser();
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite()
+ throws Exception {
+ return new TestSuite(BlockTests.class);
+ }
+
+ /**
+ * Helper function to set up the parser and parse the XML returned
+ * from the Block
+ */
+ private Document getXMLDoc(Block block)
+ throws Exception {
+ FastStringBuffer fsb = new FastStringBuffer(128);
+ String result = block.toXML(fsb).toString();
+ System.out.println("\nBlock Before Serialization:");
+ System.out.println(result);
+
+ Document d = parser.parseString(result);
+
+ if (d == null) {
+ fail("Block returned mal-formed XML document");
+ }
+
+ return d;
+ }
+
+ /**
+ * Helper to rebuild the Block from XML
+ */
+ private Block getBlock(Document d)
+ throws Exception {
+ try {
+ Block anotherBlock = (Block) Block.fromXML(d);
+ FastStringBuffer fsb = new FastStringBuffer(128);
+ System.out.println("\nBlock After De-Serialization:");
+ System.out.println(anotherBlock.toXML(fsb).toString());
+
+ return anotherBlock;
+ } catch (NullPointerException npe) {
+ npe.printStackTrace();
+ fail("Null Pointer Exception: " + npe);
+
+ return null;
+ }
+ }
+
+ /**
+ * Tests a very simple block XML Serialization
+ */
+ public void testSimpleXML()
+ throws Exception {
+ Block simpleBlock = new Block(BlockName);
+ Document d = getXMLDoc(simpleBlock);
+ Block newBlock = getBlock(d);
+ assertTrue("getBlock returned null", newBlock != null);
+ assertTrue("Proper Name", newBlock.getName().equals(BlockName));
+ }
+
+ /**
+ * Test basic Block->XML->Block Serialization
+ */
+ public void testXML()
+ throws Exception {
+ Document d = getXMLDoc(b);
+ Block newBlock = getBlock(d);
+ assertTrue("getBlock returned null", newBlock != null);
+ assertTrue("Proper Name", newBlock.getName().equals(BlockName));
+
+ try {
+ Input i;
+ Output o;
+ Transition t;
+ Block b2;
+ i = (Input) newBlock.getContent(inputName1);
+ assertTrue("i != null for " + inputName1, i != null);
+ assertTrue("i.getLabel() == " + inputLabel1,
+ i.getLabel().equals(inputLabel1));
+ i = (Input) newBlock.getContent(inputName2);
+ assertTrue("i != null for " + inputName2, i != null);
+ assertTrue("i.getLabel() == " + inputLabel2,
+ i.getLabel().equals(inputLabel2));
+ o = (Output) newBlock.getContent(outputName);
+ assertTrue("o != null for " + outputName, o != null);
+ assertTrue("o.getContent() == " + outputContent,
+ o.getContent().equals(outputContent));
+ t = (Transition) newBlock.getContent(transitionName);
+ assertTrue("t != null for " + transitionName, t != null);
+ assertTrue("t.getControllerObject() == " + transitionController,
+ t.getControllerObject().equals(transitionController));
+ assertTrue("t.getLabel() == " + transitionLabel,
+ t.getLabel().equals(transitionLabel));
+ b2 = (Block) newBlock.getContent(block2Name);
+ assertTrue("b2 != null for " + block2Name, b2 != null);
+ } catch (ClassCastException cce) {
+ cce.printStackTrace();
+ fail("Class Cast Exception: " + cce.getMessage());
+ }
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/controller/tests/InputTests.java
@@ -0,0 +1,260 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.controller.tests;
+
+import com.jcorporate.expresso.core.controller.Input;
+import com.jcorporate.expresso.core.dbobj.ValidValue;
+import com.jcorporate.expresso.core.misc.StringDOMParser;
+import com.jcorporate.expresso.kernel.util.FastStringBuffer;
+import com.jcorporate.expresso.services.test.CommandLineParser;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+import org.w3c.dom.Document;
+
+import java.util.Enumeration;
+import java.util.Vector;
+
+
+/**
+ * Unit test case for testing com.jcorporate.expresso.core.controller.Input
+ * objects.
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $
+ */
+public class InputTests
+ extends ExpressoTestCase {
+ Input i = null;
+ StringDOMParser parser = null;
+
+ public InputTests(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ CommandLineParser.parseCommandLine(args);
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void setUp()
+ throws Exception {
+ i = new Input("Test Input", "This is a test Input");
+ i.setLookup("com.jcorporate.expresso.services.dbobj.MimeTypes");
+ i.setDescription("This is a test input description");
+ i.setDisplayLength(30);
+ i.setType("boolean");
+ i.setAttribute("checkbox", "");
+ parser = new StringDOMParser();
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite()
+ throws Exception {
+ return new TestSuite(InputTests.class);
+ }
+
+ /**
+ * Helper function to set up the parser and parse the XML returned
+ * from the input
+ */
+ private Document getXMLDoc()
+ throws Exception {
+ FastStringBuffer fsb = new FastStringBuffer(128);
+ String result = i.toXML(fsb).toString();
+ System.out.println("\nInput Before Serialization:");
+ System.out.println(result);
+
+ Document d = parser.parseString(result);
+
+ if (d == null) {
+ fail("Input returned mal-formed XML document");
+ }
+
+ return d;
+ }
+
+ /**
+ * Helper to rebuild the input from XML
+ */
+ private Input getInput(Document d)
+ throws Exception {
+ Input anotherI = (Input) Input.fromXML(d);
+
+ // System.out.println("\nInput After De-Serialization:");
+ // System.out.println(anotherI.toXML(fsb).toString());
+ return anotherI;
+ }
+
+ /**
+ * Test basic Input->XML->Input Serialization
+ */
+ public void testXML()
+ throws Exception {
+ Document d = getXMLDoc();
+ Input newInput = getInput(d);
+ assertTrue("getInput returned null", newInput != null);
+ assertTrue("Proper Display Length", newInput.getDisplayLength() == 30);
+ assertTrue("Proper Lookup",
+ newInput.getLookup().equals("com.jcorporate.expresso.services.dbobj.MimeTypes"));
+ assertTrue("Proper Name", newInput.getName().equals("Test Input"));
+ assertTrue("Proper Description",
+ newInput.getDescription().equals("This is a test input description"));
+ assertTrue("Proper Label",
+ newInput.getLabel().equals("This is a test Input"));
+ assertTrue("Proper Type", newInput.getType().equals("boolean"));
+ assertTrue("Checkbox Attribute Exists",
+ newInput.getAttribute("checkbox") != null);
+ }
+
+ /**
+ * Same as testXML, but test MultiValues too
+ */
+ public void testXMLMultiValues()
+ throws Exception {
+ i.addValidValue("one", "One Value");
+ i.addValidValue("two", "Two Values");
+ i.addValidValue("three", "Three Values");
+ i.setType("C");
+
+ Document d = getXMLDoc();
+ Input newInput = getInput(d);
+ assertTrue("getInput returned null", newInput != null);
+ assertTrue("Proper Display Length", newInput.getDisplayLength() == 30);
+ assertTrue("Proper Lookup",
+ newInput.getLookup().equals("com.jcorporate.expresso.services.dbobj.MimeTypes"));
+ assertTrue("Proper Name", newInput.getName().equals("Test Input"));
+ assertTrue("Proper Description",
+ newInput.getDescription().equals("This is a test input description"));
+ assertTrue("Proper Label",
+ newInput.getLabel().equals("This is a test Input"));
+ assertTrue("Proper Type", newInput.getType().equals("C"));
+ assertTrue("Checkbox Attribute Exists",
+ newInput.getAttribute("checkbox") != null);
+
+ //Now check valid values
+ Vector v = newInput.getValidValues();
+ assertTrue("Returned Vector of valid values",
+ (v != null && !v.isEmpty()));
+ assertTrue("Returned proper number of valid values", v.size() == 3);
+
+ for (Enumeration e = v.elements(); e.hasMoreElements();) {
+ ValidValue vv = (ValidValue) e.nextElement();
+ assertTrue("Valid Value != null", vv != null);
+
+ String value = vv.getValue();
+ String description = vv.getDescription();
+
+ if (value.equals("one")) {
+ assertTrue("Proper Description for one",
+ description.equals("One Value"));
+ } else if (value.equals("two")) {
+ assertTrue("Proper Description for two",
+ description.equals("Two Values"));
+ } else if (value.equals("three")) {
+ assertTrue("Proper Description for three",
+ description.equals("Three Values"));
+ } else {
+ fail("Got invalid valid value: " + value);
+ }
+ }
+ }
+
+ /**
+ * Same as testXML, but test with nested inputs
+ */
+ public void testXMLWithNestedInput()
+ throws Exception {
+ Input nested = new Input("nested1", "label1");
+ i.addNested(nested);
+ nested = new Input("nested2", "label2");
+ i.addNested(nested);
+
+ Document d = getXMLDoc();
+ Input newInput = getInput(d);
+ assertTrue("getInput returned null", newInput != null);
+ assertTrue("Proper Display Length", newInput.getDisplayLength() == 30);
+ assertTrue("Proper Lookup",
+ newInput.getLookup().equals("com.jcorporate.expresso.services.dbobj.MimeTypes"));
+ assertTrue("Proper Name", newInput.getName().equals("Test Input"));
+ assertTrue("Proper Description",
+ newInput.getDescription().equals("This is a test input description"));
+ assertTrue("Proper Label",
+ newInput.getLabel().equals("This is a test Input"));
+ assertTrue("Proper Type", newInput.getType().equals("boolean"));
+ assertTrue("Checkbox Attribute Exists",
+ newInput.getAttribute("checkbox") != null);
+ nested = (Input) newInput.getNested("nested1");
+ assertTrue("Got nested 1", nested != null);
+ assertTrue("Proper Nested 1 Label", nested.getLabel().equals("label1"));
+ nested = (Input) newInput.getNested("nested2");
+ assertTrue("Got nested 2", nested != null);
+ assertTrue("Proper Nested 2 Label", nested.getLabel().equals("label2"));
+ }
+}
\ No newline at end of file
--- /dev/null
+++ expresso-web/WEB-INF/test-src/com/jcorporate/expresso/core/controller/tests/ControllerResponseTests.java
@@ -0,0 +1,264 @@
+/* ====================================================================
+ * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
+ *
+ * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ * if any, must include the following acknowledgment:
+ * "This product includes software developed by Jcorporate Ltd.
+ * (http://www.jcorporate.com/)."
+ * Alternately, this acknowledgment may appear in the software itself,
+ * if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. "Jcorporate" and product names such as "Expresso" must
+ * not be used to endorse or promote products derived from this
+ * software without prior written permission. For written permission,
+ * please contact info at jcorporate.com.
+ *
+ * 5. Products derived from this software may not be called "Expresso",
+ * or other Jcorporate product names; nor may "Expresso" or other
+ * Jcorporate product names appear in their name, without prior
+ * written permission of Jcorporate Ltd.
+ *
+ * 6. No product derived from this software may compete in the same
+ * market space, i.e. framework, without prior written permission
+ * of Jcorporate Ltd. For written permission, please contact
+ * partners at jcorporate.com.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Jcorporate Ltd. Contributions back
+ * to the project(s) are encouraged when you make modifications.
+ * Please send them to support at jcorporate.com. For more information
+ * on Jcorporate Ltd. and its products, please see
+ * <http://www.jcorporate.com/>.
+ *
+ * Portions of this software are based upon other open source
+ * products and are subject to their respective licenses.
+ */
+
+package com.jcorporate.expresso.core.controller.tests;
+
+import com.jcorporate.expresso.core.controller.Block;
+import com.jcorporate.expresso.core.controller.ControllerException;
+import com.jcorporate.expresso.core.controller.ControllerRequest;
+import com.jcorporate.expresso.core.controller.ControllerResponse;
+import com.jcorporate.expresso.core.controller.Input;
+import com.jcorporate.expresso.core.controller.Output;
+import com.jcorporate.expresso.core.controller.Transition;
+import com.jcorporate.expresso.core.controller.session.SimplePersistentSession;
+import com.jcorporate.expresso.core.misc.StringDOMParser;
+import com.jcorporate.expresso.services.test.CommandLineParser;
+import com.jcorporate.expresso.services.test.ExpressoTestCase;
+import junit.framework.TestSuite;
+import org.w3c.dom.Document;
+
+import java.io.IOException;
+
+
+/**
+ * Unit test case for testing com.jcorporate.expresso.core.controller.ControllerResponse
+ * objects.
+ * @author Michael Rimov
+ * @version $Revision: 1.1 $
+ * @since Expresso 5.0
+ */
+public class ControllerResponseTests
+ extends ExpressoTestCase {
+ ControllerResponse cr = null;
+ StringDOMParser parser = null;
+ static final String controllerName = "com.jcorporate.expresso.services.controller.DBMaint";
+ static final String responseTitle = "Sample Response";
+ static final String responseStyle = "xml??";
+ static final String BlockName = "TestBlock";
+ static final String outputName = "Output1";
+ static final String outputContent = "Sample Content";
+ static final String inputName1 = "Input1";
+ static final String inputLabel1 = "Enter Your Name";
+ static final String inputName2 = "Input2";
+ static final String inputLabel2 = "Enter Your Login Name";
+ static final String transitionName = "Transition1";
+ static final String transitionLabel = "Click Here To Continue";
+ static final String transitionController = "com.jcorporate.expresso.services.controller.DBMaint";
+ static final String block2Name = "Block 2";
+
+ public ControllerResponseTests(String testName)
+ throws Exception {
+ super(testName);
+ }
+
+ public static void main(String[] args)
+ throws Exception {
+
+ //Set the system properties we need
+ CommandLineParser.parseCommandLine(args);
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void setUp()
+ throws Exception {
+
+
+ cr = new ControllerResponse();
+ cr.setTitle(responseTitle);
+ cr.setControllerClass(controllerName);
+ cr.setStyle(responseStyle);
+ SimplePersistentSession session = new SimplePersistentSession();
+ ControllerRequest request = new ControllerRequest();
+ request.setUid(3);
+ request.setSession(session);
+ cr.setRequest(request);
+
+ Block b = new Block(BlockName);
+ Input i = new Input(inputName1, inputLabel1);
+ b.add(i);
+ i = new Input(inputName2, inputLabel2);
+ b.add(i);
+
+ Output o = new Output(outputName, outputContent);
+ b.add(o);
+
+ Transition t = new Transition(transitionName, transitionLabel,
+ transitionController);
+ b.add(t);
+ cr.addBlock(b);
+
+ Block b2 = new Block(block2Name);
+ cr.addBlock(b2);
+
+ //
+ //Yes, the data is already in the blocks, but this way we can
+ //test the block retrieval and Input/Output/Transition Cache
+ //
+ cr.addInput(i);
+ cr.addOutput(o);
+ cr.addTransition(t);
+ parser = new StringDOMParser();
+ }
+
+ /**
+ * Filler Function to conform to log4j test suites.
+ */
+ public static junit.framework.Test suite()
+ throws Exception {
+ return new TestSuite(ControllerResponseTests.class);
+ }
+
+ /**
+ * Helper function to set up the parser and parse the XML returned
+ * from the Output
+ */
+ private Document getXMLDoc()
+ throws Exception {
+ String result = cr.toXML();
+
+ // System.out.println("\nController Response Before Serialization:");
+ // System.out.println(result);
+ Document d = parser.parseString(result);
+
+ if (d == null) {
+ fail("ControllerResponse returned mal-formed XML document");
+ }
+
+ return d;
+ }
+
+ /**
+ * Helper to rebuild the Output from XML
+ */
+ private ControllerResponse getControllerResponse(Document d)
+ throws Exception {
+ ControllerResponse cr1 = ControllerResponse.fromXML(d);
+ System.out.println("\nController Response After De-Serialization:");
+ System.out.println(cr1.toXML());
+
+ return cr1;
+ }
+
+ /**
+ * Test basic ControllerReponse->XML->ControllerResponse Serialization
+ * Note, that the serialization of the nested blocks is only determined
+ * to make sure that the blocks exist in the Controller Element. The
+ * well-formdness of the blocks/input/ouputs/transitions is left to their
+ * respective test cases
+ */
+ public void testXML()
+ throws Exception {
+ try {
+ Document d = getXMLDoc();
+ ControllerResponse cr1 = getControllerResponse(d);
+ assertTrue("cr1 returned null", cr1 != null);
+ assertTrue("Block 1 Exists", cr1.getBlock(BlockName) != null);
+ assertTrue("Block 2 Exists", cr1.getBlock(block2Name) != null);
+ assertTrue("Proper Controller Name",
+ cr1.getControllerClass().equals(controllerName));
+ assertTrue("Proper Style", cr1.getStyle().equals(responseStyle));
+ assertTrue("Proper Title", cr1.getTitle().equals(responseTitle));
+ assertTrue("Input 2 Exists", cr1.getInput(inputName2) != null);
+ assertTrue("Output 1 Exists", cr1.getOutput(outputName) != null);
+ assertTrue("Transition 1 Exists",
+ cr1.getTransition(transitionName) != null);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ fail("Caught Exception: " + ex.getMessage());
+ }
+ }
+
+ public void testSerialization() {
+ try {
+ ControllerResponse re