geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject cvs commit: incubator-geronimo/modules/twiddle/src/test/org/apache/geronimo/twiddle/config StringValueParserTest.java
Date Sun, 24 Aug 2003 20:09:25 GMT
jdillon     2003/08/24 13:09:25

  Modified:    modules/common project.xml
               modules/twiddle project.xml
               modules/twiddle/src/java/org/apache/geronimo/twiddle/config
                        Configurator.java
  Added:       modules/common/src/test/org/apache/geronimo/common
                        StringValueParserTest.java
               modules/twiddle/src/java/org/apache/geronimo/twiddle/console
                        InteractiveConsole.java
  Removed:     modules/twiddle/src/java/org/apache/geronimo/twiddle/config
                        StringValueParser.java
               modules/twiddle/src/test/org/apache/geronimo/twiddle/config
                        StringValueParserTest.java
  Log:
   o Moved StringValueParser (and tests) to common
  
  Revision  Changes    Path
  1.6       +10 -1     incubator-geronimo/modules/common/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/common/project.xml,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- project.xml	16 Aug 2003 19:18:32 -0000	1.5
  +++ project.xml	24 Aug 2003 20:09:25 -0000	1.6
  @@ -39,6 +39,15 @@
       </dependency>
       
       <dependency>
  +      <id>commons-jexl</id>
  +      <version>SNAPSHOT</version>
  +      <url>http://jakarta.apache.org/commons/jexl.html</url>
  +      <properties>
  +        <runtime>true</runtime>
  +      </properties>
  +    </dependency>
  +    
  +    <dependency>
         <id>log4j</id>
         <version>1.2.8</version>
         <url>http://jakarta.apache.org/log4j</url>
  
  
  
  1.1                  incubator-geronimo/modules/common/src/test/org/apache/geronimo/common/StringValueParserTest.java
  
  Index: StringValueParserTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.common;
  
  import junit.framework.TestCase;
  
  /**
   * Tests for <code>Configuration</code>.
   *
   * @version <code>$Revision: 1.1 $ $Date: 2003/08/24 20:09:25 $</code>
   */
  public class StringValueParserTest
      extends TestCase
  {
      protected StringValueParser parser;
      
      /**
       * Set up instance variables required by this test case.
       */
      protected void setUp()
      {
          parser = new StringValueParser();
      }
      
      /**
       * Tear down instance variables required by this test case.
       */
      protected void tearDown()
      {
          parser = null;
      }
      
      
      /////////////////////////////////////////////////////////////////////////
      //                               Tests                                 //
      /////////////////////////////////////////////////////////////////////////
      
      public void testDefault() throws Exception
      {
          String value = "${java.home}";
          String result = parser.parse(value);
          assertEquals(result, System.getProperty("java.home"));
      }
      
      public void testSubst() throws Exception
      {
          String value = "BEFORE${java.home}AFTER";
          String result = parser.parse(value);
          assertEquals(result, "BEFORE" + System.getProperty("java.home") + "AFTER");
      }
      
      public void testVariable() throws Exception
      {
          String myvar = "this is my variable";
          parser.getVariables().put("my.var", myvar);
          
          String value = "${my.var}";
          String result = parser.parse(value);
          assertEquals(result, myvar);
      }
      
      public void testFlatVariable() throws Exception
      {
          String myvar = "this is my variable";
          parser.getVariables().put("my.var", myvar);
          parser.getVariables().put("my", "not used");
          
          String value = "${my.var}";
          String result = parser.parse(value);
          assertEquals(result, myvar);
      }
      
      public void testSyntax() throws Exception
      {
          String value = "${java.home";
              
          try {
              String result = parser.parse(value);
              assertTrue("Should have thrown an exception", false);
          }
          catch (Exception ignore) {}
      }
  }
  
  
  
  1.8       +1 -10     incubator-geronimo/modules/twiddle/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/twiddle/project.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- project.xml	24 Aug 2003 15:06:02 -0000	1.7
  +++ project.xml	24 Aug 2003 20:09:25 -0000	1.8
  @@ -127,15 +127,6 @@
       </dependency>
       
       <dependency>
  -      <id>commons-jexl</id>
  -      <version>SNAPSHOT</version>
  -      <url>http://jakarta.apache.org/commons/jexl.html</url>
  -      <properties>
  -        <runtime>true</runtime>
  -      </properties>
  -    </dependency>
  -    
  -    <dependency>
         <id>commons-cli</id>
         <version>1.0</version>
         <url>http://jakarta.apache.org/commons/cli</url>
  
  
  
  1.8       +2 -1      incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/config/Configurator.java
  
  Index: Configurator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/config/Configurator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Configurator.java	24 Aug 2003 13:57:19 -0000	1.7
  +++ Configurator.java	24 Aug 2003 20:09:25 -0000	1.8
  @@ -70,6 +70,7 @@
   
   import org.apache.geronimo.common.NullArgumentException;
   import org.apache.geronimo.common.Strings;
  +import org.apache.geronimo.common.StringValueParser;
   
   import org.apache.geronimo.twiddle.Twiddle;
   
  
  
  
  1.1                  incubator-geronimo/modules/twiddle/src/java/org/apache/geronimo/twiddle/console/InteractiveConsole.java
  
  Index: InteractiveConsole.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.twiddle.console;
  
  import java.io.IOException;
  
  import org.apache.geronimo.common.NullArgumentException;
  import org.apache.geronimo.common.ThrowableHandler;
  
  /**
   * ???
   *
   * @version <code>$Revision: 1.1 $ $Date: 2003/08/24 20:09:25 $</code>
   * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
   */
  public class InteractiveConsole
      implements Runnable
  {
      protected Console console;
      protected boolean running;
      
      public InteractiveConsole(final Console console)
      {
          if (console == null) {
              throw new NullArgumentException("console");
          }
          
          this.console = console;
      }
      
      public Console getConsole()
      {
          return console;
      }
      
      public boolean isRunning()
      {
          return running;
      }
      
      public void stop()
      {
          running = false;
      }
      
      public void run()
      {
          try {
              doRun();
          }
          catch (Exception e) {
              ThrowableHandler.add(e);
          }
      }
      
      protected void doRun() throws Exception
      {
          while (running) {
              //
              // TODO: Factor out handler/listener to deal with prompt and input processing
              //
              
              String prompt = "";
              String input = console.getLine(prompt);
              
              if (running) {
              }
              else {
                  // warn about wasted input ?
              }
          }
      }
  }
  
  
  

Mime
View raw message