commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject cvs commit: jakarta-commons-sandbox/util/src/test/org/apache/commons/util FastPropertyResourceBundle.test.conf FastPropertyResourceBundleTest.java
Date Thu, 31 Jan 2002 19:21:12 GMT
dlr         02/01/31 11:21:12

  Added:       util/src/test/org/apache/commons/util
                        FastPropertyResourceBundle.test.conf
                        FastPropertyResourceBundleTest.java
  Log:
  Test from leandro.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/util/src/test/org/apache/commons/util/FastPropertyResourceBundle.test.conf
  
  Index: FastPropertyResourceBundle.test.conf
  ===================================================================
  key1=value1
  key2=value2
  
  
  
  1.1                  jakarta-commons-sandbox/util/src/test/org/apache/commons/util/FastPropertyResourceBundleTest.java
  
  Index: FastPropertyResourceBundleTest.java
  ===================================================================
  package org.apache.commons.util;
  
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.framework.Test;
  import junit.framework.Assert;
  
  import java.io.InputStream;
  import java.io.FileInputStream;
  import java.util.Enumeration;
  
  /**
   * @author <a href="mailto:leandro@ibnetwork.com.br">Leandro Rodrigo Saad Cruz</a>
   * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
   */
  public class FastPropertyResourceBundleTest
      extends TestCase
  {
      protected static final String RESOURCE_NAME =
          "org/apache/commons/util/FastPropertyResourceBundle.test.conf";
  
      FastPropertyResourceBundle rb;
      Object first; 
      Object second; 
  
  
      public FastPropertyResourceBundleTest(String name)
      {
          super(name);
      }
  
      protected void setUp()
          throws Exception
      {
          ClassLoader loader = getClass().getClassLoader();
          InputStream in = loader.getResourceAsStream(RESOURCE_NAME);
          rb = new FastPropertyResourceBundle(in);
          first = new String("value1");
          second = new String("value2");
      }
  
      protected void tearDown()
      {
  
      }
  
      public void testFileContents()
      {
          Assert.assertTrue(rb.getString("key1").equals(first));
          Assert.assertTrue(!rb.getString("key1").equals(second));
          Assert.assertTrue(rb.getString("key2").equals(second));
          Assert.assertTrue(!rb.getString("key2").equals(first));
      }
  
      public void testCacheSize()
      {
          Enumeration enum = rb.getKeys();
          int count = 0;
          while(enum.hasMoreElements())
          {
              count++;
              enum.nextElement();
          }
          
          Assert.assertTrue(2 == count);
      }
      
      public static Test suite() 
      {
          return new TestSuite(FastPropertyResourceBundleTest.class);
      }
  }
  
  
  

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


Mime
View raw message