You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2005/03/28 18:25:59 UTC

cvs commit: jakarta-tapestry/framework/src/test/org/apache/tapestry/junit/mock/c2/pages Relative.page

hlship      2005/03/28 08:25:59

  Modified:    framework/src/test/org/apache/tapestry/resolver
                        TestComponentSpecificationResolver.java
                        AbstractSpecificationResolverTestCase.java
                        MyComponent.jwc
               framework/src/java/org/apache/tapestry/resolver
                        ResolverStrings.properties
                        PageSpecificationResolverImpl.java
                        ResolverMessages.java
  Added:       framework/src/test/org/apache/tapestry/resolver
                        TestPageSpecificationResolver.java
               framework/src/test/org/apache/tapestry/resolver/context
                        TemplatePage.html ContextRootPage.page
               framework/src/test/org/apache/tapestry/resolver/context/WEB-INF
                        MyWebInfPage.page NamespacePage.page
               framework/src/test/org/apache/tapestry/resolver/context/WEB-INF/myapp
                        MyAppPage.page
  Removed:     framework/src/test-data/context2/WEB-INF/app InPages.page
                        CWebInfApp.jwc InPages.properties CWebInfApp.html
               framework/src/test-data/context2 CRoot.jwc Relative.html
                        InAppRoot.page InPages.html ImplicitComponents.html
                        StaleLink.html CRoot.html README Home.html
                        WithApplication.html InAppRoot.html InWebInf.html
                        InAppRoot.properties
               framework/src/test-data/context2/WEB-INF CWebInf.html
                        InWebInf.page InWebInf.properties CWebInf.jwc
               framework/src/test/org/apache/tapestry/junit/mock/c2/components
                        CRelative.html CRelative.jwc
               framework/src/test/org/apache/tapestry/junit/mock/c2
                        CApp.jwc CApp.html WithApplication.page
                        C2.application
               framework/src/scripts TestSearchComponents.xml
                        TestRelative.xml TestSearchPages.xml
               framework/src/test/org/apache/tapestry/junit/mock/c2/pages
                        Relative.page
  Log:
  Add unit tests for PageSpecificationResolver.
  Remove some integration tests that test the same thing.
  
  Revision  Changes    Path
  1.2       +0 -47     jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/TestComponentSpecificationResolver.java
  
  Index: TestComponentSpecificationResolver.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/TestComponentSpecificationResolver.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestComponentSpecificationResolver.java	27 Mar 2005 17:42:23 -0000	1.1
  +++ TestComponentSpecificationResolver.java	28 Mar 2005 16:25:59 -0000	1.2
  @@ -14,13 +14,10 @@
   
   package org.apache.tapestry.resolver;
   
  -import java.net.URL;
  -
   import org.apache.commons.logging.Log;
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.Location;
   import org.apache.hivemind.Resource;
  -import org.apache.hivemind.util.URLResource;
   import org.apache.tapestry.INamespace;
   import org.apache.tapestry.IRequestCycle;
   import org.apache.tapestry.engine.ISpecificationSource;
  @@ -35,42 +32,6 @@
    */
   public class TestComponentSpecificationResolver extends AbstractSpecificationResolverTestCase
   {
  -    protected IComponentSpecification newSpecification()
  -    {
  -        return (IComponentSpecification) newMock(IComponentSpecification.class);
  -    }
  -
  -    protected IRequestCycle newCycle()
  -    {
  -        return (IRequestCycle) newMock(IRequestCycle.class);
  -    }
  -
  -    protected Log newLog()
  -    {
  -        return (Log) newMock(Log.class);
  -    }
  -
  -    protected URL newURL(String file)
  -    {
  -        return getClass().getResource(file);
  -    }
  -
  -    protected Resource newResource(URL url)
  -    {
  -        MockControl control = newControl(Resource.class);
  -        Resource resource = (Resource) control.getMock();
  -
  -        resource.getResourceURL();
  -        control.setReturnValue(url);
  -
  -        return resource;
  -    }
  -
  -    protected Resource newResource(String path)
  -    {
  -        return new URLResource(newURL(path));
  -    }
  -
       protected ISpecificationSource newSource(Resource resource, IComponentSpecification spec)
       {
           MockControl control = newControl(ISpecificationSource.class);
  @@ -82,14 +43,6 @@
           return source;
       }
   
  -    protected void train(Log log, MockControl control, String message)
  -    {
  -        log.isDebugEnabled();
  -        control.setReturnValue(true);
  -
  -        log.debug(message);
  -    }
  -
       protected ISpecificationSource newSource(INamespace framework)
       {
           MockControl control = newControl(ISpecificationSource.class);
  
  
  
  1.2       +47 -0     jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/AbstractSpecificationResolverTestCase.java
  
  Index: AbstractSpecificationResolverTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/AbstractSpecificationResolverTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractSpecificationResolverTestCase.java	27 Mar 2005 17:42:23 -0000	1.1
  +++ AbstractSpecificationResolverTestCase.java	28 Mar 2005 16:25:59 -0000	1.2
  @@ -14,7 +14,15 @@
   
   package org.apache.tapestry.resolver;
   
  +import java.net.URL;
  +
  +import org.apache.commons.logging.Log;
  +import org.apache.hivemind.Resource;
   import org.apache.hivemind.test.HiveMindTestCase;
  +import org.apache.hivemind.util.URLResource;
  +import org.apache.tapestry.IRequestCycle;
  +import org.apache.tapestry.spec.IComponentSpecification;
  +import org.easymock.MockControl;
   
   /**
    * Base class for testing specification resolvers.
  @@ -25,4 +33,43 @@
   public class AbstractSpecificationResolverTestCase extends HiveMindTestCase
   {
   
  +    protected IComponentSpecification newSpecification()
  +    {
  +        return (IComponentSpecification) newMock(IComponentSpecification.class);
  +    }
  +
  +    protected IRequestCycle newCycle()
  +    {
  +        return (IRequestCycle) newMock(IRequestCycle.class);
  +    }
  +
  +    protected URL newURL(String file)
  +    {
  +        return getClass().getResource(file);
  +    }
  +
  +    protected Resource newResource(URL url)
  +    {
  +        MockControl control = newControl(Resource.class);
  +        Resource resource = (Resource) control.getMock();
  +
  +        resource.getResourceURL();
  +        control.setReturnValue(url);
  +
  +        return resource;
  +    }
  +
  +    protected Resource newResource(String path)
  +    {
  +        return new URLResource(newURL(path));
  +    }
  +
  +    protected void train(Log log, MockControl control, String message)
  +    {
  +        log.isDebugEnabled();
  +        control.setReturnValue(true);
  +
  +        log.debug(message);
  +    }
  +
   }
  \ No newline at end of file
  
  
  
  1.2       +1 -0      jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/MyComponent.jwc
  
  Index: MyComponent.jwc
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/MyComponent.jwc,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MyComponent.jwc	27 Mar 2005 17:42:23 -0000	1.1
  +++ MyComponent.jwc	28 Mar 2005 16:25:59 -0000	1.2
  @@ -1,4 +1,5 @@
   Standin for a component spec found relative to LibraryStandin.library.<!-- 
  +<!-- 
      Copyright 2005 The Apache Software Foundation
   
      Licensed under the Apache License, Version 2.0 (the "License");
  
  
  
  1.1                  jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/TestPageSpecificationResolver.java
  
  Index: TestPageSpecificationResolver.java
  ===================================================================
  // Copyright 2005 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.resolver;
  
  import java.util.List;
  
  import org.apache.commons.logging.Log;
  import org.apache.hivemind.Location;
  import org.apache.hivemind.Resource;
  import org.apache.tapestry.INamespace;
  import org.apache.tapestry.IRequestCycle;
  import org.apache.tapestry.PageNotFoundException;
  import org.apache.tapestry.Tapestry;
  import org.apache.tapestry.engine.ISpecificationSource;
  import org.apache.tapestry.services.ComponentPropertySource;
  import org.apache.tapestry.spec.ComponentSpecification;
  import org.apache.tapestry.spec.IComponentSpecification;
  import org.apache.tapestry.spec.ILibrarySpecification;
  import org.easymock.MockControl;
  
  /**
   * Tests for {@link org.apache.tapestry.resolver.PageSpecificationResolverImpl}.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public class TestPageSpecificationResolver extends AbstractSpecificationResolverTestCase
  {
      private static class MockApplicationNamespace implements INamespace
      {
          private Resource _specificationLocation;
  
          String _pageName;
  
          IComponentSpecification _specification;
  
          MockApplicationNamespace(Resource specificationLocation)
          {
              _specificationLocation = specificationLocation;
          }
  
          public String getId()
          {
              return null;
          }
  
          public String getExtendedId()
          {
              return null;
          }
  
          public String getNamespaceId()
          {
              return null;
          }
  
          public INamespace getParentNamespace()
          {
              return null;
          }
  
          public INamespace getChildNamespace(String id)
          {
              return null;
          }
  
          public List getChildIds()
          {
              return null;
          }
  
          public IComponentSpecification getPageSpecification(String name)
          {
              return null;
          }
  
          public boolean containsPage(String name)
          {
              return false;
          }
  
          public List getPageNames()
          {
              return null;
          }
  
          public IComponentSpecification getComponentSpecification(String type)
          {
              return null;
          }
  
          public boolean containsComponentType(String type)
          {
              return false;
          }
  
          public ILibrarySpecification getSpecification()
          {
              return null;
          }
  
          public String constructQualifiedName(String pageName)
          {
              return null;
          }
  
          public Resource getSpecificationLocation()
          {
              return _specificationLocation;
          }
  
          public boolean isApplicationNamespace()
          {
              return true;
          }
  
          public void installPageSpecification(String pageName, IComponentSpecification specification)
          {
              _pageName = pageName;
              _specification = specification;
          }
  
          public void installComponentSpecification(String type, IComponentSpecification specification)
          {
          }
  
          public Location getLocation()
          {
              return null;
          }
  
          public String getPropertyValue(String propertyName)
          {
              return null;
          }
  
      }
  
      private ISpecificationSource newSource(INamespace application, INamespace framework)
      {
          MockControl control = newControl(ISpecificationSource.class);
          ISpecificationSource source = (ISpecificationSource) control.getMock();
  
          source.getApplicationNamespace();
          control.setReturnValue(application);
  
          source.getFrameworkNamespace();
          control.setReturnValue(framework);
  
          return source;
      }
  
      private ISpecificationSource newSource(INamespace application, INamespace framework,
              Resource resource, IComponentSpecification pageSpec)
      {
          MockControl control = newControl(ISpecificationSource.class);
          ISpecificationSource source = (ISpecificationSource) control.getMock();
  
          source.getApplicationNamespace();
          control.setReturnValue(application);
  
          source.getFrameworkNamespace();
          control.setReturnValue(framework);
  
          source.getPageSpecification(resource);
          control.setReturnValue(pageSpec);
  
          return source;
      }
  
      private INamespace newNamespace()
      {
          return (INamespace) newMock(INamespace.class);
      }
  
      private INamespace newNamespace(String pageName, IComponentSpecification spec)
      {
          MockControl control = newControl(INamespace.class);
          INamespace namespace = (INamespace) control.getMock();
  
          namespace.containsPage(pageName);
          control.setReturnValue(spec != null);
  
          if (spec != null)
          {
              namespace.getPageSpecification(pageName);
              control.setReturnValue(spec);
          }
  
          return namespace;
      }
  
      private ComponentPropertySource newPropertySource(INamespace namespace)
      {
          MockControl control = newControl(ComponentPropertySource.class);
          ComponentPropertySource source = (ComponentPropertySource) control.getMock();
  
          source.getNamespaceProperty(namespace, Tapestry.TEMPLATE_EXTENSION_PROPERTY);
          control.setReturnValue("html");
  
          return source;
      }
  
      public void testFoundInApplicationNamespace()
      {
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
          INamespace application = newNamespace("ExistingPage", spec);
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework);
          IRequestCycle cycle = newCycle();
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.initializeService();
  
          resolver.resolve(cycle, "ExistingPage");
  
          assertEquals("ExistingPage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(application, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testExplicitlyInFrameworkNamespace()
      {
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
          INamespace application = newNamespace();
          INamespace framework = newNamespace("ExistingPage", spec);
          ISpecificationSource source = newSource(application, framework);
          IRequestCycle cycle = newCycle();
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.initializeService();
  
          resolver.resolve(cycle, "framework:ExistingPage");
  
          assertEquals("ExistingPage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(framework, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testFoundInChildNamespace()
      {
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
  
          INamespace child = newNamespace("ChildPage", spec);
  
          MockControl control = newControl(INamespace.class);
          INamespace application = (INamespace) control.getMock();
  
          application.getChildNamespace("foo.bar");
          control.setReturnValue(child);
  
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework);
          IRequestCycle cycle = newCycle();
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.initializeService();
  
          resolver.resolve(cycle, "foo.bar:ChildPage");
  
          assertEquals("ChildPage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(child, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testFoundInNamespaceFolder()
      {
          MockControl logc = newControl(Log.class);
          Log log = (Log) logc.getMock();
  
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
  
          Resource resource = contextRoot.getRelativeResource("WEB-INF/NamespacePage.page");
  
          MockControl applicationc = newControl(INamespace.class);
          INamespace application = (INamespace) applicationc.getMock();
  
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework, resource, spec);
          IRequestCycle cycle = newCycle();
  
          application.containsPage("NamespacePage");
          applicationc.setReturnValue(false);
  
          train(log, logc, ResolverMessages.resolvingPage("NamespacePage", application));
  
          // Pretend the app spec is in the WEB-INF folder
  
          application.getSpecificationLocation();
          applicationc.setReturnValue(contextRoot.getRelativeResource("WEB-INF/"));
  
          train(log, logc, ResolverMessages.checkingResource(resource));
  
          train(log, logc, ResolverMessages.installingPage("NamespacePage", application, spec));
  
          application.installPageSpecification("NamespacePage", spec);
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.initializeService();
          resolver.setLog(log);
  
          resolver.resolve(cycle, "NamespacePage");
  
          assertEquals("NamespacePage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(application, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testFoundInWebInfAppFolder()
      {
          MockControl logc = newControl(Log.class);
          Log log = (Log) logc.getMock();
  
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
  
          Resource resource = contextRoot.getRelativeResource("WEB-INF/myapp/MyAppPage.page");
  
          MockControl applicationc = newControl(INamespace.class);
          INamespace application = (INamespace) applicationc.getMock();
  
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework, resource, spec);
          IRequestCycle cycle = newCycle();
  
          application.containsPage("MyAppPage");
          applicationc.setReturnValue(false);
  
          train(log, logc, ResolverMessages.resolvingPage("MyAppPage", application));
  
          // Pretend the app spec is in the WEB-INF folder
  
          application.getSpecificationLocation();
          applicationc.setReturnValue(contextRoot.getRelativeResource("WEB-INF/"));
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/MyAppPage.page")));
  
          application.isApplicationNamespace();
          applicationc.setReturnValue(true);
  
          train(log, logc, ResolverMessages.checkingResource(resource));
  
          train(log, logc, ResolverMessages.installingPage("MyAppPage", application, spec));
  
          application.installPageSpecification("MyAppPage", spec);
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.setLog(log);
          resolver.setApplicationId("myapp");
  
          resolver.initializeService();
  
          resolver.resolve(cycle, "MyAppPage");
  
          assertEquals("MyAppPage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(application, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testFoundInWebInfFolder()
      {
          MockControl logc = newControl(Log.class);
          Log log = (Log) logc.getMock();
  
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
  
          Resource resource = contextRoot.getRelativeResource("WEB-INF/MyWebInfPage.page");
  
          MockControl applicationc = newControl(INamespace.class);
          INamespace application = (INamespace) applicationc.getMock();
  
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework, resource, spec);
          IRequestCycle cycle = newCycle();
  
          application.containsPage("MyWebInfPage");
          applicationc.setReturnValue(false);
  
          train(log, logc, ResolverMessages.resolvingPage("MyWebInfPage", application));
  
          // Pretend the app spec is in the context root folder
          // Which isn't really something that happens in a real application
          // but is necessary to keep from finding the file too early.
  
          application.getSpecificationLocation();
          applicationc.setReturnValue(contextRoot);
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("MyWebInfPage.page")));
  
          application.isApplicationNamespace();
          applicationc.setReturnValue(true);
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/myapp/MyWebInfPage.page")));
  
          train(log, logc, ResolverMessages.checkingResource(resource));
  
          train(log, logc, ResolverMessages.installingPage("MyWebInfPage", application, spec));
  
          application.installPageSpecification("MyWebInfPage", spec);
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.setLog(log);
          resolver.setApplicationId("myapp");
  
          resolver.initializeService();
  
          resolver.resolve(cycle, "MyWebInfPage");
  
          assertEquals("MyWebInfPage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(application, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testFoundInContextRootFolder()
      {
          MockControl logc = newControl(Log.class);
          Log log = (Log) logc.getMock();
  
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
  
          Resource resource = contextRoot.getRelativeResource("ContextRootPage.page");
  
          MockControl applicationc = newControl(INamespace.class);
          INamespace application = (INamespace) applicationc.getMock();
  
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework, resource, spec);
          IRequestCycle cycle = newCycle();
  
          application.containsPage("ContextRootPage");
          applicationc.setReturnValue(false);
  
          train(log, logc, ResolverMessages.resolvingPage("ContextRootPage", application));
  
          // Pretend the app spec is in the WEB-INF folder
  
          application.getSpecificationLocation();
          applicationc.setReturnValue(contextRoot.getRelativeResource("WEB-INF/"));
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/ContextRootPage.page")));
  
          application.isApplicationNamespace();
          applicationc.setReturnValue(true);
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/myapp/ContextRootPage.page")));
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/ContextRootPage.page")));
          train(log, logc, ResolverMessages.checkingResource(resource));
  
          train(log, logc, ResolverMessages.installingPage("ContextRootPage", application, spec));
  
          application.installPageSpecification("ContextRootPage", spec);
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.setLog(log);
          resolver.setApplicationId("myapp");
  
          resolver.initializeService();
  
          resolver.resolve(cycle, "ContextRootPage");
  
          assertEquals("ContextRootPage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(application, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testFoundAsTemplate()
      {
          MockControl logc = newControl(Log.class);
          Log log = (Log) logc.getMock();
  
          Resource contextRoot = newResource("context/");
  
          Resource resource = contextRoot.getRelativeResource("TemplatePage.html");
  
          MockApplicationNamespace application = new MockApplicationNamespace(contextRoot
                  .getRelativeResource("WEB-INF/"));
  
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework);
          IRequestCycle cycle = newCycle();
  
          ComponentPropertySource propertySource = newPropertySource(application);
  
          train(log, logc, ResolverMessages.resolvingPage("TemplatePage", application));
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/TemplatePage.page")));
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/myapp/TemplatePage.page")));
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/TemplatePage.page")));
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("TemplatePage.page")));
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("TemplatePage.html")));
  
          train(log, logc, ResolverMessages.foundHTMLTemplate(resource));
  
          IComponentSpecification expectedSpec = new ComponentSpecification();
          expectedSpec.setPageSpecification(true);
          expectedSpec.setSpecificationLocation(resource);
  
          // The toString() on ComponentSpecification means we can't predict
          // what the string would be.
  
          log.isDebugEnabled();
          logc.setReturnValue(false);
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.setLog(log);
          resolver.setApplicationId("myapp");
          resolver.setComponentPropertySource(propertySource);
  
          resolver.initializeService();
  
          resolver.resolve(cycle, "TemplatePage");
  
          IComponentSpecification spec = application._specification;
  
          assertEquals(true, spec.isPageSpecification());
          assertEquals(resource, spec.getSpecificationLocation());
  
          assertEquals("TemplatePage", resolver.getSimplePageName());
          assertEquals("TemplatePage", application._pageName);
  
          assertSame(spec, resolver.getSpecification());
          assertSame(application, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testFoundInFramework()
      {
          MockControl logc = newControl(Log.class);
          Log log = (Log) logc.getMock();
  
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
  
          MockControl applicationc = newControl(INamespace.class);
          INamespace application = (INamespace) applicationc.getMock();
  
          ComponentPropertySource propertySource = newPropertySource(application);
  
          INamespace framework = newNamespace("FrameworkPage", spec);
          ISpecificationSource source = newSource(application, framework);
          IRequestCycle cycle = newCycle();
  
          application.containsPage("FrameworkPage");
          applicationc.setReturnValue(false);
  
          train(log, logc, ResolverMessages.resolvingPage("FrameworkPage", application));
  
          // Pretend the app spec is in the WEB-INF folder
  
          application.getSpecificationLocation();
          applicationc.setReturnValue(contextRoot.getRelativeResource("WEB-INF/"));
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/FrameworkPage.page")));
  
          application.isApplicationNamespace();
          applicationc.setReturnValue(true);
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/myapp/FrameworkPage.page")));
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/FrameworkPage.page")));
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("FrameworkPage.page")));
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("FrameworkPage.html")));
  
          train(log, logc, ResolverMessages.foundFrameworkPage("FrameworkPage"));
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.setLog(log);
          resolver.setApplicationId("myapp");
          resolver.setComponentPropertySource(propertySource);
  
          resolver.initializeService();
  
          resolver.resolve(cycle, "FrameworkPage");
  
          assertEquals("FrameworkPage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(framework, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testProvidedByDelegate()
      {
          MockControl logc = newControl(Log.class);
          Log log = (Log) logc.getMock();
  
          Resource contextRoot = newResource("context/");
          IComponentSpecification spec = newSpecification();
  
          MockControl applicationc = newControl(INamespace.class);
          INamespace application = (INamespace) applicationc.getMock();
  
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework);
          IRequestCycle cycle = newCycle();
  
          application.containsPage("DelegatePage");
          applicationc.setReturnValue(false);
  
          train(log, logc, ResolverMessages.resolvingPage("DelegatePage", application));
  
          // Pretend the app spec is in the WEB-INF folder
  
          application.getSpecificationLocation();
          applicationc.setReturnValue(contextRoot.getRelativeResource("WEB-INF/"));
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/DelegatePage.page")));
  
          application.isApplicationNamespace();
          applicationc.setReturnValue(false);
  
          MockControl delegatec = newControl(ISpecificationResolverDelegate.class);
          ISpecificationResolverDelegate delegate = (ISpecificationResolverDelegate) delegatec
                  .getMock();
  
          delegate.findPageSpecification(cycle, application, "DelegatePage");
          delegatec.setReturnValue(spec);
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.setLog(log);
          resolver.setApplicationId("myapp");
          resolver.setDelegate(delegate);
  
          resolver.initializeService();
  
          resolver.resolve(cycle, "DelegatePage");
  
          assertEquals("DelegatePage", resolver.getSimplePageName());
          assertSame(spec, resolver.getSpecification());
          assertSame(application, resolver.getNamespace());
  
          verifyControls();
      }
  
      public void testNotFoundAnywhere()
      {
          MockControl logc = newControl(Log.class);
          Log log = (Log) logc.getMock();
  
          Resource contextRoot = newResource("context/");
  
          MockControl applicationc = newControl(INamespace.class);
          INamespace application = (INamespace) applicationc.getMock();
  
          INamespace framework = newNamespace();
          ISpecificationSource source = newSource(application, framework);
          IRequestCycle cycle = newCycle();
  
          application.containsPage("DelegatePage");
          applicationc.setReturnValue(false);
  
          train(log, logc, ResolverMessages.resolvingPage("DelegatePage", application));
  
          // Pretend the app spec is in the WEB-INF folder
  
          application.getSpecificationLocation();
          applicationc.setReturnValue(contextRoot.getRelativeResource("WEB-INF/"));
  
          train(log, logc, ResolverMessages.checkingResource(contextRoot
                  .getRelativeResource("WEB-INF/DelegatePage.page")));
  
          application.isApplicationNamespace();
          applicationc.setReturnValue(false);
  
          MockControl delegatec = newControl(ISpecificationResolverDelegate.class);
          ISpecificationResolverDelegate delegate = (ISpecificationResolverDelegate) delegatec
                  .getMock();
  
          delegate.findPageSpecification(cycle, application, "DelegatePage");
          delegatec.setReturnValue(null);
  
          application.getNamespaceId();
          applicationc.setReturnValue("<application namespace>");
  
          replayControls();
  
          PageSpecificationResolverImpl resolver = new PageSpecificationResolverImpl();
          resolver.setContextRoot(contextRoot);
          resolver.setSpecificationSource(source);
          resolver.setLog(log);
          resolver.setApplicationId("myapp");
          resolver.setDelegate(delegate);
  
          resolver.initializeService();
  
          try
          {
              resolver.resolve(cycle, "DelegatePage");
              unreachable();
          }
          catch (PageNotFoundException ex)
          {
              assertEquals("Page 'DelegatePage' not found in <application namespace>.", ex
                      .getMessage());
          }
  
          verifyControls();
      }
  }
  
  
  1.1                  jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/context/TemplatePage.html
  
  	<<Binary file>>
  
  
  1.1                  jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/context/ContextRootPage.page
  
  Index: ContextRootPage.page
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2005 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE page-specification PUBLIC
    "-//Apache Software Foundation//Tapestry Specification 3.1//EN"
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_1.dtd">
  <page-specification/>
  
  
  
  1.4       +5 -1      jakarta-tapestry/framework/src/java/org/apache/tapestry/resolver/ResolverStrings.properties
  
  Index: ResolverStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/resolver/ResolverStrings.properties,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ResolverStrings.properties	27 Mar 2005 17:42:23 -0000	1.3
  +++ ResolverStrings.properties	28 Mar 2005 16:25:59 -0000	1.4
  @@ -14,6 +14,10 @@
   
   no-such-component-type=Component ''{0}'' not found in {1}.
   no-such-page=Page ''{0}'' not found in {1}.
  -resolving-component=Resolving component ''{0}'' in {0}.
  +resolving-component=Resolving component ''{0}'' in {1}.
  +resolving-page=Resolving page ''{0}'' in {1}.
   checking-resource=Checking: {0}
   installing-component=Installing component type ''{0}'' into {1} as {2}.
  +installing-page=Installing page ''{0}'' into {1} as {2}.
  +found-framework-page=Found page ''{0}'' in framework namespace.
  +found-html-template=Found HTML template at {0}.
  \ No newline at end of file
  
  
  
  1.7       +9 -7      jakarta-tapestry/framework/src/java/org/apache/tapestry/resolver/PageSpecificationResolverImpl.java
  
  Index: PageSpecificationResolverImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/resolver/PageSpecificationResolverImpl.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PageSpecificationResolverImpl.java	27 Mar 2005 17:42:23 -0000	1.6
  +++ PageSpecificationResolverImpl.java	28 Mar 2005 16:25:59 -0000	1.7
  @@ -121,7 +121,7 @@
           {
               _simpleName = prefixedName;
   
  -            namespace = getSpecificationSource().getApplicationNamespace();
  +            namespace = _applicationNamespace;
           }
   
           setNamespace(namespace);
  @@ -150,7 +150,7 @@
           INamespace namespace = getNamespace();
   
           if (_log.isDebugEnabled())
  -            _log.debug("Resolving unknown page '" + _simpleName + "' in " + namespace);
  +            _log.debug(ResolverMessages.resolvingPage(_simpleName, namespace));
   
           String expectedName = _simpleName + ".page";
   
  @@ -184,6 +184,9 @@
   
               Resource templateResource = getContextRoot().getRelativeResource(templateName);
   
  +            if (_log.isDebugEnabled())
  +                _log.debug(ResolverMessages.checkingResource(templateResource));
  +
               if (templateResource.getResourceURL() != null)
               {
                   setupImplicitPage(templateResource);
  @@ -195,7 +198,7 @@
               if (_frameworkNamespace.containsPage(_simpleName))
               {
                   if (_log.isDebugEnabled())
  -                    _log.debug("Found " + _simpleName + " in framework namespace.");
  +                    _log.debug(ResolverMessages.foundFrameworkPage(_simpleName));
   
                   setNamespace(_frameworkNamespace);
   
  @@ -222,7 +225,7 @@
       private void setupImplicitPage(Resource resource)
       {
           if (_log.isDebugEnabled())
  -            _log.debug("Found HTML template at " + resource);
  +            _log.debug(ResolverMessages.foundHTMLTemplate(resource));
   
           // TODO The SpecFactory in Specification parser should be used in some way to
           // create an IComponentSpecification!
  @@ -239,7 +242,7 @@
       private boolean found(Resource resource)
       {
           if (_log.isDebugEnabled())
  -            _log.debug("Checking: " + resource);
  +            _log.debug(ResolverMessages.checkingResource(resource));
   
           if (resource.getResourceURL() == null)
               return false;
  @@ -257,8 +260,7 @@
           IComponentSpecification specification = getSpecification();
   
           if (_log.isDebugEnabled())
  -            _log.debug("Installing page " + _simpleName + " into " + namespace + " as "
  -                    + specification);
  +            _log.debug(ResolverMessages.installingPage(_simpleName, namespace, specification));
   
           namespace.installPageSpecification(_simpleName, specification);
       }
  
  
  
  1.5       +21 -0     jakarta-tapestry/framework/src/java/org/apache/tapestry/resolver/ResolverMessages.java
  
  Index: ResolverMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/framework/src/java/org/apache/tapestry/resolver/ResolverMessages.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ResolverMessages.java	27 Mar 2005 17:42:23 -0000	1.4
  +++ ResolverMessages.java	28 Mar 2005 16:25:59 -0000	1.5
  @@ -55,4 +55,25 @@
       {
           return _formatter.format("installing-component", type, namespace, specification);
       }
  +
  +    static String installingPage(String pageName, INamespace namespace,
  +            IComponentSpecification specification)
  +    {
  +        return _formatter.format("installing-page", pageName, namespace, specification);
  +    }
  +
  +    static String resolvingPage(String pageName, INamespace namespace)
  +    {
  +        return _formatter.format("resolving-page", pageName, namespace);
  +    }
  +
  +    static String foundFrameworkPage(String pageName)
  +    {
  +        return _formatter.format("found-framework-page", pageName);
  +    }
  +
  +    static String foundHTMLTemplate(Resource resource)
  +    {
  +        return _formatter.format("found-html-template", resource);
  +    }
   }
  \ No newline at end of file
  
  
  
  1.1                  jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/context/WEB-INF/MyWebInfPage.page
  
  Index: MyWebInfPage.page
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2005 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE page-specification PUBLIC
    "-//Apache Software Foundation//Tapestry Specification 3.1//EN"
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_1.dtd">
  <page-specification/>
  
  
  
  1.1                  jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/context/WEB-INF/NamespacePage.page
  
  Index: NamespacePage.page
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2005 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE page-specification PUBLIC
    "-//Apache Software Foundation//Tapestry Specification 3.1//EN"
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_1.dtd">
  <page-specification/>
  
  
  
  1.1                  jakarta-tapestry/framework/src/test/org/apache/tapestry/resolver/context/WEB-INF/myapp/MyAppPage.page
  
  Index: MyAppPage.page
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- 
     Copyright 2005 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <!DOCTYPE page-specification PUBLIC
    "-//Apache Software Foundation//Tapestry Specification 3.1//EN"
    "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_1.dtd">
  <page-specification/>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org