diff --git a/artemis-web/src/test/java/org/apache/activemq/cli/test/TestCustomizer.java b/artemis-web/src/test/java/org/apache/activemq/cli/test/TestCustomizer.java new file mode 100644 index 0000000000..1de85b8c6a --- /dev/null +++ b/artemis-web/src/test/java/org/apache/activemq/cli/test/TestCustomizer.java @@ -0,0 +1,34 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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.activemq.cli.test; + +import org.eclipse.jetty.server.Connector; +import org.eclipse.jetty.server.HttpConfiguration; +import org.eclipse.jetty.server.Request; + +public class TestCustomizer implements HttpConfiguration.Customizer { + public static int count = 0; + + public TestCustomizer() { + } + + @Override + public void customize(Connector connector, HttpConfiguration httpConfiguration, Request request) { + count++; + } +} diff --git a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java index 514371405c..75b68ad113 100644 --- a/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java +++ b/artemis-web/src/test/java/org/apache/activemq/cli/test/WebServerComponentTest.java @@ -84,9 +84,21 @@ public class WebServerComponentTest extends Assert { @Test public void simpleServer() throws Exception { + internalSimpleServer(false); + } + + @Test + public void simpleServerWithCustomizer() throws Exception { + internalSimpleServer(true); + } + + private void internalSimpleServer(boolean useCustomizer) throws Exception { WebServerDTO webServerDTO = new WebServerDTO(); webServerDTO.bind = "http://localhost:0"; webServerDTO.path = "webapps"; + if (useCustomizer) { + webServerDTO.customizer = TestCustomizer.class.getName(); + } WebServerComponent webServerComponent = new WebServerComponent(); Assert.assertFalse(webServerComponent.isStarted()); webServerComponent.configure(webServerDTO, "./src/test/resources/", "./src/test/resources/"); @@ -113,6 +125,9 @@ public class WebServerComponentTest extends Assert { // Send the HTTP request. ch.writeAndFlush(request); assertTrue(latch.await(5, TimeUnit.SECONDS)); + if (useCustomizer) { + assertEquals(1, TestCustomizer.count); + } assertEquals(clientHandler.body, "12345"); assertNull(clientHandler.serverHeader); // Wait for the server to close the connection.