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/command CommandFactoryTest.java CommandPathParserTest.java
Date Sun, 24 Aug 2003 19:40:48 GMT
jdillon     2003/08/24 12:40:48

  Modified:    modules/twiddle/src/test/org/apache/geronimo/twiddle/command
                        CommandFactoryTest.java CommandPathParserTest.java
  Log:
   o Applied patch GERONIMO-16 by Sivasundaram Umapathy
  
  Revision  Changes    Path
  1.7       +55 -14    incubator-geronimo/modules/twiddle/src/test/org/apache/geronimo/twiddle/command/CommandFactoryTest.java
  
  Index: CommandFactoryTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/twiddle/src/test/org/apache/geronimo/twiddle/command/CommandFactoryTest.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- CommandFactoryTest.java	24 Aug 2003 17:12:38 -0000	1.6
  +++ CommandFactoryTest.java	24 Aug 2003 19:40:48 -0000	1.7
  @@ -60,6 +60,7 @@
   
   import org.apache.geronimo.twiddle.config.CommandConfig;
   import org.apache.geronimo.twiddle.config.Attribute;
  +import org.apache.geronimo.common.NullArgumentException;
   
   /**
    * Tests for <code>CommandFactory</code>.
  @@ -75,19 +76,19 @@
       protected void setUp()
       {
       }
  -    
  +
       /**
        * Tear down instance variables required by this test case.
        */
       protected void tearDown()
       {
       }
  -    
  -    
  +
  +
       /////////////////////////////////////////////////////////////////////////
       //                               Tests                                 //
       /////////////////////////////////////////////////////////////////////////
  -    
  +
       public void testCreateCommand() throws Exception
       {
           CommandConfig config = new CommandConfig();
  @@ -97,41 +98,81 @@
           config.setName(name);
           config.setDescription(desc);
           config.setCode(type);
  -        
  +
           CommandInfo protoInfo = new CommandInfo(config);
  +        assertEquals(config,protoInfo.getConfig());
  +        assertTrue(protoInfo.hasDescription());
           Command command = protoInfo.getPrototype();
  -        
  +
  +        try {
  +            new CommandInfo(null);
  +            fail("Expected NullArgumentException");
  +        } catch (NullArgumentException ignore) {
  +        }
  +
           // Verify command info
           CommandInfo info = command.getCommandInfo();
           assertNotNull(command.getCommandInfo());
           assertEquals(name, info.getName());
           assertEquals(desc, info.getDescription());
  -        
  +
           // Verify the class type
           assertEquals(type, command.getClass().getName());
  -        
  +
           command.execute(new String[0]);
       }
  -    
  +
       public void testCreateCommandWithAttribute() throws Exception
       {
           CommandConfig config = new CommandConfig();
           config.setName("mytest");
           config.setCode("org.apache.geronimo.twiddle.command.TestCommand");
  -        
  +
           Attribute attr = new Attribute();
           String text = "this is the value for the text attribute";
           attr.setName("text");
           attr.setContent(text);
           config.addAttribute(attr);
  -        
  +
           CommandInfo protoInfo = new CommandInfo(config);
           Command command = protoInfo.getPrototype();
  -        
  +
           // Verify that the text attribute was set correctly
           assertEquals(text, ((TestCommand)command).getText());
  -        
  +
           command.execute(new String[0]);
  +    }
  +
  +    public void testCommandFactory() {
  +        CommandFactory commandFactory;
  +
  +        try {
  +            new CommandFactory(null);
  +            fail("Expected NullArgumentException");
  +        } catch (NullArgumentException ignore) {
  +        }
  +
  +        CommandConfig config = new CommandConfig();
  +        String name = "mytest";
  +        String desc = "my test description";
  +        String type = "org.apache.geronimo.twiddle.command.TestCommand";
  +        config.setName(name);
  +        config.setDescription(desc);
  +        config.setCode(type);
  +
  +        commandFactory = new CommandFactory(config);
  +        assertEquals(config,commandFactory.getConfig());
  +        try {
  +            commandFactory.create();
  +        } catch (CommandException e) {
  +            fail("Unexpected CommandException"+e);
  +        }
  +
  +        try {
  +            new CommandFactory(new CommandConfig()).create();
  +            fail("Expected CommandException");
  +        } catch (CommandException ignore) {
  +        }
       }
   }
   
  
  
  
  1.6       +10 -3     incubator-geronimo/modules/twiddle/src/test/org/apache/geronimo/twiddle/command/CommandPathParserTest.java
  
  Index: CommandPathParserTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/twiddle/src/test/org/apache/geronimo/twiddle/command/CommandPathParserTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CommandPathParserTest.java	24 Aug 2003 17:12:38 -0000	1.5
  +++ CommandPathParserTest.java	24 Aug 2003 19:40:48 -0000	1.6
  @@ -93,6 +93,7 @@
           assertEquals(true, parser.isAbsolute());
           assertEquals(1, elements.length);
           assertEquals("/", elements[0]);
  +        assertEquals("/",parser.getPath());
       }
   
       public void testTrailing()
  @@ -104,6 +105,7 @@
           assertEquals(2, elements.length);
           assertEquals("/", elements[0]);
           assertEquals("one", elements[1]);
  +        assertEquals("/one/",parser.getPath());
       }
       
       public void testAbsolute2()
  @@ -115,6 +117,7 @@
           assertEquals(2, elements.length);
           assertEquals("/", elements[0]);
           assertEquals("one", elements[1]);
  +        assertEquals("/one",parser.getPath());
       }
   
       public void testAbsolute3()
  @@ -127,6 +130,7 @@
           assertEquals("/", elements[0]);
           assertEquals("one", elements[1]);
           assertEquals("two", elements[2]);
  +        assertEquals("/one/two",parser.getPath());
       }
   
       public void testAbsolute4()
  @@ -140,6 +144,7 @@
           assertEquals("one", elements[1]);
           assertEquals("two", elements[2]);
           assertEquals("three", elements[3]);
  +        assertEquals("/one/two/three",parser.getPath());
       }
       
       public void testRelative1()
  @@ -150,6 +155,7 @@
           assertEquals(false, parser.isAbsolute());
           assertEquals(1, elements.length);
           assertEquals("one", elements[0]);
  +        assertEquals("one",parser.getPath());
       }
   
       public void testRelative2()
  @@ -161,6 +167,7 @@
           assertEquals(2, elements.length);
           assertEquals("one", elements[0]);
           assertEquals("two", elements[1]);
  +        assertEquals("one/two",parser.getPath());
       }
   
       public void testRelative3()
  @@ -173,6 +180,6 @@
           assertEquals("one", elements[0]);
           assertEquals("two", elements[1]);
           assertEquals("three", elements[2]);
  +        assertEquals("one/two/three",parser.getPath());
       }
  -}
  -
  +}
  \ No newline at end of file
  
  
  

Mime
View raw message