commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestJNDIEnvironmentValues.java
Date Thu, 08 Jul 2004 15:30:24 GMT
ebourg      2004/07/08 08:30:24

  Modified:    configuration/src/test/org/apache/commons/configuration
                        TestJNDIEnvironmentValues.java
  Log:
  more tests for getKeys(String)
  
  Revision  Changes    Path
  1.7       +33 -6     jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestJNDIEnvironmentValues.java
  
  Index: TestJNDIEnvironmentValues.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestJNDIEnvironmentValues.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestJNDIEnvironmentValues.java	21 Jun 2004 15:35:15 -0000	1.6
  +++ TestJNDIEnvironmentValues.java	8 Jul 2004 15:30:24 -0000	1.7
  @@ -27,10 +27,9 @@
   
       public void setUp() throws Exception
       {
  -        System.setProperty("java.naming.factory.initial","org.apache.commons.configuration.MockStaticMemoryInitialContextFactory");
  +        System.setProperty("java.naming.factory.initial", TestJNDIConfiguration.CONTEXT_FACTORY);
           
           conf = new JNDIConfiguration();
  -        conf.setPrefix("");
       }
   
       public void testSimpleGet() throws Exception
  @@ -54,9 +53,9 @@
               conf.getString("test.imaginarykey");
               fail("Should have thrown NoSuchElementException");
           }
  -        catch (NoSuchElementException nsee)
  +        catch (NoSuchElementException e)
           {
  -            assertTrue(nsee.getMessage(),nsee.getMessage().indexOf("test.imaginarykey")!=-1);
  +            assertTrue(e.getMessage(), e.getMessage().indexOf("test.imaginarykey") != -1);
           }
       }
   
  @@ -91,17 +90,45 @@
   
           assertTrue("no key found", it.hasNext());
   
  -        while (it.hasNext() && !found) {
  +        while (it.hasNext() && !found)
  +        {
               found = "test.boolean".equals(it.next());
           }
   
           assertTrue("'test.boolean' key not found", found);
       }
   
  -    public void testGetKeysWithPrefix()
  +    public void testGetKeysWithUnknownPrefix()
       {
  +        // test for a unknown prefix
           Iterator it = conf.getKeys("foo.bar");
           assertFalse("no key should be found", it.hasNext());
  +    }
  +
  +    public void testGetKeysWithExistingPrefix()
  +    {
  +        // test for an existing prefix
  +        Iterator it = conf.getKeys("test");
  +        boolean found = false;
  +        while (it.hasNext() && !found)
  +        {
  +            found = "test.boolean".equals(it.next());
  +        }
  +
  +        assertTrue("'test.boolean' key not found", found);
  +    }
  +
  +    public void testGetKeysWithKeyAsPrefix()
  +    {
  +        // test for a prefix matching exactly the key of a property
  +        Iterator it = conf.getKeys("test.boolean");
  +        boolean found = false;
  +        while (it.hasNext() && !found)
  +        {
  +            found = "test.boolean".equals(it.next());
  +        }
  +
  +        assertTrue("'test.boolean' key not found", found);
       }
   
   }
  
  
  

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


Mime
View raw message