You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ivan Dubrov <wf...@gmail.com> on 2007/09/24 13:14:15 UTC

Using PageTester with tapestry-spring

Hi,

How can I use the PageTester with the Spring integration? The problem is
that when PageTester creates the registry it does not adds
SpringModuleDef to the list of modules and all my Spring services are
unavailable because of this. Extending the PageTester is not possible as
well, so I cannot extend it and provide additional module (like the
TapestrySpringFilter does), so I have to copy-paste the complete
PageTester and add a line to include SpringModuleDef module to the list.

Are there any other ways that not include dumb copy-pasting?

Just for clearness. How can I add an override to the services when
running the tests? Creating AliasContribution's with the mode set to
"test", right? But what to do if I want to keep my primary module clear
of test services and keep all my test services in the test module inside
the src/test Maven2 hierarchy (so they even aren't included in the
release build)?

-- 
WBR,
Ivan S. Dubrov



Re: Using PageTester with tapestry-spring

Posted by Doublel <mo...@gmail.com>.
I  really don't know how to do it , Thanks in advance.This is the code:
web.xml
<!DOCTYPE web-app
      PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
      "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <display-name>My Tapestry Application Test For T5.0.5</display-name>


    <context-param>
        <param-name>tapestry.app-package</param-name>
        <param-value>cn.crc.pjblog</param-value>
    </context-param>
    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/classes/log4j.properties</param-value>
    </context-param>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
        /WEB-INF/conf/applicationContext.xml
        </param-value>
        </context-param>

    <filter>
        <filter-name>app</filter-name>
        <filter-class>org.apache.tapestry.TapestryFilter</filter-class>
        </filter>

    <filter-mapping>
        <filter-name>app</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <listener>
        <listener-class>
            org.springframework.web.util.Log4jConfigListener
        </listener-class>
    </listener>
    <!-- sys -->
    <listener>
        <listener-class>cn.crc.pjblog.servlet.SysListener</listener-class>
    </listener>
    <!-- Spring Framework -->
    <listener>
        <listener-class>
            org.springframework.web.context.ContextLoaderListener
        </listener-class>
    </listener>
</web-app>
AppModule.java
@SubModule(SpringModule.class)
public class AppModule {}
SpringModule.java
public class SpringModule {

    public static void bind(ServiceBinder binder){

        binder.bind(ObjectProvider.class,SpringObjectProvider.class)
        .withId("SpringObjectProvider");
    }

    public static WebApplicationContext build(@InjectService("Context")
Context context){

        WebApplicationContext springContext = null;
        try {

            springContext = (WebApplicationContext) context.getAttribute(
WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);

        } catch (Exception e) {
            // TODO: handle exception
            throw new RuntimeException(
SpringMessages.failureObtainingContext(e),e);
        }
        if (springContext == null) throw new RuntimeException(
SpringMessages.missingContext());
        return springContext;
    }

     /**
     * Contributes a provider named "Spring".
     */
        public static void contributeMasterObjectProvider(
                        OrderedConfiguration<ObjectProvider> configuration,
                        ObjectLocator locator) {
                configuration.add("spring", locator
                                .autobuild(SpringObjectProvider.class));
        }

SpringObjectProvider.java

public class SpringObjectProvider implements ObjectProvider {
     private final Log _log;

        private final WebApplicationContext _context;

        private boolean _beansNamesLoaded = false;

        private final Map<String, String> _beanNames =
newCaseInsensitiveMap();

        public SpringObjectProvider(Log log,
@InjectService("WebApplicationContext")
        WebApplicationContext context)
        {
            _log = log;

            _context = context;
        }

        private synchronized void loadBeanNames()
        {
            if (_beansNamesLoaded) return;

            for (String name : _context.getBeanDefinitionNames())
            {
                _beanNames.put(name, name);
            }

            _log.info(SpringMessages.contextStartup(_beanNames.keySet()));

            _beansNamesLoaded = true;
        }

        /**
         * The expression is the name of a spring bean inside the context.
         */
        public <T> T provide(Class<T> objectType, AnnotationProvider
annotationProvider,
                ObjectLocator locator)
        {
            SpringBean annotation = annotationProvider.getAnnotation(
SpringBean.class);

            if (annotation == null) return null;

            String beanName = annotation.value();

            // Need to defer loading bean names to avoid some bootstrapping
problems.

            loadBeanNames();

            // Attempt to convert from the base insensitive name to the name
as defined by Spring
            // (which is, to my knowledge) case sensitive.
            String effectiveName = _beanNames.containsKey(beanName) ?
_beanNames.get(beanName)
                    : beanName;

            try
            {
                Object raw = _context.getBean(effectiveName, objectType);

                return objectType.cast(raw);
            }
            catch (Exception ex)
            {
                throw new RuntimeException(SpringMessages.beanAccessFailure(
                        effectiveName,
                        objectType,
                        ex), ex);
            }
        }

}



2007/9/27, Joel Wiegman <Jo...@btservices.com>:
>
> Without seeing any source, I can only guess that you're injecting
> WebApplicationContext somewhere in your application and your SpringModule
> isn't loading that service correctly?  Tough to say without source.
>
> -----Original Message-----
> From: Doublel [mailto:moonfly2004@gmail.com]
> Sent: Thursday, September 27, 2007 1:04 AM
> To: Tapestry users
> Subject: Re: Using PageTester with tapestry-spring
>
> Thanks ! the problem is resolved. But I ran  into this :
>
> [ERROR] WebApplicationContext Construction of service
> WebApplicationContext
> failed: Error invoking service builder method
> cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
> service 'WebApplicationContext'): An exception occurred obtaining the Spring
> WebApplicationContext: getAttribute() is not supported for
> ContextForPageTester.
> java.lang.RuntimeException: Error invoking service builder method
> cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
> service 'WebApplicationContext'): An exception occurred obtaining the Spring
> WebApplicationContext: getAttribute() is not supported for
> ContextForPageTester.
>     at
> org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
> ServiceBuilderMethodInvoker.java:87)
>     at
> org.apache.tapestry.ioc.internal.SingletonServiceLifecycle.createService(
> SingletonServiceLifecycle.java:31)
>     at
>
> org.apache.tapestry.ioc.internal.LifecycleWrappedServiceCreator.createObject
> (LifecycleWrappedServiceCreator.java:54)
>     at
> org.apache.tapestry.ioc.internal.InterceptorStackBuilder.createObject
> (InterceptorStackBuilder.java:54)
>     at
>
> org.apache.tapestry.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject
> (RecursiveServiceCreationCheckWrapper.java:60)
>     at
>
> org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
> (JustInTimeObjectCreator.java:61)
>     at
>
> $WebApplicationContext_1154558bc95._delegate($WebApplicationContext_1154558bc95.java)
>     at
>
> $WebApplicationContext_1154558bc95.getBeanDefinitionNames($WebApplicationContext_1154558bc95.java)
>     at cn.crc.spring.SpringObjectProvider.loadBeanNames(
> SpringObjectProvider.java:49)
>     at cn.crc.spring.SpringObjectProvider.provide(
> SpringObjectProvider.java
> :73)
>     at
> $ObjectProvider_1154558bc97.provide($ObjectProvider_1154558bc97.java)
>     at
> $ObjectProvider_1154558bc90.provide($ObjectProvider_1154558bc90.java)
>     at org.apache.tapestry.internal.services.InjectWorker.inject(
> InjectWorker.java:80)
>     at org.apache.tapestry.internal.services.InjectWorker.transform(
> InjectWorker.java:53)
>     at
>
> $ComponentClassTransformWorker_1154558bcc9.transform($ComponentClassTransformWorker_1154558bcc9.java)
>     at
>
> $ComponentClassTransformWorker_1154558bcc6.transform($ComponentClassTransformWorker_1154558bcc6.java)
>     at
>
> org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
> (ComponentClassTransformerImpl.java:131)
>     at
>
> $ComponentClassTransformer_1154558bcc0.transformComponentClass($ComponentClassTransformer_1154558bcc0.java)
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.onLoad
> (ComponentInstantiatorSourceImpl.java:177)
>     at javassist.Loader.findClass(Loader.java:340)
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl$PackageAwareLoader.findClass
> (ComponentInstantiatorSourceImpl.java:85)
>     at javassist.Loader.loadClass(Loader.java:311)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
> (ComponentInstantiatorSourceImpl.java:254)
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findInstantiator
> (ComponentInstantiatorSourceImpl.java:240)
>     at
>
> $ComponentInstantiatorSource_1154558bcb3.findInstantiator($ComponentInstantiatorSource_1154558bcb3.java)
>     at
>
> org.apache.tapestry.internal.services.PageElementFactoryImpl.newRootComponentElement
> (PageElementFactoryImpl.java:319)
>     at
>
> $PageElementFactory_1154558bcbe.newRootComponentElement($PageElementFactory_1154558bcbe.java)
>     at
>
> org.apache.tapestry.internal.services.PageLoaderProcessor.loadRootComponent
> (
> PageLoaderProcessor.java:405)
>     at org.apache.tapestry.internal.services.PageLoaderProcessor.loadPage(
> PageLoaderProcessor.java:390)
>     at org.apache.tapestry.internal.services.PageLoaderImpl.loadPage(
> PageLoaderImpl.java:59)
>     at $PageLoader_1154558bcbb.loadPage($PageLoader_1154558bcbb.java)
>     at org.apache.tapestry.internal.services.PagePoolImpl.checkout(
> PagePoolImpl.java:70)
>     at $PagePool_1154558bcba.checkout($PagePool_1154558bcba.java)
>     at org.apache.tapestry.internal.services.RequestPageCacheImpl.get(
> RequestPageCacheImpl.java:44)
>     at
> $RequestPageCache_1154558bcb7.get($RequestPageCache_1154558bcb7.java)
>     at
> $RequestPageCache_1154558bcaf.get($RequestPageCache_1154558bcaf.java)
>     at
> org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(
> PageRenderRequestHandlerImpl.java:55)
>     at
>
> $PageRenderRequestHandler_1154558bca5.handle($PageRenderRequestHandler_1154558bca5.java)
>     at org.apache.tapestry.internal.test.PageLinkInvoker.invoke(
> PageLinkInvoker.java:57)
>     at org.apache.tapestry.test.PageTester.invoke(PageTester.java:184)
>     at org.apache.tapestry.test.PageTester.renderPage(PageTester.java:144)
>     at cn.crc.pjblog.test.pages.BlogPostOneTest.BlogPostOneTest1(
> BlogPostOneTest.java:16)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:585)
>     at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java
> :604)
>     at org.testng.internal.Invoker.invokeMethod(Invoker.java:470)
>     at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564)
>     at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830)
>     at org.testng.internal.TestMethodWorker.invokeTestMethods(
> TestMethodWorker.java:125)
>     at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
>     at org.testng.TestRunner.runWorkers(TestRunner.java:678)
>     at org.testng.TestRunner.privateRun(TestRunner.java:624)
>     at org.testng.TestRunner.run(TestRunner.java:495)
>     at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
>     at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
>     at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
>     at org.testng.SuiteRunner.run(SuiteRunner.java:190)
>     at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
>     at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
>     at org.testng.TestNG.run(TestNG.java:699)
>     at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
>     at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
> Caused by: java.lang.RuntimeException: An exception occurred obtaining the
> Spring WebApplicationContext: getAttribute() is not supported for
> ContextForPageTester.
>     at cn.crc.spring.SpringModule.build(SpringModule.java:40)
>     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>     at sun.reflect.NativeMethodAccessorImpl.invoke(
> NativeMethodAccessorImpl.java:39)
>     at sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:25)
>     at java.lang.reflect.Method.invoke(Method.java:585)
>     at
> org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
> ServiceBuilderMethodInvoker.java:75)
>     ... 64 more
> Caused by: java.lang.UnsupportedOperationException: getAttribute() is not
> supported for ContextForPageTester.
>     at org.apache.tapestry.internal.test.PageTesterContext.getAttribute(
> PageTesterContext.java:61)
>     at $Context_1154558bccc.getAttribute($Context_1154558bccc.java)
>     at $Context_1154558bccb.getAttribute($Context_1154558bccb.java)
>     at cn.crc.spring.SpringModule.build(SpringModule.java:36)
>     ... 69 more
> FAILED: BlogPostOneTest1
> java.lang.RuntimeException: java.lang.ClassNotFoundException: caught an
> exception while obtaining a class file for cn.crc.pjblog.pages.BlogPostOne
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
> (ComponentInstantiatorSourceImpl.java:258)
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findInstantiator
> (ComponentInstantiatorSourceImpl.java:240)
>     at
>
> $ComponentInstantiatorSource_1154558bcb3.findInstantiator($ComponentInstantiatorSource_1154558bcb3.java)
>     at
>
> org.apache.tapestry.internal.services.PageElementFactoryImpl.newRootComponentElement
> (PageElementFactoryImpl.java:319)
>     at
>
> $PageElementFactory_1154558bcbe.newRootComponentElement($PageElementFactory_1154558bcbe.java)
>     at
>
> org.apache.tapestry.internal.services.PageLoaderProcessor.loadRootComponent
> (
> PageLoaderProcessor.java:405)
>     at org.apache.tapestry.internal.services.PageLoaderProcessor.loadPage(
> PageLoaderProcessor.java:390)
>     at org.apache.tapestry.internal.services.PageLoaderImpl.loadPage(
> PageLoaderImpl.java:59)
>     at $PageLoader_1154558bcbb.loadPage($PageLoader_1154558bcbb.java)
>     at org.apache.tapestry.internal.services.PagePoolImpl.checkout(
> PagePoolImpl.java:70)
>     at $PagePool_1154558bcba.checkout($PagePool_1154558bcba.java)
>     at org.apache.tapestry.internal.services.RequestPageCacheImpl.get(
> RequestPageCacheImpl.java:44)
>     at
> $RequestPageCache_1154558bcb7.get($RequestPageCache_1154558bcb7.java)
>     at
> $RequestPageCache_1154558bcaf.get($RequestPageCache_1154558bcaf.java)
>     at
> org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(
> PageRenderRequestHandlerImpl.java:55)
>     at
>
> $PageRenderRequestHandler_1154558bca5.handle($PageRenderRequestHandler_1154558bca5.java)
>     at org.apache.tapestry.internal.test.PageLinkInvoker.invoke(
> PageLinkInvoker.java:57)
>     at org.apache.tapestry.test.PageTester.invoke(PageTester.java:184)
>     at org.apache.tapestry.test.PageTester.renderPage(PageTester.java:144)
>     at cn.crc.pjblog.test.pages.BlogPostOneTest.BlogPostOneTest1(
> BlogPostOneTest.java:16)
> Caused by: java.lang.ClassNotFoundException: caught an exception while
> obtaining a class file for cn.crc.pjblog.pages.BlogPostOne
>     at javassist.Loader.findClass(Loader.java:359)
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl$PackageAwareLoader.findClass
> (ComponentInstantiatorSourceImpl.java:85)
>     at javassist.Loader.loadClass(Loader.java:311)
>     at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
> (ComponentInstantiatorSourceImpl.java:254)
>     ... 41 more
> Caused by: org.apache.tapestry.internal.services.TransformationException:
> Error obtaining injected value for field
> cn.crc.pjblog.pages.BlogPostOne.pdao: Exception constructing service
> 'WebApplicationContext': Error invoking service builder method
> cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
> service 'WebApplicationContext'): An exception occurred obtaining the Spring
> WebApplicationContext: getAttribute() is not supported for
> ContextForPageTester.
>     at
>
> org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
> (ComponentClassTransformerImpl.java:137)
>     at
>
> $ComponentClassTransformer_1154558bcc0.transformComponentClass($ComponentClassTransformer_1154558bcc0.java)
>     at
>
> org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.onLoad
> (ComponentInstantiatorSourceImpl.java:177)
>     at javassist.Loader.findClass(Loader.java:340)
>     ... 45 more
> Caused by: java.lang.RuntimeException: Error obtaining injected value for
> field cn.crc.pjblog.pages.BlogPostOne.pdao: Exception constructing service
> 'WebApplicationContext': Error invoking service builder method
> cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
> service 'WebApplicationContext'): An exception occurred obtaining the Spring
> WebApplicationContext: getAttribute() is not supported for
> ContextForPageTester.
>     at org.apache.tapestry.internal.services.InjectWorker.inject(
> InjectWorker.java:84)
>     at org.apache.tapestry.internal.services.InjectWorker.transform(
> InjectWorker.java:53)
>     at
>
> $ComponentClassTransformWorker_1154558bcc9.transform($ComponentClassTransformWorker_1154558bcc9.java)
>     at
>
> $ComponentClassTransformWorker_1154558bcc6.transform($ComponentClassTransformWorker_1154558bcc6.java)
>     at
>
> org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
> (ComponentClassTransformerImpl.java:131)
>     ... 48 more
> Caused by: java.lang.RuntimeException: Exception constructing service
> 'WebApplicationContext': Error invoking service builder method
> cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
> service 'WebApplicationContext'): An exception occurred obtaining the Spring
> WebApplicationContext: getAttribute() is not supported for
> ContextForPageTester.
>     at
>
> org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
> (JustInTimeObjectCreator.java:69)
>     at
>
> $WebApplicationContext_1154558bc95._delegate($WebApplicationContext_1154558bc95.java)
>     at
>
> $WebApplicationContext_1154558bc95.getBeanDefinitionNames($WebApplicationContext_1154558bc95.java)
>     at cn.crc.spring.SpringObjectProvider.loadBeanNames(
> SpringObjectProvider.java:49)
>     at cn.crc.spring.SpringObjectProvider.provide(
> SpringObjectProvider.java
> :73)
>     at
> $ObjectProvider_1154558bc97.provide($ObjectProvider_1154558bc97.java)
>     at
> $ObjectProvider_1154558bc90.provide($ObjectProvider_1154558bc90.java)
>     at org.apache.tapestry.internal.services.InjectWorker.inject(
> InjectWorker.java:80)
>     ... 52 more
> Caused by: java.lang.RuntimeException: Error invoking service builder
> method
> cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
> service 'WebApplicationContext'): An exception occurred obtaining the Spring
> WebApplicationContext: getAttribute() is not supported for
> ContextForPageTester.
>     at
> org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
> ServiceBuilderMethodInvoker.java:87)
>     at
> org.apache.tapestry.ioc.internal.SingletonServiceLifecycle.createService(
> SingletonServiceLifecycle.java:31)
>     at
>
> org.apache.tapestry.ioc.internal.LifecycleWrappedServiceCreator.createObject
> (LifecycleWrappedServiceCreator.java:54)
>     at
> org.apache.tapestry.ioc.internal.InterceptorStackBuilder.createObject
> (InterceptorStackBuilder.java:54)
>     at
>
> org.apache.tapestry.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject
> (RecursiveServiceCreationCheckWrapper.java:60)
>     at
>
> org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
> (JustInTimeObjectCreator.java:61)
>     ... 59 more
> Caused by: java.lang.RuntimeException: An exception occurred obtaining the
> Spring WebApplicationContext: getAttribute() is not supported for
> ContextForPageTester.
>     at cn.crc.spring.SpringModule.build(SpringModule.java:40)
>     at
> org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
> ServiceBuilderMethodInvoker.java:75)
>     ... 64 more
> Caused by: java.lang.UnsupportedOperationException: getAttribute() is not
> supported for ContextForPageTester.
>     at org.apache.tapestry.internal.test.PageTesterContext.getAttribute(
> PageTesterContext.java:61)
>     at $Context_1154558bccc.getAttribute($Context_1154558bccc.java)
>     at $Context_1154558bccb.getAttribute($Context_1154558bccb.java)
>     at cn.crc.spring.SpringModule.build(SpringModule.java:36)
>     ... 69 more
> ... Removed 26 stack frames
>
>
> 2007/9/26, Joel Wiegman <Jo...@btservices.com>:
> >
> > What's basically happening here is:
> >
> > The application module you are passing to your PageTester (via the
> > "String appName" argument) does not load your Spring context.  In the
> > alternative Spring integration link you provided this string would be
> > "Spring", assuming the class is named "SpringModule" and that it
> > exists in your <app>.services package.
> >
> > Hope that helps.
> >
> > -----Original Message-----
> > From: Doublel [mailto:moonfly2004@gmail.com]
> > Sent: Tuesday, September 25, 2007 8:06 PM
> > To: Tapestry users
> > Subject: Re: Using PageTester with tapestry-spring
> >
> > My Application use spring2+tapestry5+hibernate3 ,it can work well in
> > me IE or  FF
> >
> > so,I want to use Unit Test with testNG .I followed
> > http://tapestry.apache.org/tapestry5/tapestry-core/guide/unit-testing-
> > pages.html
> >
> > configrate spring with
> > <http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>
> > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
> > <http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>
> >
> > I want to test a tapestry page, but I got Exception .IPublicDAO is my
> > spring class
> >
> > in my tapestry page i use inject
> >
> > @Inject
> >     @SpringBean("IPublicDAO")
> >     private IPublicDAO dao;
> >
> >
> >
> > I didnot know wrong where I make. can anybody help me  thanks a lot.
> >
> > Caused by: java.lang.RuntimeException: Error obtaining injected value
> > for field cn.crc.pjblog.pages.BlogPostOne.pdao: No service implements
> > the interface cn.crc.model.impl.IPublicDAO.
> > at org.apache.tapestry.internal.services.InjectWorker.inject (
> > InjectWorker.java:84)
> > at org.apache.tapestry.internal.services.InjectWorker.transform(
> > InjectWorker.java:53)
> > at
> >
> > $ComponentClassTransformWorker_114ba61b606.transform($ComponentClassTr
> > ansformWorker_114ba61b606.java)
> > at
> >
> > $ComponentClassTransformWorker_114ba61b603.transform($ComponentClassTr
> > ansformWorker_114ba61b603.java)
> > at
> >
> > org.apache.tapestry.internal.services.ComponentClassTransformerImpl.tr
> > ansformComponentClass (ComponentClassTransformerImpl.java :131) ... 48
> > more Caused by:
> > java.lang.RuntimeException: No service implements the interface
> > cn.crc.model.impl.IPublicDAO.
> > at org.apache.tapestry.ioc.internal.RegistryImpl.getService(
> > RegistryImpl.java:447)
> > at org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(
> > ObjectLocatorImpl.java:45)
> > at org.apache.tapestry.ioc.services.TapestryIOCModule$2.provide(
> > TapestryIOCModule.java:132)
> > at
> > $ObjectProvider_114ba61b5d4.provide($ObjectProvider_114ba61b5d4.java)
> > at
> > $ObjectProvider_114ba61b5ce.provide($ObjectProvider_114ba61b5ce.java)
> > at org.apache.tapestry.internal.services.InjectWorker.inject(
> > InjectWorker.java:80)
> > ... 52 more
> > ... Removed 22 stack frames
> >
> >
> >
> >
> > 2007/9/25, Joel Wiegman <Jo...@btservices.com>:
> > >
> > > Sure... what questions do you have?
> > >
> > > I'd rather not write 8 paragraphs and still not answer your
> questions...
> > >
> > > -----Original Message-----
> > > From: Doublel [mailto:moonfly2004@gmail.com]
> > > Sent: Monday, September 24, 2007 7:59 PM
> > > To: Tapestry users
> > > Subject: Re: Using PageTester with tapestry-spring
> > >
> > > I run into the same problem  I use
> > > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternativ
> > > e2
> > > Can you explain more detail??
> > >
> > > 2007/9/24, Joel Wiegman <Jo...@btservices.com>:
> > > >
> > > > Ivan,
> > > >
> > > > I'm using PageTester with Spring integration, but you'll have to
> > > > jump through a few small hoops to accomplish this.
> > > >
> > > > I've written a "TestHarnessModule" in my <app dir>.services
> directory.
> > > > This module contributes the Spring services manually.  My code
> > > > looks very similar to what's found here:
> > > >
> > > > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternat
> > > > iv
> > > > e1
> > > >
> > > > Then, you can pass in the name of the module to your PageTester:
> > > >
> > > > PageTester pageTester= new PageTester("com.myapp.dir",
> > > > "TestHarness");
> > > >
> > > > IMHO, what's really neat about this is you can point your tests to
> > > > a different Spring configuration that uses mocked objects, mock
> > > > databases, etc.  This is what we're doing and it has worked very
> well.
> > > >
> > > > Hope this helps,
> > > >
> > > > Joel
> > > >
> > > > -----Original Message-----
> > > > From: Ivan Dubrov [mailto:wfragg@gmail.com]
> > > > Sent: Monday, September 24, 2007 7:14 AM
> > > > To: Tapestry users
> > > > Subject: Using PageTester with tapestry-spring
> > > >
> > > > Hi,
> > > >
> > > > How can I use the PageTester with the Spring integration? The
> > > > problem is that when PageTester creates the registry it does not
> > > > adds SpringModuleDef to the list of modules and all my Spring
> > > > services are unavailable because of this. Extending the PageTester
> > > > is not possible as well, so I cannot extend it and provide
> > > > additional module (like the TapestrySpringFilter does), so I have
> > > > to copy-paste the complete PageTester and add a line to include
> > SpringModuleDef module to the list.
> > > >
> > > > Are there any other ways that not include dumb copy-pasting?
> > > >
> > > > Just for clearness. How can I add an override to the services when
> > > > running the tests? Creating AliasContribution's with the mode set
> > > > to "test", right? But what to do if I want to keep my primary
> > > > module clear of test services and keep all my test services in the
> > > > test module inside the src/test Maven2 hierarchy (so they even
> > > > aren't included in the release build)?
> > > >
> > > > --
> > > > WBR,
> > > > Ivan S. Dubrov
> > > >
> > > >
> > > >
> > > > ------------------------------------------------------------------
> > > > --
> > > > - To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > 得与失都是生活
> > >
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > 得与失都是生活
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> 得与失都是生活
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
得与失都是生活

RE: Using PageTester with tapestry-spring

Posted by Joel Wiegman <Jo...@btservices.com>.
Without seeing any source, I can only guess that you're injecting WebApplicationContext somewhere in your application and your SpringModule isn't loading that service correctly?  Tough to say without source.

-----Original Message-----
From: Doublel [mailto:moonfly2004@gmail.com] 
Sent: Thursday, September 27, 2007 1:04 AM
To: Tapestry users
Subject: Re: Using PageTester with tapestry-spring

Thanks ! the problem is resolved. But I ran  into this :

[ERROR] WebApplicationContext Construction of service WebApplicationContext
failed: Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for ContextForPageTester.
java.lang.RuntimeException: Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for ContextForPageTester.
    at
org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
ServiceBuilderMethodInvoker.java:87)
    at
org.apache.tapestry.ioc.internal.SingletonServiceLifecycle.createService(
SingletonServiceLifecycle.java:31)
    at
org.apache.tapestry.ioc.internal.LifecycleWrappedServiceCreator.createObject
(LifecycleWrappedServiceCreator.java:54)
    at org.apache.tapestry.ioc.internal.InterceptorStackBuilder.createObject
(InterceptorStackBuilder.java:54)
    at
org.apache.tapestry.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject
(RecursiveServiceCreationCheckWrapper.java:60)
    at
org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
(JustInTimeObjectCreator.java:61)
    at
$WebApplicationContext_1154558bc95._delegate($WebApplicationContext_1154558bc95.java)
    at
$WebApplicationContext_1154558bc95.getBeanDefinitionNames($WebApplicationContext_1154558bc95.java)
    at cn.crc.spring.SpringObjectProvider.loadBeanNames(
SpringObjectProvider.java:49)
    at cn.crc.spring.SpringObjectProvider.provide(SpringObjectProvider.java
:73)
    at $ObjectProvider_1154558bc97.provide($ObjectProvider_1154558bc97.java)
    at $ObjectProvider_1154558bc90.provide($ObjectProvider_1154558bc90.java)
    at org.apache.tapestry.internal.services.InjectWorker.inject(
InjectWorker.java:80)
    at org.apache.tapestry.internal.services.InjectWorker.transform(
InjectWorker.java:53)
    at
$ComponentClassTransformWorker_1154558bcc9.transform($ComponentClassTransformWorker_1154558bcc9.java)
    at
$ComponentClassTransformWorker_1154558bcc6.transform($ComponentClassTransformWorker_1154558bcc6.java)
    at
org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
(ComponentClassTransformerImpl.java:131)
    at
$ComponentClassTransformer_1154558bcc0.transformComponentClass($ComponentClassTransformer_1154558bcc0.java)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.onLoad
(ComponentInstantiatorSourceImpl.java:177)
    at javassist.Loader.findClass(Loader.java:340)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl$PackageAwareLoader.findClass
(ComponentInstantiatorSourceImpl.java:85)
    at javassist.Loader.loadClass(Loader.java:311)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
(ComponentInstantiatorSourceImpl.java:254)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findInstantiator
(ComponentInstantiatorSourceImpl.java:240)
    at
$ComponentInstantiatorSource_1154558bcb3.findInstantiator($ComponentInstantiatorSource_1154558bcb3.java)
    at
org.apache.tapestry.internal.services.PageElementFactoryImpl.newRootComponentElement
(PageElementFactoryImpl.java:319)
    at
$PageElementFactory_1154558bcbe.newRootComponentElement($PageElementFactory_1154558bcbe.java)
    at
org.apache.tapestry.internal.services.PageLoaderProcessor.loadRootComponent(
PageLoaderProcessor.java:405)
    at org.apache.tapestry.internal.services.PageLoaderProcessor.loadPage(
PageLoaderProcessor.java:390)
    at org.apache.tapestry.internal.services.PageLoaderImpl.loadPage(
PageLoaderImpl.java:59)
    at $PageLoader_1154558bcbb.loadPage($PageLoader_1154558bcbb.java)
    at org.apache.tapestry.internal.services.PagePoolImpl.checkout(
PagePoolImpl.java:70)
    at $PagePool_1154558bcba.checkout($PagePool_1154558bcba.java)
    at org.apache.tapestry.internal.services.RequestPageCacheImpl.get(
RequestPageCacheImpl.java:44)
    at $RequestPageCache_1154558bcb7.get($RequestPageCache_1154558bcb7.java)
    at $RequestPageCache_1154558bcaf.get($RequestPageCache_1154558bcaf.java)
    at
org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(
PageRenderRequestHandlerImpl.java:55)
    at
$PageRenderRequestHandler_1154558bca5.handle($PageRenderRequestHandler_1154558bca5.java)
    at org.apache.tapestry.internal.test.PageLinkInvoker.invoke(
PageLinkInvoker.java:57)
    at org.apache.tapestry.test.PageTester.invoke(PageTester.java:184)
    at org.apache.tapestry.test.PageTester.renderPage(PageTester.java:144)
    at cn.crc.pjblog.test.pages.BlogPostOneTest.BlogPostOneTest1(
BlogPostOneTest.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:470)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(
TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.runWorkers(TestRunner.java:678)
    at org.testng.TestRunner.privateRun(TestRunner.java:624)
    at org.testng.TestRunner.run(TestRunner.java:495)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
    at org.testng.SuiteRunner.run(SuiteRunner.java:190)
    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
    at org.testng.TestNG.run(TestNG.java:699)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
Caused by: java.lang.RuntimeException: An exception occurred obtaining the Spring WebApplicationContext: getAttribute() is not supported for ContextForPageTester.
    at cn.crc.spring.SpringModule.build(SpringModule.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at
org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
ServiceBuilderMethodInvoker.java:75)
    ... 64 more
Caused by: java.lang.UnsupportedOperationException: getAttribute() is not supported for ContextForPageTester.
    at org.apache.tapestry.internal.test.PageTesterContext.getAttribute(
PageTesterContext.java:61)
    at $Context_1154558bccc.getAttribute($Context_1154558bccc.java)
    at $Context_1154558bccb.getAttribute($Context_1154558bccb.java)
    at cn.crc.spring.SpringModule.build(SpringModule.java:36)
    ... 69 more
FAILED: BlogPostOneTest1
java.lang.RuntimeException: java.lang.ClassNotFoundException: caught an exception while obtaining a class file for cn.crc.pjblog.pages.BlogPostOne
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
(ComponentInstantiatorSourceImpl.java:258)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findInstantiator
(ComponentInstantiatorSourceImpl.java:240)
    at
$ComponentInstantiatorSource_1154558bcb3.findInstantiator($ComponentInstantiatorSource_1154558bcb3.java)
    at
org.apache.tapestry.internal.services.PageElementFactoryImpl.newRootComponentElement
(PageElementFactoryImpl.java:319)
    at
$PageElementFactory_1154558bcbe.newRootComponentElement($PageElementFactory_1154558bcbe.java)
    at
org.apache.tapestry.internal.services.PageLoaderProcessor.loadRootComponent(
PageLoaderProcessor.java:405)
    at org.apache.tapestry.internal.services.PageLoaderProcessor.loadPage(
PageLoaderProcessor.java:390)
    at org.apache.tapestry.internal.services.PageLoaderImpl.loadPage(
PageLoaderImpl.java:59)
    at $PageLoader_1154558bcbb.loadPage($PageLoader_1154558bcbb.java)
    at org.apache.tapestry.internal.services.PagePoolImpl.checkout(
PagePoolImpl.java:70)
    at $PagePool_1154558bcba.checkout($PagePool_1154558bcba.java)
    at org.apache.tapestry.internal.services.RequestPageCacheImpl.get(
RequestPageCacheImpl.java:44)
    at $RequestPageCache_1154558bcb7.get($RequestPageCache_1154558bcb7.java)
    at $RequestPageCache_1154558bcaf.get($RequestPageCache_1154558bcaf.java)
    at
org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(
PageRenderRequestHandlerImpl.java:55)
    at
$PageRenderRequestHandler_1154558bca5.handle($PageRenderRequestHandler_1154558bca5.java)
    at org.apache.tapestry.internal.test.PageLinkInvoker.invoke(
PageLinkInvoker.java:57)
    at org.apache.tapestry.test.PageTester.invoke(PageTester.java:184)
    at org.apache.tapestry.test.PageTester.renderPage(PageTester.java:144)
    at cn.crc.pjblog.test.pages.BlogPostOneTest.BlogPostOneTest1(
BlogPostOneTest.java:16)
Caused by: java.lang.ClassNotFoundException: caught an exception while obtaining a class file for cn.crc.pjblog.pages.BlogPostOne
    at javassist.Loader.findClass(Loader.java:359)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl$PackageAwareLoader.findClass
(ComponentInstantiatorSourceImpl.java:85)
    at javassist.Loader.loadClass(Loader.java:311)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
(ComponentInstantiatorSourceImpl.java:254)
    ... 41 more
Caused by: org.apache.tapestry.internal.services.TransformationException:
Error obtaining injected value for field
cn.crc.pjblog.pages.BlogPostOne.pdao: Exception constructing service
'WebApplicationContext': Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for ContextForPageTester.
    at
org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
(ComponentClassTransformerImpl.java:137)
    at
$ComponentClassTransformer_1154558bcc0.transformComponentClass($ComponentClassTransformer_1154558bcc0.java)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.onLoad
(ComponentInstantiatorSourceImpl.java:177)
    at javassist.Loader.findClass(Loader.java:340)
    ... 45 more
Caused by: java.lang.RuntimeException: Error obtaining injected value for field cn.crc.pjblog.pages.BlogPostOne.pdao: Exception constructing service
'WebApplicationContext': Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for ContextForPageTester.
    at org.apache.tapestry.internal.services.InjectWorker.inject(
InjectWorker.java:84)
    at org.apache.tapestry.internal.services.InjectWorker.transform(
InjectWorker.java:53)
    at
$ComponentClassTransformWorker_1154558bcc9.transform($ComponentClassTransformWorker_1154558bcc9.java)
    at
$ComponentClassTransformWorker_1154558bcc6.transform($ComponentClassTransformWorker_1154558bcc6.java)
    at
org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
(ComponentClassTransformerImpl.java:131)
    ... 48 more
Caused by: java.lang.RuntimeException: Exception constructing service
'WebApplicationContext': Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for ContextForPageTester.
    at
org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
(JustInTimeObjectCreator.java:69)
    at
$WebApplicationContext_1154558bc95._delegate($WebApplicationContext_1154558bc95.java)
    at
$WebApplicationContext_1154558bc95.getBeanDefinitionNames($WebApplicationContext_1154558bc95.java)
    at cn.crc.spring.SpringObjectProvider.loadBeanNames(
SpringObjectProvider.java:49)
    at cn.crc.spring.SpringObjectProvider.provide(SpringObjectProvider.java
:73)
    at $ObjectProvider_1154558bc97.provide($ObjectProvider_1154558bc97.java)
    at $ObjectProvider_1154558bc90.provide($ObjectProvider_1154558bc90.java)
    at org.apache.tapestry.internal.services.InjectWorker.inject(
InjectWorker.java:80)
    ... 52 more
Caused by: java.lang.RuntimeException: Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for ContextForPageTester.
    at
org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
ServiceBuilderMethodInvoker.java:87)
    at
org.apache.tapestry.ioc.internal.SingletonServiceLifecycle.createService(
SingletonServiceLifecycle.java:31)
    at
org.apache.tapestry.ioc.internal.LifecycleWrappedServiceCreator.createObject
(LifecycleWrappedServiceCreator.java:54)
    at org.apache.tapestry.ioc.internal.InterceptorStackBuilder.createObject
(InterceptorStackBuilder.java:54)
    at
org.apache.tapestry.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject
(RecursiveServiceCreationCheckWrapper.java:60)
    at
org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
(JustInTimeObjectCreator.java:61)
    ... 59 more
Caused by: java.lang.RuntimeException: An exception occurred obtaining the Spring WebApplicationContext: getAttribute() is not supported for ContextForPageTester.
    at cn.crc.spring.SpringModule.build(SpringModule.java:40)
    at
org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
ServiceBuilderMethodInvoker.java:75)
    ... 64 more
Caused by: java.lang.UnsupportedOperationException: getAttribute() is not supported for ContextForPageTester.
    at org.apache.tapestry.internal.test.PageTesterContext.getAttribute(
PageTesterContext.java:61)
    at $Context_1154558bccc.getAttribute($Context_1154558bccc.java)
    at $Context_1154558bccb.getAttribute($Context_1154558bccb.java)
    at cn.crc.spring.SpringModule.build(SpringModule.java:36)
    ... 69 more
... Removed 26 stack frames


2007/9/26, Joel Wiegman <Jo...@btservices.com>:
>
> What's basically happening here is:
>
> The application module you are passing to your PageTester (via the 
> "String appName" argument) does not load your Spring context.  In the 
> alternative Spring integration link you provided this string would be 
> "Spring", assuming the class is named "SpringModule" and that it 
> exists in your <app>.services package.
>
> Hope that helps.
>
> -----Original Message-----
> From: Doublel [mailto:moonfly2004@gmail.com]
> Sent: Tuesday, September 25, 2007 8:06 PM
> To: Tapestry users
> Subject: Re: Using PageTester with tapestry-spring
>
> My Application use spring2+tapestry5+hibernate3 ,it can work well in 
> me IE or  FF
>
> so,I want to use Unit Test with testNG .I followed 
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/unit-testing-
> pages.html
>
> configrate spring with
> <http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>
> http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
> <http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>
>
> I want to test a tapestry page, but I got Exception .IPublicDAO is my 
> spring class
>
> in my tapestry page i use inject
>
> @Inject
>     @SpringBean("IPublicDAO")
>     private IPublicDAO dao;
>
>
>
> I didnot know wrong where I make. can anybody help me  thanks a lot.
>
> Caused by: java.lang.RuntimeException: Error obtaining injected value 
> for field cn.crc.pjblog.pages.BlogPostOne.pdao: No service implements 
> the interface cn.crc.model.impl.IPublicDAO.
> at org.apache.tapestry.internal.services.InjectWorker.inject (
> InjectWorker.java:84)
> at org.apache.tapestry.internal.services.InjectWorker.transform(
> InjectWorker.java:53)
> at
>
> $ComponentClassTransformWorker_114ba61b606.transform($ComponentClassTr
> ansformWorker_114ba61b606.java)
> at
>
> $ComponentClassTransformWorker_114ba61b603.transform($ComponentClassTr
> ansformWorker_114ba61b603.java)
> at
>
> org.apache.tapestry.internal.services.ComponentClassTransformerImpl.tr
> ansformComponentClass (ComponentClassTransformerImpl.java :131) ... 48 
> more Caused by:
> java.lang.RuntimeException: No service implements the interface 
> cn.crc.model.impl.IPublicDAO.
> at org.apache.tapestry.ioc.internal.RegistryImpl.getService(
> RegistryImpl.java:447)
> at org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(
> ObjectLocatorImpl.java:45)
> at org.apache.tapestry.ioc.services.TapestryIOCModule$2.provide(
> TapestryIOCModule.java:132)
> at 
> $ObjectProvider_114ba61b5d4.provide($ObjectProvider_114ba61b5d4.java)
> at 
> $ObjectProvider_114ba61b5ce.provide($ObjectProvider_114ba61b5ce.java)
> at org.apache.tapestry.internal.services.InjectWorker.inject(
> InjectWorker.java:80)
> ... 52 more
> ... Removed 22 stack frames
>
>
>
>
> 2007/9/25, Joel Wiegman <Jo...@btservices.com>:
> >
> > Sure... what questions do you have?
> >
> > I'd rather not write 8 paragraphs and still not answer your questions...
> >
> > -----Original Message-----
> > From: Doublel [mailto:moonfly2004@gmail.com]
> > Sent: Monday, September 24, 2007 7:59 PM
> > To: Tapestry users
> > Subject: Re: Using PageTester with tapestry-spring
> >
> > I run into the same problem  I use
> > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternativ
> > e2
> > Can you explain more detail??
> >
> > 2007/9/24, Joel Wiegman <Jo...@btservices.com>:
> > >
> > > Ivan,
> > >
> > > I'm using PageTester with Spring integration, but you'll have to 
> > > jump through a few small hoops to accomplish this.
> > >
> > > I've written a "TestHarnessModule" in my <app dir>.services directory.
> > > This module contributes the Spring services manually.  My code 
> > > looks very similar to what's found here:
> > >
> > > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternat
> > > iv
> > > e1
> > >
> > > Then, you can pass in the name of the module to your PageTester:
> > >
> > > PageTester pageTester= new PageTester("com.myapp.dir", 
> > > "TestHarness");
> > >
> > > IMHO, what's really neat about this is you can point your tests to 
> > > a different Spring configuration that uses mocked objects, mock 
> > > databases, etc.  This is what we're doing and it has worked very well.
> > >
> > > Hope this helps,
> > >
> > > Joel
> > >
> > > -----Original Message-----
> > > From: Ivan Dubrov [mailto:wfragg@gmail.com]
> > > Sent: Monday, September 24, 2007 7:14 AM
> > > To: Tapestry users
> > > Subject: Using PageTester with tapestry-spring
> > >
> > > Hi,
> > >
> > > How can I use the PageTester with the Spring integration? The 
> > > problem is that when PageTester creates the registry it does not 
> > > adds SpringModuleDef to the list of modules and all my Spring 
> > > services are unavailable because of this. Extending the PageTester 
> > > is not possible as well, so I cannot extend it and provide 
> > > additional module (like the TapestrySpringFilter does), so I have 
> > > to copy-paste the complete PageTester and add a line to include
> SpringModuleDef module to the list.
> > >
> > > Are there any other ways that not include dumb copy-pasting?
> > >
> > > Just for clearness. How can I add an override to the services when 
> > > running the tests? Creating AliasContribution's with the mode set 
> > > to "test", right? But what to do if I want to keep my primary 
> > > module clear of test services and keep all my test services in the 
> > > test module inside the src/test Maven2 hierarchy (so they even 
> > > aren't included in the release build)?
> > >
> > > --
> > > WBR,
> > > Ivan S. Dubrov
> > >
> > >
> > >
> > > ------------------------------------------------------------------
> > > --
> > > - To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > 得与失都是生活
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> 得与失都是生活
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


--
得与失都是生活

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


Re: Using PageTester with tapestry-spring

Posted by Doublel <mo...@gmail.com>.
Thanks ! the problem is resolved. But I ran  into this :

[ERROR] WebApplicationContext Construction of service WebApplicationContext
failed: Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for
ContextForPageTester.
java.lang.RuntimeException: Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for
ContextForPageTester.
    at
org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
ServiceBuilderMethodInvoker.java:87)
    at
org.apache.tapestry.ioc.internal.SingletonServiceLifecycle.createService(
SingletonServiceLifecycle.java:31)
    at
org.apache.tapestry.ioc.internal.LifecycleWrappedServiceCreator.createObject
(LifecycleWrappedServiceCreator.java:54)
    at org.apache.tapestry.ioc.internal.InterceptorStackBuilder.createObject
(InterceptorStackBuilder.java:54)
    at
org.apache.tapestry.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject
(RecursiveServiceCreationCheckWrapper.java:60)
    at
org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
(JustInTimeObjectCreator.java:61)
    at
$WebApplicationContext_1154558bc95._delegate($WebApplicationContext_1154558bc95.java)
    at
$WebApplicationContext_1154558bc95.getBeanDefinitionNames($WebApplicationContext_1154558bc95.java)
    at cn.crc.spring.SpringObjectProvider.loadBeanNames(
SpringObjectProvider.java:49)
    at cn.crc.spring.SpringObjectProvider.provide(SpringObjectProvider.java
:73)
    at $ObjectProvider_1154558bc97.provide($ObjectProvider_1154558bc97.java)
    at $ObjectProvider_1154558bc90.provide($ObjectProvider_1154558bc90.java)
    at org.apache.tapestry.internal.services.InjectWorker.inject(
InjectWorker.java:80)
    at org.apache.tapestry.internal.services.InjectWorker.transform(
InjectWorker.java:53)
    at
$ComponentClassTransformWorker_1154558bcc9.transform($ComponentClassTransformWorker_1154558bcc9.java)
    at
$ComponentClassTransformWorker_1154558bcc6.transform($ComponentClassTransformWorker_1154558bcc6.java)
    at
org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
(ComponentClassTransformerImpl.java:131)
    at
$ComponentClassTransformer_1154558bcc0.transformComponentClass($ComponentClassTransformer_1154558bcc0.java)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.onLoad
(ComponentInstantiatorSourceImpl.java:177)
    at javassist.Loader.findClass(Loader.java:340)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl$PackageAwareLoader.findClass
(ComponentInstantiatorSourceImpl.java:85)
    at javassist.Loader.loadClass(Loader.java:311)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
(ComponentInstantiatorSourceImpl.java:254)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findInstantiator
(ComponentInstantiatorSourceImpl.java:240)
    at
$ComponentInstantiatorSource_1154558bcb3.findInstantiator($ComponentInstantiatorSource_1154558bcb3.java)
    at
org.apache.tapestry.internal.services.PageElementFactoryImpl.newRootComponentElement
(PageElementFactoryImpl.java:319)
    at
$PageElementFactory_1154558bcbe.newRootComponentElement($PageElementFactory_1154558bcbe.java)
    at
org.apache.tapestry.internal.services.PageLoaderProcessor.loadRootComponent(
PageLoaderProcessor.java:405)
    at org.apache.tapestry.internal.services.PageLoaderProcessor.loadPage(
PageLoaderProcessor.java:390)
    at org.apache.tapestry.internal.services.PageLoaderImpl.loadPage(
PageLoaderImpl.java:59)
    at $PageLoader_1154558bcbb.loadPage($PageLoader_1154558bcbb.java)
    at org.apache.tapestry.internal.services.PagePoolImpl.checkout(
PagePoolImpl.java:70)
    at $PagePool_1154558bcba.checkout($PagePool_1154558bcba.java)
    at org.apache.tapestry.internal.services.RequestPageCacheImpl.get(
RequestPageCacheImpl.java:44)
    at $RequestPageCache_1154558bcb7.get($RequestPageCache_1154558bcb7.java)
    at $RequestPageCache_1154558bcaf.get($RequestPageCache_1154558bcaf.java)
    at
org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(
PageRenderRequestHandlerImpl.java:55)
    at
$PageRenderRequestHandler_1154558bca5.handle($PageRenderRequestHandler_1154558bca5.java)
    at org.apache.tapestry.internal.test.PageLinkInvoker.invoke(
PageLinkInvoker.java:57)
    at org.apache.tapestry.test.PageTester.invoke(PageTester.java:184)
    at org.apache.tapestry.test.PageTester.renderPage(PageTester.java:144)
    at cn.crc.pjblog.test.pages.BlogPostOneTest.BlogPostOneTest1(
BlogPostOneTest.java:16)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:470)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(
TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.runWorkers(TestRunner.java:678)
    at org.testng.TestRunner.privateRun(TestRunner.java:624)
    at org.testng.TestRunner.run(TestRunner.java:495)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:300)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275)
    at org.testng.SuiteRunner.run(SuiteRunner.java:190)
    at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:765)
    at org.testng.TestNG.run(TestNG.java:699)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
Caused by: java.lang.RuntimeException: An exception occurred obtaining the
Spring WebApplicationContext: getAttribute() is not supported for
ContextForPageTester.
    at cn.crc.spring.SpringModule.build(SpringModule.java:40)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at
org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
ServiceBuilderMethodInvoker.java:75)
    ... 64 more
Caused by: java.lang.UnsupportedOperationException: getAttribute() is not
supported for ContextForPageTester.
    at org.apache.tapestry.internal.test.PageTesterContext.getAttribute(
PageTesterContext.java:61)
    at $Context_1154558bccc.getAttribute($Context_1154558bccc.java)
    at $Context_1154558bccb.getAttribute($Context_1154558bccb.java)
    at cn.crc.spring.SpringModule.build(SpringModule.java:36)
    ... 69 more
FAILED: BlogPostOneTest1
java.lang.RuntimeException: java.lang.ClassNotFoundException: caught an
exception while obtaining a class file for cn.crc.pjblog.pages.BlogPostOne
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
(ComponentInstantiatorSourceImpl.java:258)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findInstantiator
(ComponentInstantiatorSourceImpl.java:240)
    at
$ComponentInstantiatorSource_1154558bcb3.findInstantiator($ComponentInstantiatorSource_1154558bcb3.java)
    at
org.apache.tapestry.internal.services.PageElementFactoryImpl.newRootComponentElement
(PageElementFactoryImpl.java:319)
    at
$PageElementFactory_1154558bcbe.newRootComponentElement($PageElementFactory_1154558bcbe.java)
    at
org.apache.tapestry.internal.services.PageLoaderProcessor.loadRootComponent(
PageLoaderProcessor.java:405)
    at org.apache.tapestry.internal.services.PageLoaderProcessor.loadPage(
PageLoaderProcessor.java:390)
    at org.apache.tapestry.internal.services.PageLoaderImpl.loadPage(
PageLoaderImpl.java:59)
    at $PageLoader_1154558bcbb.loadPage($PageLoader_1154558bcbb.java)
    at org.apache.tapestry.internal.services.PagePoolImpl.checkout(
PagePoolImpl.java:70)
    at $PagePool_1154558bcba.checkout($PagePool_1154558bcba.java)
    at org.apache.tapestry.internal.services.RequestPageCacheImpl.get(
RequestPageCacheImpl.java:44)
    at $RequestPageCache_1154558bcb7.get($RequestPageCache_1154558bcb7.java)
    at $RequestPageCache_1154558bcaf.get($RequestPageCache_1154558bcaf.java)
    at
org.apache.tapestry.internal.services.PageRenderRequestHandlerImpl.handle(
PageRenderRequestHandlerImpl.java:55)
    at
$PageRenderRequestHandler_1154558bca5.handle($PageRenderRequestHandler_1154558bca5.java)
    at org.apache.tapestry.internal.test.PageLinkInvoker.invoke(
PageLinkInvoker.java:57)
    at org.apache.tapestry.test.PageTester.invoke(PageTester.java:184)
    at org.apache.tapestry.test.PageTester.renderPage(PageTester.java:144)
    at cn.crc.pjblog.test.pages.BlogPostOneTest.BlogPostOneTest1(
BlogPostOneTest.java:16)
Caused by: java.lang.ClassNotFoundException: caught an exception while
obtaining a class file for cn.crc.pjblog.pages.BlogPostOne
    at javassist.Loader.findClass(Loader.java:359)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl$PackageAwareLoader.findClass
(ComponentInstantiatorSourceImpl.java:85)
    at javassist.Loader.loadClass(Loader.java:311)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.findClass
(ComponentInstantiatorSourceImpl.java:254)
    ... 41 more
Caused by: org.apache.tapestry.internal.services.TransformationException:
Error obtaining injected value for field
cn.crc.pjblog.pages.BlogPostOne.pdao: Exception constructing service
'WebApplicationContext': Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for
ContextForPageTester.
    at
org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
(ComponentClassTransformerImpl.java:137)
    at
$ComponentClassTransformer_1154558bcc0.transformComponentClass($ComponentClassTransformer_1154558bcc0.java)
    at
org.apache.tapestry.internal.services.ComponentInstantiatorSourceImpl.onLoad
(ComponentInstantiatorSourceImpl.java:177)
    at javassist.Loader.findClass(Loader.java:340)
    ... 45 more
Caused by: java.lang.RuntimeException: Error obtaining injected value for
field cn.crc.pjblog.pages.BlogPostOne.pdao: Exception constructing service
'WebApplicationContext': Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for
ContextForPageTester.
    at org.apache.tapestry.internal.services.InjectWorker.inject(
InjectWorker.java:84)
    at org.apache.tapestry.internal.services.InjectWorker.transform(
InjectWorker.java:53)
    at
$ComponentClassTransformWorker_1154558bcc9.transform($ComponentClassTransformWorker_1154558bcc9.java)
    at
$ComponentClassTransformWorker_1154558bcc6.transform($ComponentClassTransformWorker_1154558bcc6.java)
    at
org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
(ComponentClassTransformerImpl.java:131)
    ... 48 more
Caused by: java.lang.RuntimeException: Exception constructing service
'WebApplicationContext': Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for
ContextForPageTester.
    at
org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
(JustInTimeObjectCreator.java:69)
    at
$WebApplicationContext_1154558bc95._delegate($WebApplicationContext_1154558bc95.java)
    at
$WebApplicationContext_1154558bc95.getBeanDefinitionNames($WebApplicationContext_1154558bc95.java)
    at cn.crc.spring.SpringObjectProvider.loadBeanNames(
SpringObjectProvider.java:49)
    at cn.crc.spring.SpringObjectProvider.provide(SpringObjectProvider.java
:73)
    at $ObjectProvider_1154558bc97.provide($ObjectProvider_1154558bc97.java)
    at $ObjectProvider_1154558bc90.provide($ObjectProvider_1154558bc90.java)
    at org.apache.tapestry.internal.services.InjectWorker.inject(
InjectWorker.java:80)
    ... 52 more
Caused by: java.lang.RuntimeException: Error invoking service builder method
cn.crc.spring.SpringModule.build(Context) (at SpringModule.java:34) (for
service 'WebApplicationContext'): An exception occurred obtaining the Spring
WebApplicationContext: getAttribute() is not supported for
ContextForPageTester.
    at
org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
ServiceBuilderMethodInvoker.java:87)
    at
org.apache.tapestry.ioc.internal.SingletonServiceLifecycle.createService(
SingletonServiceLifecycle.java:31)
    at
org.apache.tapestry.ioc.internal.LifecycleWrappedServiceCreator.createObject
(LifecycleWrappedServiceCreator.java:54)
    at org.apache.tapestry.ioc.internal.InterceptorStackBuilder.createObject
(InterceptorStackBuilder.java:54)
    at
org.apache.tapestry.ioc.internal.RecursiveServiceCreationCheckWrapper.createObject
(RecursiveServiceCreationCheckWrapper.java:60)
    at
org.apache.tapestry.ioc.internal.services.JustInTimeObjectCreator.createObject
(JustInTimeObjectCreator.java:61)
    ... 59 more
Caused by: java.lang.RuntimeException: An exception occurred obtaining the
Spring WebApplicationContext: getAttribute() is not supported for
ContextForPageTester.
    at cn.crc.spring.SpringModule.build(SpringModule.java:40)
    at
org.apache.tapestry.ioc.internal.ServiceBuilderMethodInvoker.createObject(
ServiceBuilderMethodInvoker.java:75)
    ... 64 more
Caused by: java.lang.UnsupportedOperationException: getAttribute() is not
supported for ContextForPageTester.
    at org.apache.tapestry.internal.test.PageTesterContext.getAttribute(
PageTesterContext.java:61)
    at $Context_1154558bccc.getAttribute($Context_1154558bccc.java)
    at $Context_1154558bccb.getAttribute($Context_1154558bccb.java)
    at cn.crc.spring.SpringModule.build(SpringModule.java:36)
    ... 69 more
... Removed 26 stack frames


2007/9/26, Joel Wiegman <Jo...@btservices.com>:
>
> What's basically happening here is:
>
> The application module you are passing to your PageTester (via the "String
> appName" argument) does not load your Spring context.  In the alternative
> Spring integration link you provided this string would be "Spring", assuming
> the class is named "SpringModule" and that it exists in your <app>.services
> package.
>
> Hope that helps.
>
> -----Original Message-----
> From: Doublel [mailto:moonfly2004@gmail.com]
> Sent: Tuesday, September 25, 2007 8:06 PM
> To: Tapestry users
> Subject: Re: Using PageTester with tapestry-spring
>
> My Application use spring2+tapestry5+hibernate3 ,it can work well in me IE
> or  FF
>
> so,I want to use Unit Test with testNG .I followed
> http://tapestry.apache.org/tapestry5/tapestry-core/guide/unit-testing-pages.html
>
> configrate spring with
> <http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>
> http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
> <http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>
>
> I want to test a tapestry page, but I got Exception .IPublicDAO is my
> spring class
>
> in my tapestry page i use inject
>
> @Inject
>     @SpringBean("IPublicDAO")
>     private IPublicDAO dao;
>
>
>
> I didnot know wrong where I make. can anybody help me  thanks a lot.
>
> Caused by: java.lang.RuntimeException: Error obtaining injected value for
> field cn.crc.pjblog.pages.BlogPostOne.pdao: No service implements the
> interface cn.crc.model.impl.IPublicDAO.
> at org.apache.tapestry.internal.services.InjectWorker.inject (
> InjectWorker.java:84)
> at org.apache.tapestry.internal.services.InjectWorker.transform(
> InjectWorker.java:53)
> at
>
> $ComponentClassTransformWorker_114ba61b606.transform($ComponentClassTransformWorker_114ba61b606.java)
> at
>
> $ComponentClassTransformWorker_114ba61b603.transform($ComponentClassTransformWorker_114ba61b603.java)
> at
>
> org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
> (ComponentClassTransformerImpl.java :131) ... 48 more Caused by:
> java.lang.RuntimeException: No service implements the interface
> cn.crc.model.impl.IPublicDAO.
> at org.apache.tapestry.ioc.internal.RegistryImpl.getService(
> RegistryImpl.java:447)
> at org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(
> ObjectLocatorImpl.java:45)
> at org.apache.tapestry.ioc.services.TapestryIOCModule$2.provide(
> TapestryIOCModule.java:132)
> at $ObjectProvider_114ba61b5d4.provide($ObjectProvider_114ba61b5d4.java)
> at $ObjectProvider_114ba61b5ce.provide($ObjectProvider_114ba61b5ce.java)
> at org.apache.tapestry.internal.services.InjectWorker.inject(
> InjectWorker.java:80)
> ... 52 more
> ... Removed 22 stack frames
>
>
>
>
> 2007/9/25, Joel Wiegman <Jo...@btservices.com>:
> >
> > Sure... what questions do you have?
> >
> > I'd rather not write 8 paragraphs and still not answer your questions...
> >
> > -----Original Message-----
> > From: Doublel [mailto:moonfly2004@gmail.com]
> > Sent: Monday, September 24, 2007 7:59 PM
> > To: Tapestry users
> > Subject: Re: Using PageTester with tapestry-spring
> >
> > I run into the same problem  I use
> > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
> > Can you explain more detail??
> >
> > 2007/9/24, Joel Wiegman <Jo...@btservices.com>:
> > >
> > > Ivan,
> > >
> > > I'm using PageTester with Spring integration, but you'll have to
> > > jump through a few small hoops to accomplish this.
> > >
> > > I've written a "TestHarnessModule" in my <app dir>.services directory.
> > > This module contributes the Spring services manually.  My code looks
> > > very similar to what's found here:
> > >
> > > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternativ
> > > e1
> > >
> > > Then, you can pass in the name of the module to your PageTester:
> > >
> > > PageTester pageTester= new PageTester("com.myapp.dir",
> > > "TestHarness");
> > >
> > > IMHO, what's really neat about this is you can point your tests to a
> > > different Spring configuration that uses mocked objects, mock
> > > databases, etc.  This is what we're doing and it has worked very well.
> > >
> > > Hope this helps,
> > >
> > > Joel
> > >
> > > -----Original Message-----
> > > From: Ivan Dubrov [mailto:wfragg@gmail.com]
> > > Sent: Monday, September 24, 2007 7:14 AM
> > > To: Tapestry users
> > > Subject: Using PageTester with tapestry-spring
> > >
> > > Hi,
> > >
> > > How can I use the PageTester with the Spring integration? The
> > > problem is that when PageTester creates the registry it does not
> > > adds SpringModuleDef to the list of modules and all my Spring
> > > services are unavailable because of this. Extending the PageTester
> > > is not possible as well, so I cannot extend it and provide
> > > additional module (like the TapestrySpringFilter does), so I have to
> > > copy-paste the complete PageTester and add a line to include
> SpringModuleDef module to the list.
> > >
> > > Are there any other ways that not include dumb copy-pasting?
> > >
> > > Just for clearness. How can I add an override to the services when
> > > running the tests? Creating AliasContribution's with the mode set to
> > > "test", right? But what to do if I want to keep my primary module
> > > clear of test services and keep all my test services in the test
> > > module inside the src/test Maven2 hierarchy (so they even aren't
> > > included in the release build)?
> > >
> > > --
> > > WBR,
> > > Ivan S. Dubrov
> > >
> > >
> > >
> > > --------------------------------------------------------------------
> > > - To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > 得与失都是生活
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> 得与失都是生活
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
得与失都是生活

RE: Using PageTester with tapestry-spring

Posted by Joel Wiegman <Jo...@btservices.com>.
What's basically happening here is:

The application module you are passing to your PageTester (via the "String appName" argument) does not load your Spring context.  In the alternative Spring integration link you provided this string would be "Spring", assuming the class is named "SpringModule" and that it exists in your <app>.services package.

Hope that helps.

-----Original Message-----
From: Doublel [mailto:moonfly2004@gmail.com] 
Sent: Tuesday, September 25, 2007 8:06 PM
To: Tapestry users
Subject: Re: Using PageTester with tapestry-spring

My Application use spring2+tapestry5+hibernate3 ,it can work well in me IE or  FF

so,I want to use Unit Test with testNG .I followed http://tapestry.apache.org/tapestry5/tapestry-core/guide/unit-testing-pages.html

configrate spring with
<http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>
http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
<http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>

I want to test a tapestry page, but I got Exception .IPublicDAO is my spring class

in my tapestry page i use inject

@Inject
    @SpringBean("IPublicDAO")
    private IPublicDAO dao;



I didnot know wrong where I make. can anybody help me  thanks a lot.

Caused by: java.lang.RuntimeException: Error obtaining injected value for field cn.crc.pjblog.pages.BlogPostOne.pdao: No service implements the interface cn.crc.model.impl.IPublicDAO.
at org.apache.tapestry.internal.services.InjectWorker.inject (
InjectWorker.java:84)
at org.apache.tapestry.internal.services.InjectWorker.transform(
InjectWorker.java:53)
at
$ComponentClassTransformWorker_114ba61b606.transform($ComponentClassTransformWorker_114ba61b606.java)
at
$ComponentClassTransformWorker_114ba61b603.transform($ComponentClassTransformWorker_114ba61b603.java)
at
org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
(ComponentClassTransformerImpl.java :131) ... 48 more Caused by: java.lang.RuntimeException: No service implements the interface cn.crc.model.impl.IPublicDAO.
at org.apache.tapestry.ioc.internal.RegistryImpl.getService(
RegistryImpl.java:447)
at org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(
ObjectLocatorImpl.java:45)
at org.apache.tapestry.ioc.services.TapestryIOCModule$2.provide(
TapestryIOCModule.java:132)
at $ObjectProvider_114ba61b5d4.provide($ObjectProvider_114ba61b5d4.java)
at $ObjectProvider_114ba61b5ce.provide($ObjectProvider_114ba61b5ce.java)
at org.apache.tapestry.internal.services.InjectWorker.inject(
InjectWorker.java:80)
... 52 more
... Removed 22 stack frames




2007/9/25, Joel Wiegman <Jo...@btservices.com>:
>
> Sure... what questions do you have?
>
> I'd rather not write 8 paragraphs and still not answer your questions...
>
> -----Original Message-----
> From: Doublel [mailto:moonfly2004@gmail.com]
> Sent: Monday, September 24, 2007 7:59 PM
> To: Tapestry users
> Subject: Re: Using PageTester with tapestry-spring
>
> I run into the same problem  I use
> http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
> Can you explain more detail??
>
> 2007/9/24, Joel Wiegman <Jo...@btservices.com>:
> >
> > Ivan,
> >
> > I'm using PageTester with Spring integration, but you'll have to 
> > jump through a few small hoops to accomplish this.
> >
> > I've written a "TestHarnessModule" in my <app dir>.services directory.
> > This module contributes the Spring services manually.  My code looks 
> > very similar to what's found here:
> >
> > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternativ
> > e1
> >
> > Then, you can pass in the name of the module to your PageTester:
> >
> > PageTester pageTester= new PageTester("com.myapp.dir", 
> > "TestHarness");
> >
> > IMHO, what's really neat about this is you can point your tests to a 
> > different Spring configuration that uses mocked objects, mock 
> > databases, etc.  This is what we're doing and it has worked very well.
> >
> > Hope this helps,
> >
> > Joel
> >
> > -----Original Message-----
> > From: Ivan Dubrov [mailto:wfragg@gmail.com]
> > Sent: Monday, September 24, 2007 7:14 AM
> > To: Tapestry users
> > Subject: Using PageTester with tapestry-spring
> >
> > Hi,
> >
> > How can I use the PageTester with the Spring integration? The 
> > problem is that when PageTester creates the registry it does not 
> > adds SpringModuleDef to the list of modules and all my Spring 
> > services are unavailable because of this. Extending the PageTester 
> > is not possible as well, so I cannot extend it and provide 
> > additional module (like the TapestrySpringFilter does), so I have to 
> > copy-paste the complete PageTester and add a line to include SpringModuleDef module to the list.
> >
> > Are there any other ways that not include dumb copy-pasting?
> >
> > Just for clearness. How can I add an override to the services when 
> > running the tests? Creating AliasContribution's with the mode set to 
> > "test", right? But what to do if I want to keep my primary module 
> > clear of test services and keep all my test services in the test 
> > module inside the src/test Maven2 hierarchy (so they even aren't 
> > included in the release build)?
> >
> > --
> > WBR,
> > Ivan S. Dubrov
> >
> >
> >
> > --------------------------------------------------------------------
> > - To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> 得与失都是生活
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


--
得与失都是生活

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


Re: Using PageTester with tapestry-spring

Posted by Doublel <mo...@gmail.com>.
My Application use spring2+tapestry5+hibernate3 ,it can work well in me
IE or  FF

so,I want to use Unit Test with testNG .I followed
http://tapestry.apache.org/tapestry5/tapestry-core/guide/unit-testing-pages.html

configrate spring with
<http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>
http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
<http://wiki.apache.org/tapestry/Tapestry5SpringIntegration>

I want to test a tapestry page, but I got Exception .IPublicDAO is my spring
class

in my tapestry page i use inject

@Inject
    @SpringBean("IPublicDAO")
    private IPublicDAO dao;



I didnot know wrong where I make. can anybody help me  thanks a lot.

Caused by: java.lang.RuntimeException: Error obtaining injected value for
field cn.crc.pjblog.pages.BlogPostOne.pdao: No service implements the
interface cn.crc.model.impl.IPublicDAO.
at org.apache.tapestry.internal.services.InjectWorker.inject (
InjectWorker.java:84)
at org.apache.tapestry.internal.services.InjectWorker.transform(
InjectWorker.java:53)
at
$ComponentClassTransformWorker_114ba61b606.transform($ComponentClassTransformWorker_114ba61b606.java)
at
$ComponentClassTransformWorker_114ba61b603.transform($ComponentClassTransformWorker_114ba61b603.java)
at
org.apache.tapestry.internal.services.ComponentClassTransformerImpl.transformComponentClass
(ComponentClassTransformerImpl.java :131)
... 48 more
Caused by: java.lang.RuntimeException: No service implements the interface
cn.crc.model.impl.IPublicDAO.
at org.apache.tapestry.ioc.internal.RegistryImpl.getService(
RegistryImpl.java:447)
at org.apache.tapestry.ioc.internal.ObjectLocatorImpl.getService(
ObjectLocatorImpl.java:45)
at org.apache.tapestry.ioc.services.TapestryIOCModule$2.provide(
TapestryIOCModule.java:132)
at $ObjectProvider_114ba61b5d4.provide($ObjectProvider_114ba61b5d4.java)
at $ObjectProvider_114ba61b5ce.provide($ObjectProvider_114ba61b5ce.java)
at org.apache.tapestry.internal.services.InjectWorker.inject(
InjectWorker.java:80)
... 52 more
... Removed 22 stack frames




2007/9/25, Joel Wiegman <Jo...@btservices.com>:
>
> Sure... what questions do you have?
>
> I'd rather not write 8 paragraphs and still not answer your questions...
>
> -----Original Message-----
> From: Doublel [mailto:moonfly2004@gmail.com]
> Sent: Monday, September 24, 2007 7:59 PM
> To: Tapestry users
> Subject: Re: Using PageTester with tapestry-spring
>
> I run into the same problem  I use
> http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
> Can you explain more detail??
>
> 2007/9/24, Joel Wiegman <Jo...@btservices.com>:
> >
> > Ivan,
> >
> > I'm using PageTester with Spring integration, but you'll have to jump
> > through a few small hoops to accomplish this.
> >
> > I've written a "TestHarnessModule" in my <app dir>.services directory.
> > This module contributes the Spring services manually.  My code looks
> > very similar to what's found here:
> >
> > http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative1
> >
> > Then, you can pass in the name of the module to your PageTester:
> >
> > PageTester pageTester= new PageTester("com.myapp.dir", "TestHarness");
> >
> > IMHO, what's really neat about this is you can point your tests to a
> > different Spring configuration that uses mocked objects, mock
> > databases, etc.  This is what we're doing and it has worked very well.
> >
> > Hope this helps,
> >
> > Joel
> >
> > -----Original Message-----
> > From: Ivan Dubrov [mailto:wfragg@gmail.com]
> > Sent: Monday, September 24, 2007 7:14 AM
> > To: Tapestry users
> > Subject: Using PageTester with tapestry-spring
> >
> > Hi,
> >
> > How can I use the PageTester with the Spring integration? The problem
> > is that when PageTester creates the registry it does not adds
> > SpringModuleDef to the list of modules and all my Spring services are
> > unavailable because of this. Extending the PageTester is not possible
> > as well, so I cannot extend it and provide additional module (like the
> > TapestrySpringFilter does), so I have to copy-paste the complete
> > PageTester and add a line to include SpringModuleDef module to the list.
> >
> > Are there any other ways that not include dumb copy-pasting?
> >
> > Just for clearness. How can I add an override to the services when
> > running the tests? Creating AliasContribution's with the mode set to
> > "test", right? But what to do if I want to keep my primary module
> > clear of test services and keep all my test services in the test
> > module inside the src/test Maven2 hierarchy (so they even aren't
> > included in the release build)?
> >
> > --
> > WBR,
> > Ivan S. Dubrov
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> 得与失都是生活
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
得与失都是生活

RE: Using PageTester with tapestry-spring

Posted by Joel Wiegman <Jo...@btservices.com>.
Sure... what questions do you have?

I'd rather not write 8 paragraphs and still not answer your questions...

-----Original Message-----
From: Doublel [mailto:moonfly2004@gmail.com] 
Sent: Monday, September 24, 2007 7:59 PM
To: Tapestry users
Subject: Re: Using PageTester with tapestry-spring

I run into the same problem  I use
http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
Can you explain more detail??

2007/9/24, Joel Wiegman <Jo...@btservices.com>:
>
> Ivan,
>
> I'm using PageTester with Spring integration, but you'll have to jump 
> through a few small hoops to accomplish this.
>
> I've written a "TestHarnessModule" in my <app dir>.services directory.
> This module contributes the Spring services manually.  My code looks 
> very similar to what's found here:
>
> http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative1
>
> Then, you can pass in the name of the module to your PageTester:
>
> PageTester pageTester= new PageTester("com.myapp.dir", "TestHarness");
>
> IMHO, what's really neat about this is you can point your tests to a 
> different Spring configuration that uses mocked objects, mock 
> databases, etc.  This is what we're doing and it has worked very well.
>
> Hope this helps,
>
> Joel
>
> -----Original Message-----
> From: Ivan Dubrov [mailto:wfragg@gmail.com]
> Sent: Monday, September 24, 2007 7:14 AM
> To: Tapestry users
> Subject: Using PageTester with tapestry-spring
>
> Hi,
>
> How can I use the PageTester with the Spring integration? The problem 
> is that when PageTester creates the registry it does not adds 
> SpringModuleDef to the list of modules and all my Spring services are 
> unavailable because of this. Extending the PageTester is not possible 
> as well, so I cannot extend it and provide additional module (like the 
> TapestrySpringFilter does), so I have to copy-paste the complete 
> PageTester and add a line to include SpringModuleDef module to the list.
>
> Are there any other ways that not include dumb copy-pasting?
>
> Just for clearness. How can I add an override to the services when 
> running the tests? Creating AliasContribution's with the mode set to 
> "test", right? But what to do if I want to keep my primary module 
> clear of test services and keep all my test services in the test 
> module inside the src/test Maven2 hierarchy (so they even aren't 
> included in the release build)?
>
> --
> WBR,
> Ivan S. Dubrov
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


--
得与失都是生活

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


Re: Using PageTester with tapestry-spring

Posted by Doublel <mo...@gmail.com>.
I run into the same problem  I use
http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative2
Can you explain more detail??

2007/9/24, Joel Wiegman <Jo...@btservices.com>:
>
> Ivan,
>
> I'm using PageTester with Spring integration, but you'll have to jump
> through a few small hoops to accomplish this.
>
> I've written a "TestHarnessModule" in my <app dir>.services directory.
> This module contributes the Spring services manually.  My code looks
> very similar to what's found here:
>
> http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative1
>
> Then, you can pass in the name of the module to your PageTester:
>
> PageTester pageTester= new PageTester("com.myapp.dir", "TestHarness");
>
> IMHO, what's really neat about this is you can point your tests to a
> different Spring configuration that uses mocked objects, mock databases,
> etc.  This is what we're doing and it has worked very well.
>
> Hope this helps,
>
> Joel
>
> -----Original Message-----
> From: Ivan Dubrov [mailto:wfragg@gmail.com]
> Sent: Monday, September 24, 2007 7:14 AM
> To: Tapestry users
> Subject: Using PageTester with tapestry-spring
>
> Hi,
>
> How can I use the PageTester with the Spring integration? The problem is
> that when PageTester creates the registry it does not adds
> SpringModuleDef to the list of modules and all my Spring services are
> unavailable because of this. Extending the PageTester is not possible as
> well, so I cannot extend it and provide additional module (like the
> TapestrySpringFilter does), so I have to copy-paste the complete
> PageTester and add a line to include SpringModuleDef module to the list.
>
> Are there any other ways that not include dumb copy-pasting?
>
> Just for clearness. How can I add an override to the services when
> running the tests? Creating AliasContribution's with the mode set to
> "test", right? But what to do if I want to keep my primary module clear
> of test services and keep all my test services in the test module inside
> the src/test Maven2 hierarchy (so they even aren't included in the
> release build)?
>
> --
> WBR,
> Ivan S. Dubrov
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
得与失都是生活

RE: Using PageTester with tapestry-spring

Posted by Joel Wiegman <Jo...@btservices.com>.
Ivan,

I'm using PageTester with Spring integration, but you'll have to jump
through a few small hoops to accomplish this.

I've written a "TestHarnessModule" in my <app dir>.services directory.
This module contributes the Spring services manually.  My code looks
very similar to what's found here:

http://wiki.apache.org/tapestry/Tapestry5SpringIntegrationAlternative1

Then, you can pass in the name of the module to your PageTester:

PageTester pageTester= new PageTester("com.myapp.dir", "TestHarness");

IMHO, what's really neat about this is you can point your tests to a
different Spring configuration that uses mocked objects, mock databases,
etc.  This is what we're doing and it has worked very well.

Hope this helps,

Joel

-----Original Message-----
From: Ivan Dubrov [mailto:wfragg@gmail.com] 
Sent: Monday, September 24, 2007 7:14 AM
To: Tapestry users
Subject: Using PageTester with tapestry-spring

Hi,

How can I use the PageTester with the Spring integration? The problem is
that when PageTester creates the registry it does not adds
SpringModuleDef to the list of modules and all my Spring services are
unavailable because of this. Extending the PageTester is not possible as
well, so I cannot extend it and provide additional module (like the
TapestrySpringFilter does), so I have to copy-paste the complete
PageTester and add a line to include SpringModuleDef module to the list.

Are there any other ways that not include dumb copy-pasting?

Just for clearness. How can I add an override to the services when
running the tests? Creating AliasContribution's with the mode set to
"test", right? But what to do if I want to keep my primary module clear
of test services and keep all my test services in the test module inside
the src/test Maven2 hierarchy (so they even aren't included in the
release build)?

--
WBR,
Ivan S. Dubrov



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