This closes #3032
This commit is contained in:
commit
bdbce09fba
|
@ -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++;
|
||||
}
|
||||
}
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue