You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by eg...@apache.org on 2006/11/30 15:22:51 UTC
svn commit: r480937 - in /incubator/cxf/trunk/rt/transports/http/src:
main/java/org/apache/cxf/transport/http/
test/java/org/apache/cxf/transport/http/
Author: eglynn
Date: Thu Nov 30 06:22:50 2006
New Revision: 480937
URL: http://svn.apache.org/viewvc?view=rev&rev=480937
Log:
Applying Sergey's patch for CXF-278
Added:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/cxfcfg.xml (with props)
incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPServerEngineTest.java (with props)
Modified:
incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPServerEngine.java
Modified: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPServerEngine.java?view=diff&rev=480937&r1=480936&r2=480937
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPServerEngine.java (original)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/JettyHTTPServerEngine.java Thu Nov 30 06:22:50 2006
@@ -47,21 +47,12 @@
private int servantCount;
private HttpServer server;
private SocketListener listener;
- private final JettyListenerFactory listenerFactory;
+ private JettyListenerFactory listenerFactory;
private final int port;
JettyHTTPServerEngine(Bus bus, String protocol, int p) {
- this(bus, protocol, p, null);
- }
-
- JettyHTTPServerEngine(Bus bus, String protocol, int p, SSLServerPolicy sslServerPolicy) {
port = p;
- if (sslServerPolicy != null) {
- sslServer = sslServerPolicy;
- }
- listenerFactory = HTTPTransportFactory.getListenerFactory(sslServer);
- init();
- }
+ }
@Override
public String getBeanName() {
@@ -80,8 +71,10 @@
SSLServerPolicy sslServerPolicy) {
JettyHTTPServerEngine ref = portMap.get(p);
if (ref == null) {
- ref = new JettyHTTPServerEngine(bus, protocol, p, sslServerPolicy);
+ ref = new JettyHTTPServerEngine(bus, protocol, p);
configure(bus, ref);
+ ref.init(sslServerPolicy);
+ ref.retrieveListenerFactory();
portMap.put(p, ref);
}
return ref;
@@ -260,7 +253,14 @@
}
}
- private void init() {
+ private void retrieveListenerFactory() {
+ listenerFactory = HTTPTransportFactory.getListenerFactory(getSslServer());
+ }
+
+ private void init(SSLServerPolicy sslServerPolicy) {
+ if (!isSetSslServer()) {
+ setSslServer(sslServerPolicy);
+ }
if (!isSetListener()) {
setListener(new HTTPListenerPolicy());
}
Added: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/cxfcfg.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/cxfcfg.xml?view=auto&rev=480937
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/cxfcfg.xml (added)
+++ incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/cxfcfg.xml Thu Nov 30 06:22:50 2006
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:sec="http://cxf.apache.org/configuration/security"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+ <bean name="org.apache.cxf.transport.http.JettyHTTPServerEngine.1234" abstract="true">
+
+ <property name="sslServer">
+ <value>
+ <sec:sslServer/>
+ </value>
+ </property>
+ </bean>
+
+</beans>
\ No newline at end of file
Propchange: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/cxfcfg.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/cxfcfg.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPServerEngineTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPServerEngineTest.java?view=auto&rev=480937
==============================================================================
--- incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPServerEngineTest.java (added)
+++ incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPServerEngineTest.java Thu Nov 30 06:22:50 2006
@@ -0,0 +1,107 @@
+/**
+ * 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.cxf.transport.http;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.configuration.Configurer;
+import org.apache.cxf.configuration.security.SSLServerPolicy;
+import org.apache.cxf.configuration.spring.ConfigurerImpl;
+import org.easymock.classextension.EasyMock;
+import org.easymock.classextension.IMocksControl;
+
+public class JettyHTTPServerEngineTest extends TestCase {
+
+ private Bus bus;
+ private IMocksControl control;
+
+ public void setUp() throws Exception {
+ control = EasyMock.createNiceControl();
+ bus = control.createMock(Bus.class);
+ }
+
+ public void testEngineEquality() {
+
+ setUpConfigurer(null);
+
+ JettyHTTPServerEngine engine = JettyHTTPServerEngine.getForPort(bus, "http", 1234);
+ assertTrue("Engine references for the same port should point to the same instance",
+ engine == JettyHTTPServerEngine.getForPort(bus, "http", 1234));
+ assertFalse("Engine references for the different ports should point to diff instances",
+ engine == JettyHTTPServerEngine.getForPort(bus, "http", 1235));
+ JettyHTTPServerEngine.destroyForPort(1234);
+ JettyHTTPServerEngine.destroyForPort(1235);
+ }
+
+ public void testNoSSLServerPolicySet() {
+
+ setUpConfigurer(null);
+
+ JettyHTTPServerEngine engine = JettyHTTPServerEngine.getForPort(bus, "http", 1234);
+ assertFalse("SSLServerPolicy must not be set", engine.isSetSslServer());
+ engine = JettyHTTPServerEngine.getForPort(bus, "http", 1235, null);
+ assertFalse("SSLServerPolicy must not be set", engine.isSetSslServer());
+ JettyHTTPServerEngine engine2 = JettyHTTPServerEngine.getForPort(bus, "http", 1234,
+ new SSLServerPolicy());
+ assertFalse("SSLServerPolicy must not be set for already intialized engine",
+ engine2.isSetSslServer());
+ JettyHTTPServerEngine.destroyForPort(1234);
+ JettyHTTPServerEngine.destroyForPort(1235);
+ }
+
+ public void testDestinationSSLServerPolicy() {
+
+ setUpConfigurer(null);
+
+ SSLServerPolicy policy = new SSLServerPolicy();
+ JettyHTTPServerEngine engine = JettyHTTPServerEngine.getForPort(bus, "http", 1234,
+ policy);
+ assertTrue("SSLServerPolicy must be set", engine.getSslServer() == policy);
+ JettyHTTPServerEngine engine2 = JettyHTTPServerEngine.getForPort(bus, "http", 1234,
+ new SSLServerPolicy());
+ assertTrue("Engine references for the same port should point to the same instance",
+ engine == engine2);
+ assertTrue("SSLServerPolicy must not be set for already intialized engine",
+ engine.getSslServer() == policy);
+
+ JettyHTTPServerEngine.destroyForPort(1234);
+ }
+
+ public void testSSLServerPolicySetFromConfig() {
+
+ setUpConfigurer("/org/apache/cxf/transport/http/cxfcfg.xml");
+
+ JettyHTTPServerEngine engine = JettyHTTPServerEngine.getForPort(bus, "http", 1234);
+ assertTrue("SSLServerPolicy must be set", engine.isSetSslServer());
+
+ JettyHTTPServerEngine.destroyForPort(1234);
+ }
+
+ private void setUpConfigurer(String cxfFile) {
+ Configurer configurer = cxfFile == null
+ ? new ConfigurerImpl() : new ConfigurerImpl(cxfFile);
+
+
+ bus.getExtension(Configurer.class);
+ EasyMock.expectLastCall().andReturn(configurer).anyTimes();
+ control.replay();
+ }
+}
Propchange: incubator/cxf/trunk/rt/transports/http/src/test/java/org/apache/cxf/transport/http/JettyHTTPServerEngineTest.java
------------------------------------------------------------------------------
svn:eol-style = native