[ 
https://issues.apache.org/jira/browse/TAP5-2273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13948488#comment-13948488
 ] 

Balázs Palcsó commented on TAP5-2273:
-------------------------------------

Since I stopped using tapestry-spring (and therefore the above solution) I am 
still using a base class based solution what looks like this:

{code:java}
import org.apache.tapestry5.SymbolConstants;
import org.apache.tapestry5.internal.InternalConstants;
import org.apache.tapestry5.internal.SingleKeySymbolProvider;
import org.apache.tapestry5.internal.TapestryAppInitializer;
import org.apache.tapestry5.internal.test.PageTesterContext;
import org.apache.tapestry5.internal.util.DelegatingSymbolProvider;
import org.apache.tapestry5.ioc.Registry;
import 
org.apache.tapestry5.ioc.internal.services.SystemPropertiesSymbolProvider;
import org.apache.tapestry5.ioc.services.SymbolProvider;
import org.apache.tapestry5.services.ApplicationGlobals;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.AfterClass;

public class TapestryTestCase
{

    private static final Logger LOGGER = 
LoggerFactory.getLogger(AjanlatotKapokSeleniumTestCase.class);
    private static final Registry registry;

    static {

        final SymbolProvider combinedProvider = new DelegatingSymbolProvider(
                new SystemPropertiesSymbolProvider(),
                new SingleKeySymbolProvider(SymbolConstants.EXECUTION_MODE, 
"production"),
                new 
SingleKeySymbolProvider(InternalConstants.TAPESTRY_APP_PACKAGE_PARAM, 
"com.ajanlatotkapok.tapestry"));

        final TapestryAppInitializer appInitializer = new 
TapestryAppInitializer(LOGGER, combinedProvider, "AjanlatotKapok", 
"production");

        registry = appInitializer.createRegistry();
        final ApplicationGlobals globals = 
registry.getObject(ApplicationGlobals.class, null);
        globals.storeContext(new PageTesterContext("/"));
        registry.performRegistryStartup();
    }

    @AfterClass
    private static void shutdown() {
        registry.cleanupThread();
        registry.shutdown();
    }

    public final <T> T getService(final Class<T> serviceInterface) {
        return registry.getService(serviceInterface);
    }
}

{code}

Hope it helps to implement the JUnit test runner.

> TapestryIOCJunit4ClassRunner
> ----------------------------
>
>                 Key: TAP5-2273
>                 URL: https://issues.apache.org/jira/browse/TAP5-2273
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-test
>            Reporter: Lance
>            Priority: Minor
>         Attachments: TapestryGenericWebContextLoader.java, 
> TapestryTestApplicationContext.java
>
>
> Implement a TapestryIOCJunit4ClassRunner in a similar style to 
> SpringJUnit4ClassRunner 
> (http://docs.spring.io/spring/docs/2.5.6/api/org/springframework/test/context/junit4/SpringJUnit4ClassRunner.html)



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to