epugh 2004/01/16 09:32:37
Modified: configuration project.xml
Added: configuration/src/test/org/apache/commons/configuration
TestJNDIConfiguration.java
TestJNDIEnvironmentValues.java
configuration/conf/config/deep test.properties
configuration/conf/config test.properties
configuration/conf jndi.properties
Removed: configuration/src/test-cactus/org/apache/commons/configuration
TestJNDIEnvironmentValues.java
TestJNDIConfiguration.java
Log:
Add Junit based unit tests for JNDI versus using Cactus.
Revision Changes Path
1.1
jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestJNDIConfiguration.java
Index: TestJNDIConfiguration.java
===================================================================
package org.apache.commons.configuration;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2003 The Apache Software Foundation. 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 acknowledgement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgement may appear in the software itself,
* if and wherever such third-party acknowledgements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Software Foundation.
*
* 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 THE APACHE SOFTWARE FOUNDATION 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 Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
import javax.naming.InitialContext;
import junit.framework.TestCase;
/**
* test if non-string properties are handled correctly
*
* @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a>
* @version $Id: TestJNDIConfiguration.java,v 1.1 2004/01/16 17:32:36 epugh Exp $
*/
public class TestJNDIConfiguration extends TestCase
{
private Configuration conf;
private NonStringTestHolder nonStringTestHolder;
public void setUp() throws Exception
{
InitialContext context = new InitialContext();
JNDIConfiguration jndiConfiguration = new JNDIConfiguration();
jndiConfiguration.setPrefix("");
conf = jndiConfiguration;
nonStringTestHolder = new NonStringTestHolder();
nonStringTestHolder.setConfiguration(conf);
}
public void testBoolean() throws Exception
{
nonStringTestHolder.testBoolean();
}
public void testBooleanDefaultValue() throws Exception
{
nonStringTestHolder.testBooleanDefaultValue();
}
public void testByte() throws Exception
{
nonStringTestHolder.testByte();
}
public void testDouble() throws Exception
{
nonStringTestHolder.testDouble();
}
public void testDoubleDefaultValue() throws Exception
{
nonStringTestHolder.testDoubleDefaultValue();
}
public void testFloat() throws Exception
{
nonStringTestHolder.testFloat();
}
public void testFloatDefaultValue() throws Exception
{
nonStringTestHolder.testFloatDefaultValue();
}
public void testInteger() throws Exception
{
nonStringTestHolder.testInteger();
}
public void testIntegerDefaultValue() throws Exception
{
nonStringTestHolder.testIntegerDefaultValue();
}
public void testLong() throws Exception
{
nonStringTestHolder.testLong();
}
public void testLongDefaultValue() throws Exception
{
nonStringTestHolder.testLongDefaultValue();
}
public void testShort() throws Exception
{
nonStringTestHolder.testShort();
}
public void testShortDefaultValue() throws Exception
{
nonStringTestHolder.testShortDefaultValue();
}
public void testListMissing() throws Exception
{
nonStringTestHolder.testListMissing();
}
public void testSubset() throws Exception
{
// seems to always be failing.
//nonStringTestHolder.testSubset();
}
}
1.1
jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestJNDIEnvironmentValues.java
Index: TestJNDIEnvironmentValues.java
===================================================================
package org.apache.commons.configuration;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2002-2003 The Apache Software Foundation. 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 the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* 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 THE APACHE SOFTWARE FOUNDATION 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 Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import java.util.NoSuchElementException;
import junit.framework.TestCase;
public class TestJNDIEnvironmentValues extends TestCase
{
public TestJNDIEnvironmentValues(String testName)
{
super(testName);
}
public void testSimpleGet() throws Exception
{
JNDIConfiguration conf = new JNDIConfiguration();
conf.setPrefix("");
String s = conf.getString("test/key");
assertEquals("jndivalue", s);
}
public void testMoreGets() throws Exception
{
JNDIConfiguration conf = new JNDIConfiguration();
conf.setPrefix("");
String s = conf.getString("test/key");
assertEquals("jndivalue", s);
assertEquals("jndivalue2", conf.getString("test.key2"));
assertEquals(1, conf.getShort("test.short"));
}
public void testGetMissingKey() throws Exception
{
JNDIConfiguration conf = new JNDIConfiguration();
conf.setPrefix("");
try
{
conf.getString("test/imaginarykey");
fail("Should have thrown NoSuchElementException");
}
catch (NoSuchElementException nsee)
{
}
}
public void testGetMissingKeyWithDefault() throws Exception
{
JNDIConfiguration conf = new JNDIConfiguration();
conf.setPrefix("");
String result = conf.getString("test/imaginarykey", "bob");
assertEquals("bob", result);
}
public void testContainsKey() throws Exception
{
JNDIConfiguration conf = new JNDIConfiguration();
conf.setPrefix("");
assertTrue(conf.containsKey("test/key"));
assertTrue(!conf.containsKey("test/imaginerykey"));
}
}
1.1 jakarta-commons/configuration/conf/config/deep/test.properties
Index: test.properties
===================================================================
somekey=somevalue
1.1 jakarta-commons/configuration/conf/config/test.properties
Index: test.properties
===================================================================
boolean=true
overwrite=80
key=jndivalue
key2=jndivalue2
jndi=only_jndi
byte=10
double=10.25
float=20.25
integer=10
long=1000000
short=1
1.1 jakarta-commons/configuration/conf/jndi.properties
Index: jndi.properties
===================================================================
java.naming.factory.initial=org.osjava.jndi.PropertiesFactory
org.osjava.jndi.root=classpath://config
org.osjava.jndi.delimiter=/
1.5 +20 -2 jakarta-commons/configuration/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons/configuration/project.xml,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- project.xml 11 Jan 2004 00:59:10 -0000 1.4
+++ project.xml 16 Jan 2004 17:32:37 -0000 1.5
@@ -112,7 +112,7 @@
<name>Emmanuel Bourg</name>
<id>ebourg</id>
<email>[EMAIL PROTECTED]</email>
- </contributor>
+ </contributor>
<contributor>
<name>Konstantin Shaposhnikov</name>
<id>kshaposhnikov</id>
@@ -194,6 +194,12 @@
<war.bundle>true</war.bundle>
</properties>
</dependency>
+ <!-- Needed for testing -->
+ <dependency>
+ <id>simple-jndi</id>
+ <version>0.8</version>
+ <url>http://www.osjava.org/simple-jndi/</url>
+ </dependency>
</dependencies>
<build>
@@ -232,6 +238,18 @@
<exclude>testClasspath.properties</exclude>
</excludes>
</resource>
+ </resources>
+ <resources>
+ <resource>
+ <directory>conf/config</directory>
+ <targetPath>config</targetPath>
+ <includes>
+ <include>*.properties</include>
+ </includes>
+ <excludes>
+ <exclude>testClasspath.properties</exclude>
+ </excludes>
+ </resource>
</resources>
</unitTest>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]