You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2007/03/11 20:17:21 UTC
svn commit: r516994 - in /tapestry/tapestry5/tapestry-spring/trunk/src:
main/java/org/apache/tapestry/spring/SpringModule.java
test/java/org/apache/tapestry/spring/SpringModuleTest.java
Author: hlship
Date: Sun Mar 11 12:17:20 2007
New Revision: 516994
URL: http://svn.apache.org/viewvc?view=rev&rev=516994
Log:
TAPESTRY-1341: Allow service builders named "build" and determine service id from the result type
Modified:
tapestry/tapestry5/tapestry-spring/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java
tapestry/tapestry5/tapestry-spring/trunk/src/test/java/org/apache/tapestry/spring/SpringModuleTest.java
Modified: tapestry/tapestry5/tapestry-spring/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java?view=diff&rev=516994&r1=516993&r2=516994
==============================================================================
--- tapestry/tapestry5/tapestry-spring/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java (original)
+++ tapestry/tapestry5/tapestry-spring/trunk/src/main/java/org/apache/tapestry/spring/SpringModule.java Sun Mar 11 12:17:20 2007
@@ -41,9 +41,8 @@
* href="http://static.springframework.org/spring/docs/1.2.x/reference/beans.html#context-create">standard
* way</a> (which involves adding a listener to the web.xml deployment descriptor).
*/
- public static WebApplicationContext buildWebApplicationContext(
- @Inject("infrastructure:context")
- Context context)
+ public static WebApplicationContext build(@Inject("infrastructure:context")
+ Context context)
{
WebApplicationContext springContext = null;
Modified: tapestry/tapestry5/tapestry-spring/trunk/src/test/java/org/apache/tapestry/spring/SpringModuleTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-spring/trunk/src/test/java/org/apache/tapestry/spring/SpringModuleTest.java?view=diff&rev=516994&r1=516993&r2=516994
==============================================================================
--- tapestry/tapestry5/tapestry-spring/trunk/src/test/java/org/apache/tapestry/spring/SpringModuleTest.java (original)
+++ tapestry/tapestry5/tapestry-spring/trunk/src/test/java/org/apache/tapestry/spring/SpringModuleTest.java Sun Mar 11 12:17:20 2007
@@ -22,71 +22,71 @@
public class SpringModuleTest extends TapestryTestCase
{
- @Test
- public void missing_spring_context()
- {
- Context context = newContext(null);
+ @Test
+ public void missing_spring_context()
+ {
+ Context context = newContext(null);
- replay();
+ replay();
- try
- {
- SpringModule.buildWebApplicationContext(context);
+ try
+ {
+ SpringModule.build(context);
+
+ unreachable();
+ }
+ catch (RuntimeException ex)
+ {
+ assertEquals(
+ ex.getMessage(),
+ "The Spring WebApplicationContext is not present. The likely cause is that the org.springframework.web.context.ContextLoaderListener listener was not declared inside the application\'s web.xml deployment descriptor.");
+ }
- unreachable();
- }
- catch (RuntimeException ex)
- {
- assertEquals(
- ex.getMessage(),
- "The Spring WebApplicationContext is not present. The likely cause is that the org.springframework.web.context.ContextLoaderListener listener was not declared inside the application\'s web.xml deployment descriptor.");
+ verify();
}
- verify();
- }
+ @Test
+ public void success()
+ {
+ WebApplicationContext webContext = newMock(WebApplicationContext.class);
+ Context context = newContext(webContext);
- @Test
- public void success()
- {
- WebApplicationContext webContext = newMock(WebApplicationContext.class);
- Context context = newContext(webContext);
+ replay();
- replay();
+ assertSame(SpringModule.build(context), webContext);
- assertSame(SpringModule.buildWebApplicationContext(context), webContext);
+ verify();
+ }
- verify();
- }
+ protected final Context newContext(Object webApplicationContext)
+ {
+ Context context = newContext();
- protected final Context newContext(Object webApplicationContext)
- {
- Context context = newContext();
+ expect(context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE))
+ .andReturn(webApplicationContext);
- expect(context.getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE))
- .andReturn(webApplicationContext);
+ return context;
+ }
- return context;
- }
+ @Test
+ public void error_getting_spring_context()
+ {
+ Context context = newContext("[Placeholder]");
- @Test
- public void error_getting_spring_context()
- {
- Context context = newContext("[Placeholder]");
+ replay();
- replay();
+ try
+ {
+ SpringModule.build(context);
+ unreachable();
+ }
+ catch (RuntimeException ex)
+ {
+ assertTrue(ex.getMessage().startsWith(
+ "An exception occurred obtaining the Spring WebApplicationContext"));
+ }
- try
- {
- SpringModule.buildWebApplicationContext(context);
- unreachable();
+ verify();
}
- catch (RuntimeException ex)
- {
- assertTrue(ex.getMessage().startsWith(
- "An exception occurred obtaining the Spring WebApplicationContext"));
- }
-
- verify();
- }
}