Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 44514 invoked from network); 8 Jul 2004 15:30:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 8 Jul 2004 15:30:31 -0000 Received: (qmail 3181 invoked by uid 500); 8 Jul 2004 15:30:26 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 3046 invoked by uid 500); 8 Jul 2004 15:30:25 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 3033 invoked by uid 500); 8 Jul 2004 15:30:25 -0000 Received: (qmail 3025 invoked by uid 99); 8 Jul 2004 15:30:25 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Thu, 08 Jul 2004 08:30:25 -0700 Received: (qmail 44347 invoked by uid 1865); 8 Jul 2004 15:30:24 -0000 Date: 8 Jul 2004 15:30:24 -0000 Message-ID: <20040708153024.44346.qmail@minotaur.apache.org> From: ebourg@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration TestJNDIEnvironmentValues.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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