tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-tapestry/junit/src/org/apache/tapestry/junit/parse TestSpecificationParser.java
Date Fri, 21 Mar 2003 19:00:54 GMT
hlship      2003/03/21 11:00:54

  Modified:    junit/src/org/apache/tapestry/junit/parse
                        TestSpecificationParser.java
  Log:
  Optimize allocations of Location objects while parsing specifications.
  
  Revision  Changes    Path
  1.3       +58 -16    jakarta-tapestry/junit/src/org/apache/tapestry/junit/parse/TestSpecificationParser.java
  
  Index: TestSpecificationParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/junit/src/org/apache/tapestry/junit/parse/TestSpecificationParser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestSpecificationParser.java	15 Mar 2003 21:22:18 -0000	1.2
  +++ TestSpecificationParser.java	21 Mar 2003 19:00:54 -0000	1.3
  @@ -57,6 +57,7 @@
   
   import java.util.Map;
   
  +import org.apache.tapestry.ILocatable;
   import org.apache.tapestry.bean.StringBeanInitializer;
   import org.apache.tapestry.junit.TapestryTestCase;
   import org.apache.tapestry.spec.BeanSpecification;
  @@ -90,6 +91,11 @@
           super(name);
       }
   
  +    private void checkLine(ILocatable locatable, int line)
  +    {
  +        assertEquals("Line", line, locatable.getLocation().getLineNumber());
  +    }
  +
       /**
        *  Tests that the parser can handle a specification
        *  that includes a <string-binding> element.
  @@ -104,6 +110,8 @@
   
           assertEquals("type", BindingType.STRING, bs.getType());
           assertEquals("key", "label.hello", bs.getValue());
  +
  +        checkLine(bs, 10);
       }
   
       /**
  @@ -120,6 +128,7 @@
           ParameterSpecification ps = spec.getParameter("valid");
   
           assertNotNull("Parameter specification.", ps);
  +        checkLine(ps, 9);
       }
   
       /**
  @@ -199,6 +208,8 @@
       {
           ILibrarySpecification spec = parseLib("ValidLibrary.library");
   
  +        checkLine(spec, 9);
  +
           checkList("serviceNames", new String[] { "service1", "service2" }, spec.getServiceNames());
   
           checkList("pageNames", new String[] { "FirstPage", "SecondPage" }, spec.getPageNames());
  @@ -375,6 +386,7 @@
   
           assertNull(spec.getEngineClassName());
           assertNull(spec.getName());
  +        checkLine(spec, 10);
       }
   
       /**
  @@ -402,6 +414,7 @@
           ComponentSpecification spec = parseComponent("NulledComponent.jwc");
   
           assertNull(spec.getComponentClassName());
  +        checkLine(spec, 7);
       }
   
       /**
  @@ -415,6 +428,7 @@
           ComponentSpecification spec = parsePage("NulledPage.page");
   
           assertNull(spec.getComponentClassName());
  +        checkLine(spec, 7);
       }
   
       /**
  @@ -429,6 +443,8 @@
       {
           ComponentSpecification spec = parsePage("PropertyValue.page");
   
  +        checkLine(spec, 7);
  +
           assertEquals("rubble", spec.getProperty("barney"));
           assertEquals("flintstone", spec.getProperty("wilma"));
       }
  @@ -445,11 +461,25 @@
       {
           ComponentSpecification spec = parsePage("StaticBindingValue.page");
   
  +        checkLine(spec, 7);
  +
           ContainedComponent c = spec.getComponent("c");
   
  -        assertEquals("flintstone", c.getBinding("fred").getValue());
  -        assertEquals("rubble", c.getBinding("barney").getValue());
  -        assertEquals("hudson", c.getBinding("rock").getValue());
  +        checkLine(c, 9);
  +
  +        BindingSpecification b = c.getBinding("fred");
  +        checkLine(b, 10);
  +
  +        assertEquals("flintstone", b.getValue());
  +
  +        b = c.getBinding("barney");
  +        checkLine(b, 11);
  +
  +        assertEquals("rubble", b.getValue());
  +
  +        b = c.getBinding("rock");
  +        checkLine(b, 12);
  +        assertEquals("hudson", b.getValue());
       }
   
       public void testAttributeAndBody() throws Exception
  @@ -479,6 +509,9 @@
       {
           ILibrarySpecification spec = parseLib("ConfigureValue.library");
   
  +        checkLine(spec, 7);
  +        checkLine(spec.getExtensionSpecification("map"), 9);
  +
           Map map = (Map) spec.getExtension("map", Map.class);
   
           assertEquals("flintstone", map.get("fred"));
  @@ -495,10 +528,15 @@
       {
           ComponentSpecification spec = parsePage("ListenerBinding.page");
   
  +        checkLine(spec, 7);
           ContainedComponent c = spec.getComponent("c");
   
  +        checkLine(c, 9);
  +
           ListenerBindingSpecification lbs = (ListenerBindingSpecification) c.getBinding("listener");
   
  +        checkLine(lbs, 10);
  +
           String expectedScript =
               buildExpectedScript(
                   new String[] {
  @@ -542,18 +580,21 @@
           assertEquals("persistent", false, ps.isPersistent());
           assertEquals("type", "boolean", ps.getType());
           assertNull("initialValue", ps.getInitialValue());
  +        checkLine(ps, 9);
   
           ps = spec.getPropertySpecification("init");
           assertEquals("name", "init", ps.getName());
           assertEquals("persistent", false, ps.isPersistent());
           assertEquals("type", "java.lang.Object", ps.getType());
           assertEquals("initialValue", "pageName", ps.getInitialValue());
  +        checkLine(ps, 11);
   
           ps = spec.getPropertySpecification("persist");
           assertEquals("name", "persist", ps.getName());
           assertEquals("persistent", true, ps.isPersistent());
           assertEquals("type", "java.lang.Object", ps.getType());
           assertNull("initialValue", ps.getInitialValue());
  +        checkLine(ps, 10);
   
           ps = spec.getPropertySpecification("unknown");
   
  @@ -593,18 +634,19 @@
                   "Element <binding> does not specify a value for attribute 'expression',
or contain a body value.");
           }
       }
  -    
  +
       /** @since 2.4 **/
  -    
  -    public void testStringBeanInitializer()
  -    throws Exception
  -    {
  -    	ComponentSpecification spec = parsePage("StringBeanInitializer.page");
  -    	
  -    	BeanSpecification bs = spec.getBeanSpecification("fred");
  -    	StringBeanInitializer i = (StringBeanInitializer)bs.getInitializers().get(0);
  -    	
  -    	assertEquals("barney", i.getPropertyName());
  -    	assertEquals("rubble", i.getKey());
  +
  +    public void testStringBeanInitializer() throws Exception
  +    {
  +        ComponentSpecification spec = parsePage("StringBeanInitializer.page");
  +
  +        BeanSpecification bs = spec.getBeanSpecification("fred");
  +        checkLine(bs, 9);
  +        StringBeanInitializer i = (StringBeanInitializer) bs.getInitializers().get(0);
  +
  +        assertEquals("barney", i.getPropertyName());
  +        assertEquals("rubble", i.getKey());
  +        checkLine(i, 10);
       }
   }
  
  
  

Mime
View raw message