commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ohe...@apache.org
Subject svn commit: r1081931 - in /commons/proper/configuration/branches/configuration2_experimental/src: changes/changes.xml main/java/org/apache/commons/configuration2/JNDIConfiguration.java test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java
Date Tue, 15 Mar 2011 20:30:51 GMT
Author: oheger
Date: Tue Mar 15 20:30:51 2011
New Revision: 1081931

URL: http://svn.apache.org/viewvc?rev=1081931&view=rev
Log:
Fixed some warnings.
Added a test to demonstrate that JNDIConfiguration.getKeys() does not log an exception for
an unknown prefix.

Modified:
    commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml
    commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/JNDIConfiguration.java
    commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java

Modified: commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml?rev=1081931&r1=1081930&r2=1081931&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/changes/changes.xml
Tue Mar 15 20:30:51 2011
@@ -79,6 +79,10 @@
     </release>
 
     <release version="1.7" date="in SVN" description="">
+      <action dev="oheger" type="update" issue="CONFIGURATION-438" due-to="Mike Noordermeer">
+        JNDIConfiguration.getKeys() no more logs an exception if the prefix does
+        not exist.
+      </action>
       <action dev="oheger" type="fix" issue="CONFIGURATION-434">
         HierarchicalINIConfiguration now recognizes comment characters in
         property definitions only if they are preceded by whitespace. Thus

Modified: commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/JNDIConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/JNDIConfiguration.java?rev=1081931&r1=1081930&r2=1081931&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/JNDIConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/main/java/org/apache/commons/configuration2/JNDIConfiguration.java
Tue Mar 15 20:30:51 2011
@@ -20,7 +20,6 @@ package org.apache.commons.configuration
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import org.apache.commons.logging.LogFactory;
 
 import javax.naming.Context;
 import javax.naming.InitialContext;
@@ -30,6 +29,7 @@ import javax.naming.NamingEnumeration;
 import javax.naming.NamingException;
 
 import org.apache.commons.configuration2.expr.AbstractNodeHandler;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * This Configuration class allows you to interface with a JNDI datasource.
@@ -114,6 +114,7 @@ public class JNDIConfiguration extends A
         addErrorLogListener();
     }
 
+    @Override
     public JNDINode getRootNode()
     {
         return root;
@@ -230,6 +231,7 @@ public class JNDIConfiguration extends A
             this.config = config;
         }
 
+        @Override
         public boolean hasAttributes(JNDINode node)
         {
             return false;
@@ -321,14 +323,14 @@ public class JNDIConfiguration extends A
                 {
                     Context context = (Context) value;
 
-                    NamingEnumeration elements = null;
+                    NamingEnumeration<NameClassPair> elements = null;
 
                     try
                     {
                         elements = context.list("");
                         while (elements.hasMore())
                         {
-                            NameClassPair nameClassPair = (NameClassPair) elements.next();
+                            NameClassPair nameClassPair = elements.next();
                             String name = nameClassPair.getName();
 
                             children.add(new JNDINode(context, name, node.depth + 1));

Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java
URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java?rev=1081931&r1=1081930&r2=1081931&view=diff
==============================================================================
--- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java
(original)
+++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestJNDIConfiguration.java
Tue Mar 15 20:30:51 2011
@@ -20,6 +20,7 @@ package org.apache.commons.configuration
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.NoSuchElementException;
+
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
@@ -40,6 +41,7 @@ public class TestJNDIConfiguration exten
     /** A test error listener for counting internal errors.*/
     private ConfigurationErrorListenerImpl listener;
 
+    @Override
     public void setUp() throws Exception
     {
         System.setProperty("java.naming.factory.initial", CONTEXT_FACTORY);
@@ -57,6 +59,7 @@ public class TestJNDIConfiguration exten
      * Clears the test environment. If an error listener is defined, checks
      * whether no error event was received.
      */
+    @Override
     protected void tearDown() throws Exception
     {
         if (listener != null)
@@ -186,7 +189,7 @@ public class TestJNDIConfiguration exten
     public void testGetKeys() throws Exception
     {
         boolean found = false;
-        Iterator it = conf.getKeys();
+        Iterator<String> it = conf.getKeys();
 
         assertTrue("no key found", it.hasNext());
 
@@ -201,14 +204,15 @@ public class TestJNDIConfiguration exten
     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());
+        listener.verify();
     }
 
     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)
         {
@@ -335,7 +339,7 @@ public class TestJNDIConfiguration exten
      */
     public void testGetKeysWithCycles() throws NamingException
     {
-        Hashtable env = new Hashtable();
+        Hashtable<Object, Object> env = new Hashtable<Object, Object>();
         env.put(MockInitialContextFactory.PROP_CYCLES, Boolean.TRUE);
         InitialContext initCtx = new InitialContext(env);
         conf = new JNDIConfiguration(initCtx);



Mime
View raw message