[mod_cluster-commits] mod_cluster SVN: r787 - in trunk/container: catalina/src/test/java/org/jboss/modcluster/container/catalina and 7 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Wed Apr 4 11:55:13 EDT 2012
Author: pferraro
Date: 2012-04-04 11:55:11 -0400 (Wed, 04 Apr 2012)
New Revision: 787
Added:
trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/AutoProxyConnectorProvider.java
trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/ProxyConnectorProvider.java
trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/SimpleProxyConnectorProvider.java
trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/AutoProxyConnectorProviderTestCase.java
trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/SimpleProxyConnectorProviderTestCase.java
trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/JBossWebEventHandlerAdapterTestCase.java
trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapterTestCase.java
Removed:
trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaLifecycleListenerFactory.java
trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/ContainerEventHandlerAdapterTestCase.java
trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java
Modified:
trunk/container/catalina-standalone/src/main/java/org/jboss/modcluster/container/catalina/standalone/ModClusterListener.java
trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaEngine.java
trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaEventHandlerAdapter.java
trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaFactoryRegistry.java
trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/ServiceLoaderCatalinaFactory.java
trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/ContainerEventHandlerAdapterTestCase.java
trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/EngineTestCase.java
trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/ServiceLoaderCatalinaFactoryTestCase.java
trunk/container/jbossweb/src/main/java/org/jboss/modcluster/container/jbossweb/JBossWebEventHandlerAdapter.java
trunk/container/tomcat6/src/main/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapter.java
trunk/container/tomcat6/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java
trunk/container/tomcat6/src/test/java/org/jboss/modcluster/container/tomcat/ServiceLoaderCatalinaFactoryTestCase.java
trunk/container/tomcat7/src/main/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapter.java
Log:
Create ProxyConnectorProvider abstraction to allow customization of proxy connector selection. Needed to fix JBPAPP-8466.
Added: trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/AutoProxyConnectorProvider.java
===================================================================
--- trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/AutoProxyConnectorProvider.java (rev 0)
+++ trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/AutoProxyConnectorProvider.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.modcluster.container.catalina;
+
+import org.apache.catalina.Engine;
+import org.jboss.modcluster.container.Connector;
+
+/**
+ * Proxy connector provider that prefers an AJP/reverse connector;
+ * or, if none are present, chooses the connector with the highest thread capacity.
+ * @author Paul Ferraro
+ */
+public class AutoProxyConnectorProvider implements ProxyConnectorProvider {
+ @Override
+ public Connector createProxyConnector(ConnectorFactory factory, Engine engine) {
+ int highestMaxThreads = 0;
+ Connector bestConnector = null;
+
+ for (org.apache.catalina.connector.Connector connector : engine.getService().findConnectors()) {
+ Connector catalinaConnector = factory.createConnector(connector);
+
+ if (CatalinaConnector.isAJP(connector) || catalinaConnector.isReverse()) {
+ return catalinaConnector;
+ }
+
+ int maxThreads = catalinaConnector.getMaxThreads();
+
+ if (maxThreads > highestMaxThreads) {
+ highestMaxThreads = maxThreads;
+ bestConnector = catalinaConnector;
+ }
+ }
+
+ if (bestConnector == null) {
+ throw new IllegalStateException();
+ }
+
+ return bestConnector;
+ }
+}
Modified: trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaEngine.java
===================================================================
--- trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaEngine.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaEngine.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -131,29 +131,7 @@
@Override
public Connector getProxyConnector() {
- int highestMaxThreads = 0;
- Connector bestConnector = null;
-
- for (org.apache.catalina.connector.Connector connector : this.engine.getService().findConnectors()) {
- Connector catalinaConnector = CatalinaEngine.this.registry.getConnectorFactory().createConnector(connector);
-
- if (CatalinaConnector.isAJP(connector) || catalinaConnector.isReverse()) {
- return catalinaConnector;
- }
-
- int maxThreads = catalinaConnector.getMaxThreads();
-
- if (maxThreads > highestMaxThreads) {
- highestMaxThreads = maxThreads;
- bestConnector = catalinaConnector;
- }
- }
-
- if (bestConnector == null) {
- throw new IllegalStateException();
- }
-
- return bestConnector;
+ return this.registry.getProxyConnectorProvider().createProxyConnector(this.registry.getConnectorFactory(), this.engine);
}
@Override
Modified: trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaEventHandlerAdapter.java
===================================================================
--- trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaEventHandlerAdapter.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaEventHandlerAdapter.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -39,6 +39,7 @@
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.Server;
import org.apache.catalina.Service;
+import org.apache.catalina.connector.Connector;
import org.jboss.modcluster.container.ContainerEventHandler;
/**
@@ -47,7 +48,7 @@
public class CatalinaEventHandlerAdapter implements CatalinaEventHandler {
protected final ContainerEventHandler eventHandler;
- protected final ServerProvider provider;
+ protected final ServerProvider serverProvider;
protected final CatalinaFactory factory;
// Flags used to ignore redundant or invalid events
@@ -66,26 +67,30 @@
}
public CatalinaEventHandlerAdapter(ContainerEventHandler eventHandler, MBeanServer mbeanServer) {
- this(eventHandler, new JMXServerProvider(mbeanServer, toObjectName("Catalina:type=Server")));
+ this(eventHandler, new JMXServerProvider(mbeanServer, toObjectName("Catalina:type=Server")), new AutoProxyConnectorProvider());
}
public CatalinaEventHandlerAdapter(ContainerEventHandler eventHandler, Server server) {
- this(eventHandler, new SimpleServerProvider(server), new ServiceLoaderCatalinaFactory());
+ this(eventHandler, new SimpleServerProvider(server), new AutoProxyConnectorProvider());
}
- public CatalinaEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider provider) {
- this(eventHandler, provider, new ServiceLoaderCatalinaFactory());
+ public CatalinaEventHandlerAdapter(ContainerEventHandler eventHandler, Server server, Connector connector) {
+ this(eventHandler, new SimpleServerProvider(server), new SimpleProxyConnectorProvider(connector));
}
- public CatalinaEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
+ public CatalinaEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider serverProvider, ProxyConnectorProvider connectorProvider) {
+ this(eventHandler, serverProvider, new ServiceLoaderCatalinaFactory(connectorProvider));
+ }
+
+ public CatalinaEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider serverProvider, CatalinaFactory factory) {
this.eventHandler = eventHandler;
- this.provider = provider;
+ this.serverProvider = serverProvider;
this.factory = factory;
}
@Override
public void start() {
- Server server = this.provider.getServer();
+ Server server = this.serverProvider.getServer();
if (!(server instanceof Lifecycle)) throw new IllegalStateException();
@@ -106,7 +111,7 @@
@Override
public void stop() {
- Server server = this.provider.getServer();
+ Server server = this.serverProvider.getServer();
if (!(server instanceof Lifecycle)) throw new IllegalStateException();
@@ -242,10 +247,10 @@
}
}
- /* to be overrided in the "real" class. */
protected boolean isAfterInit(LifecycleEvent event) {
return false;
}
+
protected boolean isBeforeDestroy(LifecycleEvent event) {
return false;
}
Modified: trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaFactoryRegistry.java
===================================================================
--- trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaFactoryRegistry.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaFactoryRegistry.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -11,4 +11,6 @@
ContextFactory getContextFactory();
ConnectorFactory getConnectorFactory();
+
+ ProxyConnectorProvider getProxyConnectorProvider();
}
Deleted: trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaLifecycleListenerFactory.java
===================================================================
--- trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaLifecycleListenerFactory.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/CatalinaLifecycleListenerFactory.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -1,12 +0,0 @@
-package org.jboss.modcluster.container.catalina;
-
-import org.apache.catalina.LifecycleListener;
-import org.jboss.modcluster.container.ContainerEventHandler;
-
-public class CatalinaLifecycleListenerFactory implements LifecycleListenerFactory {
-
- @Override
- public LifecycleListener createListener(ContainerEventHandler handler) {
- return new CatalinaEventHandlerAdapter(handler);
- }
-}
Added: trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/ProxyConnectorProvider.java
===================================================================
--- trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/ProxyConnectorProvider.java (rev 0)
+++ trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/ProxyConnectorProvider.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -0,0 +1,33 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.modcluster.container.catalina;
+
+import org.apache.catalina.Engine;
+import org.jboss.modcluster.container.Connector;
+
+/**
+ * Strategy for determining the connector with which mod_cluster will communicate.
+ * @author Paul Ferraro
+ */
+public interface ProxyConnectorProvider {
+ Connector createProxyConnector(ConnectorFactory factory, Engine engine);
+}
Modified: trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/ServiceLoaderCatalinaFactory.java
===================================================================
--- trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/ServiceLoaderCatalinaFactory.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/ServiceLoaderCatalinaFactory.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -13,7 +13,8 @@
private final HostFactory hostFactory;
private final ContextFactory contextFactory;
private final ConnectorFactory connectorFactory;
-
+ private final ProxyConnectorProvider provider;
+
private static <T> T load(Class<T> targetClass, Class<? extends T> defaultClass) {
for (T value : ServiceLoader.load(targetClass, targetClass.getClassLoader())) {
return value;
@@ -24,21 +25,23 @@
throw new IllegalStateException(e);
}
}
-
- public ServiceLoaderCatalinaFactory() {
+
+ public ServiceLoaderCatalinaFactory(ProxyConnectorProvider provider) {
this.serverFactory = load(ServerFactory.class, CatalinaServerFactory.class);
this.engineFactory = load(EngineFactory.class, CatalinaEngineFactory.class);
this.hostFactory = load(HostFactory.class, CatalinaHostFactory.class);
this.contextFactory = load(ContextFactory.class, CatalinaContextFactory.class);
this.connectorFactory = load(ConnectorFactory.class, CatalinaConnectorFactory.class);
+ this.provider = provider;
}
-
- public ServiceLoaderCatalinaFactory(ServerFactory serverFactory, EngineFactory engineFactory, HostFactory hostFactory, ContextFactory contextFactory, ConnectorFactory connectorFactory) {
+
+ public ServiceLoaderCatalinaFactory(ServerFactory serverFactory, EngineFactory engineFactory, HostFactory hostFactory, ContextFactory contextFactory, ConnectorFactory connectorFactory, ProxyConnectorProvider provider) {
this.serverFactory = serverFactory;
this.engineFactory = engineFactory;
this.hostFactory = hostFactory;
this.contextFactory = contextFactory;
this.connectorFactory = connectorFactory;
+ this.provider = provider;
}
@Override
@@ -62,6 +65,11 @@
}
@Override
+ public ProxyConnectorProvider getProxyConnectorProvider() {
+ return this.provider;
+ }
+
+ @Override
public ServerFactory getServerFactory() {
return this.serverFactory;
}
Added: trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/SimpleProxyConnectorProvider.java
===================================================================
--- trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/SimpleProxyConnectorProvider.java (rev 0)
+++ trunk/container/catalina/src/main/java/org/jboss/modcluster/container/catalina/SimpleProxyConnectorProvider.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -0,0 +1,42 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.modcluster.container.catalina;
+
+import org.apache.catalina.Engine;
+import org.jboss.modcluster.container.Connector;
+
+/**
+ * Proxy connector provider that uses a specific connector.
+ * @author Paul Ferraro
+ */
+public class SimpleProxyConnectorProvider implements ProxyConnectorProvider {
+ private final org.apache.catalina.connector.Connector connector;
+
+ public SimpleProxyConnectorProvider(org.apache.catalina.connector.Connector connector) {
+ this.connector = connector;
+ }
+
+ @Override
+ public Connector createProxyConnector(ConnectorFactory factory, Engine engine) {
+ return factory.createConnector(this.connector);
+ }
+}
Added: trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/AutoProxyConnectorProviderTestCase.java
===================================================================
--- trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/AutoProxyConnectorProviderTestCase.java (rev 0)
+++ trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/AutoProxyConnectorProviderTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -0,0 +1,31 @@
+package org.jboss.modcluster.container.catalina;
+
+import static org.junit.Assert.assertSame;
+import static org.mockito.Matchers.same;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.catalina.Engine;
+import org.apache.catalina.Service;
+import org.jboss.modcluster.container.Connector;
+import org.junit.Test;
+
+public class AutoProxyConnectorProviderTestCase {
+ @Test
+ public void createProxyConnector() throws Exception {
+ ConnectorFactory factory = mock(ConnectorFactory.class);
+ Engine engine = mock(Engine.class);
+ Service service = mock(Service.class);
+ Connector expected = mock(Connector.class);
+
+ org.apache.catalina.connector.Connector connector = new org.apache.catalina.connector.Connector("AJP/1.3");
+
+ when(engine.getService()).thenReturn(service);
+ when(service.findConnectors()).thenReturn(new org.apache.catalina.connector.Connector[] { connector });
+ when(factory.createConnector(same(connector))).thenReturn(expected);
+
+ Connector result = new AutoProxyConnectorProvider().createProxyConnector(factory, engine);
+
+ assertSame(expected, result);
+ }
+}
Modified: trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/ContainerEventHandlerAdapterTestCase.java
===================================================================
--- trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/ContainerEventHandlerAdapterTestCase.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/ContainerEventHandlerAdapterTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -22,7 +22,11 @@
package org.jboss.modcluster.container.catalina;
import static org.mockito.Matchers.same;
-import static org.mockito.Mockito.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.reset;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.mockito.Mockito.when;
import java.beans.PropertyChangeEvent;
@@ -36,26 +40,27 @@
import org.jboss.modcluster.container.Context;
import org.jboss.modcluster.container.Engine;
import org.jboss.modcluster.container.Server;
+import org.junit.After;
import org.junit.Test;
import org.mockito.Mockito;
/**
* @author Paul Ferraro
- *
*/
-public class ContainerEventHandlerAdapterTestCase {
+public abstract class ContainerEventHandlerAdapterTestCase {
protected final ContainerEventHandler eventHandler = mock(ContainerEventHandler.class);
protected final LifecycleServer server = mock(LifecycleServer.class);
protected final CatalinaFactory factory = mock(CatalinaFactory.class);
protected final ServerProvider provider = mock(ServerProvider.class);
- protected CatalinaEventHandler createEventHandler(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
- return new CatalinaEventHandlerAdapter(eventHandler, provider, factory);
+ protected abstract CatalinaEventHandler createEventHandler(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory);
+
+ @After
+ public void init() {
+ Mockito.reset(this.eventHandler, this.server, this.factory, this.provider);
}
-
+
@Test
- public void empty() {
- }
public void start() {
Service service = mock(Service.class);
LifecycleListener listener = mock(LifecycleListener.class);
@@ -85,6 +90,7 @@
verify(this.eventHandler).start(same(server));
}
+ @Test
public void stop() throws Exception {
Server server = mock(Server.class);
Service service = mock(Service.class);
@@ -115,6 +121,7 @@
verify(this.eventHandler).shutdown();
}
+ @Test
public void deployWebApp() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
@@ -157,6 +164,7 @@
verify(this.eventHandler).add(same(catalinaContext));
}
+ @Test
public void deployHost() {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
@@ -169,6 +177,7 @@
verify(engine).addContainerListener(handler);
}
+ @Test
public void undeployWebApp() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
@@ -213,6 +222,7 @@
verify(this.eventHandler).remove(same(catalinaContext));
}
+ @Test
public void undeployHost() {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
@@ -225,6 +235,7 @@
verify(engine).removeContainerListener(handler);
}
+ @Test
public void startWebApp() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
@@ -259,6 +270,7 @@
verify(this.eventHandler).start(same(catalinaContext));
}
+ @Test
public void initServer() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
LifecycleServer server = mock(LifecycleServer.class);
@@ -302,6 +314,7 @@
return new LifecycleEvent(lifecycle, "destroy", null);
}
+ @Test
public void startServer() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
LifecycleServer server = mock(LifecycleServer.class);
@@ -326,6 +339,7 @@
reset(this.eventHandler);
}
+ @Test
public void stopWebApp() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
@@ -359,6 +373,7 @@
verify(this.eventHandler).stop(same(catalinaContext));
}
+ @Test
public void stopServer() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
@@ -391,6 +406,7 @@
Mockito.verifyZeroInteractions(this.eventHandler);
}
+ @Test
public void destroyServer() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
@@ -427,6 +443,7 @@
Mockito.verifyZeroInteractions(this.eventHandler);
}
+ @Test
public void periodicEvent() throws Exception {
CatalinaEventHandler handler = this.createEventHandler(this.eventHandler, this.provider, this.factory);
Modified: trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/EngineTestCase.java
===================================================================
--- trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/EngineTestCase.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/EngineTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -24,7 +24,6 @@
import java.util.Iterator;
import org.apache.catalina.Container;
-import org.apache.catalina.Service;
import org.jboss.modcluster.container.Connector;
import org.jboss.modcluster.container.Engine;
import org.jboss.modcluster.container.Host;
@@ -106,15 +105,13 @@
@Test
public void getProxyConnector() throws Exception {
- org.apache.catalina.connector.Connector connector = new org.apache.catalina.connector.Connector("AJP/1.3");
- Service service = mock(Service.class);
+ ProxyConnectorProvider provider = mock(ProxyConnectorProvider.class);
Connector expected = mock(Connector.class);
ConnectorFactory factory = mock(ConnectorFactory.class);
- when(this.engine.getService()).thenReturn(service);
- when(service.findConnectors()).thenReturn(new org.apache.catalina.connector.Connector[] { connector });
+ when(this.registry.getProxyConnectorProvider()).thenReturn(provider);
when(this.registry.getConnectorFactory()).thenReturn(factory);
- when(factory.createConnector(same(connector))).thenReturn(expected);
+ when(provider.createProxyConnector(factory, this.engine)).thenReturn(expected);
Connector result = this.catalinaEngine.getProxyConnector();
Modified: trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/ServiceLoaderCatalinaFactoryTestCase.java
===================================================================
--- trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/ServiceLoaderCatalinaFactoryTestCase.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/ServiceLoaderCatalinaFactoryTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -16,21 +16,23 @@
private final HostFactory hostFactory = mock(HostFactory.class);
private final ContextFactory contextFactory = mock(ContextFactory.class);
private final ConnectorFactory connectorFactory = mock(ConnectorFactory.class);
+ private final ProxyConnectorProvider provider = mock(ProxyConnectorProvider.class);
@Test
public void testCatalinaFactoryRegistry() {
- CatalinaFactoryRegistry registry = new ServiceLoaderCatalinaFactory(this.serverFactory, this.engineFactory, this.hostFactory, this.contextFactory, this.connectorFactory);
+ CatalinaFactoryRegistry registry = new ServiceLoaderCatalinaFactory(this.serverFactory, this.engineFactory, this.hostFactory, this.contextFactory, this.connectorFactory, this.provider);
assertSame(this.serverFactory, registry.getServerFactory());
assertSame(this.engineFactory, registry.getEngineFactory());
assertSame(this.hostFactory, registry.getHostFactory());
assertSame(this.contextFactory, registry.getContextFactory());
assertSame(this.connectorFactory, registry.getConnectorFactory());
+ assertSame(this.provider, registry.getProxyConnectorProvider());
}
@Test
public void testCatalinaFactories() throws Exception {
- ServiceLoaderCatalinaFactory factory = new ServiceLoaderCatalinaFactory(this.serverFactory, this.engineFactory, this.hostFactory, this.contextFactory, this.connectorFactory);
+ ServiceLoaderCatalinaFactory factory = new ServiceLoaderCatalinaFactory(this.serverFactory, this.engineFactory, this.hostFactory, this.contextFactory, this.connectorFactory, this.provider);
org.apache.catalina.Server catalinaServer = mock(org.apache.catalina.Server.class);
Server server = mock(Server.class);
@@ -68,14 +70,15 @@
@Test
public void testServiceLoader() {
- this.verifyCatalinaFactoryTypes(new ServiceLoaderCatalinaFactory());
+ this.verifyCatalinaFactoryTypes(new ServiceLoaderCatalinaFactory(this.provider));
}
protected void verifyCatalinaFactoryTypes(CatalinaFactoryRegistry registry) {
- assertSame(registry.getServerFactory().getClass(), CatalinaServerFactory.class);
- assertSame(registry.getEngineFactory().getClass(), CatalinaEngineFactory.class);
- assertSame(registry.getHostFactory().getClass(), CatalinaHostFactory.class);
- assertSame(registry.getContextFactory().getClass(), CatalinaContextFactory.class);
- assertSame(registry.getConnectorFactory().getClass(), CatalinaConnectorFactory.class);
+ assertSame(CatalinaServerFactory.class, registry.getServerFactory().getClass());
+ assertSame(CatalinaEngineFactory.class, registry.getEngineFactory().getClass());
+ assertSame(CatalinaHostFactory.class, registry.getHostFactory().getClass());
+ assertSame(CatalinaContextFactory.class, registry.getContextFactory().getClass());
+ assertSame(CatalinaConnectorFactory.class, registry.getConnectorFactory().getClass());
+ assertSame(this.provider, registry.getProxyConnectorProvider());
}
}
Added: trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/SimpleProxyConnectorProviderTestCase.java
===================================================================
--- trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/SimpleProxyConnectorProviderTestCase.java (rev 0)
+++ trunk/container/catalina/src/test/java/org/jboss/modcluster/container/catalina/SimpleProxyConnectorProviderTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -0,0 +1,27 @@
+package org.jboss.modcluster.container.catalina;
+
+import static org.junit.Assert.assertSame;
+import static org.mockito.Matchers.same;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import org.apache.catalina.Engine;
+import org.jboss.modcluster.container.Connector;
+import org.junit.Test;
+
+public class SimpleProxyConnectorProviderTestCase {
+ @Test
+ public void createProxyConnector() throws Exception {
+ ConnectorFactory factory = mock(ConnectorFactory.class);
+ Engine engine = mock(Engine.class);
+ Connector expected = mock(Connector.class);
+
+ org.apache.catalina.connector.Connector connector = new org.apache.catalina.connector.Connector("AJP/1.3");
+
+ when(factory.createConnector(same(connector))).thenReturn(expected);
+
+ Connector result = new SimpleProxyConnectorProvider(connector).createProxyConnector(factory, engine);
+
+ assertSame(expected, result);
+ }
+}
Modified: trunk/container/catalina-standalone/src/main/java/org/jboss/modcluster/container/catalina/standalone/ModClusterListener.java
===================================================================
--- trunk/container/catalina-standalone/src/main/java/org/jboss/modcluster/container/catalina/standalone/ModClusterListener.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/catalina-standalone/src/main/java/org/jboss/modcluster/container/catalina/standalone/ModClusterListener.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -25,6 +25,7 @@
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.Map;
+import java.util.ServiceConfigurationError;
import java.util.ServiceLoader;
import java.util.concurrent.TimeUnit;
@@ -43,7 +44,6 @@
import org.jboss.modcluster.Strings;
import org.jboss.modcluster.config.JvmRouteFactory;
import org.jboss.modcluster.config.impl.ModClusterConfig;
-import org.jboss.modcluster.container.catalina.CatalinaLifecycleListenerFactory;
import org.jboss.modcluster.container.catalina.LifecycleListenerFactory;
import org.jboss.modcluster.load.LoadBalanceFactorProvider;
import org.jboss.modcluster.load.LoadBalanceFactorProviderFactory;
@@ -94,10 +94,10 @@
}
private LifecycleListenerFactory loadFactory() {
- for (LifecycleListenerFactory factory: ServiceLoader.load(LifecycleListenerFactory.class)) {
+ for (LifecycleListenerFactory factory: ServiceLoader.load(LifecycleListenerFactory.class, LifecycleListenerFactory.class.getClassLoader())) {
return factory;
}
- return new CatalinaLifecycleListenerFactory();
+ throw new ServiceConfigurationError(String.format("No %s service provider found.", LifecycleListenerFactory.class.getName()));
}
protected ModClusterListener(ModClusterServiceMBean mbean, LifecycleListener listener) {
Modified: trunk/container/jbossweb/src/main/java/org/jboss/modcluster/container/jbossweb/JBossWebEventHandlerAdapter.java
===================================================================
--- trunk/container/jbossweb/src/main/java/org/jboss/modcluster/container/jbossweb/JBossWebEventHandlerAdapter.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/jbossweb/src/main/java/org/jboss/modcluster/container/jbossweb/JBossWebEventHandlerAdapter.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -15,6 +15,7 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
import org.jboss.modcluster.container.ContainerEventHandler;
+import org.jboss.modcluster.container.catalina.AutoProxyConnectorProvider;
import org.jboss.modcluster.container.catalina.CatalinaEventHandlerAdapter;
import org.jboss.modcluster.container.catalina.CatalinaFactory;
import org.jboss.modcluster.container.catalina.JMXServerProvider;
@@ -25,47 +26,30 @@
private volatile ObjectName serviceObjectName = toObjectName("jboss.web:service=WebServer");
private volatile String connectorsStartedNotificationType = "jboss.tomcat.connectors.started";
private volatile String connectorsStoppedNotificationType = "jboss.tomcat.connectors.stopped";
- private final MBeanServer mbeanServer;
+ private final MBeanServer server;
public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler) {
this(eventHandler, ManagementFactory.getPlatformMBeanServer());
}
- public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler, MBeanServer mbeanServer) {
- this(eventHandler, mbeanServer, new JMXServerProvider(mbeanServer, toObjectName("jboss.web:type=Server")));
+ public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler, MBeanServer server) {
+ super(eventHandler, new JMXServerProvider(server, toObjectName("jboss.web:type=Server")), new AutoProxyConnectorProvider());
+ this.server = server;
}
- public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler, Server server) {
- super(eventHandler, server);
- this.mbeanServer = ManagementFactory.getPlatformMBeanServer();
+ public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler, MBeanServer server, ServerProvider serverProvider, CatalinaFactory factory) {
+ super(eventHandler, serverProvider, factory);
+ this.server = server;
}
- public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider provider) {
- this(eventHandler, ManagementFactory.getPlatformMBeanServer(), provider);
- }
-
- public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler, MBeanServer mbeanServer, ServerProvider provider) {
- super(eventHandler, provider);
- this.mbeanServer = mbeanServer;
- }
-
- public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
- this(eventHandler, ManagementFactory.getPlatformMBeanServer(), provider, factory);
- }
-
- public JBossWebEventHandlerAdapter(ContainerEventHandler eventHandler, MBeanServer mbeanServer, ServerProvider provider, CatalinaFactory factory) {
- super(eventHandler, provider, factory);
- this.mbeanServer = mbeanServer;
- }
-
@Override
protected void init(Server server) {
super.init(server);
// Register for mbean notifications if JBoss Web server mbean exists
- if (this.mbeanServer.isRegistered(this.serviceObjectName)) {
+ if (this.server.isRegistered(this.serviceObjectName)) {
try {
- this.mbeanServer.addNotificationListener(this.serviceObjectName, this, null, server);
+ this.server.addNotificationListener(this.serviceObjectName, this, null, server);
} catch (InstanceNotFoundException e) {
throw new IllegalStateException(e);
}
@@ -75,9 +59,9 @@
@Override
protected void destroy(Server server) {
// Unregister for mbean notifications if JBoss Web server mbean exists
- if (this.mbeanServer.isRegistered(this.serviceObjectName)) {
+ if (this.server.isRegistered(this.serviceObjectName)) {
try {
- this.mbeanServer.removeNotificationListener(this.serviceObjectName, this);
+ this.server.removeNotificationListener(this.serviceObjectName, this);
} catch (InstanceNotFoundException e) {
throw new IllegalStateException(e);
} catch (ListenerNotFoundException e) {
@@ -146,10 +130,13 @@
// to trigger *after* any listener with 0 hashCode.
return 1;
}
- protected boolean isAfterInit(LifecycleEvent event) {
- return event.getType().equals(Lifecycle.INIT_EVENT);
- }
+
@Override
+ protected boolean isAfterInit(LifecycleEvent event) {
+ return event.getType().equals(Lifecycle.INIT_EVENT);
+ }
+
+ @Override
protected boolean isBeforeDestroy(LifecycleEvent event) {
return event.getType().equals(Lifecycle.DESTROY_EVENT);
}
Deleted: trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/ContainerEventHandlerAdapterTestCase.java
===================================================================
--- trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/ContainerEventHandlerAdapterTestCase.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/ContainerEventHandlerAdapterTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -1,262 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.modcluster.container.jbossweb;
-
-import static org.junit.Assert.*;
-import static org.mockito.Matchers.*;
-import static org.mockito.Mockito.*;
-
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationFilter;
-import javax.management.ObjectName;
-
-import org.apache.catalina.Container;
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.Service;
-import org.jboss.modcluster.container.ContainerEventHandler;
-import org.jboss.modcluster.container.Engine;
-import org.jboss.modcluster.container.Server;
-import org.jboss.modcluster.container.catalina.CatalinaEventHandler;
-import org.jboss.modcluster.container.catalina.CatalinaFactory;
-import org.jboss.modcluster.container.catalina.ServerProvider;
-import org.junit.Test;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Matchers;
-import org.mockito.Mockito;
-
-
-/**
- * @author Paul Ferraro
- *
- */
-public class ContainerEventHandlerAdapterTestCase extends org.jboss.modcluster.container.catalina.ContainerEventHandlerAdapterTestCase {
- private final MBeanServer mbeanServer = mock(MBeanServer.class);
-
- @Override
- protected CatalinaEventHandler createEventHandler(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
- return new JBossWebEventHandlerAdapter(eventHandler, provider, factory);
- }
-
- @Override
- public void initServer() throws Exception {
- JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
- LifecycleServer server = mock(LifecycleServer.class);
- Service service = mock(Service.class);
- LifecycleEngine engine = mock(LifecycleEngine.class);
- Container container = mock(Container.class);
- LifecycleContainer childContainer = mock(LifecycleContainer.class);
- Server catalinaServer = mock(Server.class);
- ArgumentCaptor<ObjectName> capturedName = ArgumentCaptor.forClass(ObjectName.class);
-
- when(server.findServices()).thenReturn(new Service[] { service });
- when(service.getContainer()).thenReturn(engine);
- when(engine.findChildren()).thenReturn(new Container[] { container });
- when(container.findChildren()).thenReturn(new Container[] { childContainer });
- when(this.factory.createServer(server)).thenReturn(catalinaServer);
-
- when(this.mbeanServer.isRegistered(capturedName.capture())).thenReturn(true);
-
- handler.lifecycleEvent(this.createAfterInitEvent(server));
-
- ObjectName name = capturedName.getValue();
- assertEquals("jboss.web", name.getDomain());
- assertEquals(1, name.getKeyPropertyList().size());
- assertEquals("WebServer", name.getKeyProperty("service"));
-
- verify(this.eventHandler).init(same(catalinaServer));
- verify(engine).addContainerListener(handler);
- verify(engine).addLifecycleListener(handler);
- verify(container).addContainerListener(handler);
- verify(childContainer).addLifecycleListener(handler);
- verify(this.mbeanServer).addNotificationListener(same(name), same(handler), (NotificationFilter) Matchers.isNull(), same(server));
-
- reset(this.eventHandler);
-
- handler.lifecycleEvent(this.createAfterInitEvent(server));
- }
-
- @Override
- public void destroyServer() throws Exception {
- JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
-
- LifecycleServer server = mock(LifecycleServer.class);
- LifecycleEvent event = new LifecycleEvent(server, Lifecycle.DESTROY_EVENT, null);
-
- handler.lifecycleEvent(event);
-
- Mockito.verifyZeroInteractions(this.eventHandler);
-
- this.initServer(handler, server);
-
- Service service = mock(Service.class);
- LifecycleEngine engine = mock(LifecycleEngine.class);
- Container container = mock(Container.class);
- LifecycleContainer childContainer = mock(LifecycleContainer.class);
- ArgumentCaptor<ObjectName> capturedName = ArgumentCaptor.forClass(ObjectName.class);
-
- when(server.findServices()).thenReturn(new Service[] { service });
- when(service.getContainer()).thenReturn(engine);
- when(engine.findChildren()).thenReturn(new Container[] { container });
- when(container.findChildren()).thenReturn(new Container[] { childContainer });
-
- when(this.mbeanServer.isRegistered(capturedName.capture())).thenReturn(true);
-
- handler.lifecycleEvent(event);
-
- ObjectName name = capturedName.getValue();
- assertEquals("jboss.web", name.getDomain());
- assertEquals(1, name.getKeyPropertyList().size());
- assertEquals("WebServer", name.getKeyProperty("service"));
-
- verify(engine).removeContainerListener(handler);
- verify(engine).removeLifecycleListener(handler);
- verify(container).removeContainerListener(handler);
- verify(childContainer).removeLifecycleListener(handler);
- verify(this.eventHandler).shutdown();
- verify(this.mbeanServer).removeNotificationListener(same(name), same(handler));
- reset(this.eventHandler);
-
- handler.lifecycleEvent(event);
-
- Mockito.verifyZeroInteractions(this.eventHandler);
- }
-
- @Test
- public void handleConnectorsStartedNotification() throws Exception {
- JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
- LifecycleServer server = mock(LifecycleServer.class);
-
- Notification notification = new Notification("jboss.tomcat.connectors.started", new Object(), 1);
-
- handler.handleNotification(notification, server);
-
- this.initServer(handler, server);
-
- handler.handleNotification(notification, server);
-
- this.startServer(handler, server);
-
- Service service = mock(Service.class);
- org.apache.catalina.Engine engine = mock(org.apache.catalina.Engine.class);
- Engine catalinaEngine = mock(Engine.class);
-
- when(server.findServices()).thenReturn(new Service[] { service });
- when(service.getContainer()).thenReturn(engine);
- when(this.factory.createEngine(same(engine))).thenReturn(catalinaEngine);
-
- handler.handleNotification(notification, server);
-
- verify(this.eventHandler).status(same(catalinaEngine));
- }
-
- @Test
- public void handleConnectorsStoppedNotification() throws Exception {
- JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
- LifecycleServer server = mock(LifecycleServer.class);
-
- Notification notification = new Notification("jboss.tomcat.connectors.stopped", new Object(), 1);
-
- handler.handleNotification(notification, server);
-
- this.initServer(handler, server);
-
- handler.handleNotification(notification, server);
-
- this.startServer(handler, server);
-
- Server catalinaServer = mock(Server.class);
-
- when(this.factory.createServer(same(server))).thenReturn(catalinaServer);
-
- handler.handleNotification(notification, server);
-
- verify(this.eventHandler).stop(same(catalinaServer));
- }
-
- @Test
- public void handleOtherNotification() {
- JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
- LifecycleServer server = mock(LifecycleServer.class);
-
- Notification notification = new Notification("blah", new Object(), 1);
-
- handler.handleNotification(notification, server);
- }
-
- @Override
- protected LifecycleEvent createAfterInitEvent(Lifecycle lifecycle) {
- return new LifecycleEvent(lifecycle, Lifecycle.INIT_EVENT, null);
- }
- @Override
- protected LifecycleEvent createBeforeDestroyInitEvent(Lifecycle lifecycle) {
- return new LifecycleEvent(lifecycle, Lifecycle.DESTROY_EVENT, null);
- }
-
- /* From catalina ContainerEventHandlerAdapterTestCase.java */
- @Test
- public void start() {
- super.start();
- }
- @Test
- public void stop() throws Exception {
- super.stop();
- }
- @Test
- public void deployWebApp() throws Exception {
- super.deployWebApp();
- }
- @Test
- public void deployHost() {
- super.deployHost();
- }
- @Test
- public void undeployWebApp() throws Exception {
- super.undeployWebApp();
- }
- @Test
- public void undeployHost() {
- super.undeployHost();
- }
- @Test
- public void startWebApp() throws Exception {
- super.startWebApp();
- }
- @Test
- public void startServer() throws Exception {
- super.startServer();
- }
- @Test
- public void stopWebApp() throws Exception {
- super.stopWebApp();
- }
- @Test
- public void stopServer() throws Exception {
- super.stopServer();
- }
- @Test
- public void periodicEvent() throws Exception {
- super.periodicEvent();
- }
-
-}
Copied: trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/JBossWebEventHandlerAdapterTestCase.java (from rev 772, trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/ContainerEventHandlerAdapterTestCase.java)
===================================================================
--- trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/JBossWebEventHandlerAdapterTestCase.java (rev 0)
+++ trunk/container/jbossweb/src/test/java/org/jboss/modcluster/container/jbossweb/JBossWebEventHandlerAdapterTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -0,0 +1,217 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.modcluster.container.jbossweb;
+
+import static org.junit.Assert.*;
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.*;
+
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationFilter;
+import javax.management.ObjectName;
+
+import org.apache.catalina.Container;
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.Service;
+import org.jboss.modcluster.container.ContainerEventHandler;
+import org.jboss.modcluster.container.Engine;
+import org.jboss.modcluster.container.Server;
+import org.jboss.modcluster.container.catalina.CatalinaEventHandler;
+import org.jboss.modcluster.container.catalina.CatalinaFactory;
+import org.jboss.modcluster.container.catalina.ContainerEventHandlerAdapterTestCase;
+import org.jboss.modcluster.container.catalina.ServerProvider;
+import org.junit.Test;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Matchers;
+import org.mockito.Mockito;
+
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class JBossWebEventHandlerAdapterTestCase extends ContainerEventHandlerAdapterTestCase {
+ private final MBeanServer mbeanServer = mock(MBeanServer.class);
+
+ @Override
+ protected CatalinaEventHandler createEventHandler(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
+ return new JBossWebEventHandlerAdapter(eventHandler, this.mbeanServer, provider, factory);
+ }
+
+ @Override
+ public void initServer() throws Exception {
+ JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
+ LifecycleServer server = mock(LifecycleServer.class);
+ Service service = mock(Service.class);
+ LifecycleEngine engine = mock(LifecycleEngine.class);
+ Container container = mock(Container.class);
+ LifecycleContainer childContainer = mock(LifecycleContainer.class);
+ Server catalinaServer = mock(Server.class);
+ ArgumentCaptor<ObjectName> capturedName = ArgumentCaptor.forClass(ObjectName.class);
+
+ when(server.findServices()).thenReturn(new Service[] { service });
+ when(service.getContainer()).thenReturn(engine);
+ when(engine.findChildren()).thenReturn(new Container[] { container });
+ when(container.findChildren()).thenReturn(new Container[] { childContainer });
+ when(this.factory.createServer(server)).thenReturn(catalinaServer);
+
+ when(this.mbeanServer.isRegistered(capturedName.capture())).thenReturn(true);
+
+ handler.lifecycleEvent(this.createAfterInitEvent(server));
+
+ ObjectName name = capturedName.getValue();
+ assertEquals("jboss.web", name.getDomain());
+ assertEquals(1, name.getKeyPropertyList().size());
+ assertEquals("WebServer", name.getKeyProperty("service"));
+
+ verify(this.eventHandler).init(same(catalinaServer));
+ verify(engine).addContainerListener(handler);
+ verify(engine).addLifecycleListener(handler);
+ verify(container).addContainerListener(handler);
+ verify(childContainer).addLifecycleListener(handler);
+ verify(this.mbeanServer).addNotificationListener(same(name), same(handler), (NotificationFilter) Matchers.isNull(), same(server));
+
+ reset(this.eventHandler);
+
+ handler.lifecycleEvent(this.createAfterInitEvent(server));
+ }
+
+ @Override
+ public void destroyServer() throws Exception {
+ JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
+
+ LifecycleServer server = mock(LifecycleServer.class);
+ LifecycleEvent event = new LifecycleEvent(server, Lifecycle.DESTROY_EVENT, null);
+
+ handler.lifecycleEvent(event);
+
+ Mockito.verifyZeroInteractions(this.eventHandler);
+
+ this.initServer(handler, server);
+
+ Service service = mock(Service.class);
+ LifecycleEngine engine = mock(LifecycleEngine.class);
+ Container container = mock(Container.class);
+ LifecycleContainer childContainer = mock(LifecycleContainer.class);
+ ArgumentCaptor<ObjectName> capturedName = ArgumentCaptor.forClass(ObjectName.class);
+
+ when(server.findServices()).thenReturn(new Service[] { service });
+ when(service.getContainer()).thenReturn(engine);
+ when(engine.findChildren()).thenReturn(new Container[] { container });
+ when(container.findChildren()).thenReturn(new Container[] { childContainer });
+
+ when(this.mbeanServer.isRegistered(capturedName.capture())).thenReturn(true);
+
+ handler.lifecycleEvent(event);
+
+ ObjectName name = capturedName.getValue();
+ assertEquals("jboss.web", name.getDomain());
+ assertEquals(1, name.getKeyPropertyList().size());
+ assertEquals("WebServer", name.getKeyProperty("service"));
+
+ verify(engine).removeContainerListener(handler);
+ verify(engine).removeLifecycleListener(handler);
+ verify(container).removeContainerListener(handler);
+ verify(childContainer).removeLifecycleListener(handler);
+ verify(this.eventHandler).shutdown();
+ verify(this.mbeanServer).removeNotificationListener(same(name), same(handler));
+ reset(this.eventHandler);
+
+ handler.lifecycleEvent(event);
+
+ Mockito.verifyZeroInteractions(this.eventHandler);
+ }
+
+ @Test
+ public void handleConnectorsStartedNotification() throws Exception {
+ JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
+ LifecycleServer server = mock(LifecycleServer.class);
+
+ Notification notification = new Notification("jboss.tomcat.connectors.started", new Object(), 1);
+
+ handler.handleNotification(notification, server);
+
+ this.initServer(handler, server);
+
+ handler.handleNotification(notification, server);
+
+ this.startServer(handler, server);
+
+ Service service = mock(Service.class);
+ org.apache.catalina.Engine engine = mock(org.apache.catalina.Engine.class);
+ Engine catalinaEngine = mock(Engine.class);
+
+ when(server.findServices()).thenReturn(new Service[] { service });
+ when(service.getContainer()).thenReturn(engine);
+ when(this.factory.createEngine(same(engine))).thenReturn(catalinaEngine);
+
+ handler.handleNotification(notification, server);
+
+ verify(this.eventHandler).status(same(catalinaEngine));
+ }
+
+ @Test
+ public void handleConnectorsStoppedNotification() throws Exception {
+ JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
+ LifecycleServer server = mock(LifecycleServer.class);
+
+ Notification notification = new Notification("jboss.tomcat.connectors.stopped", new Object(), 1);
+
+ handler.handleNotification(notification, server);
+
+ this.initServer(handler, server);
+
+ handler.handleNotification(notification, server);
+
+ this.startServer(handler, server);
+
+ Server catalinaServer = mock(Server.class);
+
+ when(this.factory.createServer(same(server))).thenReturn(catalinaServer);
+
+ handler.handleNotification(notification, server);
+
+ verify(this.eventHandler).stop(same(catalinaServer));
+ }
+
+ @Test
+ public void handleOtherNotification() {
+ JBossWebEventHandlerAdapter handler = new JBossWebEventHandlerAdapter(this.eventHandler, this.mbeanServer, this.provider, this.factory);
+ LifecycleServer server = mock(LifecycleServer.class);
+
+ Notification notification = new Notification("blah", new Object(), 1);
+
+ handler.handleNotification(notification, server);
+ }
+
+ @Override
+ protected LifecycleEvent createAfterInitEvent(Lifecycle lifecycle) {
+ return new LifecycleEvent(lifecycle, Lifecycle.INIT_EVENT, null);
+ }
+
+ @Override
+ protected LifecycleEvent createBeforeDestroyInitEvent(Lifecycle lifecycle) {
+ return new LifecycleEvent(lifecycle, Lifecycle.DESTROY_EVENT, null);
+ }
+}
Modified: trunk/container/tomcat6/src/main/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapter.java
===================================================================
--- trunk/container/tomcat6/src/main/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapter.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/tomcat6/src/main/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapter.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -24,7 +24,6 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.Server;
import org.jboss.modcluster.container.ContainerEventHandler;
import org.jboss.modcluster.container.catalina.CatalinaEventHandlerAdapter;
import org.jboss.modcluster.container.catalina.CatalinaFactory;
@@ -36,22 +35,15 @@
super(eventHandler);
}
- public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, Server server) {
- super(eventHandler, server);
+ public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider serverProvider, CatalinaFactory factory) {
+ super(eventHandler, serverProvider, factory);
}
- public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider provider) {
- super(eventHandler, provider);
- }
-
- public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
- super(eventHandler, provider, factory);
- }
-
@Override
protected boolean isAfterInit(LifecycleEvent event) {
return event.getType().equals(Lifecycle.INIT_EVENT);
}
+
@Override
protected boolean isBeforeDestroy(LifecycleEvent event) {
return event.getType().equals(Lifecycle.DESTROY_EVENT);
Modified: trunk/container/tomcat6/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java
===================================================================
--- trunk/container/tomcat6/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/tomcat6/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -21,19 +21,13 @@
*/
package org.jboss.modcluster.container.tomcat;
-import static org.mockito.Matchers.same;
-import static org.mockito.Mockito.*;
-
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
-
import org.jboss.modcluster.container.ContainerEventHandler;
import org.jboss.modcluster.container.catalina.CatalinaEventHandler;
import org.jboss.modcluster.container.catalina.CatalinaFactory;
import org.jboss.modcluster.container.catalina.ServerProvider;
-import org.junit.Test;
-
/**
* @author Paul Ferraro
*
@@ -49,63 +43,9 @@
protected LifecycleEvent createAfterInitEvent(Lifecycle lifecycle) {
return new LifecycleEvent(lifecycle, Lifecycle.INIT_EVENT, null);
}
+
@Override
protected LifecycleEvent createBeforeDestroyInitEvent(Lifecycle lifecycle) {
return new LifecycleEvent(lifecycle, Lifecycle.DESTROY_EVENT, null);
}
-
- /* From catalina ContainerEventHandlerAdapterTestCase.java */
- @Test
- public void start() {
- super.start();
- }
- @Test
- public void stop() throws Exception {
- super.stop();
- }
- @Test
- public void deployWebApp() throws Exception {
- super.deployWebApp();
- }
- @Test
- public void deployHost() {
- super.deployHost();
- }
- @Test
- public void undeployWebApp() throws Exception {
- super.undeployWebApp();
- }
- @Test
- public void undeployHost() {
- super.undeployHost();
- }
- @Test
- public void startWebApp() throws Exception {
- super.startWebApp();
- }
- @Test
- public void initServer() throws Exception {
- super.initServer();
- }
- @Test
- public void startServer() throws Exception {
- super.startServer();
- }
- @Test
- public void stopWebApp() throws Exception {
- super.stopWebApp();
- }
- @Test
- public void stopServer() throws Exception {
- super.stopServer();
- }
- @Test
- public void destroyServer() throws Exception {
- super.destroyServer();
- }
- @Test
- public void periodicEvent() throws Exception {
- super.periodicEvent();
- }
-
}
Modified: trunk/container/tomcat6/src/test/java/org/jboss/modcluster/container/tomcat/ServiceLoaderCatalinaFactoryTestCase.java
===================================================================
--- trunk/container/tomcat6/src/test/java/org/jboss/modcluster/container/tomcat/ServiceLoaderCatalinaFactoryTestCase.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/tomcat6/src/test/java/org/jboss/modcluster/container/tomcat/ServiceLoaderCatalinaFactoryTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -2,7 +2,6 @@
import static org.junit.Assert.assertSame;
-import org.jboss.modcluster.container.catalina.CatalinaEngineFactory;
import org.jboss.modcluster.container.catalina.CatalinaFactoryRegistry;
import org.jboss.modcluster.container.catalina.CatalinaHostFactory;
import org.jboss.modcluster.container.catalina.CatalinaServerFactory;
Modified: trunk/container/tomcat7/src/main/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapter.java
===================================================================
--- trunk/container/tomcat7/src/main/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapter.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/tomcat7/src/main/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapter.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -2,7 +2,6 @@
import org.apache.catalina.Lifecycle;
import org.apache.catalina.LifecycleEvent;
-import org.apache.catalina.Server;
import org.jboss.modcluster.container.ContainerEventHandler;
import org.jboss.modcluster.container.catalina.CatalinaEventHandlerAdapter;
import org.jboss.modcluster.container.catalina.CatalinaFactory;
@@ -14,22 +13,15 @@
super(eventHandler);
}
- public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, Server server) {
- super(eventHandler, server);
+ public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider serverProvider, CatalinaFactory factory) {
+ super(eventHandler, serverProvider, factory);
}
- public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider provider) {
- super(eventHandler, provider);
- }
-
- public TomcatEventHandlerAdapter(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
- super(eventHandler, provider, factory);
- }
-
@Override
protected boolean isAfterInit(LifecycleEvent event) {
return event.getType().equals(Lifecycle.AFTER_INIT_EVENT);
}
+
@Override
protected boolean isBeforeDestroy(LifecycleEvent event) {
return event.getType().equals(Lifecycle.BEFORE_DESTROY_EVENT);
Deleted: trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java
===================================================================
--- trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java 2012-04-04 14:54:45 UTC (rev 786)
+++ trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -1,107 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.modcluster.container.tomcat;
-
-import org.apache.catalina.Lifecycle;
-import org.apache.catalina.LifecycleEvent;
-import org.jboss.modcluster.container.ContainerEventHandler;
-import org.jboss.modcluster.container.catalina.CatalinaEventHandler;
-import org.jboss.modcluster.container.catalina.CatalinaFactory;
-import org.jboss.modcluster.container.catalina.ServerProvider;
-
-import org.junit.Test;
-
-/**
- * @author Paul Ferraro
- *
- */
-public class ContainerEventHandlerAdapterTestCase extends org.jboss.modcluster.container.catalina.ContainerEventHandlerAdapterTestCase {
-
- @Override
- protected CatalinaEventHandler createEventHandler(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
- return new TomcatEventHandlerAdapter(eventHandler, provider, factory);
- }
-
- @Override
- protected LifecycleEvent createAfterInitEvent(Lifecycle lifecycle) {
- return new LifecycleEvent(lifecycle, Lifecycle.AFTER_INIT_EVENT, null);
- }
- @Override
- protected LifecycleEvent createBeforeDestroyInitEvent(Lifecycle lifecycle) {
- return new LifecycleEvent(lifecycle, Lifecycle.BEFORE_DESTROY_EVENT, null);
- }
-
- /* From catalina ContainerEventHandlerAdapterTestCase.java */
- @Test
- public void start() {
- super.start();
- }
- @Test
- public void stop() throws Exception {
- super.stop();
- }
- @Test
- public void deployWebApp() throws Exception {
- super.deployWebApp();
- }
- @Test
- public void deployHost() {
- super.deployHost();
- }
- @Test
- public void undeployWebApp() throws Exception {
- super.undeployWebApp();
- }
- @Test
- public void undeployHost() {
- super.undeployHost();
- }
- @Test
- public void startWebApp() throws Exception {
- super.startWebApp();
- }
- @Test
- public void initServer() throws Exception {
- super.initServer();
- }
- @Test
- public void startServer() throws Exception {
- super.startServer();
- }
- @Test
- public void stopWebApp() throws Exception {
- super.stopWebApp();
- }
- @Test
- public void stopServer() throws Exception {
- super.stopServer();
- }
- @Test
- public void destroyServer() throws Exception {
- super.destroyServer();
- }
- @Test
- public void periodicEvent() throws Exception {
- super.periodicEvent();
- }
-
-}
Copied: trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapterTestCase.java (from rev 784, trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/ContainerEventHandlerAdapterTestCase.java)
===================================================================
--- trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapterTestCase.java (rev 0)
+++ trunk/container/tomcat7/src/test/java/org/jboss/modcluster/container/tomcat/TomcatEventHandlerAdapterTestCase.java 2012-04-04 15:55:11 UTC (rev 787)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.modcluster.container.tomcat;
+
+import org.apache.catalina.Lifecycle;
+import org.apache.catalina.LifecycleEvent;
+import org.jboss.modcluster.container.ContainerEventHandler;
+import org.jboss.modcluster.container.catalina.CatalinaEventHandler;
+import org.jboss.modcluster.container.catalina.CatalinaFactory;
+import org.jboss.modcluster.container.catalina.ContainerEventHandlerAdapterTestCase;
+import org.jboss.modcluster.container.catalina.ServerProvider;
+
+/**
+ * @author Paul Ferraro
+ *
+ */
+public class TomcatEventHandlerAdapterTestCase extends ContainerEventHandlerAdapterTestCase {
+
+ @Override
+ protected CatalinaEventHandler createEventHandler(ContainerEventHandler eventHandler, ServerProvider provider, CatalinaFactory factory) {
+ return new TomcatEventHandlerAdapter(eventHandler, provider, factory);
+ }
+
+ @Override
+ protected LifecycleEvent createAfterInitEvent(Lifecycle lifecycle) {
+ return new LifecycleEvent(lifecycle, Lifecycle.AFTER_INIT_EVENT, null);
+ }
+
+ @Override
+ protected LifecycleEvent createBeforeDestroyInitEvent(Lifecycle lifecycle) {
+ return new LifecycleEvent(lifecycle, Lifecycle.BEFORE_DESTROY_EVENT, null);
+ }
+}
More information about the mod_cluster-commits
mailing list