Author: hlship
Date: Tue Dec 30 11:22:22 2008
New Revision: 730216

URL: http://svn.apache.org/viewvc?rev=730216&view=rev
Log:
TAP5-428: It should be possible to use tapestry-spring in an environment where 
the Spring ApplicationContext is created externally (as was the case in 
Tapestry 5.0)

Added:
    
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java
    
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/SpringTestCase.java
Modified:
    
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
    
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModule.java
    
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java
    tapestry/tapestry5/trunk/tapestry-spring/src/site/apt/index.apt
    
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/CustomizingContextLoaderTest.java
    
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryApplicationContextTest.java

Modified: 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java?rev=730216&r1=730215&r2=730216&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/SymbolConstants.java
 Tue Dec 30 11:22:22 2008
@@ -98,4 +98,12 @@
      * Per-page initialization always goes at the bottom.
      */
     public static final String SCRIPTS_AT_TOP = "tapestry.script-at-top";
+
+    /**
+     * If true, then Tapestry will attempt to use an externally configured 
Spring ApplicationContext rather than create
+     * its own. This will disable the ability to inject Tapestry IoC services 
and objects into Spring beans.
+     *
+     * @since 5.1.0.0
+     */
+    public static final String USE_EXTERNAL_SPRING_CONTEXT = 
"tapestry.use-external-spring-context";
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModule.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModule.java?rev=730216&r1=730215&r2=730216&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModule.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModule.java
 Tue Dec 30 11:22:22 2008
@@ -14,6 +14,8 @@
 
 package org.apache.tapestry5.internal.spring;
 
+import org.apache.tapestry5.SymbolConstants;
+import org.apache.tapestry5.ioc.MappedConfiguration;
 import org.apache.tapestry5.ioc.OrderedConfiguration;
 import org.apache.tapestry5.services.ApplicationInitializer;
 import org.apache.tapestry5.services.ApplicationInitializerFilter;
@@ -25,6 +27,8 @@
 /**
  * Module for Tapestry/Spring Integration. This module exists to force the 
load of the Spring ApplicationContext as part
  * of Tapestry application initialization.
+ *
+ * @since 5.1.0.0
  */
 public class SpringModule
 {
@@ -50,4 +54,9 @@
 
         configuration.add("SpringContextInitialization", filter);
     }
+
+    public static void contributeFactoryDefaults(MappedConfiguration<String, 
String> configuration)
+    {
+        configuration.add(SymbolConstants.USE_EXTERNAL_SPRING_CONTEXT, 
"false");
+    }
 }

Modified: 
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java?rev=730216&r1=730215&r2=730216&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-spring/src/main/java/org/apache/tapestry5/internal/spring/SpringModuleDef.java
 Tue Dec 30 11:22:22 2008
@@ -14,6 +14,7 @@
 
 package org.apache.tapestry5.internal.spring;
 
+import org.apache.tapestry5.SymbolConstants;
 import org.apache.tapestry5.internal.AbstractContributionDef;
 import org.apache.tapestry5.ioc.*;
 import org.apache.tapestry5.ioc.def.ContributionDef;
@@ -23,9 +24,7 @@
 import org.apache.tapestry5.ioc.internal.util.CollectionFactory;
 import org.apache.tapestry5.ioc.internal.util.InternalUtils;
 import org.apache.tapestry5.ioc.internal.util.Invokable;
-import org.apache.tapestry5.ioc.services.ClassFabUtils;
-import org.apache.tapestry5.ioc.services.RegistryShutdownHub;
-import org.apache.tapestry5.ioc.services.RegistryShutdownListener;
+import org.apache.tapestry5.ioc.services.*;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.SpringVersion;
 import org.springframework.web.context.ConfigurableWebApplicationContext;
@@ -43,64 +42,74 @@
  */
 public class SpringModuleDef implements ModuleDef
 {
-    private static final String SERVICE_ID = "ApplicationContext";
+    static final String SERVICE_ID = "ApplicationContext";
 
     private final Map<String, ServiceDef> services = 
CollectionFactory.newMap();
 
     private final AtomicBoolean applicationContextCreated = new 
AtomicBoolean(false);
 
-    public SpringModuleDef(final ServletContext servletContext, final 
ApplicationContextCustomizer customizer)
-    {
-        ServiceDef sd = new ServiceDef()
-        {
-            public ObjectCreator createServiceCreator(final 
ServiceBuilderResources resources)
-            {
-                final CustomizingContextLoader loader = new 
CustomizingContextLoader(
-                        customizer);
+    private final ServletContext servletContext;
 
-                final RegistryShutdownListener shutdownListener = new 
RegistryShutdownListener()
-                {
-                    public void registryDidShutdown()
-                    {
-                        loader.closeWebApplicationContext(servletContext);
-                    }
-                };
+    private final ApplicationContextCustomizer customizer;
 
-                final RegistryShutdownHub shutdownHub = 
resources.getService(RegistryShutdownHub.class);
+    private class ExternalApplicationContextLookupCreator implements 
ObjectCreator
+    {
+        private final OperationTracker tracker;
 
+        public ExternalApplicationContextLookupCreator(OperationTracker 
tracker)
+        {
+            this.tracker = tracker;
+        }
 
-                return new ObjectCreator()
-                {
-                    public Object createObject()
+        public Object createObject()
+        {
+            return tracker.invoke(
+                    "Obtaining Spring ApplicationContext from ServletContext",
+                    new Invokable<Object>()
                     {
-                        return resources.getTracker().invoke(
-                                "Creating Spring ApplicationContext via 
ContextLoader",
-                                new Invokable<Object>()
-                                {
-                                    public Object invoke()
-                                    {
-                                        
resources.getLogger().info(String.format(
-                                                "Starting Spring (version %s)",
-                                                SpringVersion.getVersion()));
+                        public Object invoke()
+                        {
+                            ConfigurableWebApplicationContext context = 
(ConfigurableWebApplicationContext) servletContext.getAttribute(
+                                    
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
+
+                            if (context == null)
+                                throw new NullPointerException(String.format(
+                                        "No Spring ApplicationContext stored 
in the ServletContext as attribute '%s'. " +
+                                                "You should either re-enable 
Tapestry as the creator of the ApplicationContext, or " +
+                                                "add a Spring 
ContextLoaderListener to web.xml.",
+                                        
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE));
+
+                            applicationContextCreated.set(true);
+
+                            return context;
+                        }
+                    });
+        }
+    }
 
-                                        WebApplicationContext context = 
loader.initWebApplicationContext(
-                                                servletContext);
+    public SpringModuleDef(ServletContext servletContext, final 
ApplicationContextCustomizer customizer)
+    {
+        this.servletContext = servletContext;
+        this.customizer = customizer;
 
-                                        
shutdownHub.addRegistryShutdownListener(shutdownListener);
+        ServiceDef sd = new ServiceDef()
+        {
+            public ObjectCreator createServiceCreator(final 
ServiceBuilderResources resources)
+            {
+                TypeCoercer coercer = resources.getService(TypeCoercer.class);
+                SymbolSource symbolSource = 
resources.getService(SymbolSource.class);
 
-                                        applicationContextCreated.set(true);
+                boolean useExternal = coercer.coerce(
+                        
symbolSource.valueForSymbol(SymbolConstants.USE_EXTERNAL_SPRING_CONTEXT), 
boolean.class);
 
-                                        return context;
-                                    }
-                                });
-                    }
+                final OperationTracker tracker = resources.getTracker();
 
-                    @Override
-                    public String toString()
-                    {
-                        return "ObjectCreator for Spring ApplicationContext";
-                    }
-                };
+                if (useExternal)
+                {
+                    return new 
ExternalApplicationContextLookupCreator(tracker);
+                }
+
+                return constructObjectCreatorForApplicationContext(resources);
             }
 
             public String getServiceId()
@@ -132,6 +141,55 @@
         services.put(SERVICE_ID, sd);
     }
 
+    private ObjectCreator constructObjectCreatorForApplicationContext(final 
ServiceBuilderResources resources
+    )
+    {
+        final CustomizingContextLoader loader = new 
CustomizingContextLoader(customizer);
+
+        final RegistryShutdownListener shutdownListener = new 
RegistryShutdownListener()
+        {
+            public void registryDidShutdown()
+            {
+                loader.closeWebApplicationContext(servletContext);
+            }
+        };
+
+        final RegistryShutdownHub shutdownHub = 
resources.getService(RegistryShutdownHub.class);
+
+        return new ObjectCreator()
+        {
+            public Object createObject()
+            {
+                return resources.getTracker().invoke(
+                        "Creating Spring ApplicationContext via ContextLoader",
+                        new Invokable<Object>()
+                        {
+                            public Object invoke()
+                            {
+                                resources.getLogger().info(String.format(
+                                        "Starting Spring (version %s)",
+                                        SpringVersion.getVersion()));
+
+                                WebApplicationContext context = 
loader.initWebApplicationContext(
+                                        servletContext);
+
+                                
shutdownHub.addRegistryShutdownListener(shutdownListener);
+
+                                applicationContextCreated.set(true);
+
+                                return context;
+                            }
+                        });
+            }
+
+            @Override
+            public String toString()
+            {
+                return "ObjectCreator for Spring ApplicationContext";
+            }
+        };
+    }
+
     public Class getBuilderClass()
     {
         return null;
@@ -150,36 +208,7 @@
 
     private ContributionDef createContributionToMasterObjectProvider()
     {
-        final ObjectProvider springBeanProvider = new ObjectProvider()
-        {
-            public <T> T provide(Class<T> objectType, AnnotationProvider 
annotationProvider, ObjectLocator locator)
-            {
-                ApplicationContext context = locator.getService(SERVICE_ID, 
ApplicationContext.class);
-
-                Map beanMap = context.getBeansOfType(objectType);
-
-                switch (beanMap.size())
-                {
-                    case 0:
-                        return null;
 
-                    case 1:
-
-                        Object bean = beanMap.values().iterator().next();
-
-                        return objectType.cast(bean);
-
-                    default:
-
-                        String message = String.format("Spring context 
contains %d beans assignable to type %s: %s.",
-                                                       beanMap.size(),
-                                                       
ClassFabUtils.toJavaClassName(objectType),
-                                                       
InternalUtils.joinSorted(beanMap.keySet()));
-
-                        throw new IllegalArgumentException(message);
-                }
-            }
-        };
 
         ContributionDef def = new AbstractContributionDef()
         {
@@ -194,6 +223,40 @@
             {
                 final OperationTracker tracker = resources.getTracker();
 
+                final ApplicationContext context = 
resources.getService(SERVICE_ID, ApplicationContext.class);
+
+                final ObjectProvider springBeanProvider = new ObjectProvider()
+                {
+                    public <T> T provide(Class<T> objectType, 
AnnotationProvider annotationProvider,
+                                         ObjectLocator locator)
+                    {
+
+                        Map beanMap = context.getBeansOfType(objectType);
+
+                        switch (beanMap.size())
+                        {
+                            case 0:
+                                return null;
+
+                            case 1:
+
+                                Object bean = 
beanMap.values().iterator().next();
+
+                                return objectType.cast(bean);
+
+                            default:
+
+                                String message = String.format(
+                                        "Spring context contains %d beans 
assignable to type %s: %s.",
+                                        beanMap.size(),
+                                        
ClassFabUtils.toJavaClassName(objectType),
+                                        
InternalUtils.joinSorted(beanMap.keySet()));
+
+                                throw new IllegalArgumentException(message);
+                        }
+                    }
+                };
+
                 final ObjectProvider springBeanProviderInvoker = new 
ObjectProvider()
                 {
                     public <T> T provide(final Class<T> objectType, final 
AnnotationProvider annotationProvider,
@@ -240,7 +303,7 @@
 
     public String getLoggerName()
     {
-        return "Spring";
+        return SpringModuleDef.class.getName();
     }
 
     public ServiceDef getServiceDef(String serviceId)

Modified: tapestry/tapestry5/trunk/tapestry-spring/src/site/apt/index.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/site/apt/index.apt?rev=730216&r1=730215&r2=730216&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/src/site/apt/index.apt (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/src/site/apt/index.apt Tue Dec 30 
11:22:22 2008
@@ -75,7 +75,14 @@
 ApplicationContext Service
 
   The Spring ApplicationContext is also added as a service.
-  
+
+External Configuration
+
+ In some circumstances, it is desirable to configure the Spring 
ApplicationContext externally. The  symbol
+ "tapestry.use-external-spring-context" can be configured to "true".  Tapestry 
will then use an existing ApplicationContext,
+ provided by a Spring ContextLoaderListener. You will still be able to inject 
Spring beans into Tapestry components and services,
+ and the ApplicationContext service will be visible ... but you will not be 
able to inject Tapestry IoC services into Spring beans.
+
 Limitations
 
   Non-singleton beans are not handled properly. Tapestry will request the 
beans from the application context in a manner unsuitable for their lifecycle.

Modified: 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/CustomizingContextLoaderTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/CustomizingContextLoaderTest.java?rev=730216&r1=730215&r2=730216&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/CustomizingContextLoaderTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/CustomizingContextLoaderTest.java
 Tue Dec 30 11:22:22 2008
@@ -14,7 +14,7 @@
 
 package org.apache.tapestry5.internal.spring;
 
-import org.apache.tapestry5.ioc.test.TestBase;
+import org.apache.tapestry5.spring.SpringTestCase;
 import org.apache.tapestry5.spring.TapestryApplicationContext;
 import org.springframework.web.context.ContextLoader;
 import org.springframework.web.context.support.XmlWebApplicationContext;
@@ -22,7 +22,7 @@
 
 import javax.servlet.ServletContext;
 
-public class CustomizingContextLoaderTest extends TestBase
+public class CustomizingContextLoaderTest extends SpringTestCase
 {
     @Test
     public void specified_context_class_is_not_compatible()
@@ -51,16 +51,6 @@
         verify();
     }
 
-    protected final void train_getInitParameter(ServletContext context, String 
parameterName, String parameterValue)
-    {
-        
expect(context.getInitParameter(parameterName)).andReturn(parameterValue).atLeastOnce();
-    }
-
-    protected final ServletContext mockServletContext()
-    {
-        return newMock(ServletContext.class);
-    }
-
     @Test
     public void specified_context_class_is_compatible()
     {

Added: 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java?rev=730216&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/internal/spring/SpringModuleDefTest.java
 Tue Dec 30 11:22:22 2008
@@ -0,0 +1,110 @@
+// Copyright 2008 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.tapestry5.internal.spring;
+
+import org.apache.tapestry5.SymbolConstants;
+import org.apache.tapestry5.ioc.ObjectCreator;
+import org.apache.tapestry5.ioc.ServiceBuilderResources;
+import org.apache.tapestry5.ioc.def.ServiceDef;
+import org.apache.tapestry5.ioc.internal.QuietOperationTracker;
+import org.apache.tapestry5.ioc.services.SymbolSource;
+import org.apache.tapestry5.ioc.services.TypeCoercer;
+import org.apache.tapestry5.spring.SpringTestCase;
+import org.springframework.web.context.ConfigurableWebApplicationContext;
+import org.springframework.web.context.WebApplicationContext;
+import org.testng.annotations.Test;
+
+import javax.servlet.ServletContext;
+
+public class SpringModuleDefTest extends SpringTestCase
+{
+    @Test
+    public void load_application_context_externally()
+    {
+        ServletContext servletContext = mockServletContext();
+        TypeCoercer tc = mockTypeCoercer();
+        SymbolSource ss = mockSymbolSource();
+        ConfigurableWebApplicationContext ac = 
newMock(ConfigurableWebApplicationContext.class);
+
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+
+        train_for_external_spring_context(resources, tc, ss);
+
+        train_getAttribute(servletContext, 
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ac);
+
+        train_getTracker(resources, new QuietOperationTracker());
+
+        replay();
+
+        SpringModuleDef moduleDef = new SpringModuleDef(servletContext, null);
+
+        ServiceDef serviceDef = 
moduleDef.getServiceDef(SpringModuleDef.SERVICE_ID);
+
+        ObjectCreator serviceCreator = 
serviceDef.createServiceCreator(resources);
+
+        assertSame(serviceCreator.createObject(), ac);
+
+        verify();
+    }
+
+    @Test
+    public void missing_external_application_context()
+    {
+        ServletContext servletContext = mockServletContext();
+        TypeCoercer tc = mockTypeCoercer();
+        SymbolSource ss = mockSymbolSource();
+
+        ServiceBuilderResources resources = mockServiceBuilderResources();
+
+        train_for_external_spring_context(resources, tc, ss);
+
+        train_getAttribute(servletContext, 
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, null);
+
+        train_getTracker(resources, new QuietOperationTracker());
+
+        replay();
+
+        SpringModuleDef moduleDef = new SpringModuleDef(servletContext, null);
+
+        ServiceDef serviceDef = 
moduleDef.getServiceDef(SpringModuleDef.SERVICE_ID);
+
+        ObjectCreator serviceCreator = 
serviceDef.createServiceCreator(resources);
+
+        try
+        {
+            serviceCreator.createObject();
+            unreachable();
+        }
+        catch (NullPointerException ex)
+        {
+            assertMessageContains(ex,
+                                  "No Spring ApplicationContext stored in the 
ServletContext",
+                                  
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
+        }
+
+        verify();
+    }
+
+    private void train_for_external_spring_context(ServiceBuilderResources 
resources, TypeCoercer coercer,
+                                                   SymbolSource source)
+    {
+
+        train_getService(resources, TypeCoercer.class, coercer);
+        train_getService(resources, SymbolSource.class, source);
+
+        
expect(source.valueForSymbol(SymbolConstants.USE_EXTERNAL_SPRING_CONTEXT)).andReturn("true");
+        train_coerce(coercer, "true", boolean.class, true);
+    }
+}

Added: 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/SpringTestCase.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/SpringTestCase.java?rev=730216&view=auto
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/SpringTestCase.java
 (added)
+++ 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/SpringTestCase.java
 Tue Dec 30 11:22:22 2008
@@ -0,0 +1,40 @@
+// Copyright 2008 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.tapestry5.spring;
+
+import org.apache.tapestry5.test.TapestryTestCase;
+
+import javax.servlet.ServletContext;
+
+/**
+ * Base class for Spring Integration test cases.
+ */
+public class SpringTestCase extends TapestryTestCase
+{
+    protected final void train_getInitParameter(ServletContext context, String 
parameterName, String parameterValue)
+    {
+        
expect(context.getInitParameter(parameterName)).andReturn(parameterValue).atLeastOnce();
+    }
+
+    protected final ServletContext mockServletContext()
+    {
+        return newMock(ServletContext.class);
+    }
+
+    protected final void train_getAttribute(ServletContext context, String 
attributeName, Object attributeValue)
+    {
+        expect(context.getAttribute(attributeName)).andReturn(attributeValue);
+    }
+}

Modified: 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryApplicationContextTest.java
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryApplicationContextTest.java?rev=730216&r1=730215&r2=730216&view=diff
==============================================================================
--- 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryApplicationContextTest.java
 (original)
+++ 
tapestry/tapestry5/trunk/tapestry-spring/src/test/java/org/apache/tapestry5/spring/TapestryApplicationContextTest.java
 Tue Dec 30 11:22:22 2008
@@ -15,19 +15,18 @@
 package org.apache.tapestry5.spring;
 
 import org.apache.tapestry5.TapestryFilter;
-import org.apache.tapestry5.ioc.test.TestBase;
 import org.testng.annotations.Test;
 
 import javax.servlet.ServletContext;
 
-public class TapestryApplicationContextTest extends TestBase
+public class TapestryApplicationContextTest extends SpringTestCase
 {
     @Test
     public void no_registry_in_servlet_context()
     {
-        ServletContext context = newMock(ServletContext.class);
+        ServletContext context = mockServletContext();
 
-        
expect(context.getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME)).andReturn(null);
+        train_getAttribute(context, TapestryFilter.REGISTRY_CONTEXT_NAME, 
null);
 
         replay();
 


Reply via email to