You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2007/08/27 17:57:03 UTC

svn commit: r570166 [2/2] - in /tapestry/tapestry5/trunk: ./ src/site/apt/ src/site/resources/css/ tapestry-core/ tapestry-core/src/main/java/org/apache/tapestry/ tapestry-core/src/main/java/org/apache/tapestry/internal/test/ tapestry-core/src/main/res...

Added: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/services/RegistryStartupTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/services/RegistryStartupTest.java?rev=570166&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/services/RegistryStartupTest.java (added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/services/RegistryStartupTest.java Mon Aug 27 08:56:56 2007
@@ -0,0 +1,134 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc.internal.services;
+
+import java.util.List;
+
+import org.apache.tapestry.ioc.Registry;
+import org.apache.tapestry.ioc.internal.util.CollectionFactory;
+import org.apache.tapestry.ioc.test.IOCTestCase;
+import org.slf4j.Logger;
+import org.testng.annotations.Test;
+
+public class RegistryStartupTest extends IOCTestCase
+{
+    /** Runnable runs. */
+    @Test
+    public void success()
+    {
+        List<Runnable> configuration = CollectionFactory.newList();
+
+        Runnable r1 = newMock(Runnable.class);
+        Runnable r2 = newMock(Runnable.class);
+
+        configuration.add(r1);
+        configuration.add(r2);
+
+        Logger logger = mockLogger();
+
+        getMocksControl().checkOrder(true);
+
+        r1.run();
+        r2.run();
+
+        replay();
+
+        Runnable startup = new RegistryStartup(logger, configuration);
+
+        startup.run();
+
+        verify();
+
+        // The configuration is cleared out at the end of the execution.
+        assertTrue(configuration.isEmpty());
+    }
+
+    @Test
+    public void failure_is_logged_but_execution_continues()
+    {
+        List<Runnable> configuration = CollectionFactory.newList();
+        RuntimeException t = new RuntimeException("Runnable r1 has been a naughty boy.");
+
+        Runnable r1 = newMock(Runnable.class);
+        Runnable r2 = newMock(Runnable.class);
+
+        configuration.add(r1);
+        configuration.add(r2);
+
+        Logger logger = mockLogger();
+
+        getMocksControl().checkOrder(true);
+
+        r1.run();
+
+        getMocksControl().andThrow(t);
+
+        logger.error(ServiceMessages.startupFailure(t));
+
+        r2.run();
+
+        replay();
+
+        Runnable startup = new RegistryStartup(logger, configuration);
+
+        startup.run();
+
+        verify();
+    }
+
+    @Test
+    public void run_may_only_be_called_once()
+    {
+        Logger logger = mockLogger();
+        List<Runnable> configuration = CollectionFactory.newList();
+
+        replay();
+
+        Runnable startup = new RegistryStartup(logger, configuration);
+
+        startup.run();
+
+        try
+        {
+            startup.run();
+            unreachable();
+        }
+        catch (IllegalStateException ex)
+        {
+            assertMessageContains(
+                    ex,
+                    "Method org.apache.tapestry.ioc.internal.services.RegistryStartup.run(",
+                    "may no longer be invoked.");
+
+        }
+
+        verify();
+    }
+
+    @Test
+    public void integration()
+    {
+        Registry r = buildRegistry(StartupModule.class);
+
+        assertFalse(StartupModule._startupInvoked);
+
+        r.performRegistryStartup();
+
+        assertTrue(StartupModule._startupInvoked);
+
+        // Ideally we'd have a way to show that the ThreadCleanupHub was notified after
+        // RegistryStartup did its thing, but ...
+    }
+}

Added: tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/services/StartupModule.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/services/StartupModule.java?rev=570166&view=auto
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/services/StartupModule.java (added)
+++ tapestry/tapestry5/trunk/tapestry-ioc/src/test/java/org/apache/tapestry/ioc/internal/services/StartupModule.java Mon Aug 27 08:56:56 2007
@@ -0,0 +1,35 @@
+// Copyright 2007 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package org.apache.tapestry.ioc.internal.services;
+
+import org.apache.tapestry.ioc.OrderedConfiguration;
+
+public class StartupModule
+{
+    public static boolean _startupInvoked;
+
+    public static void contributeRegistryStartup(OrderedConfiguration<Runnable> configuration)
+    {
+        Runnable r = new Runnable()
+        {
+            public void run()
+            {
+                _startupInvoked = true;
+            }
+        };
+
+        configuration.add("Contribution", r);
+    }
+}

Modified: tapestry/tapestry5/trunk/tapestry-spring/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-spring/pom.xml?rev=570166&r1=570165&r2=570166&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-spring/pom.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-spring/pom.xml Mon Aug 27 08:56:56 2007
@@ -74,29 +74,6 @@
   <reporting>
     <plugins>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <configuration>
-          <!--
-            <tags>
-            <tag>
-            <name>todo</name>
-            <!- - Should be a combinaison of the letters Xaoptcmf - ->
-            <placement>a</placement>
-            <head>To do something:</head>
-            </tag>
-            </tags> -->
-          <linksource>true</linksource>
-          <links>
-            <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
-            <link>http://jakarta.apache.org/commons/logging/apidocs/</link>
-            <link>http://tapestry.apache.org/tapestry5/tapestry-ioc/apidocs/</link>
-            <link>http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/</link>
-          </links>
-          <stylesheetfile>${basedir}/src/site/resources/css/jdstyle.css</stylesheetfile>
-        </configuration>
-      </plugin>
-      <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>cobertura-maven-plugin</artifactId>
         <version>${cobertura-plugin-version}</version>

Modified: tapestry/tapestry5/trunk/tapestry-test/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-test/pom.xml?rev=570166&r1=570165&r2=570166&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-test/pom.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-test/pom.xml Mon Aug 27 08:56:56 2007
@@ -47,29 +47,4 @@
       </plugin>
     </plugins>
   </build>
-  <reporting>
-    <plugins>
-      <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <configuration>
-          <!--
-            <tags>
-            <tag>
-            <name>todo</name>
-            <!- - Should be a combinaition of the letters Xaoptcmf - ->
-            <placement>a</placement>
-            <head>To do something:</head>
-            </tag>
-            </tags> -->
-          <linksource>true</linksource>
-          <links>
-            <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
-            <link>http://jakarta.apache.org/commons/logging/apidocs/</link>
-          </links>
-          <stylesheetfile>${basedir}/src/site/resources/css/jdstyle.css</stylesheetfile>
-        </configuration>
-      </plugin>
-    </plugins>
-  </reporting>
 </project>

Modified: tapestry/tapestry5/trunk/tapestry-upload/pom.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-upload/pom.xml?rev=570166&r1=570165&r2=570166&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-upload/pom.xml (original)
+++ tapestry/tapestry5/trunk/tapestry-upload/pom.xml Mon Aug 27 08:56:56 2007
@@ -94,29 +94,6 @@
   <reporting>
     <plugins>
       <plugin>
-        <groupId>org.apache.maven.plugins</groupId>
-        <artifactId>maven-javadoc-plugin</artifactId>
-        <configuration>
-          <!--
-                   <tags>
-                   <tag>
-                   <name>todo</name>
-                   <!- - Should be a combinaison of the letters Xaoptcmf - ->
-                   <placement>a</placement>
-                   <head>To do something:</head>
-                   </tag>
-                   </tags> -->
-          <linksource>true</linksource>
-          <links>
-            <link>http://java.sun.com/j2se/1.5.0/docs/api/</link>
-            <link>http://jakarta.apache.org/commons/logging/apidocs/</link>
-            <link>http://tapestry.apache.org/tapestry5/tapestry-ioc/apidocs/</link>
-            <link>http://tapestry.apache.org/tapestry5/tapestry-core/apidocs/</link>
-          </links>
-          <stylesheetfile>${basedir}/src/site/resources/css/jdstyle.css</stylesheetfile>
-        </configuration>
-      </plugin>
-      <plugin>
         <groupId>org.codehaus.mojo</groupId>
         <artifactId>cobertura-maven-plugin</artifactId>
         <version>${cobertura-plugin-version}</version>