tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r596141 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/java/org/apache/tapestry/internal/services/ main/java/org/apache/tapestry/services/ test/java/org/apache/tapestry/integration/ test/java/org/apache/tapestry/internal/services/ t...
Date Sun, 18 Nov 2007 21:42:59 GMT
Author: hlship
Date: Sun Nov 18 13:42:58 2007
New Revision: 596141

URL: http://svn.apache.org/viewvc?rev=596141&view=rev
Log:
TAPESTRY-1917: Tapestry should list available pages, components and mixins at startup, and
when classes change

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java?rev=596141&r1=596140&r2=596141&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/internal/services/ComponentClassResolverImpl.java
Sun Nov 18 13:42:58 2007
@@ -18,16 +18,16 @@
 import org.apache.tapestry.internal.events.InvalidationListener;
 import org.apache.tapestry.ioc.annotations.Inject;
 import org.apache.tapestry.ioc.annotations.Symbol;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
 import static org.apache.tapestry.ioc.internal.util.CollectionFactory.*;
 import org.apache.tapestry.ioc.internal.util.ConcurrentBarrier;
+import org.apache.tapestry.ioc.internal.util.InternalUtils;
 import org.apache.tapestry.ioc.internal.util.Invokable;
 import org.apache.tapestry.services.ComponentClassResolver;
 import org.apache.tapestry.services.LibraryMapping;
+import org.slf4j.Logger;
 
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
 
 public class ComponentClassResolverImpl implements ComponentClassResolver, InvalidationListener
 {
@@ -39,6 +39,8 @@
 
     private static final String PAGES_SUBPACKAGE = "pages";
 
+    private final Logger _logger;
+
     private final ComponentInstantiatorSource _componentInstantiatorSource;
 
     private final ClassNameLocator _classNameLocator;
@@ -59,30 +61,47 @@
 
     private boolean _needsRebuild = true;
 
+    /**
+     * Logical page name to class name.
+     */
     private final Map<String, String> _pageToClassName = newCaseInsensitiveMap();
 
+    /**
+     * Component type to class name.
+     */
     private final Map<String, String> _componentToClassName = newCaseInsensitiveMap();
 
+    /**
+     * Mixing type to class name.
+     */
     private final Map<String, String> _mixinToClassName = newCaseInsensitiveMap();
 
     /**
-     * This one is case sensitive, since class names do always have a particular case.
+     * Page class name to logical name (needed to build URLs). This one is case sensitive,
since class names do always have a particular case.
      */
     private final Map<String, String> _pageClassNameToLogicalName = newMap();
 
+
+    /**
+     * Used to convert an logical page name to the canonical form of the page name; this
ensures that uniform case for page
+     * names is used.
+     */
     private final Map<String, String> _pageNameToCanonicalPageName = newCaseInsensitiveMap();
 
     private final ConcurrentBarrier _barrier = new ConcurrentBarrier();
 
-    public ComponentClassResolverImpl(ComponentInstantiatorSource componentInstantiatorSource,
+    public ComponentClassResolverImpl(Logger logger,
+
+                                      ComponentInstantiatorSource componentInstantiatorSource,
+
                                       ClassNameLocator classNameLocator,
 
-                                      @Inject
-                                      @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
+                                      @Inject @Symbol(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM)
                                       String appRootPackage,
 
                                       Collection<LibraryMapping> mappings)
     {
+        _logger = logger;
         _componentInstantiatorSource = componentInstantiatorSource;
         _classNameLocator = classNameLocator;
 
@@ -135,17 +154,15 @@
             public void run()
             {
                 _needsRebuild = true;
-
-                _pageToClassName.clear();
-                _componentToClassName.clear();
-                _mixinToClassName.clear();
-                _pageClassNameToLogicalName.clear();
-                _pageNameToCanonicalPageName.clear();
             }
         });
 
     }
 
+    /**
+     * Invoked from within a withRead() block, checks to see if a rebuild is needed,
+     * and then performs the rebuild within a withWrite() block.
+     */
     private void rebuild()
     {
         if (!_needsRebuild) return;
@@ -154,31 +171,105 @@
         {
             public void run()
             {
-                rebuild("", _appRootPackage);
+                performRebuild();
+            }
+        });
+    }
+
+    private void performRebuild()
+    {
 
-                for (String prefix : _mappings.keySet())
-                {
-                    List<String> packages = _mappings.get(prefix);
+        Map<String, String> savedPages = CollectionFactory.newMap(_pageToClassName);
+        Map<String, String> savedComponents = CollectionFactory.newMap(_componentToClassName);
+        Map<String, String> savedMixins = CollectionFactory.newMap(_mixinToClassName);
 
-                    String folder = prefix + "/";
+        _pageToClassName.clear();
+        _componentToClassName.clear();
+        _mixinToClassName.clear();
+        _pageClassNameToLogicalName.clear();
+        _pageNameToCanonicalPageName.clear();
+
+        rebuild("", _appRootPackage);
+
+        for (String prefix : _mappings.keySet())
+        {
+            List<String> packages = _mappings.get(prefix);
 
-                    for (String packageName : packages)
-                        rebuild(folder, packageName);
-                }
+            String folder = prefix + "/";
 
-                _needsRebuild = false;
+            for (String packageName : packages)
+                rebuild(folder, packageName);
+        }
+
+
+        showChanges("pages", savedPages, _pageToClassName);
+        showChanges("components", savedComponents, _componentToClassName);
+        showChanges("mixins", savedMixins, _mixinToClassName);
+
+        _needsRebuild = false;
+    }
+
+    private void showChanges(String title, Map<String, String> savedMap, Map<String,
String> newMap)
+    {
+        if (savedMap.equals(newMap)) return;
+
+        Map<String, String> fixed = CollectionFactory.newMap();
+
+        int maxLength = 0;
+
+        // Pass # 1: Get all the stuff in the core library
+
+        for (String name : newMap.keySet())
+        {
+            if (name.startsWith(CORE_LIBRARY_PREFIX))
+            {
+
+                // Strip of the "core/" prefix.
+
+                String key = name.substring(CORE_LIBRARY_PREFIX.length());
+
+                maxLength = Math.max(maxLength, key.length());
+
+                fixed.put(key, newMap.get(name));
             }
-        });
+        }
+
+        // Pass #2: Get everything else (may overwrite some of  pass #1).
+
+        for (String name : newMap.keySet())
+        {
+            if (name.startsWith(CORE_LIBRARY_PREFIX)) continue;
+
+            maxLength = Math.max(maxLength, name.length());
+
+            fixed.put(name, newMap.get(name));
+        }
+
+
+        StringBuilder builder = new StringBuilder(2000);
+        Formatter f = new Formatter(builder);
+
+        f.format("Available %s:\n", title);
+
+        String formatString = "%" + maxLength + "s: %s\n";
+
+        List<String> sorted = InternalUtils.sortedKeys(fixed);
+
+        for (String name : sorted)
+        {
+            String className = fixed.get(name);
+
+            f.format(formatString, name, className);
+        }
+
+        _logger.info(builder.toString());
+
     }
 
     private void rebuild(String pathPrefix, String rootPackage)
     {
         fillNameToClassNameMap(pathPrefix, rootPackage, PAGES_SUBPACKAGE, _pageToClassName);
-        fillNameToClassNameMap(
-                pathPrefix,
-                rootPackage,
-                COMPONENTS_SUBPACKAGE,
-                _componentToClassName);
+        fillNameToClassNameMap(pathPrefix, rootPackage, COMPONENTS_SUBPACKAGE, _componentToClassName);
         fillNameToClassNameMap(pathPrefix, rootPackage, MIXINS_SUBPACKAGE, _mixinToClassName);
     }
 
@@ -281,10 +372,8 @@
             {
                 String result = locate(pageName, _pageToClassName);
 
-                if (result == null)
-                    throw new IllegalArgumentException(ServicesMessages.couldNotResolvePageName(
-                            pageName,
-                            presentableNames(_pageToClassName)));
+                if (result == null) throw new IllegalArgumentException(
+                        ServicesMessages.couldNotResolvePageName(pageName, presentableNames(_pageToClassName)));
 
                 return result;
             }
@@ -311,11 +400,8 @@
             {
                 String result = locate(componentType, _componentToClassName);
 
-                if (result == null)
-                    throw new IllegalArgumentException(ServicesMessages
-                            .couldNotResolveComponentType(
-                            componentType,
-                            presentableNames(_componentToClassName)));
+                if (result == null) throw new IllegalArgumentException(ServicesMessages
+                        .couldNotResolveComponentType(componentType, presentableNames(_componentToClassName)));
 
                 return result;
             }
@@ -349,10 +435,8 @@
             {
                 String result = locate(mixinType, _mixinToClassName);
 
-                if (result == null)
-                    throw new IllegalArgumentException(ServicesMessages.couldNotResolveMixinType(
-                            mixinType,
-                            presentableNames(_mixinToClassName)));
+                if (result == null) throw new IllegalArgumentException(
+                        ServicesMessages.couldNotResolveMixinType(mixinType, presentableNames(_mixinToClassName)));
 
                 return result;
             }
@@ -391,9 +475,8 @@
 
                 String result = _pageClassNameToLogicalName.get(pageClassName);
 
-                if (result == null)
-                    throw new IllegalArgumentException(ServicesMessages
-                            .pageNameUnresolved(pageClassName));
+                if (result == null) throw new IllegalArgumentException(ServicesMessages
+                        .pageNameUnresolved(pageClassName));
 
                 return result;
             }
@@ -408,11 +491,8 @@
             {
                 String result = locate(pageName, _pageNameToCanonicalPageName);
 
-                if (result == null)
-                    throw new IllegalArgumentException(ServicesMessages
-                            .couldNotCanonicalizePageName(
-                            pageName,
-                            presentableNames(_pageNameToCanonicalPageName)));
+                if (result == null) throw new IllegalArgumentException(ServicesMessages
+                        .couldNotCanonicalizePageName(pageName, presentableNames(_pageNameToCanonicalPageName)));
 
                 return result;
             }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java?rev=596141&r1=596140&r2=596141&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry/services/TapestryModule.java
Sun Nov 18 13:42:58 2007
@@ -1617,12 +1617,13 @@
     }
 
     /**
-     * Adds a filter that sets the application package (for class loading purposes). The
filter is
-     * ordered before:*.*".
+     * Adds a listener to the {@link org.apache.tapestry.internal.services.ComponentInstantiatorSource}
that clears
+     * the {@link PropertyAccess} and {@link TypeCoercer} caches on a class loader invalidation.
 In addition, forces
+     * the realization of {@link ComponentClassResolver} at startup.
      */
     public void contributeApplicationInitializer(OrderedConfiguration<ApplicationInitializerFilter>
configuration,
-                                                 final ApplicationGlobals applicationGlobals,
-                                                 final PropertyAccess propertyAccess, final
TypeCoercer typeCoercer)
+                                                 final PropertyAccess propertyAccess, final
TypeCoercer typeCoercer,
+                                                 final ComponentClassResolver componentClassResolver)
     {
         final InvalidationListener listener = new InvalidationListener()
         {
@@ -1643,6 +1644,11 @@
                 _componentInstantiatorSource.addInvalidationListener(listener);
 
                 initializer.initializeApplication(context);
+
+                // We don't care about the result, but this forces a load of the service
+                // at application startup, rather than on first request.
+
+                componentClassResolver.isPageName("ForceLoadAtStartup");
             }
         };
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java?rev=596141&r1=596140&r2=596141&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/integration/RunJetty.java
Sun Nov 18 13:42:58 2007
@@ -17,17 +17,13 @@
 import org.apache.tapestry.test.JettyRunner;
 
 /**
- * Temporary "shim" to run Demo App #1 inside IntelliJ.  Eventually, we should write a "Jetty
InPlace Integration Plugin"
- * that works like JettyLauncher for Eclipse.
+ * A "shim" to run Demo App #1 inside IntelliJ.  I still haven't found a way to get IntelliJ
to
+ * export test classes and resources into a web facet.
  */
 public class RunJetty
 {
     public static void main(String[] args) throws InterruptedException
     {
-        JettyRunner runner = new JettyRunner("/", 8080, "src/test/app1");
-
-        Thread.sleep(Long.MAX_VALUE);
-
-        runner.stop();
+        new JettyRunner("/", 8080, "src/test/app1");
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java?rev=596141&r1=596140&r2=596141&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry/internal/services/ComponentClassResolverImplTest.java
Sun Nov 18 13:42:58 2007
@@ -17,7 +17,9 @@
 import org.apache.tapestry.internal.test.InternalBaseTestCase;
 import org.apache.tapestry.services.ComponentClassResolver;
 import org.apache.tapestry.services.LibraryMapping;
+import org.easymock.EasyMock;
 import static org.easymock.EasyMock.isA;
+import org.slf4j.Logger;
 import org.testng.annotations.Test;
 
 import java.util.Arrays;
@@ -37,12 +39,23 @@
 
     private static final String LIB_ROOT_PACKAGE = "org.example.lib";
 
-    private ComponentClassResolverImpl create(ComponentInstantiatorSource source,
+    private ComponentClassResolverImpl create(Logger logger, ComponentInstantiatorSource
source,
                                               ClassNameLocator locator, LibraryMapping...
mappings)
     {
         List<LibraryMapping> list = Arrays.asList(mappings);
 
-        return new ComponentClassResolverImpl(source, locator, APP_ROOT_PACKAGE, list);
+        return new ComponentClassResolverImpl(logger, source, locator, APP_ROOT_PACKAGE,
list);
+    }
+
+    private Logger compliantLogger()
+    {
+        Logger logger = mockLogger();
+
+        logger.info(EasyMock.isA(String.class));
+
+        getMocksControl().atLeastOnce();
+
+        return logger;
     }
 
     @Test
@@ -50,6 +63,7 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -59,7 +73,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolvePageNameToClassName("SimplePage"), className);
 
@@ -71,6 +85,7 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -80,7 +95,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.canonicalizePageName("simplepage"), "SimplePage");
 
@@ -93,6 +108,7 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -102,7 +118,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolvePageNameToClassName("subfolder/NestedPage"), className);
 
@@ -114,6 +130,7 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -123,7 +140,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolvePageNameToClassName("admin/edit/User"), className);
 
@@ -135,6 +152,7 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -144,7 +162,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolvePageNameToClassName("subfolder/NestedPage"), className);
 
@@ -157,6 +175,7 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -166,7 +185,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolvePageNameToClassName("foo/Bar"), className);
 
@@ -178,19 +197,20 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_packages(source, CORE_ROOT_PACKAGE);
         train_for_app_packages(source);
 
-        train_locateComponentClassNames(locator, CORE_ROOT_PACKAGE + ".pages", CORE_ROOT_PACKAGE
-                + ".pages.Fred", CORE_ROOT_PACKAGE + ".pages.Barney");
-        train_locateComponentClassNames(locator, APP_ROOT_PACKAGE + ".pages", APP_ROOT_PACKAGE
-                + ".pages.Wilma", APP_ROOT_PACKAGE + ".pages.Betty");
+        train_locateComponentClassNames(locator, CORE_ROOT_PACKAGE + ".pages", CORE_ROOT_PACKAGE
+ ".pages.Fred",
+                                        CORE_ROOT_PACKAGE + ".pages.Barney");
+        train_locateComponentClassNames(locator, APP_ROOT_PACKAGE + ".pages", APP_ROOT_PACKAGE
+ ".pages.Wilma",
+                                        APP_ROOT_PACKAGE + ".pages.Betty");
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         try
         {
@@ -199,9 +219,8 @@
         }
         catch (RuntimeException ex)
         {
-            assertEquals(
-                    ex.getMessage(),
-                    "Unable to resolve \'Unknown\' to a page class name.  Available page
names: Barney, Betty, Fred, Wilma.");
+            assertEquals(ex.getMessage(),
+                         "Unable to resolve \'Unknown\' to a page class name.  Available
page names: Barney, Betty, Fred, Wilma.");
         }
 
         verify();
@@ -212,6 +231,7 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -221,7 +241,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertTrue(resolver.isPageName("SimplePage"));
         assertTrue(resolver.isPageName("simplepage"));
@@ -235,6 +255,7 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
         train_for_packages(source, CORE_ROOT_PACKAGE);
@@ -245,8 +266,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         // Can look like an application page, but still resolves to the core library class
name.
 
@@ -277,8 +298,8 @@
         expect(locator.locateClassNames(isA(String.class))).andStubReturn(noMatches);
     }
 
-    protected final void train_locateComponentClassNames(ClassNameLocator locator,
-                                                         String packageName, String... classNames)
+    protected final void train_locateComponentClassNames(ClassNameLocator locator, String
packageName,
+                                                         String... classNames)
     {
         expect(locator.locateClassNames(packageName)).andReturn(Arrays.asList(classNames));
     }
@@ -290,6 +311,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -297,7 +319,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolvePageClassNameToPageName(className), "SimplePage");
 
@@ -310,11 +332,11 @@
     @Test
     public void resolved_page_names_are_cached()
     {
-
         String pageClassName = APP_ROOT_PACKAGE + ".pages.SimplePage";
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -322,7 +344,7 @@
 
         replay();
 
-        ComponentClassResolverImpl resolver = create(source, locator);
+        ComponentClassResolverImpl resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolvePageNameToClassName("SimplePage"), pageClassName);
 
@@ -357,6 +379,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_packages(source, CORE_ROOT_PACKAGE);
         train_for_app_packages(source);
@@ -365,8 +388,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("CorePage"), className);
 
@@ -380,6 +403,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_packages(source, CORE_ROOT_PACKAGE);
         train_for_app_packages(source);
@@ -388,8 +412,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageClassNameToPageName(className), "core/CorePage");
 
@@ -403,6 +427,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_packages(source, LIB_ROOT_PACKAGE);
         train_for_packages(source, CORE_ROOT_PACKAGE);
@@ -412,8 +437,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(LIB_PREFIX,
-                                                                                     LIB_ROOT_PACKAGE),
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
                                                  new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/LibPage"), className);
@@ -428,6 +453,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_packages(source, LIB_ROOT_PACKAGE);
         train_for_packages(source, CORE_ROOT_PACKAGE);
@@ -437,8 +463,8 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(LIB_PREFIX,
-                                                                                     LIB_ROOT_PACKAGE),
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
                                                  new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/libpage"), className);
@@ -452,14 +478,15 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = mockLogger();
 
         train_for_packages(source, CORE_ROOT_PACKAGE);
         train_for_app_packages(source);
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         String className = LIB_ROOT_PACKAGE + ".pages.LibPage";
 
@@ -470,8 +497,7 @@
         }
         catch (IllegalArgumentException ex)
         {
-            assertEquals(ex.getMessage(), "Unable to resolve class name " + className
-                    + " to a logical page name.");
+            assertEquals(ex.getMessage(), "Unable to resolve class name " + className + "
to a logical page name.");
         }
 
         verify();
@@ -483,17 +509,17 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_packages(source, CORE_ROOT_PACKAGE);
         train_for_app_packages(source);
 
-        train_locateComponentClassNames(locator, APP_ROOT_PACKAGE + ".pages", APP_ROOT_PACKAGE
-                + ".pages.Start");
+        train_locateComponentClassNames(locator, APP_ROOT_PACKAGE + ".pages", APP_ROOT_PACKAGE
+ ".pages.Start");
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         try
         {
@@ -502,9 +528,8 @@
         }
         catch (IllegalArgumentException ex)
         {
-            assertEquals(
-                    ex.getMessage(),
-                    "Unable to resolve \'MissingPage\' to a known page name. Available page
names: Start.");
+            assertEquals(ex.getMessage(),
+                         "Unable to resolve \'MissingPage\' to a known page name. Available
page names: Start.");
         }
 
         verify();
@@ -515,14 +540,15 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = mockLogger();
 
         train_for_packages(source, CORE_ROOT_PACKAGE);
         train_for_app_packages(source);
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         String className = CORE_ROOT_PACKAGE + ".foo.CorePage";
 
@@ -533,8 +559,7 @@
         }
         catch (IllegalArgumentException ex)
         {
-            assertEquals(ex.getMessage(), "Unable to resolve class name " + className
-                    + " to a logical page name.");
+            assertEquals(ex.getMessage(), "Unable to resolve class name " + className + "
to a logical page name.");
         }
 
         verify();
@@ -548,6 +573,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_packages(source, LIB_ROOT_PACKAGE);
         train_for_packages(source, secondaryLibPackage);
@@ -558,12 +584,10 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(
-                source,
-                locator,
-                new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
-                new LibraryMapping(LIB_PREFIX, secondaryLibPackage),
-                new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
+                                                 new LibraryMapping(LIB_PREFIX, secondaryLibPackage),
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         assertEquals(resolver.resolvePageNameToClassName("lib/LibPage"), className);
 
@@ -577,6 +601,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = mockLogger();
 
         train_for_packages(source, deepPackage);
         train_for_packages(source, LIB_ROOT_PACKAGE);
@@ -587,10 +612,9 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping("lib/deep",
-                                                                                     deepPackage),
-                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
new LibraryMapping(
-                CORE_PREFIX, CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator, new LibraryMapping("lib/deep",
deepPackage),
+                                                 new LibraryMapping(LIB_PREFIX, LIB_ROOT_PACKAGE),
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         try
         {
@@ -624,6 +648,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -631,7 +656,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolveComponentTypeToClassName("SimpleComponent"), className);
 
@@ -649,6 +674,7 @@
 
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = compliantLogger();
 
         train_for_app_packages(source);
 
@@ -656,7 +682,7 @@
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator);
+        ComponentClassResolver resolver = create(logger, source, locator);
 
         assertEquals(resolver.resolveMixinTypeToClassName("SimpleMixin"), expectedClassName);
 
@@ -668,14 +694,15 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = mockLogger();
 
         train_for_packages(source, CORE_ROOT_PACKAGE);
         train_for_app_packages(source);
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         try
         {
@@ -696,14 +723,15 @@
     {
         ComponentInstantiatorSource source = mockComponentInstantiatorSource();
         ClassNameLocator locator = newClassNameLocator();
+        Logger logger = mockLogger();
 
         train_for_packages(source, CORE_ROOT_PACKAGE);
         train_for_app_packages(source);
 
         replay();
 
-        ComponentClassResolver resolver = create(source, locator, new LibraryMapping(CORE_PREFIX,
-                                                                                     CORE_ROOT_PACKAGE));
+        ComponentClassResolver resolver = create(logger, source, locator,
+                                                 new LibraryMapping(CORE_PREFIX, CORE_ROOT_PACKAGE));
 
         try
         {
@@ -712,8 +740,7 @@
         }
         catch (IllegalArgumentException ex)
         {
-            assertTrue(ex.getMessage().contains(
-                    "Unable to resolve 'SimpleComponent' to a component class name."));
+            assertTrue(ex.getMessage().contains("Unable to resolve 'SimpleComponent' to a
component class name."));
         }
 
         verify();

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties?rev=596141&r1=596140&r2=596141&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/log4j.properties Sun Nov 18
13:42:58 2007
@@ -12,19 +12,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-log4j.rootCategory=WARN, A1
-
-# A1 is set to be a ConsoleAppender. 
-log4j.appender.A1=org.apache.log4j.ConsoleAppender
-
-# A1 uses PatternLayout.
-log4j.appender.A1.layout=org.apache.log4j.PatternLayout
-log4j.appender.A1.layout.ConversionPattern=[%p] %c{1} %m%n
-
-log4j.category.org.apache.tapestry.TapestryFilter=info
-log4j.category.org.apache.tapestry=error
-
-log4j.category.app=info
-log4j.category.org.apache.tapestry.integration.app1=error
-log4j.category.org.apache.tapestry.corelib=error
+log4j.rootCategory=INFO, A1
+
+# A1 is set to be a ConsoleAppender. 
+log4j.appender.A1=org.apache.log4j.ConsoleAppender
+
+# A1 uses PatternLayout.
+log4j.appender.A1.layout=org.apache.log4j.PatternLayout
+log4j.appender.A1.layout.ConversionPattern=[%p] %c{1} %m%n
+
+log4j.category.app=info
+
 



Mime
View raw message