[jira] [Comment Edited] (TAP5-2273) TapestryIOCJunit4ClassRunner

2014-09-24 Thread Lance (JIRA)

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

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

{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}



was (Author: uklance):
eg:
{code:java}
@RunWith(TapestryIOCJunit4ClassRunner.class)
@Registry(
   modules={SecurityModule.class, HibernateModule.class, MyTestModule.class},
   moduleDefs={SpringModuleDef.class},
   addDefaultModules=true
)
public class MyIOCTest {
   public static class MyTestModule {
  public static void bind(ServiceBinder binder) {
 binder
.bind(Foo.class, FooImpl.class)
.withId(myFoo)
.withMarker(Primary.class);
  }
   }

   // lookup from registry
   @Inject
   @ServiceId(myFoo)
   @Primary
   private Foo foo;

   public void testFoo() {
  Assert.assertNotNull(foo.doStuff());
   }
}
{code}

The test runner is ultimately a convenience wrapper which invokes methods in 
RegistryBuilder and IOCUtilities


 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)


[jira] [Comment Edited] (TAP5-2273) TapestryIOCJunit4ClassRunner

2014-09-24 Thread Lance (JIRA)

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

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

{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}



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)


[jira] [Comment Edited] (TAP5-2273) TapestryIOCJunit4ClassRunner

2014-09-24 Thread Lance (JIRA)

[ 
https://issues.apache.org/jira/browse/TAP5-2273?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanelfocusedCommentId=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)


[jira] [Comment Edited] (TAP5-2273) TapestryIOCJunit4ClassRunner

2014-03-18 Thread Lance (JIRA)

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

Lance edited comment on TAP5-2273 at 3/18/14 9:43 AM:
--

eg:
{code:java}
@RunWith(TapestryIOCJunit4ClassRunner.class)
@Registry(
   modules={SecurityModule.class, HibernateModule.class, MyTestModule.class},
   moduleDefs={SpringModuleDef.class},
   addDefaultModules=true
)
public class MyIOCTest {
   public static class MyTestModule {
  public static void bind(ServiceBinder binder) {
 binder
.bind(Foo.class, FooImpl.class)
.withId(myFoo)
.withMarker(Primary.class);
  }
   }

   // lookup from registry
   @Inject
   @ServiceId(myFoo)
   @Primary
   private Foo foo;

   public void testFoo() {
  Assert.assertNotNull(foo.doStuff());
   }
}
{code}

The test runner is ultimately a convenience wrapper which invokes methods in 
RegistryBuilder and IOCUtilities



was (Author: uklance):
eg:
{code:java}
@RunWith(TapestryIOCJunit4ClassRunner.class)

// call RegistryBuilder.add(Class... moduleClasses) 
@Modules({SecurityModule.class, HibernateModule.class, MyTestModule.class})

// call RegistryBuilder.add(ModuleDef moduleDef) 
@ModuleDefs({SpringModuleDef.class})

// call IOCUtilities.addDefaultModules(RegistryBuilder)
@AddDefaultModules

public class MyIOCTest {
   public static class MyTestModule {
  public static void bind(ServiceBinder binder) {
 binder
.bind(Foo.class, FooImpl.class)
.withId(myFoo)
.withMarker(Primary.class);
  }
   }

   // lookup from registry
   @Inject
   @ServiceId(myFoo)
   @Primary
   private Foo foo;

   public void testFoo() {
  Assert.assertNotNull(foo.doStuff());
   }
}
{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
Priority: Minor

 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)


[jira] [Comment Edited] (TAP5-2273) TapestryIOCJunit4ClassRunner

2014-01-22 Thread Lance (JIRA)

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

Lance edited comment on TAP5-2273 at 1/22/14 4:44 PM:
--

eg:
{code:java}
@RunWith(TapestryIOCJunit4ClassRunner.class)

// call RegistryBuilder.add(Class... moduleClasses) 
@Modules({SecurityModule.class, HibernateModule.class, MyTestModule.class})

// call RegistryBuilder.add(ModuleDef moduleDef) 
@ModuleDefs({SpringModuleDef.class})

// call IOCUtilities.addDefaultModules(RegistryBuilder)
@AddDefaultModules

public class MyIOCTest {
   public static class MyTestModule {
  public static void bind(ServiceBinder binder) {
 binder
.bind(Foo.class, FooImpl.class)
.withId(myFoo)
.withMarker(Primary.class);
  }
   }

   // lookup from registry
   @Inject
   @ServiceId(myFoo)
   @Primary
   private Foo foo;

   public void testFoo() {
  Assert.assertNotNull(foo.doStuff());
   }
}
{code}


was (Author: uklance):
eg:
{code:java}
@RunWith(TapestryIOCJunit4ClassRunner.class)

// call RegistryBuilder.add(Class... moduleClasses) 
@Modules({SecurityModule.class, HibernateModule.class, MyTestModule.class})

// call RegistryBuilder.add(ModuleDef moduleDef) 
@ModuleDefs({SpringModuleDef.class})

// call IOCUtilities.addDefaultModules(RegistryBuilder)
@AddDefaultModules

public class MyIOCTest {
   public static class MyTestModule {
  public static void bind(ServiceBinder binder) {
 binder.bind(Foo.class, FooImpl.class);
  }
   }

   // lookup from registry
   @Inject
   private Foo foo;

   public void testFoo() {
  Assert.assertNotNull(foo.doStuff());
   }
}
{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
Priority: Minor

 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.1.5#6160)