You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jm...@apache.org on 2005/05/13 20:32:13 UTC

svn commit: r170067 - in /jakarta/commons/proper/resources/trunk/src: java/org/apache/commons/resources/Messages.java test/org/apache/commons/resources/MessagesTestCase.java test/org/apache/commons/resources/impl/BasicMessageListTestCase.java test/org/apache/commons/resources/impl/BasicMessageTestCase.java

Author: jmitchell
Date: Fri May 13 11:32:13 2005
New Revision: 170067

URL: http://svn.apache.org/viewcvs?rev=170067&view=rev
Log:
BasicMessage is at 100% test coverage

Modified:
    jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
    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

Modified: jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java?rev=170067&r1=170066&r2=170067&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java (original)
+++ jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java Fri May 13 11:32:13 2005
@@ -220,7 +220,6 @@
 		String message = null;
 		try {
 			message = resources.getString(key, locale, null);
-
 		} catch (ResourcesException e) {
 			log.debug("Failed retrieving message for key: '" + key + "'.", e);
 		}

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=170067&r1=170066&r2=170067&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 Fri May 13 11:32:13 2005
@@ -182,6 +182,19 @@
 		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());
+		}
+		
 	}
 
 

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=170067&r1=170066&r2=170067&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 Fri May 13 11:32:13 2005
@@ -45,6 +45,8 @@
 	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.
@@ -83,6 +85,8 @@
 		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() {

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=170067&r1=170066&r2=170067&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 Fri May 13 11:32:13 2005
@@ -38,6 +38,8 @@
     
     protected BasicMessage amWithOneValue = null;
     
+    protected BasicMessage amWithMultipleValues = null;
+    
     /**
      * Defines the testcase name for JUnit.
      *
@@ -70,6 +72,9 @@
         amWithNoValue = new BasicMessage("amWithNoValue");
         amWithOneValue =
             new BasicMessage("amWithOneValue", new String("stringValue"));
+        amWithMultipleValues =
+            new BasicMessage("amWithOneValue", 
+					new String[]{"stringValue1", "stringValue2", "stringValue3"});
     }
 
     public void tearDown() {
@@ -77,6 +82,8 @@
     }
     
     public void testBasicMessageWithNoValue() {
+		
+		
         assertTrue(
             "testBasicMessageWithNoValue value is not null",
             amWithNoValue.getValues() == null);
@@ -84,6 +91,13 @@
         assertTrue(
             "testBasicMessageWithNoValue key is not amWithNoValue",
             amWithNoValue.getKey() == "amWithNoValue");
+		
+		amWithNoValue = new BasicMessage();
+
+        assertNull(
+	            "testBasicMessageWithNoValue value is not null",
+	            amWithNoValue.getValues());
+		
     }
 
     public void testBasicMessageWithAStringValue() {
@@ -99,5 +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]");
+		
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org