You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by ni...@apache.org on 2005/12/07 16:12:14 UTC
svn commit: r354761 - in
/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources:
./ impl/
Author: niallp
Date: Wed Dec 7 07:11:58 2005
New Revision: 354761
URL: http://svn.apache.org/viewcvs?rev=354761&view=rev
Log:
de-tab tests and replace cvs $Header$ with SVN $Id$
Modified:
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageListTestCase.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageTestCase.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResources.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResourcesFactory.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollectionResourcesBaseTestCase.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/MessageResources.xml
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/PropertyResourcesTestCase.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesFactoryTestCase.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourcesFactoryBaseTestCase.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/TestResourcesFactory.java
jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/XMLResourcesTestCase.java
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/MessagesTestCase.java,v 1.9 2004/03/27 21:34:10 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -94,176 +94,175 @@
/**
* Test the use of the shortcut getMessages() method.
*/
- public void testLocal() {
- String message = null;
+ public void testLocal() {
+ String message = null;
+
+ Messages local =
+ Messages.getMessages(
+ "org.apache.commons.resources.impl.LocalStrings");
- Messages local =
- Messages.getMessages(
- "org.apache.commons.resources.impl.LocalStrings");
-
assertNotNull("Local messages found", local);
- message = local.getMessage("local.message");
-
+ message = local.getMessage("local.message");
+
assertEquals(
- "Correct individual message",
- "[Local] REPLACE {0} WITH {1}",
- message);
+ "Correct individual message",
+ "[Local] REPLACE {0} WITH {1}",
+ message);
- message =
- local.getMessage("local.message", new String[] { "abc", "def" });
+ message =
+ local.getMessage("local.message", new String[] { "abc", "def" });
- assertEquals(
- "Correct replaced message",
- "[Local] REPLACE abc WITH def",
- message);
-
- local.getResources().setReturnNull(false);
- message = local.getMessage("local.missing");
- assertEquals("Correct missing message", "???local.missing???", message);
-
-
- Messages messages2 = new MyMessages(null);
- Messages messages3 = messages2.getMessages(null);
- assertNull("Invalid Messages", messages3);
+ assertEquals(
+ "Correct replaced message",
+ "[Local] REPLACE abc WITH def",
+ message);
+
+ local.getResources().setReturnNull(false);
+ message = local.getMessage("local.missing");
+ assertEquals("Correct missing message", "???local.missing???", message);
+
- }
-
+ Messages messages2 = new MyMessages(null);
+ Messages messages3 = messages2.getMessages(null);
+ assertNull("Invalid Messages", messages3);
+
+ }
+
/**
* Test the ability to retrieve messages with replacements.
*/
- public void testMessage() {
- String message = null;
+ public void testMessage() {
+ String message = null;
- message = messages.getMessage("test.missing");
- assertEquals("Correct missing message", "???test.missing???", message);
-
- message = messages.getMessage(Locale.ENGLISH, "test.message");
- assertEquals(
- "Correct individual message",
- "[Base] REPLACE {0} WITH {1}",
- message);
-
- message =
- messages.getMessage("test.message", new String[] { "abc", "def" });
-
+ message = messages.getMessage("test.missing");
+ assertEquals("Correct missing message", "???test.missing???", message);
+
+ message = messages.getMessage(Locale.ENGLISH, "test.message");
assertEquals(
- "Correct replaced message",
- "[Base] REPLACE abc WITH def",
- message);
-
- message =
- messages.getMessage(Locale.ENGLISH, "test.message", new String[] { "abc", "def" });
-
+ "Correct individual message",
+ "[Base] REPLACE {0} WITH {1}",
+ message);
+
+ message =
+ messages.getMessage("test.message", new String[] { "abc", "def" });
+
assertEquals(
- "Correct replaced message",
- "[Base] REPLACE abc WITH def",
- message);
-
- message =
- messages.getMessage(Locale.ENGLISH, "test.message.single", "abc");
-
+ "Correct replaced message",
+ "[Base] REPLACE abc WITH def",
+ message);
+
+ message =
+ messages.getMessage(Locale.ENGLISH, "test.message", new String[] { "abc", "def" });
+
+ assertEquals(
+ "Correct replaced message",
+ "[Base] REPLACE abc WITH def",
+ message);
+
+ message =
+ messages.getMessage(Locale.ENGLISH, "test.message.single", "abc");
+
assertEquals(
- "Correct replaced message",
- "[Base] REPLACE abc",
- message);
-
- message =
- messages.getMessage("test.message.single", "abc");
-
+ "Correct replaced message",
+ "[Base] REPLACE abc",
+ message);
+
+ message =
+ messages.getMessage("test.message.single", "abc");
+
assertEquals(
- "Correct replaced message",
- "[Base] REPLACE abc",
- message);
-
- Resources resources2 =
- factory.getResources(NAME + "-does-not-exist",
- CONFIG + "-does-not-exist");
- resources2.setReturnNull(false);
+ "Correct replaced message",
+ "[Base] REPLACE abc",
+ message);
+
+ Resources resources2 =
+ factory.getResources(NAME + "-does-not-exist",
+ CONFIG + "-does-not-exist");
+ resources2.setReturnNull(false);
Messages messages2 = new Messages(resources2);
- message = messages2.getMessage("test.message");
-
- Exception exception = new Exception("Bad Implementation");
- ResourcesException resourcesException = new ResourcesException(exception);
- try{
- if (true)
- throw resourcesException;
- }
- catch(ResourcesException e){
- assertEquals("Check exception", e, resourcesException);
- assertEquals("Check exception cause", e.getRootCause(), exception);
- assertEquals("Check exception message", e.getMessage(), exception.getMessage());
- }
-
- }
+ message = messages2.getMessage("test.message");
+
+ Exception exception = new Exception("Bad Implementation");
+ ResourcesException resourcesException = new ResourcesException(exception);
+ try{
+ if (true)
+ throw resourcesException;
+ }
+ catch(ResourcesException e){
+ assertEquals("Check exception", e, resourcesException);
+ assertEquals("Check exception cause", e.getRootCause(), exception);
+ assertEquals("Check exception message", e.getMessage(), exception.getMessage());
+ }
+
+ }
/**
* Test the ability to retrieve messages with replacements.
*/
- public void testMessages() {
- String message = null;
+ public void testMessages() {
+ String message = null;
+
+ message = messages.getMessage("test.message");
+ assertEquals(
+ "Correct individual message",
+ "[Base] REPLACE {0} WITH {1}",
+ message);
- message = messages.getMessage("test.message");
- assertEquals(
- "Correct individual message",
- "[Base] REPLACE {0} WITH {1}",
- message);
-
- message =
- messages.getMessage("test.message", new String[] { "abc", "def" });
-
+ message =
+ messages.getMessage("test.message", new String[] { "abc", "def" });
+
assertEquals(
- "Correct replaced message",
- "[Base] REPLACE abc WITH def",
- message);
-
- message = messages.getMessage("test.missing");
- assertEquals("Correct missing message", "???test.missing???", message);
-
-
- }
+ "Correct replaced message",
+ "[Base] REPLACE abc WITH def",
+ message);
+
+ message = messages.getMessage("test.missing");
+ assertEquals("Correct missing message", "???test.missing???", message);
+
+
+ }
/**
* Test the characteristics of a newly created instance.
*/
- public void testPristine() {
- assertNotNull(messages);
- assertTrue(
- "Correct wrapped resources",
- resources == messages.getResources());
- }
-
-
- class MyMessages extends Messages{
-
- public MyMessages(Resources resources) {
- super(resources);
- ResourcesFactory factory = new ResourcesFactory(){
- public Resources getResources(String name)
- throws ResourcesException{
- throw new ResourcesException("Bad Implementation");
- }
-
- public boolean isReturnNull() {
- return false;
- }
-
- public void setReturnNull(boolean returnNull) {}
-
- public Resources getResources(String name, String config) throws ResourcesException {
- return null;
- }
-
- public void release() throws ResourcesException {
-
- }
- };
- Messages.setFactory(factory);
- }
-
- }
+ public void testPristine() {
+ assertNotNull(messages);
+ assertTrue(
+ "Correct wrapped resources",
+ resources == messages.getResources());
+ }
+
+
+ class MyMessages extends Messages{
+
+ public MyMessages(Resources resources) {
+ super(resources);
+ ResourcesFactory factory = new ResourcesFactory() {
+ public Resources getResources(String name)
+ throws ResourcesException {
+ throw new ResourcesException("Bad Implementation");
+ }
+
+ public boolean isReturnNull() {
+ return false;
+ }
+
+ public void setReturnNull(boolean returnNull) {}
+
+ public Resources getResources(String name, String config) throws ResourcesException {
+ return null;
+ }
+
+ public void release() throws ResourcesException {
+ }
+ };
+ Messages.setFactory(factory);
+ }
+
+ }
}
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageListTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageListTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageListTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageListTestCase.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/BasicMessageListTestCase.java,v 1.8 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -40,223 +40,223 @@
* Originally based on org.apache.http.action.TestMessages, Revision 1.4.
*/
public class BasicMessageListTestCase extends TestCase {
- protected MessageList aMsgs = null;
- protected MessageList anMsgs = null;
- protected Message msg1 = null;
- protected Message msg2 = null;
- protected Message msg3 = null;
- protected Message msg4 = null;
- protected Message msg5 = null;
- protected Message msg6 = null;
- protected Message msg7 = null;
-
- /**
- * Defines the testcase name for JUnit.
- *
- * @param theName the testcase's name.
- */
- public BasicMessageListTestCase(String theName) {
- super(theName);
- }
-
- /**
- * Start the tests.
- *
- * @param theArgs the arguments. Not used
- */
- public static void main(String[] theArgs) {
- junit.awtui.TestRunner.main(new String[] { BasicMessageListTestCase.class.getName()});
- }
-
- /**
- * @return a test suite (<code>TestSuite</code>) that includes all methods
- * starting with "test"
- */
- public static Test suite() {
- // All methods starting with "test" will be executed in the test suite.
- return new TestSuite(BasicMessageListTestCase.class);
- }
-
- public void setUp() {
- aMsgs = new BasicMessageList();
- anMsgs = new BasicMessageList();
- Object[] objs1 = new Object[] { "a", "b", "c", "d", "e" };
- Object[] objs2 = new Object[] { "f", "g", "h", "i", "j" };
- msg1 = new BasicMessage("aMessage", objs1);
- msg2 = new BasicMessage("anMessage", objs2);
- msg3 = new BasicMessage("msg3", "value1");
- msg4 = new BasicMessage("msg4", "value2");
- msg5 = new BasicMessage("msg5", "value3", "value4");
- msg6 = new BasicMessage("msg5", "value3", "value4", "value5");
- msg7 = new BasicMessage("msg5", "value3", "value4", "value5", "value6");
- }
-
- public void tearDown() {
- aMsgs = null;
- }
-
- public void testEmpty() {
- assertTrue("aMsgs is not empty!", aMsgs.isEmpty());
- }
-
- public void testNotEmpty() {
- aMsgs.add("myProp", msg1);
- assertTrue("aMsgs is empty!", !aMsgs.isEmpty());
- }
-
- public void testSizeWithOneProperty() {
- aMsgs.add("myProp", msg1);
- aMsgs.add("myProp", msg2);
- assertEquals(2, aMsgs.size("myProp"));
- }
-
- public void testSizeWithManyProperties() {
- aMsgs.add("myProp1", msg1);
- aMsgs.add("myProp2", msg2);
- aMsgs.add("myProp3", msg3);
- aMsgs.add("myProp3", msg4);
- aMsgs.add("myProp4", msg5);
- assertEquals(1, aMsgs.size("myProp1"));
- assertEquals(5, aMsgs.size());
- }
-
- public void testSizeAndEmptyAfterClear() {
- testSizeWithOneProperty();
- aMsgs.clear();
- testEmpty();
- assertEquals(0, aMsgs.size("myProp"));
- }
-
- public void testGetWithNoProperty() {
- Iterator it = aMsgs.get("myProp");
- assertTrue("iterator is not empty!", !it.hasNext());
+ protected MessageList aMsgs = null;
+ protected MessageList anMsgs = null;
+ protected Message msg1 = null;
+ protected Message msg2 = null;
+ protected Message msg3 = null;
+ protected Message msg4 = null;
+ protected Message msg5 = null;
+ protected Message msg6 = null;
+ protected Message msg7 = null;
+
+ /**
+ * Defines the testcase name for JUnit.
+ *
+ * @param theName the testcase's name.
+ */
+ public BasicMessageListTestCase(String theName) {
+ super(theName);
+ }
+
+ /**
+ * Start the tests.
+ *
+ * @param theArgs the arguments. Not used
+ */
+ public static void main(String[] theArgs) {
+ junit.awtui.TestRunner.main(new String[] { BasicMessageListTestCase.class.getName()});
+ }
+
+ /**
+ * @return a test suite (<code>TestSuite</code>) that includes all methods
+ * starting with "test"
+ */
+ public static Test suite() {
+ // All methods starting with "test" will be executed in the test suite.
+ return new TestSuite(BasicMessageListTestCase.class);
+ }
+
+ public void setUp() {
+ aMsgs = new BasicMessageList();
+ anMsgs = new BasicMessageList();
+ Object[] objs1 = new Object[] { "a", "b", "c", "d", "e" };
+ Object[] objs2 = new Object[] { "f", "g", "h", "i", "j" };
+ msg1 = new BasicMessage("aMessage", objs1);
+ msg2 = new BasicMessage("anMessage", objs2);
+ msg3 = new BasicMessage("msg3", "value1");
+ msg4 = new BasicMessage("msg4", "value2");
+ msg5 = new BasicMessage("msg5", "value3", "value4");
+ msg6 = new BasicMessage("msg5", "value3", "value4", "value5");
+ msg7 = new BasicMessage("msg5", "value3", "value4", "value5", "value6");
+ }
+
+ public void tearDown() {
+ aMsgs = null;
+ }
+
+ public void testEmpty() {
+ assertTrue("aMsgs is not empty!", aMsgs.isEmpty());
+ }
+
+ public void testNotEmpty() {
+ aMsgs.add("myProp", msg1);
+ assertTrue("aMsgs is empty!", !aMsgs.isEmpty());
+ }
+
+ public void testSizeWithOneProperty() {
+ aMsgs.add("myProp", msg1);
+ aMsgs.add("myProp", msg2);
+ assertEquals(2, aMsgs.size("myProp"));
+ }
+
+ public void testSizeWithManyProperties() {
+ aMsgs.add("myProp1", msg1);
+ aMsgs.add("myProp2", msg2);
+ aMsgs.add("myProp3", msg3);
+ aMsgs.add("myProp3", msg4);
+ aMsgs.add("myProp4", msg5);
+ assertEquals(1, aMsgs.size("myProp1"));
+ assertEquals(5, aMsgs.size());
+ }
+
+ public void testSizeAndEmptyAfterClear() {
+ testSizeWithOneProperty();
+ aMsgs.clear();
+ testEmpty();
+ assertEquals(0, aMsgs.size("myProp"));
+ }
+
+ public void testGetWithNoProperty() {
+ Iterator it = aMsgs.get("myProp");
+ assertTrue("iterator is not empty!", !it.hasNext());
assertTrue(aMsgs.isAccessed());
- }
+ }
- public void testGetForAProperty() {
- testSizeWithOneProperty();
- Iterator it = aMsgs.get("myProp");
- assertTrue("iterator is empty!", it.hasNext());
+ public void testGetForAProperty() {
+ testSizeWithOneProperty();
+ Iterator it = aMsgs.get("myProp");
+ assertTrue("iterator is empty!", it.hasNext());
assertTrue(aMsgs.isAccessed());
- }
+ }
-
-
- /**
- * Tests using the globalMessageKey on the MessageList object.
- */
- public void testGlobalMessageKey() {
- BasicMessage foo1 = new BasicMessage("key1");
- BasicMessage foo2 = new BasicMessage("key2");
- BasicMessage foo3 = new BasicMessage("key3");
-
- MessageList customKeyList =
- new BasicMessageList("custom.global.message.key");
-
- MessageList standardKeyList =
- new BasicMessageList();
-
- customKeyList.add("foo1", foo1);
- customKeyList.add("foo2", foo2);
- customKeyList.add(foo3);
-
- standardKeyList.add("foo1", foo1);
- standardKeyList.add(foo2);
- standardKeyList.add("foo3", foo3);
-
- assertTrue(customKeyList.size() == 3);
- assertTrue(standardKeyList.size() == 3);
-
- assertEquals(customKeyList.getGlobalMessageKey(),
- "custom.global.message.key");
-
- assertEquals(standardKeyList.getGlobalMessageKey(),
- MessageList.GLOBAL_MESSAGE_KEY);
-
- Iterator customKeyListIter =
- customKeyList.get(MessageList.GLOBAL_MESSAGE_KEY);
- while (customKeyListIter.hasNext()) {
- fail("List should be empty");
- }
-
- Message msg = null;
- Iterator standardKeyListIter =
- standardKeyList.get(MessageList.GLOBAL_MESSAGE_KEY);
- while (standardKeyListIter.hasNext()) {
- msg = (Message)standardKeyListIter.next();
- assertEquals(msg.getKey(), "key2");
- }
- msg = null;
-
-
- MessageList customKeyList2 =
- new BasicMessageList("custom.global.message.key", customKeyList);
-
- MessageList standardKeyList2 =
- new BasicMessageList(standardKeyList);
-
- Iterator customKeyList2Iter =
- customKeyList2.get(MessageList.GLOBAL_MESSAGE_KEY);
- while (customKeyList2Iter.hasNext()) {
- fail("List should be empty");
- }
-
- Iterator standardKeyList2Iter =
- standardKeyList2.get(MessageList.GLOBAL_MESSAGE_KEY);
- while (standardKeyList2Iter.hasNext()) {
- msg = (Message)standardKeyList2Iter.next();
- assertEquals(msg.getKey(), "key2");
- }
- msg = null;
-
- Map map = new HashMap();
- assertTrue(map.isEmpty());
-
- MessageList emptyList = new BasicMessageList();
- Iterator emptyListIter = emptyList.get();
- while (emptyListIter.hasNext()) {
- fail("List should be empty");
- }
-
- MessageList mList = new BasicMessageList("foo");
- assertEquals(mList.toString(), "{}");
-
- }
-
-
-
- /**
- * Tests adding an MessageList object to an MessageList object.
- */
- public void testAddMessages() {
-
- msg1 = new BasicMessage("key");
- msg2 = new BasicMessage("key2");
- msg3 = new BasicMessage("key3");
- MessageList outer = new BasicMessageList();
- MessageList inner = new BasicMessageList();
-
- outer.add("prop1", msg1);
- inner.add("prop1", msg2);
- inner.add("prop3", msg3);
-
- outer.add(inner);
- assertEquals(3, outer.size());
- assertEquals(2, outer.size("prop1"));
-
- // test message order
- Iterator props = outer.get();
- int count = 1;
- while (props.hasNext()) {
- Message msg = (Message) props.next();
- if (count == 1) {
- assertTrue(msg.getKey().equals("key"));
- } else if (count == 2) {
- assertTrue(msg.getKey().equals("key2"));
- } else {
- assertTrue(msg.getKey().equals("key3"));
- }
+
+
+ /**
+ * Tests using the globalMessageKey on the MessageList object.
+ */
+ public void testGlobalMessageKey() {
+ BasicMessage foo1 = new BasicMessage("key1");
+ BasicMessage foo2 = new BasicMessage("key2");
+ BasicMessage foo3 = new BasicMessage("key3");
+
+ MessageList customKeyList =
+ new BasicMessageList("custom.global.message.key");
+
+ MessageList standardKeyList =
+ new BasicMessageList();
+
+ customKeyList.add("foo1", foo1);
+ customKeyList.add("foo2", foo2);
+ customKeyList.add(foo3);
+
+ standardKeyList.add("foo1", foo1);
+ standardKeyList.add(foo2);
+ standardKeyList.add("foo3", foo3);
+
+ assertTrue(customKeyList.size() == 3);
+ assertTrue(standardKeyList.size() == 3);
+
+ assertEquals(customKeyList.getGlobalMessageKey(),
+ "custom.global.message.key");
+
+ assertEquals(standardKeyList.getGlobalMessageKey(),
+ MessageList.GLOBAL_MESSAGE_KEY);
+
+ Iterator customKeyListIter =
+ customKeyList.get(MessageList.GLOBAL_MESSAGE_KEY);
+ while (customKeyListIter.hasNext()) {
+ fail("List should be empty");
+ }
+
+ Message msg = null;
+ Iterator standardKeyListIter =
+ standardKeyList.get(MessageList.GLOBAL_MESSAGE_KEY);
+ while (standardKeyListIter.hasNext()) {
+ msg = (Message)standardKeyListIter.next();
+ assertEquals(msg.getKey(), "key2");
+ }
+ msg = null;
+
+
+ MessageList customKeyList2 =
+ new BasicMessageList("custom.global.message.key", customKeyList);
+
+ MessageList standardKeyList2 =
+ new BasicMessageList(standardKeyList);
+
+ Iterator customKeyList2Iter =
+ customKeyList2.get(MessageList.GLOBAL_MESSAGE_KEY);
+ while (customKeyList2Iter.hasNext()) {
+ fail("List should be empty");
+ }
+
+ Iterator standardKeyList2Iter =
+ standardKeyList2.get(MessageList.GLOBAL_MESSAGE_KEY);
+ while (standardKeyList2Iter.hasNext()) {
+ msg = (Message)standardKeyList2Iter.next();
+ assertEquals(msg.getKey(), "key2");
+ }
+ msg = null;
+
+ Map map = new HashMap();
+ assertTrue(map.isEmpty());
+
+ MessageList emptyList = new BasicMessageList();
+ Iterator emptyListIter = emptyList.get();
+ while (emptyListIter.hasNext()) {
+ fail("List should be empty");
+ }
+
+ MessageList mList = new BasicMessageList("foo");
+ assertEquals(mList.toString(), "{}");
+
+ }
+
+
+
+ /**
+ * Tests adding an MessageList object to an MessageList object.
+ */
+ public void testAddMessages() {
+
+ msg1 = new BasicMessage("key");
+ msg2 = new BasicMessage("key2");
+ msg3 = new BasicMessage("key3");
+ MessageList outer = new BasicMessageList();
+ MessageList inner = new BasicMessageList();
+
+ outer.add("prop1", msg1);
+ inner.add("prop1", msg2);
+ inner.add("prop3", msg3);
+
+ outer.add(inner);
+ assertEquals(3, outer.size());
+ assertEquals(2, outer.size("prop1"));
+
+ // test message order
+ Iterator props = outer.get();
+ int count = 1;
+ while (props.hasNext()) {
+ Message msg = (Message) props.next();
+ if (count == 1) {
+ assertTrue(msg.getKey().equals("key"));
+ } else if (count == 2) {
+ assertTrue(msg.getKey().equals("key2"));
+ } else {
+ assertTrue(msg.getKey().equals("key3"));
+ }
count++;
- }
- }
+ }
+ }
}
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/BasicMessageTestCase.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/BasicMessageTestCase.java,v 1.6 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -74,7 +74,7 @@
new BasicMessage("amWithOneValue", new String("stringValue"));
amWithMultipleValues =
new BasicMessage("amWithOneValue",
- new String[]{"stringValue1", "stringValue2", "stringValue3"});
+ new String[]{"stringValue1", "stringValue2", "stringValue3"});
}
public void tearDown() {
@@ -82,8 +82,8 @@
}
public void testBasicMessageWithNoValue() {
-
-
+
+
assertTrue(
"testBasicMessageWithNoValue value is not null",
amWithNoValue.getValues() == null);
@@ -91,13 +91,13 @@
assertTrue(
"testBasicMessageWithNoValue key is not amWithNoValue",
amWithNoValue.getKey() == "amWithNoValue");
-
- amWithNoValue = new BasicMessage();
+
+ amWithNoValue = new BasicMessage();
assertNull(
- "testBasicMessageWithNoValue value is not null",
- amWithNoValue.getValues());
-
+ "testBasicMessageWithNoValue value is not null",
+ amWithNoValue.getValues());
+
}
public void testBasicMessageWithAStringValue() {
@@ -113,11 +113,11 @@
assertTrue(
"testBasicMessageWithAStringValue key is not amWithOneValue",
amWithOneValue.getKey() == "amWithOneValue");
-
- assertEquals("Test toString", amWithOneValue.toString(), "amWithOneValue[stringValue]");
-
- assertEquals("Test toString() (multiple)",
- amWithMultipleValues.toString(), "amWithOneValue[stringValue1, stringValue2, stringValue3]");
-
+
+ assertEquals("Test toString", amWithOneValue.toString(), "amWithOneValue[stringValue]");
+
+ assertEquals("Test toString() (multiple)",
+ amWithMultipleValues.toString(), "amWithOneValue[stringValue1, stringValue2, stringValue3]");
+
}
}
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResources.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResources.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResources.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResources.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/CollResources.java,v 1.7 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResourcesFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResourcesFactory.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResourcesFactory.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollResourcesFactory.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/CollResourcesFactory.java,v 1.7 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollectionResourcesBaseTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollectionResourcesBaseTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollectionResourcesBaseTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/CollectionResourcesBaseTestCase.java Wed Dec 7 07:11:58 2005
@@ -157,14 +157,14 @@
} catch (ResourcesException e) {
fail("Should have returned null");
}
-
+
try {
- resources.setReturnNull(false);
- resources.getString("test.missing", locale);
- fail("Should have thrown ResourcesException");
- } catch (ResourcesKeyException e) {
- // Expected result
- }
+ resources.setReturnNull(false);
+ resources.getString("test.missing", locale);
+ fail("Should have thrown ResourcesException");
+ } catch (ResourcesKeyException e) {
+ // Expected result
+ }
}
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/JDBCResourcesTestCase.java Wed Dec 7 07:11:58 2005
@@ -46,7 +46,7 @@
// ----------------------------------------------------- Instance Variables
- private Connection con;
+ private Connection con;
protected String getBase() throws Exception
@@ -83,10 +83,10 @@
factory = new JDBCResourcesFactory();
resources = factory.getResources(NAME, getBase());
-
-// InputStream in = this.getClass().getResourceAsStream("init.sql");
+
+// InputStream in = this.getClass().getResourceAsStream("init.sql");
// File file = new File("init.sql");
-
+
// change this to load from init.sql
String[] sql = {""
+ "create table resources ("
@@ -98,7 +98,7 @@
+ " msgKey"
+ " )"
+ " );"
- , "Insert into resources (locale, msgKey, val) Values ('', 'test.base', '[Base] ONLY');"
+ , "Insert into resources (locale, msgKey, val) Values ('', 'test.base', '[Base] ONLY');"
, "Insert into resources (locale, msgKey, val) Values ('', 'test.specific', '[Base] SPECIFIC');"
, "Insert into resources (locale, msgKey, val) Values ('', 'test.inherit', '[Base] INHERIT');"
, "Insert into resources (locale, msgKey, val) Values ('', 'test.message.single', '[Base] REPLACE {0}');"
@@ -125,11 +125,11 @@
return;
}
try{
- runSql(new String[]{"drop table resources"});
- con.close();
+ runSql(new String[]{"drop table resources"});
+ con.close();
}catch(Exception e){
- // not really necessary to fail if creation also fails
- e.printStackTrace();
+ // not really necessary to fail if creation also fails
+ e.printStackTrace();
}
}
@@ -179,35 +179,35 @@
// ------------------------------------------------------ Private Methods
/**
- * @param sql
- * @throws SQLException
- */
- private void runSql(String[] sql) throws SQLException {
-
- String url = "jdbc:hsqldb:.";
-
- Statement stmt;
- try {
- Class.forName("org.hsqldb.jdbcDriver");
-
- } catch(java.lang.ClassNotFoundException e) {
- fail("ClassNotFoundException:" + e.getMessage());
- }
-
- try {
- // TODO change this to pull from jdbc.test.config.properties
- if (con == null || con.isClosed())
- con = DriverManager.getConnection(url, "sa", "");
- stmt = con.createStatement();
-
- for (int i = 0; i < sql.length; i++) {
- stmt.execute(sql[i]);
- }
- stmt.close();
-
- } catch(SQLException ex) {
- fail("SQLException: " + ex.getMessage());
- }
+ * @param sql
+ * @throws SQLException
+ */
+ private void runSql(String[] sql) throws SQLException {
+
+ String url = "jdbc:hsqldb:.";
+
+ Statement stmt;
+ try {
+ Class.forName("org.hsqldb.jdbcDriver");
+
+ } catch(java.lang.ClassNotFoundException e) {
+ fail("ClassNotFoundException:" + e.getMessage());
+ }
+
+ try {
+ // TODO change this to pull from jdbc.test.config.properties
+ if (con == null || con.isClosed())
+ con = DriverManager.getConnection(url, "sa", "");
+ stmt = con.createStatement();
+
+ for (int i = 0; i < sql.length; i++) {
+ stmt.execute(sql[i]);
+ }
+ stmt.close();
+
+ } catch(SQLException ex) {
+ fail("SQLException: " + ex.getMessage());
+ }
}
private boolean isPre14JVM() {
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/MessageResources.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/MessageResources.xml?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/MessageResources.xml (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/MessageResources.xml Wed Dec 7 07:11:58 2005
@@ -7,7 +7,7 @@
<sql-map name="MessageResources">
<result-map name="bundle-result"
- class="org.apache.commons.resources.impl.DatabaseBasicMessage">
+ class="org.apache.commons.resources.impl.DatabaseBasicMessage">
<property name="locale" type="VARCHAR" column="locale"/>
<property name="key" type="VARCHAR" column="msgKey"/>
<property name="value" type="VARCHAR" column="val"/>
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/PropertyResourcesTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/PropertyResourcesTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/PropertyResourcesTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/PropertyResourcesTestCase.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/PropertyResourcesTestCase.java,v 1.7 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesFactoryTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesFactoryTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesFactoryTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesFactoryTestCase.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/ResourceBundleResourcesFactoryTestCase.java,v 1.6 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourcesFactoryBaseTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourcesFactoryBaseTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourcesFactoryBaseTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/ResourcesFactoryBaseTestCase.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/ResourcesFactoryBaseTestCase.java,v 1.6 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/TestResourcesFactory.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/TestResourcesFactory.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/TestResourcesFactory.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/TestResourcesFactory.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/TestResourcesFactory.java,v 1.8 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/XMLResourcesTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/XMLResourcesTestCase.java?rev=354761&r1=354760&r2=354761&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/XMLResourcesTestCase.java (original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/impl/XMLResourcesTestCase.java Wed Dec 7 07:11:58 2005
@@ -1,11 +1,11 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//resources/src/test/org/apache/commons/resources/impl/XMLResourcesTestCase.java,v 1.7 2004/03/27 21:34:09 dgraham Exp $
+ * $Id$
* $Revision$
* $Date$
*
* ====================================================================
*
- * Copyright 2003-2004 The Apache Software Foundation
+ * Copyright 2003-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org