commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1224816 - /commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullJNDIEnvironmentValues.java
Date Mon, 26 Dec 2011 21:18:18 GMT
Author: oheger
Date: Mon Dec 26 21:18:18 2011
New Revision: 1224816

URL: http://svn.apache.org/viewvc?rev=1224816&view=rev
Log:
Converted tests to JUnit 4, fixed warnings.

Modified:
    commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullJNDIEnvironmentValues.java

Modified: commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullJNDIEnvironmentValues.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullJNDIEnvironmentValues.java?rev=1224816&r1=1224815&r2=1224816&view=diff
==============================================================================
--- commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullJNDIEnvironmentValues.java
(original)
+++ commons/proper/configuration/trunk/src/test/java/org/apache/commons/configuration/TestNullJNDIEnvironmentValues.java
Mon Dec 26 21:18:18 2011
@@ -17,33 +17,44 @@
 
 package org.apache.commons.configuration;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 import java.util.Iterator;
 
-import junit.framework.TestCase;
+import org.junit.Before;
+import org.junit.Test;
 
-public class TestNullJNDIEnvironmentValues extends TestCase
+public class TestNullJNDIEnvironmentValues
 {
     private JNDIConfiguration conf = null;
 
+    @Before
     public void setUp() throws Exception
     {
         System.setProperty("java.naming.factory.initial", TestJNDIConfiguration.CONTEXT_FACTORY);
-        
+
         conf = new JNDIConfiguration();
         conf.setThrowExceptionOnMissing(false);
     }
 
+    @Test
     public void testThrowExceptionOnMissing()
     {
         assertFalse("Throw Exception Property is set!", conf.isThrowExceptionOnMissing());
     }
 
+    @Test
     public void testSimpleGet() throws Exception
     {
         String s = conf.getString("test.key");
         assertEquals("jndivalue", s);
     }
 
+    @Test
     public void testMoreGets() throws Exception
     {
         String s = conf.getString("test.key");
@@ -52,39 +63,45 @@ public class TestNullJNDIEnvironmentValu
         assertEquals(1, conf.getShort("test.short"));
     }
 
+    @Test
     public void testGetMissingKey() throws Exception
     {
         assertNull("Missing Key is not null!", conf.getString("test.imaginarykey"));
     }
 
+    @Test
     public void testGetMissingKeyWithDefault() throws Exception
     {
         String result = conf.getString("test.imaginarykey", "bob");
         assertEquals("bob", result);
     }
 
+    @Test
     public void testContainsKey() throws Exception
     {
         assertTrue(conf.containsKey("test.key"));
         assertTrue(!conf.containsKey("test.imaginarykey"));
     }
-    
+
+    @Test
     public void testClearProperty()
     {
         assertNotNull("null short for the 'test.short' key", conf.getShort("test.short",
null));
         conf.clearProperty("test.short");
         assertNull("'test.short' property not cleared", conf.getShort("test.short", null));
     }
-    
+
+    @Test
     public void testIsEmpty()
     {
         assertFalse("the configuration shouldn't be empty", conf.isEmpty());
     }
-    
+
+    @Test
     public void testGetKeys() throws Exception
     {
         boolean found = false;
-        Iterator it = conf.getKeys();
+        Iterator<String> it = conf.getKeys();
 
         assertTrue("no key found", it.hasNext());
 
@@ -96,17 +113,19 @@ public class TestNullJNDIEnvironmentValu
         assertTrue("'test.boolean' key not found", found);
     }
 
+    @Test
     public void testGetKeysWithUnknownPrefix()
     {
         // test for a unknown prefix
-        Iterator it = conf.getKeys("foo.bar");
+        Iterator<String> it = conf.getKeys("foo.bar");
         assertFalse("no key should be found", it.hasNext());
     }
 
+    @Test
     public void testGetKeysWithExistingPrefix()
     {
         // test for an existing prefix
-        Iterator it = conf.getKeys("test");
+        Iterator<String> it = conf.getKeys("test");
         boolean found = false;
         while (it.hasNext() && !found)
         {
@@ -116,10 +135,11 @@ public class TestNullJNDIEnvironmentValu
         assertTrue("'test.boolean' key not found", found);
     }
 
+    @Test
     public void testGetKeysWithKeyAsPrefix()
     {
         // test for a prefix matching exactly the key of a property
-        Iterator it = conf.getKeys("test.boolean");
+        Iterator<String> it = conf.getKeys("test.boolean");
         boolean found = false;
         while (it.hasNext() && !found)
         {
@@ -128,5 +148,4 @@ public class TestNullJNDIEnvironmentValu
 
         assertTrue("'test.boolean' key not found", found);
     }
-
 }



Mime
View raw message