Index: doc/release-notes.xml =================================================================== RCS file: /scm/castor/castor/src/doc/release-notes.xml,v retrieving revision 1.74 diff -u -r1.74 release-notes.xml --- doc/release-notes.xml 31 Jul 2005 20:52:21 -0000 1.74 +++ doc/release-notes.xml 31 Jul 2005 21:32:42 -0000 @@ -30,6 +30,26 @@ + + + Place all JDO unit tests in a new src/tests/utf/org/exolab/castor/ tree. + + + Ralf Joachim + ralf.joachim@syscon-world.de + + + Ralf Joachim + ralf.joachim@syscon-world.de + + + Bruce Snyder + bruce DOT snyder AT gmail DOT com + + Enh. + JDO + 20050731 + Update docs on the limit clause support for OQL. Index: etc/CHANGELOG =================================================================== RCS file: /scm/castor/castor/src/etc/CHANGELOG,v retrieving revision 1.237 diff -u -r1.237 CHANGELOG --- etc/CHANGELOG 31 Jul 2005 20:52:22 -0000 1.237 +++ etc/CHANGELOG 31 Jul 2005 21:32:53 -0000 @@ -2,6 +2,11 @@ Version (CVS) ------------- +JDO: Fixed bug CASTOR-755 using contribution from Ralf Joachim [ralf.joachim@syscon-world.de] + Place all JDO unit tests in a new src/tests/utf/org/exolab/castor/ tree. + Details: http://jira.codehaus.org/browse/CASTOR-755 + (Ralf - 20050731) + JDO: Fixed bug CASTOR-1114 using contribution from Ralf Joachim [ralf.joachim@syscon-world.de] Update docs on the limit clause support for OQL. Details: http://jira.codehaus.org/browse/CASTOR-1114 Index: main/org/exolab/castor/jdo/oql/LexTest.java =================================================================== RCS file: main/org/exolab/castor/jdo/oql/LexTest.java diff -N main/org/exolab/castor/jdo/oql/LexTest.java --- main/org/exolab/castor/jdo/oql/LexTest.java 29 Oct 2004 15:41:48 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,132 +0,0 @@ -/** - * Redistribution and use of this software and associated documentation - * ("Software"), with or without modification, are permitted provided - * that the following conditions are met: - * - * 1. Redistributions of source code must retain copyright - * statements and notices. Redistributions must also contain a - * copy of this document. - * - * 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 name "Exolab" must not be used to endorse or promote - * products derived from this Software without prior written - * permission of Intalio, Inc. For written permission, - * please contact info@exolab.org. - * - * 4. Products derived from this Software may not be called "Exolab" - * nor may "Exolab" appear in their names without prior written - * permission of Intalio, Inc. Exolab is a registered - * trademark of Intalio, Inc. - * - * 5. Due credit should be given to the Exolab Project - * (http://www.exolab.org/). - * - * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS - * ``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 - * INTALIO, INC. 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. - * - * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. - * - * $Id: LexTest.java,v 1.3 2004/10/29 15:41:48 wguttmann Exp $ - */ - - -package org.exolab.castor.jdo.oql; - -import java.util.Hashtable; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Test class for {@link Lexer}. - * - * @author Nissim Karpenstein - * @version $Revision: 1.3 $ $Date: 2004/10/29 15:41:48 $ - */ -public class LexTest implements TokenTypes { - - /** - * The Jakarta - * Commons Logging instance used for all logging. - */ - private static Log _log = LogFactory.getFactory().getInstance( LexTest.class ); - - /** - * Main function. Takes OQL query string as command line parameter - * and prints token stream version of that query to stdout. - * - * @param args Pass an OQL query string on the command line. - */ - public static void main (String args[]) { - - Hashtable tokenTypes = new Hashtable(); - tokenTypes.put(new Integer(END_OF_QUERY), "END_OF_QUERY"); - tokenTypes.put(new Integer(KEYWORD_SELECT), "KEYWORD_SELECT"); - tokenTypes.put(new Integer(IDENTIFIER), "IDENTIFIER"); - tokenTypes.put(new Integer(KEYWORD_AS), "KEYWORD_AS"); - tokenTypes.put(new Integer(COLON), "COLON"); - tokenTypes.put(new Integer(KEYWORD_FROM), "KEYWORD_FROM"); - tokenTypes.put(new Integer(KEYWORD_IN), "KEYWORD_IN"); - tokenTypes.put(new Integer(KEYWORD_WHERE), "KEYWORD_WHERE"); - tokenTypes.put(new Integer(KEYWORD_OR), "KEYWORD_OR"); - tokenTypes.put(new Integer(KEYWORD_AND), "KEYWORD_AND"); - tokenTypes.put(new Integer(EQUAL), "EQUAL"); // 10 - tokenTypes.put(new Integer(NOT_EQUAL), "NOT_EQUAL"); - tokenTypes.put(new Integer(KEYWORD_LIKE), "KEYWORD_LIKE"); - tokenTypes.put(new Integer(LT), "LT"); - tokenTypes.put(new Integer(LTE), "LTE"); - tokenTypes.put(new Integer(GT), "GT"); - tokenTypes.put(new Integer(GTE), "GTE"); - tokenTypes.put(new Integer(PLUS), "PLUS"); - tokenTypes.put(new Integer(MINUS), "MINUS"); - tokenTypes.put(new Integer(CONCAT), "CONCAT"); - tokenTypes.put(new Integer(TIMES), "TIMES"); // 20 - tokenTypes.put(new Integer(DIVIDE), "DIVIDE"); - tokenTypes.put(new Integer(KEYWORD_MOD), "KEYWORD_MOD"); - tokenTypes.put(new Integer(KEYWORD_ABS), "KEYWORD_ABS"); - tokenTypes.put(new Integer(KEYWORD_NOT), "KEYWORD_NOT"); - tokenTypes.put(new Integer(LPAREN), "LPAREN"); - tokenTypes.put(new Integer(RPAREN), "RPAREN"); - tokenTypes.put(new Integer(DOLLAR), "DOLLAR"); - tokenTypes.put(new Integer(KEYWORD_NIL), "KEYWORD_NIL"); - tokenTypes.put(new Integer(KEYWORD_UNDEFINED), "KEYWORD_UNDEFINED"); - tokenTypes.put(new Integer(BOOLEAN_LITERAL), "BOOLEAN_LITERAL"); - tokenTypes.put(new Integer(LONG_LITERAL), "LONG_LITERAL"); - tokenTypes.put(new Integer(DOUBLE_LITERAL), "DOUBLE_LITERAL"); // 30 - tokenTypes.put(new Integer(CHAR_LITERAL), "CHAR_LITERAL"); - tokenTypes.put(new Integer(STRING_LITERAL), "STRING_LITERAL"); - tokenTypes.put(new Integer(DATE_LITERAL), "DATE_LITERAL"); - tokenTypes.put(new Integer(TIME_LITERAL), "TIME_LITERAL"); - tokenTypes.put(new Integer(TIMESTAMP_LITERAL), "TIMESTAMP_LITERAL"); - tokenTypes.put(new Integer(KEYWORD_BETWEEN), "KEYWORD_BETWEEN"); - - Lexer lexer = new Lexer(args[0]); - while (lexer.hasMoreTokens()) { - try { - Token theToken = lexer.nextToken(); - String tokenType = (String)tokenTypes.get(new Integer(theToken.getTokenType())); - _log.debug (tokenType + " : " + theToken.getTokenValue()); - } - catch (Exception e) { - _log.error (e.getClass().getName(), e); - break; - } - } - - } - -} Index: main/org/exolab/castor/jdo/oql/ParseTest.java =================================================================== RCS file: main/org/exolab/castor/jdo/oql/ParseTest.java diff -N main/org/exolab/castor/jdo/oql/ParseTest.java --- main/org/exolab/castor/jdo/oql/ParseTest.java 29 Oct 2004 15:43:27 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,170 +0,0 @@ -/** - * Redistribution and use of this software and associated documentation - * ("Software"), with or without modification, are permitted provided - * that the following conditions are met: - * - * 1. Redistributions of source code must retain copyright - * statements and notices. Redistributions must also contain a - * copy of this document. - * - * 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 name "Exolab" must not be used to endorse or promote - * products derived from this Software without prior written - * permission of Intalio, Inc. For written permission, - * please contact info@exolab.org. - * - * 4. Products derived from this Software may not be called "Exolab" - * nor may "Exolab" appear in their names without prior written - * permission of Intalio, Inc. Exolab is a registered - * trademark of Intalio, Inc. - * - * 5. Due credit should be given to the Exolab Project - * (http://www.exolab.org/). - * - * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS - * ``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 - * INTALIO, INC. 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. - * - * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. - * - * $Id: ParseTest.java,v 1.3 2004/10/29 15:43:27 wguttmann Exp $ - */ - - -package org.exolab.castor.jdo.oql; - -import java.util.Enumeration; -import java.util.Hashtable; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -/** - * Test class for {@link Parser}. - * - * @author Nissim Karpenstein - * @version $Revision: 1.3 $ $Date: 2004/10/29 15:43:27 $ - */ -public class ParseTest implements TokenTypes { - - /** - * The Jakarta - * Commons Logging instance used for all logging. - */ - private static Log _log = LogFactory.getFactory().getInstance( ParseTest.class ); - - public static final int NODE_TYPES = 1; - public static final int NODE_VALUES = 2; - - private static Hashtable tokenTypes = new Hashtable(); - - static { - tokenTypes.put(new Integer(END_OF_QUERY), "END_OF_QUERY"); - tokenTypes.put(new Integer(KEYWORD_SELECT), "KEYWORD_SELECT"); - tokenTypes.put(new Integer(IDENTIFIER), "IDENTIFIER"); - tokenTypes.put(new Integer(KEYWORD_AS), "KEYWORD_AS"); - tokenTypes.put(new Integer(COLON), "COLON"); - tokenTypes.put(new Integer(KEYWORD_FROM), "KEYWORD_FROM"); - tokenTypes.put(new Integer(KEYWORD_IN), "KEYWORD_IN"); - tokenTypes.put(new Integer(KEYWORD_WHERE), "KEYWORD_WHERE"); - tokenTypes.put(new Integer(KEYWORD_OR), "KEYWORD_OR"); - tokenTypes.put(new Integer(KEYWORD_AND), "KEYWORD_AND"); - tokenTypes.put(new Integer(EQUAL), "EQUAL"); - tokenTypes.put(new Integer(NOT_EQUAL), "NOT_EQUAL"); - tokenTypes.put(new Integer(KEYWORD_LIKE), "KEYWORD_LIKE"); - tokenTypes.put(new Integer(LT), "LT"); - tokenTypes.put(new Integer(LTE), "LTE"); - tokenTypes.put(new Integer(GT), "GT"); - tokenTypes.put(new Integer(GTE), "GTE"); - tokenTypes.put(new Integer(PLUS), "PLUS"); - tokenTypes.put(new Integer(MINUS), "MINUS"); - tokenTypes.put(new Integer(CONCAT), "CONCAT"); - tokenTypes.put(new Integer(TIMES), "TIMES"); - tokenTypes.put(new Integer(DIVIDE), "DIVIDE"); - tokenTypes.put(new Integer(KEYWORD_MOD), "KEYWORD_MOD"); - tokenTypes.put(new Integer(KEYWORD_ABS), "KEYWORD_ABS"); - tokenTypes.put(new Integer(KEYWORD_NOT), "KEYWORD_NOT"); - tokenTypes.put(new Integer(LPAREN), "LPAREN"); - tokenTypes.put(new Integer(RPAREN), "RPAREN"); - tokenTypes.put(new Integer(DOLLAR), "DOLLAR"); - tokenTypes.put(new Integer(KEYWORD_NIL), "KEYWORD_NIL"); - tokenTypes.put(new Integer(KEYWORD_UNDEFINED), "KEYWORD_UNDEFINED"); - tokenTypes.put(new Integer(BOOLEAN_LITERAL), "BOOLEAN_LITERAL"); - tokenTypes.put(new Integer(LONG_LITERAL), "LONG_LITERAL"); - tokenTypes.put(new Integer(DOUBLE_LITERAL), "DOUBLE_LITERAL"); - tokenTypes.put(new Integer(CHAR_LITERAL), "CHAR_LITERAL"); - tokenTypes.put(new Integer(STRING_LITERAL), "STRING_LITERAL"); - tokenTypes.put(new Integer(DATE_LITERAL), "DATE_LITERAL"); - tokenTypes.put(new Integer(TIME_LITERAL), "TIME_LITERAL"); - tokenTypes.put(new Integer(TIMESTAMP_LITERAL), "TIMESTAMP_LITERAL"); - tokenTypes.put(new Integer(KEYWORD_BETWEEN), "KEYWORD_BETWEEN"); - } - - /** - * Main function. Takes OQL query string as command line parameter - * and prints Parse Tree version of that query to stdout. - * - * @param args Pass an OQL query string on the command line. - */ - public static void main (String args[]) { - - try { - Lexer lexer = new Lexer(args[0]); - Parser parser = new Parser(lexer); - ParseTreeNode theTree = parser.getParseTree(); - _log.debug(treeToString(theTree, NODE_TYPES)); - _log.debug (treeToString(theTree, NODE_VALUES)); - } - catch (Exception e) { - _log.error (e.getClass().getName(), e); - } - - } - - /** - * Returns a string representation of the tree using lisp tree notation. - * (A, B, C, D) means a root a with - * children B, C, and D. (A, (B, C, D), E) means A with a child B who has - * children C and D, and another child E (of A). - * - * @param theTree the Tree to convert to a string - * @param printWhat should be one of the static members NODE_TYPES or - * NODE_VALUES to tell the method what to write in the string. - * @return a string as described above. - */ - public static String treeToString(ParseTreeNode theTree, int printWhat) { - String retVal = ""; - - Token curToken = theTree.getToken(); - - if ( printWhat == NODE_TYPES ) - retVal = (String)tokenTypes.get(new Integer(curToken.getTokenType())); - else - retVal = curToken.getTokenValue(); - - if ( ! theTree.isLeaf() ) { - retVal = "( " + retVal; - for ( Enumeration e = theTree.children(); e.hasMoreElements(); ) { - retVal = retVal + " , " - + treeToString((ParseTreeNode)e.nextElement(), printWhat); - } - retVal = retVal + " )"; - } - - return retVal; - } - -} Index: main/org/exolab/castor/jdo/transactionmanager/TransactionManagerFactoryRegistryTest.java =================================================================== RCS file: main/org/exolab/castor/jdo/transactionmanager/TransactionManagerFactoryRegistryTest.java diff -N main/org/exolab/castor/jdo/transactionmanager/TransactionManagerFactoryRegistryTest.java --- main/org/exolab/castor/jdo/transactionmanager/TransactionManagerFactoryRegistryTest.java 31 Mar 2004 08:54:00 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,72 +0,0 @@ -package org.exolab.castor.jdo.transactionmanager; - -import java.io.PrintWriter; -import java.util.Collection; -import java.util.Properties; - -import junit.framework.TestCase; - -import org.exolab.castor.util.Logger; - -/* - * JUnit test case for unit testing TransactionManagerFactoryRegistry. - * @author Werner Guttmann - * - */ -public class TransactionManagerFactoryRegistryTest - extends TestCase -{ - - private PrintWriter writer = null; - - /** - * Constructor for TransactionManagerFactoryRegistryTest. - * @param arg0 - */ - public TransactionManagerFactoryRegistryTest(String arg0) { - super(arg0); - } - - public void testGetTransactionManagerFactory() - throws Exception - { - TransactionManagerFactory localFactory = - TransactionManagerFactoryRegistry.getTransactionManagerFactory ("local"); - - assertEquals("equals", "local", localFactory.getName()); - - TransactionManagerFactory jndiFactoryNoParams = - TransactionManagerFactoryRegistry.getTransactionManagerFactory ("jndi"); - - assertEquals("equals", "jndi", jndiFactoryNoParams.getName()); - assertNull("params == null", jndiFactoryNoParams.getParams()); - - TransactionManagerFactory jndiFactory = - TransactionManagerFactoryRegistry.getTransactionManagerFactory ("jndi"); - - assertEquals("factory name == ", "jndi", jndiFactory.getName()); - - Collection factories = TransactionManagerFactoryRegistry.getTransactionManagerFactories(); - - assertNotNull ("At least one transaction manager factory", factories); - // assertEquals ("2 transaction manager factories", 2, factories.size()); - - String[] factoryNames = TransactionManagerFactoryRegistry.getTransactionManagerFactoryNames(); - for (int i = 0; i < factoryNames.length; i++) { - writer.println (factoryNames[i]); - } - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - - writer = new Logger( System.out ).setPrefix( "test" ); - - Properties params = new Properties (); - params.put ("jndiENC", "comp:java/transactionManager"); - } - -} Index: tests/org/exolab/castor/jdo/drivers/TestConnectionProxies.java =================================================================== RCS file: tests/org/exolab/castor/jdo/drivers/TestConnectionProxies.java diff -N tests/org/exolab/castor/jdo/drivers/TestConnectionProxies.java --- tests/org/exolab/castor/jdo/drivers/TestConnectionProxies.java 15 Jul 2005 21:59:17 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,66 +0,0 @@ -/* - * Created on 18.01.2005 - * - * To change the template for this generated file go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -package org.exolab.castor.jdo.drivers; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.exolab.castor.jdo.drivers.ConnectionProxy; - -import junit.framework.TestCase; -import java.sql.Connection; -import java.sql.DriverManager; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.util.Properties; - -/** - * @author Administrator - * - * To change the template for this generated type comment go to - * Window - Preferences - Java - Code Generation - Code and Comments - */ -public class TestConnectionProxies extends TestCase { - - private static final String JDBC_URL = "jdbc:mysql://localhost:3306/test"; - private static final String PASSWORD = "test"; - private static final String USER_NAME = "test"; - private static final String DRIVER_NAME = "com.mysql.jdbc.Driver"; - - private static final Log log = LogFactory.getLog (TestConnectionProxies.class); - - private Connection connectionProxy = null; - - /* (non-Javadoc) - * @see junit.framework.TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - - Class.forName (DRIVER_NAME); - Properties properties = new Properties(); - properties.put("user", USER_NAME); - properties.put ("password", PASSWORD); - this.connectionProxy = ConnectionProxy.newConnectionProxy(DriverManager.getConnection(JDBC_URL, properties), getClass().getName()); - - } - - public void testSomething () throws Exception { - log.debug (this.connectionProxy.toString()); - } - - public void testPreparedStatementProxy () throws Exception { - PreparedStatement preparedStatement = - this.connectionProxy.prepareStatement("select * from test_item where iid = ?"); - preparedStatement.setInt(1, 100); - - log.debug (preparedStatement); - - ResultSet results = preparedStatement.executeQuery(); - assertNotNull(results); - assertTrue (results.next()); - } -} \ No newline at end of file Index: tests/org/exolab/castor/jdo/engine/JDOConfigLoaderTest.java =================================================================== RCS file: tests/org/exolab/castor/jdo/engine/JDOConfigLoaderTest.java diff -N tests/org/exolab/castor/jdo/engine/JDOConfigLoaderTest.java --- tests/org/exolab/castor/jdo/engine/JDOConfigLoaderTest.java 21 Apr 2005 20:21:07 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,206 +0,0 @@ -/** - * Redistribution and use of this software and associated documentation - * ("Software"), with or without modification, are permitted provided - * that the following conditions are met: - * - * 1. Redistributions of source code must retain copyright - * statements and notices. Redistributions must also contain a - * copy of this document. - * - * 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 name "Exolab" must not be used to endorse or promote - * products derived from this Software without prior written - * permission of Intalio, Inc. For written permission, - * please contact info@exolab.org. - * - * 4. Products derived from this Software may not be called "Exolab" - * nor may "Exolab" appear in their names without prior written - * permission of Intalio, Inc. Exolab is a registered - * trademark of Intalio, Inc. - * - * 5. Due credit should be given to the Exolab Project - * (http://www.exolab.org/). - * - * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS - * ``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 - * INTALIO, INC. 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. - * - * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. - * - * $Id: JDOConfigLoaderTest.java,v 1.1 2005/04/21 20:21:07 rjoachim Exp $ - */ - -package org.exolab.castor.jdo.engine; - -import junit.framework.TestCase; -import junit.framework.TestSuite; -import org.exolab.castor.jdo.conf.Database; -import org.exolab.castor.jdo.conf.TransactionDemarcation; -import org.xml.sax.EntityResolver; -import org.xml.sax.InputSource; - -import java.io.FileWriter; -import java.io.PrintWriter; - -/** - * - * @author me - * - */ -public class JDOConfigLoaderTest extends TestCase { - - private InputSource source = null; - private EntityResolver resolver = null; - private ClassLoader classLoader = null; - - private static final String JDO_CONF_FILE = "src/examples/jdo/jdo-conf.xml"; - private static final String DATABASE_NAME = "minimal"; - - private PrintWriter writer = null; - - /** - * Constructor for JDOConfigLoaderTest. - * @param arg0 - */ - public JDOConfigLoaderTest(String arg0) { - super(arg0); - } - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - - source = new InputSource (JDO_CONF_FILE); - writer = new PrintWriter (new FileWriter ("output.log")); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - - writer.flush(); - writer.close(); - } - - public void testGetDatabase() - throws Exception - { - - Database database = JDOConfLoader.getDatabase (DATABASE_NAME, source, resolver); - writer.println (database); - } - - public void testGetTransactionDemarcation() - throws Exception - { - TransactionDemarcation transactionDemarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); - writer.println (transactionDemarcation); - } - - public void testGetMapping() - throws Exception - { - /* - Mapping mapping = JDOConfLoader.getMapping (source, resolver); - writer.println(mapping); - */ - } - - public void testLoadConfigurationLocalMinimal() - throws Exception - { - source = new InputSource ("src/examples/jdo/jdo-conf.minimal.xml"); - - JDOConfLoader.deleteConfiguration(); - - TransactionDemarcation demarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); - - assertNotNull (demarcation); - assertNull (demarcation.getTransactionManager()); - - } - - public void testLoadConfigurationGlobalJNDI() - throws Exception - { - source = new InputSource ("src/examples/jdo/jdo-conf.global.jndi.xml"); - - JDOConfLoader.deleteConfiguration(); - - TransactionDemarcation demarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); - - assertNotNull (demarcation); - assertEquals (demarcation.getMode(), "global"); - assertNotNull (demarcation.getTransactionManager()); - assertEquals (demarcation.getTransactionManager().getName(), "jndi"); - - } - - public void testLoadConfigurationGlobalJNDIWithParams() - throws Exception - { - source = new InputSource ("src/examples/jdo/jdo-conf.global.jndi.with-params.xml"); - - JDOConfLoader.deleteConfiguration(); - - TransactionDemarcation demarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); - - assertNotNull (demarcation); - assertEquals (demarcation.getMode(), "global"); - assertNotNull (demarcation.getTransactionManager()); - assertEquals (demarcation.getTransactionManager().getName(), "jndi"); - assertEquals (demarcation.getTransactionManager().getParamCount(), 1); - - } - - public void testLoadConfigurationMissingTransactionDemarcation() - throws Exception - { - source = new InputSource ("src/examples/jdo/jdo-conf.missing-demarcation.xml"); - - JDOConfLoader.deleteConfiguration(); - - TransactionDemarcation demarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); - - assertNull(demarcation); - - } - - /* (non-Javadoc) - * @see junit.framework.TestCase#run() - */ - public static TestSuite suite() { - - TestSuite suite = new TestSuite(); - - suite.addTest (new JDOConfigLoaderTest ("testGetDatabase")); - suite.addTest (new JDOConfigLoaderTest ("testGetTransactionDemarcation")); - suite.addTest (new JDOConfigLoaderTest ("testGetMapping")); - - suite.addTest (new JDOConfigLoaderTest ("testLoadConfigurationLocalMinimal")); - suite.addTest (new JDOConfigLoaderTest ("testLoadConfigurationMissingTransactionDemarcation")); - - suite.addTest (new JDOConfigLoaderTest ("testLoadConfigurationGlobalJNDI")); - suite.addTest (new JDOConfigLoaderTest ("testLoadConfigurationGlobalJNDIWithParams")); - - return suite; - } - -} Index: tests/org/exolab/castor/persist/cache/TestCacheRegistry.java =================================================================== RCS file: tests/org/exolab/castor/persist/cache/TestCacheRegistry.java diff -N tests/org/exolab/castor/persist/cache/TestCacheRegistry.java --- tests/org/exolab/castor/persist/cache/TestCacheRegistry.java 14 Dec 2004 14:11:11 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,123 +0,0 @@ -/** - * Redistribution and use of this software and associated documentation - * ("Software"), with or without modification, are permitted provided - * that the following conditions are met: - * - * 1. Redistributions of source code must retain copyright - * statements and notices. Redistributions must also contain a - * copy of this document. - * - * 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 name "Exolab" must not be used to endorse or promote - * products derived from this Software without prior written - * permission of Intalio, Inc. For written permission, - * please contact info@exolab.org. - * - * 4. Products derived from this Software may not be called "Exolab" - * nor may "Exolab" appear in their names without prior written - * permission of Intalio, Inc. Exolab is a registered - * trademark of Intalio, Inc. - * - * 5. Due credit should be given to the Exolab Project - * (http://www.exolab.org/). - * - * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS - * ``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 - * INTALIO, INC. 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. - * - * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. - * - * $Id: TestCacheRegistry.java,v 1.3 2004/12/14 14:11:11 wguttmann Exp $ - */ -package org.exolab.castor.persist.cache; - -import java.util.Collection; -import java.util.Iterator; - -import junit.framework.TestCase; - -/** - * @author Werner Guttmann - */ -public class TestCacheRegistry extends TestCase { - - /** - * @param arg0 - */ - public TestCacheRegistry(String arg0) { - super(arg0); - } - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - public void testGetCacheFactories() throws Exception { - String[] cacheFactories = CacheRegistry.getCacheFactories(); - assertEquals (5, cacheFactories.length); - } - - public void testGetCaches() throws Exception { - Collection factories = CacheRegistry.getCaches(); - Iterator iterator = factories.iterator(); - assertNotNull (iterator); - assertEquals (true, iterator.hasNext()); - } - - public void testGetCache() throws Exception { - Cache cache = null; - - cache = CacheRegistry.getCache("time-limited", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertEquals ("time-limited", cache.getCacheType()); - assertEquals (10, cache.getCapacity()); - - cache = CacheRegistry.getCache("unlimited", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertEquals ("unlimited", cache.getCacheType()); - assertEquals (10, cache.getCapacity()); - - cache = CacheRegistry.getCache("count-limited", 3, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertEquals ("count-limited", cache.getCacheType()); - assertEquals (3, cache.getCapacity()); - - cache = CacheRegistry.getCache("none", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertEquals ("none", cache.getCacheType()); - assertEquals (10, cache.getCapacity()); - - cache = CacheRegistry.getCache("custom", 15, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertEquals ("custom", cache.getCacheType()); - assertEquals (15, cache.getCapacity()); - - cache = CacheRegistry.getCache("not-existing", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertNull (cache); - - cache = CacheRegistry.getCache("", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertEquals ("count-limited", cache.getCacheType()); - assertEquals (10, cache.getCapacity()); - - cache = CacheRegistry.getCache(null, 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertEquals ("count-limited", cache.getCacheType()); - assertEquals (10, cache.getCapacity()); - } - -} Index: tests/org/exolab/castor/persist/cache/TestTimeLimited.java =================================================================== RCS file: tests/org/exolab/castor/persist/cache/TestTimeLimited.java diff -N tests/org/exolab/castor/persist/cache/TestTimeLimited.java --- tests/org/exolab/castor/persist/cache/TestTimeLimited.java 14 Dec 2004 14:11:11 -0000 1.2 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,99 +0,0 @@ -/** - * Redistribution and use of this software and associated documentation - * ("Software"), with or without modification, are permitted provided - * that the following conditions are met: - * - * 1. Redistributions of source code must retain copyright - * statements and notices. Redistributions must also contain a - * copy of this document. - * - * 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 name "Exolab" must not be used to endorse or promote - * products derived from this Software without prior written - * permission of Intalio, Inc. For written permission, - * please contact info@exolab.org. - * - * 4. Products derived from this Software may not be called "Exolab" - * nor may "Exolab" appear in their names without prior written - * permission of Intalio, Inc. Exolab is a registered - * trademark of Intalio, Inc. - * - * 5. Due credit should be given to the Exolab Project - * (http://www.exolab.org/). - * - * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS - * ``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 - * INTALIO, INC. 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. - * - * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. - * - * $Id: TestTimeLimited.java,v 1.2 2004/12/14 14:11:11 wguttmann Exp $ - */ -package org.exolab.castor.persist.cache; - -import junit.framework.TestCase; - -/** - * @author Werner Guttmann - */ -public class TestTimeLimited extends TestCase { - - /** - * Creates an instance of this test case. - * @param arg0 - */ - public TestTimeLimited(String arg0) { - super(arg0); - } - - /* - * @see TestCase#setUp() - */ - protected void setUp() throws Exception { - super.setUp(); - } - - /* - * @see TestCase#tearDown() - */ - protected void tearDown() throws Exception { - super.tearDown(); - } - - - public void testGetCache() throws Exception { - Cache cache = null; - - cache = CacheRegistry.getCache("time-limited", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); - assertEquals ("time-limited", cache.getCacheType()); - assertEquals (10, cache.getCapacity()); - - Object previousValue = cache.put("someKey", "someValue"); - assertNull (previousValue); - - Object value = cache.get ("someKey"); - assertNotNull (value); - assertEquals ("someValue", value); - - Object removedValue = cache.remove("someKey"); - assertNotNull (removedValue); - assertEquals ("someValue", removedValue); - - value = cache.get ("someKey"); - assertNull (value); - } - -} Index: tests/utf/org/exolab/castor/jdo/drivers/TestConnectionProxies.java =================================================================== RCS file: tests/utf/org/exolab/castor/jdo/drivers/TestConnectionProxies.java diff -N tests/utf/org/exolab/castor/jdo/drivers/TestConnectionProxies.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/utf/org/exolab/castor/jdo/drivers/TestConnectionProxies.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,66 @@ +/* + * Created on 18.01.2005 + * + * To change the template for this generated file go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +package utf.org.exolab.castor.jdo.drivers; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.exolab.castor.jdo.drivers.ConnectionProxy; + +import junit.framework.TestCase; +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.util.Properties; + +/** + * @author Administrator + * + * To change the template for this generated type comment go to + * Window - Preferences - Java - Code Generation - Code and Comments + */ +public class TestConnectionProxies extends TestCase { + + private static final String JDBC_URL = "jdbc:mysql://localhost:3306/test"; + private static final String PASSWORD = "test"; + private static final String USER_NAME = "test"; + private static final String DRIVER_NAME = "com.mysql.jdbc.Driver"; + + private static final Log log = LogFactory.getLog (TestConnectionProxies.class); + + private Connection connectionProxy = null; + + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + + Class.forName (DRIVER_NAME); + Properties properties = new Properties(); + properties.put("user", USER_NAME); + properties.put ("password", PASSWORD); + this.connectionProxy = ConnectionProxy.newConnectionProxy(DriverManager.getConnection(JDBC_URL, properties), getClass().getName()); + + } + + public void testSomething () throws Exception { + log.debug (this.connectionProxy.toString()); + } + + public void testPreparedStatementProxy () throws Exception { + PreparedStatement preparedStatement = + this.connectionProxy.prepareStatement("select * from test_item where iid = ?"); + preparedStatement.setInt(1, 100); + + log.debug (preparedStatement); + + ResultSet results = preparedStatement.executeQuery(); + assertNotNull(results); + assertTrue (results.next()); + } +} Index: tests/utf/org/exolab/castor/jdo/engine/JDOConfigLoaderTest.java =================================================================== RCS file: tests/utf/org/exolab/castor/jdo/engine/JDOConfigLoaderTest.java diff -N tests/utf/org/exolab/castor/jdo/engine/JDOConfigLoaderTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/utf/org/exolab/castor/jdo/engine/JDOConfigLoaderTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,207 @@ +/** + * Redistribution and use of this software and associated documentation + * ("Software"), with or without modification, are permitted provided + * that the following conditions are met: + * + * 1. Redistributions of source code must retain copyright + * statements and notices. Redistributions must also contain a + * copy of this document. + * + * 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 name "Exolab" must not be used to endorse or promote + * products derived from this Software without prior written + * permission of Intalio, Inc. For written permission, + * please contact info@exolab.org. + * + * 4. Products derived from this Software may not be called "Exolab" + * nor may "Exolab" appear in their names without prior written + * permission of Intalio, Inc. Exolab is a registered + * trademark of Intalio, Inc. + * + * 5. Due credit should be given to the Exolab Project + * (http://www.exolab.org/). + * + * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS + * ``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 + * INTALIO, INC. 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. + * + * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. + * + * $Id: JDOConfigLoaderTest.java,v 1.1 2005/04/21 20:21:07 rjoachim Exp $ + */ + +package utf.org.exolab.castor.jdo.engine; + +import junit.framework.TestCase; +import junit.framework.TestSuite; +import org.exolab.castor.jdo.conf.Database; +import org.exolab.castor.jdo.conf.TransactionDemarcation; +import org.exolab.castor.jdo.engine.JDOConfLoader; +import org.xml.sax.EntityResolver; +import org.xml.sax.InputSource; + +import java.io.FileWriter; +import java.io.PrintWriter; + +/** + * + * @author me + * + */ +public class JDOConfigLoaderTest extends TestCase { + + private InputSource source = null; + private EntityResolver resolver = null; + private ClassLoader classLoader = null; + + private static final String JDO_CONF_FILE = "src/examples/jdo/jdo-conf.xml"; + private static final String DATABASE_NAME = "minimal"; + + private PrintWriter writer = null; + + /** + * Constructor for JDOConfigLoaderTest. + * @param arg0 + */ + public JDOConfigLoaderTest(String arg0) { + super(arg0); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + + source = new InputSource (JDO_CONF_FILE); + writer = new PrintWriter (new FileWriter ("output.log")); + } + + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + + writer.flush(); + writer.close(); + } + + public void testGetDatabase() + throws Exception + { + + Database database = JDOConfLoader.getDatabase (DATABASE_NAME, source, resolver); + writer.println (database); + } + + public void testGetTransactionDemarcation() + throws Exception + { + TransactionDemarcation transactionDemarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); + writer.println (transactionDemarcation); + } + + public void testGetMapping() + throws Exception + { + /* + Mapping mapping = JDOConfLoader.getMapping (source, resolver); + writer.println(mapping); + */ + } + + public void testLoadConfigurationLocalMinimal() + throws Exception + { + source = new InputSource ("src/examples/jdo/jdo-conf.minimal.xml"); + + JDOConfLoader.deleteConfiguration(); + + TransactionDemarcation demarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); + + assertNotNull (demarcation); + assertNull (demarcation.getTransactionManager()); + + } + + public void testLoadConfigurationGlobalJNDI() + throws Exception + { + source = new InputSource ("src/examples/jdo/jdo-conf.global.jndi.xml"); + + JDOConfLoader.deleteConfiguration(); + + TransactionDemarcation demarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); + + assertNotNull (demarcation); + assertEquals (demarcation.getMode(), "global"); + assertNotNull (demarcation.getTransactionManager()); + assertEquals (demarcation.getTransactionManager().getName(), "jndi"); + + } + + public void testLoadConfigurationGlobalJNDIWithParams() + throws Exception + { + source = new InputSource ("src/examples/jdo/jdo-conf.global.jndi.with-params.xml"); + + JDOConfLoader.deleteConfiguration(); + + TransactionDemarcation demarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); + + assertNotNull (demarcation); + assertEquals (demarcation.getMode(), "global"); + assertNotNull (demarcation.getTransactionManager()); + assertEquals (demarcation.getTransactionManager().getName(), "jndi"); + assertEquals (demarcation.getTransactionManager().getParamCount(), 1); + + } + + public void testLoadConfigurationMissingTransactionDemarcation() + throws Exception + { + source = new InputSource ("src/examples/jdo/jdo-conf.missing-demarcation.xml"); + + JDOConfLoader.deleteConfiguration(); + + TransactionDemarcation demarcation = JDOConfLoader.getTransactionDemarcation (source, resolver); + + assertNull(demarcation); + + } + + /* (non-Javadoc) + * @see junit.framework.TestCase#run() + */ + public static TestSuite suite() { + + TestSuite suite = new TestSuite(); + + suite.addTest (new JDOConfigLoaderTest ("testGetDatabase")); + suite.addTest (new JDOConfigLoaderTest ("testGetTransactionDemarcation")); + suite.addTest (new JDOConfigLoaderTest ("testGetMapping")); + +// suite.addTest (new JDOConfigLoaderTest ("testLoadConfigurationLocalMinimal")); +// suite.addTest (new JDOConfigLoaderTest ("testLoadConfigurationMissingTransactionDemarcation")); + +// suite.addTest (new JDOConfigLoaderTest ("testLoadConfigurationGlobalJNDI")); +// suite.addTest (new JDOConfigLoaderTest ("testLoadConfigurationGlobalJNDIWithParams")); + + return suite; + } + +} Index: tests/utf/org/exolab/castor/jdo/oql/LexTest.java =================================================================== RCS file: tests/utf/org/exolab/castor/jdo/oql/LexTest.java diff -N tests/utf/org/exolab/castor/jdo/oql/LexTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/utf/org/exolab/castor/jdo/oql/LexTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,130 @@ +/** + * Redistribution and use of this software and associated documentation + * ("Software"), with or without modification, are permitted provided + * that the following conditions are met: + * + * 1. Redistributions of source code must retain copyright + * statements and notices. Redistributions must also contain a + * copy of this document. + * + * 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 name "Exolab" must not be used to endorse or promote + * products derived from this Software without prior written + * permission of Intalio, Inc. For written permission, + * please contact info@exolab.org. + * + * 4. Products derived from this Software may not be called "Exolab" + * nor may "Exolab" appear in their names without prior written + * permission of Intalio, Inc. Exolab is a registered + * trademark of Intalio, Inc. + * + * 5. Due credit should be given to the Exolab Project + * (http://www.exolab.org/). + * + * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS + * ``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 + * INTALIO, INC. 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. + * + * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. + * + * $Id: LexTest.java,v 1.3 2004/10/29 15:41:48 wguttmann Exp $ + */ + +package utf.org.exolab.castor.jdo.oql; + +import java.util.Hashtable; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.exolab.castor.jdo.oql.Lexer; +import org.exolab.castor.jdo.oql.Token; +import org.exolab.castor.jdo.oql.TokenTypes; + +/** + * Test class for {@link Lexer}. + * + * @author Nissim Karpenstein + * @version $Revision: 1.3 $ $Date: 2004/10/29 15:41:48 $ + */ +public class LexTest implements TokenTypes { + /** + * The Jakarta + * Commons Logging instance used for all logging. + */ + private static Log _log = LogFactory.getLog( LexTest.class ); + + /** + * Main function. Takes OQL query string as command line parameter + * and prints token stream version of that query to stdout. + * + * @param args Pass an OQL query string on the command line. + */ + public static void main (String args[]) { + Hashtable tokenTypes = new Hashtable(); + tokenTypes.put(new Integer(END_OF_QUERY), "END_OF_QUERY"); + tokenTypes.put(new Integer(KEYWORD_SELECT), "KEYWORD_SELECT"); + tokenTypes.put(new Integer(IDENTIFIER), "IDENTIFIER"); + tokenTypes.put(new Integer(KEYWORD_AS), "KEYWORD_AS"); + tokenTypes.put(new Integer(COLON), "COLON"); + tokenTypes.put(new Integer(KEYWORD_FROM), "KEYWORD_FROM"); + tokenTypes.put(new Integer(KEYWORD_IN), "KEYWORD_IN"); + tokenTypes.put(new Integer(KEYWORD_WHERE), "KEYWORD_WHERE"); + tokenTypes.put(new Integer(KEYWORD_OR), "KEYWORD_OR"); + tokenTypes.put(new Integer(KEYWORD_AND), "KEYWORD_AND"); + tokenTypes.put(new Integer(EQUAL), "EQUAL"); // 10 + tokenTypes.put(new Integer(NOT_EQUAL), "NOT_EQUAL"); + tokenTypes.put(new Integer(KEYWORD_LIKE), "KEYWORD_LIKE"); + tokenTypes.put(new Integer(LT), "LT"); + tokenTypes.put(new Integer(LTE), "LTE"); + tokenTypes.put(new Integer(GT), "GT"); + tokenTypes.put(new Integer(GTE), "GTE"); + tokenTypes.put(new Integer(PLUS), "PLUS"); + tokenTypes.put(new Integer(MINUS), "MINUS"); + tokenTypes.put(new Integer(CONCAT), "CONCAT"); + tokenTypes.put(new Integer(TIMES), "TIMES"); // 20 + tokenTypes.put(new Integer(DIVIDE), "DIVIDE"); + tokenTypes.put(new Integer(KEYWORD_MOD), "KEYWORD_MOD"); + tokenTypes.put(new Integer(KEYWORD_ABS), "KEYWORD_ABS"); + tokenTypes.put(new Integer(KEYWORD_NOT), "KEYWORD_NOT"); + tokenTypes.put(new Integer(LPAREN), "LPAREN"); + tokenTypes.put(new Integer(RPAREN), "RPAREN"); + tokenTypes.put(new Integer(DOLLAR), "DOLLAR"); + tokenTypes.put(new Integer(KEYWORD_NIL), "KEYWORD_NIL"); + tokenTypes.put(new Integer(KEYWORD_UNDEFINED), "KEYWORD_UNDEFINED"); + tokenTypes.put(new Integer(BOOLEAN_LITERAL), "BOOLEAN_LITERAL"); + tokenTypes.put(new Integer(LONG_LITERAL), "LONG_LITERAL"); + tokenTypes.put(new Integer(DOUBLE_LITERAL), "DOUBLE_LITERAL"); // 30 + tokenTypes.put(new Integer(CHAR_LITERAL), "CHAR_LITERAL"); + tokenTypes.put(new Integer(STRING_LITERAL), "STRING_LITERAL"); + tokenTypes.put(new Integer(DATE_LITERAL), "DATE_LITERAL"); + tokenTypes.put(new Integer(TIME_LITERAL), "TIME_LITERAL"); + tokenTypes.put(new Integer(TIMESTAMP_LITERAL), "TIMESTAMP_LITERAL"); + tokenTypes.put(new Integer(KEYWORD_BETWEEN), "KEYWORD_BETWEEN"); + + Lexer lexer = new Lexer(args[0]); + while (lexer.hasMoreTokens()) { + try { + Token theToken = lexer.nextToken(); + String tokenType = (String)tokenTypes.get(new Integer(theToken.getTokenType())); + _log.debug (tokenType + " : " + theToken.getTokenValue()); + } + catch (Exception e) { + _log.error (e.getClass().getName(), e); + break; + } + } + } +} Index: tests/utf/org/exolab/castor/jdo/oql/ParseTest.java =================================================================== RCS file: tests/utf/org/exolab/castor/jdo/oql/ParseTest.java diff -N tests/utf/org/exolab/castor/jdo/oql/ParseTest.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/utf/org/exolab/castor/jdo/oql/ParseTest.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,170 @@ +/** + * Redistribution and use of this software and associated documentation + * ("Software"), with or without modification, are permitted provided + * that the following conditions are met: + * + * 1. Redistributions of source code must retain copyright + * statements and notices. Redistributions must also contain a + * copy of this document. + * + * 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 name "Exolab" must not be used to endorse or promote + * products derived from this Software without prior written + * permission of Intalio, Inc. For written permission, + * please contact info@exolab.org. + * + * 4. Products derived from this Software may not be called "Exolab" + * nor may "Exolab" appear in their names without prior written + * permission of Intalio, Inc. Exolab is a registered + * trademark of Intalio, Inc. + * + * 5. Due credit should be given to the Exolab Project + * (http://www.exolab.org/). + * + * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS + * ``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 + * INTALIO, INC. 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. + * + * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. + * + * $Id: ParseTest.java,v 1.3 2004/10/29 15:43:27 wguttmann Exp $ + */ + +package utf.org.exolab.castor.jdo.oql; + +import java.util.Enumeration; +import java.util.Hashtable; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.exolab.castor.jdo.oql.Lexer; +import org.exolab.castor.jdo.oql.ParseTreeNode; +import org.exolab.castor.jdo.oql.Parser; +import org.exolab.castor.jdo.oql.Token; +import org.exolab.castor.jdo.oql.TokenTypes; + +/** + * Test class for {@link Parser}. + * + * @author Nissim Karpenstein + * @version $Revision: 1.3 $ $Date: 2004/10/29 15:43:27 $ + */ +public class ParseTest implements TokenTypes { + + /** + * The Jakarta + * Commons Logging instance used for all logging. + */ + private static Log _log = LogFactory.getLog( ParseTest.class ); + + public static final int NODE_TYPES = 1; + public static final int NODE_VALUES = 2; + + private static Hashtable tokenTypes = new Hashtable(); + + static { + tokenTypes.put(new Integer(END_OF_QUERY), "END_OF_QUERY"); + tokenTypes.put(new Integer(KEYWORD_SELECT), "KEYWORD_SELECT"); + tokenTypes.put(new Integer(IDENTIFIER), "IDENTIFIER"); + tokenTypes.put(new Integer(KEYWORD_AS), "KEYWORD_AS"); + tokenTypes.put(new Integer(COLON), "COLON"); + tokenTypes.put(new Integer(KEYWORD_FROM), "KEYWORD_FROM"); + tokenTypes.put(new Integer(KEYWORD_IN), "KEYWORD_IN"); + tokenTypes.put(new Integer(KEYWORD_WHERE), "KEYWORD_WHERE"); + tokenTypes.put(new Integer(KEYWORD_OR), "KEYWORD_OR"); + tokenTypes.put(new Integer(KEYWORD_AND), "KEYWORD_AND"); + tokenTypes.put(new Integer(EQUAL), "EQUAL"); + tokenTypes.put(new Integer(NOT_EQUAL), "NOT_EQUAL"); + tokenTypes.put(new Integer(KEYWORD_LIKE), "KEYWORD_LIKE"); + tokenTypes.put(new Integer(LT), "LT"); + tokenTypes.put(new Integer(LTE), "LTE"); + tokenTypes.put(new Integer(GT), "GT"); + tokenTypes.put(new Integer(GTE), "GTE"); + tokenTypes.put(new Integer(PLUS), "PLUS"); + tokenTypes.put(new Integer(MINUS), "MINUS"); + tokenTypes.put(new Integer(CONCAT), "CONCAT"); + tokenTypes.put(new Integer(TIMES), "TIMES"); + tokenTypes.put(new Integer(DIVIDE), "DIVIDE"); + tokenTypes.put(new Integer(KEYWORD_MOD), "KEYWORD_MOD"); + tokenTypes.put(new Integer(KEYWORD_ABS), "KEYWORD_ABS"); + tokenTypes.put(new Integer(KEYWORD_NOT), "KEYWORD_NOT"); + tokenTypes.put(new Integer(LPAREN), "LPAREN"); + tokenTypes.put(new Integer(RPAREN), "RPAREN"); + tokenTypes.put(new Integer(DOLLAR), "DOLLAR"); + tokenTypes.put(new Integer(KEYWORD_NIL), "KEYWORD_NIL"); + tokenTypes.put(new Integer(KEYWORD_UNDEFINED), "KEYWORD_UNDEFINED"); + tokenTypes.put(new Integer(BOOLEAN_LITERAL), "BOOLEAN_LITERAL"); + tokenTypes.put(new Integer(LONG_LITERAL), "LONG_LITERAL"); + tokenTypes.put(new Integer(DOUBLE_LITERAL), "DOUBLE_LITERAL"); + tokenTypes.put(new Integer(CHAR_LITERAL), "CHAR_LITERAL"); + tokenTypes.put(new Integer(STRING_LITERAL), "STRING_LITERAL"); + tokenTypes.put(new Integer(DATE_LITERAL), "DATE_LITERAL"); + tokenTypes.put(new Integer(TIME_LITERAL), "TIME_LITERAL"); + tokenTypes.put(new Integer(TIMESTAMP_LITERAL), "TIMESTAMP_LITERAL"); + tokenTypes.put(new Integer(KEYWORD_BETWEEN), "KEYWORD_BETWEEN"); + } + + /** + * Main function. Takes OQL query string as command line parameter + * and prints Parse Tree version of that query to stdout. + * + * @param args Pass an OQL query string on the command line. + */ + public static void main (String args[]) { + try { + Lexer lexer = new Lexer(args[0]); + Parser parser = new Parser(lexer); + ParseTreeNode theTree = parser.getParseTree(); + _log.debug(treeToString(theTree, NODE_TYPES)); + _log.debug (treeToString(theTree, NODE_VALUES)); + } catch (Exception e) { + _log.error (e.getClass().getName(), e); + } + } + + /** + * Returns a string representation of the tree using lisp tree notation. + * (A, B, C, D) means a root a with + * children B, C, and D. (A, (B, C, D), E) means A with a child B who has + * children C and D, and another child E (of A). + * + * @param theTree the Tree to convert to a string + * @param printWhat should be one of the static members NODE_TYPES or + * NODE_VALUES to tell the method what to write in the string. + * @return a string as described above. + */ + public static String treeToString(ParseTreeNode theTree, int printWhat) { + String retVal = ""; + + Token curToken = theTree.getToken(); + + if ( printWhat == NODE_TYPES ) + retVal = (String)tokenTypes.get(new Integer(curToken.getTokenType())); + else + retVal = curToken.getTokenValue(); + + if ( ! theTree.isLeaf() ) { + retVal = "( " + retVal; + for ( Enumeration e = theTree.children(); e.hasMoreElements(); ) { + retVal = retVal + " , " + + treeToString((ParseTreeNode)e.nextElement(), printWhat); + } + retVal = retVal + " )"; + } + + return retVal; + } +} Index: tests/utf/org/exolab/castor/jdo/transactionmanager/TestTransactionManagerFactoryRegistry.java =================================================================== RCS file: tests/utf/org/exolab/castor/jdo/transactionmanager/TestTransactionManagerFactoryRegistry.java diff -N tests/utf/org/exolab/castor/jdo/transactionmanager/TestTransactionManagerFactoryRegistry.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/utf/org/exolab/castor/jdo/transactionmanager/TestTransactionManagerFactoryRegistry.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,66 @@ +package utf.org.exolab.castor.jdo.transactionmanager; + +import java.io.PrintWriter; +import java.util.Collection; +import java.util.Properties; + +import org.exolab.castor.jdo.transactionmanager.TransactionManagerFactory; +import org.exolab.castor.jdo.transactionmanager.TransactionManagerFactoryRegistry; + +import junit.framework.TestCase; + +/* + * JUnit test case for unit testing TransactionManagerFactoryRegistry. + * @author Werner Guttmann + * + */ +public class TestTransactionManagerFactoryRegistry + extends TestCase +{ + + private PrintWriter writer = null; + + /** + * Constructor for TransactionManagerFactoryRegistryTest. + * @param arg0 + */ + public TestTransactionManagerFactoryRegistry(String arg0) { + super(arg0); + } + + public void testGetTransactionManagerFactory() + throws Exception + { + TransactionManagerFactory localFactory = + TransactionManagerFactoryRegistry.getTransactionManagerFactory ("local"); + + assertEquals("equals", "local", localFactory.getName()); + + TransactionManagerFactory jndiFactoryNoParams = + TransactionManagerFactoryRegistry.getTransactionManagerFactory ("jndi"); + + assertEquals("equals", "jndi", jndiFactoryNoParams.getName()); + assertNull("params == null", jndiFactoryNoParams.getParams()); + + TransactionManagerFactory jndiFactory = + TransactionManagerFactoryRegistry.getTransactionManagerFactory ("jndi"); + + assertEquals("factory name == ", "jndi", jndiFactory.getName()); + + Collection factories = TransactionManagerFactoryRegistry.getTransactionManagerFactories(); + + assertNotNull ("At least one transaction manager factory", factories); + assertEquals ("5 transaction manager factories", 5, factories.size()); + } + + /* (non-Javadoc) + * @see junit.framework.TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + + Properties params = new Properties (); + params.put ("jndiENC", "comp:java/transactionManager"); + } + +} Index: tests/utf/org/exolab/castor/persist/cache/TestCacheRegistry.java =================================================================== RCS file: tests/utf/org/exolab/castor/persist/cache/TestCacheRegistry.java diff -N tests/utf/org/exolab/castor/persist/cache/TestCacheRegistry.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/utf/org/exolab/castor/persist/cache/TestCacheRegistry.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,122 @@ +/** + * Redistribution and use of this software and associated documentation + * ("Software"), with or without modification, are permitted provided + * that the following conditions are met: + * + * 1. Redistributions of source code must retain copyright + * statements and notices. Redistributions must also contain a + * copy of this document. + * + * 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 name "Exolab" must not be used to endorse or promote + * products derived from this Software without prior written + * permission of Intalio, Inc. For written permission, + * please contact info@exolab.org. + * + * 4. Products derived from this Software may not be called "Exolab" + * nor may "Exolab" appear in their names without prior written + * permission of Intalio, Inc. Exolab is a registered + * trademark of Intalio, Inc. + * + * 5. Due credit should be given to the Exolab Project + * (http://www.exolab.org/). + * + * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS + * ``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 + * INTALIO, INC. 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. + * + * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. + * + * $Id: TestCacheRegistry.java,v 1.3 2004/12/14 14:11:11 wguttmann Exp $ + */ +package utf.org.exolab.castor.persist.cache; + +import java.util.Collection; +import java.util.Iterator; + +import org.exolab.castor.persist.cache.Cache; +import org.exolab.castor.persist.cache.CacheRegistry; + +import junit.framework.TestCase; + +/** + * @author Werner Guttmann + */ +public class TestCacheRegistry extends TestCase { + + /** + * @param arg0 + */ + public TestCacheRegistry(String arg0) { + super(arg0); + } + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + } + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + } + + public void testGetCacheFactories() throws Exception { + String[] cacheFactories = CacheRegistry.getCacheFactories(); + assertEquals (4, cacheFactories.length); + } + + public void testGetCaches() throws Exception { + Collection factories = CacheRegistry.getCaches(); + Iterator iterator = factories.iterator(); + assertNotNull (iterator); + assertEquals (true, iterator.hasNext()); + } + + public void testGetCache() throws Exception { + Cache cache = null; + + cache = CacheRegistry.getCache("time-limited", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); + assertEquals ("time-limited", cache.getCacheType()); + assertEquals (10, cache.getCapacity()); + + cache = CacheRegistry.getCache("unlimited", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); + assertEquals ("unlimited", cache.getCacheType()); + assertEquals (10, cache.getCapacity()); + + cache = CacheRegistry.getCache("count-limited", 3, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); + assertEquals ("count-limited", cache.getCacheType()); + assertEquals (30, cache.getCapacity()); + + cache = CacheRegistry.getCache("none", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); + assertEquals ("none", cache.getCacheType()); + assertEquals (10, cache.getCapacity()); + + cache = CacheRegistry.getCache("not-existing", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); + assertNull (cache); + + cache = CacheRegistry.getCache("", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); + assertEquals ("count-limited", cache.getCacheType()); + assertEquals (30, cache.getCapacity()); + + cache = CacheRegistry.getCache(null, 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); + assertEquals ("count-limited", cache.getCacheType()); + assertEquals (30, cache.getCapacity()); + } + +} Index: tests/utf/org/exolab/castor/persist/cache/TestTimeLimited.java =================================================================== RCS file: tests/utf/org/exolab/castor/persist/cache/TestTimeLimited.java diff -N tests/utf/org/exolab/castor/persist/cache/TestTimeLimited.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ tests/utf/org/exolab/castor/persist/cache/TestTimeLimited.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,102 @@ +/** + * Redistribution and use of this software and associated documentation + * ("Software"), with or without modification, are permitted provided + * that the following conditions are met: + * + * 1. Redistributions of source code must retain copyright + * statements and notices. Redistributions must also contain a + * copy of this document. + * + * 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 name "Exolab" must not be used to endorse or promote + * products derived from this Software without prior written + * permission of Intalio, Inc. For written permission, + * please contact info@exolab.org. + * + * 4. Products derived from this Software may not be called "Exolab" + * nor may "Exolab" appear in their names without prior written + * permission of Intalio, Inc. Exolab is a registered + * trademark of Intalio, Inc. + * + * 5. Due credit should be given to the Exolab Project + * (http://www.exolab.org/). + * + * THIS SOFTWARE IS PROVIDED BY INTALIO, INC. AND CONTRIBUTORS + * ``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 + * INTALIO, INC. 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. + * + * Copyright 1999 (C) Intalio, Inc. All Rights Reserved. + * + * $Id: TestTimeLimited.java,v 1.2 2004/12/14 14:11:11 wguttmann Exp $ + */ +package utf.org.exolab.castor.persist.cache; + +import org.exolab.castor.persist.cache.Cache; +import org.exolab.castor.persist.cache.CacheRegistry; + +import junit.framework.TestCase; + +/** + * @author Werner Guttmann + */ +public class TestTimeLimited extends TestCase { + + /** + * Creates an instance of this test case. + * @param arg0 + */ + public TestTimeLimited(String arg0) { + super(arg0); + } + + /* + * @see TestCase#setUp() + */ + protected void setUp() throws Exception { + super.setUp(); + } + + /* + * @see TestCase#tearDown() + */ + protected void tearDown() throws Exception { + super.tearDown(); + } + + + public void testGetCache() throws Exception { + Cache cache = null; + + cache = CacheRegistry.getCache("time-limited", 10, "org.exolab.castor.entity.Sample", getClass().getClassLoader()); + assertEquals ("time-limited", cache.getCacheType()); + assertEquals (10, cache.getCapacity()); + + Object previousValue = cache.put("someKey", "someValue"); + assertNull (previousValue); + + Object value = cache.get ("someKey"); + assertNotNull (value); + assertEquals ("someValue", value); + + Object removedValue = cache.remove("someKey"); + assertNotNull (removedValue); + assertEquals ("someValue", removedValue); + + value = cache.get ("someKey"); + assertNull (value); + } + +}