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

Lance edited comment on TAP5-2273 at 9/24/14 8:41 AM:
------------------------------------------------------

{code:java}
@RunWith(TapestryIOCJUnit4ClassRunner.class)
@Registry(modules=TestTapestryModule.class, 
shutdown=RegistryShutdownType.AFTER_METHOD)
public class MyTest {
   public static class TestTapestryModule {
      public static void bind(ServiceBinder binder) {
         binder.bind(TapestryService.class, TapestryServiceImpl.class);
      }
   }
   
   @Configuration
   public static class TestSpringConfiguration {
      @Bean
      public SpringService springService() {
         return new SpringServiceImpl();
      }
   }

   @ModuleDef
   public static SpringModuleDef createSpringModuleDef() {
      ServletContext servletContext = new MockServletContext();
      ApplicationContext applicationContext = new 
AnnotationConfigApplicationContext(TestSpringConfiguration.class);
      
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
 applicationContext);
      return new SpringModuleDef(servletContext);
   }

   @Inject
   private TapestryService tapestryService;
   
   @Inject
   private SpringService springService;

   @Test
   public void testServices() {
      assertNotNull(tapestryService);
      assertNotNull(springService);
   }
}
{code}



was (Author: uklance):
{code:java}
@RunWith(TapestryIOCJUnit4ClassRunner.class)
@Registry(modules=TestTapestryModule.class)
public class MyTest {
   public static class TestTapestryModule {
      public static void bind(ServiceBinder binder) {
         binder.bind(TapestryService.class, TapestryServiceImpl.class);
      }
   }
   
   @Configuration
   public static class TestSpringConfiguration {
      @Bean
      public SpringService springService() {
         return new SpringServiceImpl();
      }
   }

   @ModuleDef
   public static SpringModuleDef createSpringModuleDef() {
      ServletContext servletContext = new MockServletContext();
      ApplicationContext applicationContext = new 
AnnotationConfigApplicationContext(TestSpringConfiguration.class);
      
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE,
 applicationContext);
      return new SpringModuleDef(servletContext);
   }

   @Inject
   private TapestryService tapestryService;
   
   @Inject
   private SpringService springService;

   @Test
   public void testServices() {
      assertNotNull(tapestryService);
      assertNotNull(springService);
   }
}
{code}


> TapestryIOCJunit4ClassRunner
> ----------------------------
>
>                 Key: TAP5-2273
>                 URL: https://issues.apache.org/jira/browse/TAP5-2273
>             Project: Tapestry 5
>          Issue Type: Bug
>          Components: tapestry-test
>            Reporter: Lance
>            Assignee: Lance
>            Priority: Minor
>             Fix For: 5.4
>
>         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.3.4#6332)

Reply via email to