qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rob...@apache.org
Subject svn commit: r1146594 - in /qpid/trunk/qpid/java: broker/src/main/java/org/apache/qpid/server/ client/src/main/java/org/apache/qpid/client/ common/src/main/java/org/apache/qpid/transport/ common/src/main/java/org/apache/qpid/transport/network/ common/sr...
Date Thu, 14 Jul 2011 08:15:32 GMT
Author: robbie
Date: Thu Jul 14 08:15:31 2011
New Revision: 1146594

URL: http://svn.apache.org/viewvc?rev=1146594&view=rev
Log:
QPID-3345: restore/add ability to use sys props to select the NetworkTransport used to make/accept
connections

Applied patch by Keith Wall <keith.wall@gmail.com>

Added:
    qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java
Modified:
    qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
    qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
    qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java
    qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java
    qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java
    qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
    qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java

Modified: qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java?rev=1146594&r1=1146593&r2=1146594&view=diff
==============================================================================
--- qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java (original)
+++ qpid/trunk/qpid/java/broker/src/main/java/org/apache/qpid/server/Broker.java Thu Jul 14
08:15:31 2011
@@ -215,7 +215,7 @@ public class Broker
                     NetworkTransportConfiguration settings = 
                         new ServerNetworkTransportConfiguration(serverConfig, port, bindAddress.getHostName(),
Transport.TCP);
 
-                    IncomingNetworkTransport transport = new MinaNetworkTransport();
+                    IncomingNetworkTransport transport = Transport.getIncomingTransportInstance();
                     MultiVersionProtocolEngineFactory protocolEngineFactory =
                         new MultiVersionProtocolEngineFactory(hostName, supported);
 

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java?rev=1146594&r1=1146593&r2=1146594&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
(original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionDelegate_8_0.java
Thu Jul 14 08:15:31 2011
@@ -52,7 +52,7 @@ import org.apache.qpid.ssl.SSLContextFac
 import org.apache.qpid.transport.ConnectionSettings;
 import org.apache.qpid.transport.network.NetworkConnection;
 import org.apache.qpid.transport.network.OutgoingNetworkTransport;
-import org.apache.qpid.transport.network.mina.MinaNetworkTransport;
+import org.apache.qpid.transport.network.Transport;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -105,7 +105,7 @@ public class AMQConnectionDelegate_8_0 i
             sslFactory = new SSLContextFactory(sslConfig.getKeystorePath(), sslConfig.getKeystorePassword(),
sslConfig.getCertType());
         }
 
-        OutgoingNetworkTransport transport = new MinaNetworkTransport();
+        OutgoingNetworkTransport transport = Transport.getOutgoingTransportInstance(getProtocolVersion());
         NetworkConnection network = transport.connect(settings, _conn._protocolHandler, sslFactory);
         _conn._protocolHandler.setNetworkConnection(network);
         _conn._protocolHandler.getProtocolSession().init();

Modified: qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java?rev=1146594&r1=1146593&r2=1146594&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java (original)
+++ qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/Connection.java Thu
Jul 14 08:15:31 2011
@@ -25,7 +25,6 @@ import static org.apache.qpid.transport.
 import static org.apache.qpid.transport.Connection.State.NEW;
 import static org.apache.qpid.transport.Connection.State.OPEN;
 import static org.apache.qpid.transport.Connection.State.OPENING;
-import static org.apache.qpid.transport.Connection.State.RESUMING;
 
 import java.nio.ByteBuffer;
 import java.util.ArrayList;
@@ -41,12 +40,13 @@ import java.util.concurrent.atomic.Atomi
 import javax.security.sasl.SaslClient;
 import javax.security.sasl.SaslServer;
 
+import org.apache.qpid.framing.ProtocolVersion;
 import org.apache.qpid.transport.network.Assembler;
 import org.apache.qpid.transport.network.Disassembler;
 import org.apache.qpid.transport.network.InputHandler;
 import org.apache.qpid.transport.network.NetworkConnection;
 import org.apache.qpid.transport.network.OutgoingNetworkTransport;
-import org.apache.qpid.transport.network.io.IoNetworkTransport;
+import org.apache.qpid.transport.network.Transport;
 import org.apache.qpid.transport.network.security.SecurityLayer;
 import org.apache.qpid.transport.util.Logger;
 import org.apache.qpid.transport.util.Waiter;
@@ -242,10 +242,9 @@ public class Connection extends Connecti
             userID = settings.getUsername();
             delegate = new ClientDelegate(settings);
 
-            securityLayer = new SecurityLayer();
-            securityLayer.init(this);
+            securityLayer = new SecurityLayer(this);
 
-            OutgoingNetworkTransport transport = new IoNetworkTransport();
+            OutgoingNetworkTransport transport = Transport.getOutgoingTransportInstance(ProtocolVersion.v0_10);
             Receiver<ByteBuffer> receiver = securityLayer.receiver(new InputHandler(new
Assembler(this)));
             NetworkConnection network = transport.connect(settings, receiver, null);
             sender = new Disassembler(securityLayer.sender(network.getSender()), settings.getMaxFrameSize());

Modified: qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java?rev=1146594&r1=1146593&r2=1146594&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java
(original)
+++ qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/NetworkTransport.java
Thu Jul 14 08:15:31 2011
@@ -20,6 +20,10 @@
  */
 package org.apache.qpid.transport.network;
 
+/**
+ * A network transport is responsible for the establishment of network connections.
+ * NetworkTransport implementations are pluggable via the {@link Transport} class.
+ */
 public interface NetworkTransport
 {
     public void close();

Modified: qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java?rev=1146594&r1=1146593&r2=1146594&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java
(original)
+++ qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/Transport.java
Thu Jul 14 08:15:31 2011
@@ -20,7 +20,116 @@
  */
 package org.apache.qpid.transport.network;
 
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.qpid.framing.ProtocolVersion;
+import org.apache.qpid.transport.TransportException;
+
 public class Transport
 {
+    public static final String QPID_TRANSPORT_PROPNAME = "qpid.transport";
+    public static final String QPID_TRANSPORT_V0_8_PROPNAME = "qpid.transport.v0_8";
+    public static final String QPID_TRANSPORT_V0_9_PROPNAME = "qpid.transport.v0_9";
+    public static final String QPID_TRANSPORT_V0_9_1_PROPNAME = "qpid.transport.v0_9_1";
+    public static final String QPID_TRANSPORT_V0_10_PROPNAME = "qpid.transport.v0_10";
+    public static final String QPID_BROKER_TRANSPORT_PROPNAME = "qpid.broker.transport";
+
+    // Can't reference the class directly here, as this would preclude the ability to bundle
transports separately.
+    private static final String MINA_TRANSPORT_CLASSNAME = "org.apache.qpid.transport.network.mina.MinaNetworkTransport";
+    private static final String IO_TRANSPORT_CLASSNAME = "org.apache.qpid.transport.network.io.IoNetworkTransport";
+
     public static final String TCP = "tcp";
+
+    private final static Map<ProtocolVersion,String> OUTGOING_PROTOCOL_TO_IMPLDEFAULTS_MAP;
+
+    static
+    {
+        final Map<ProtocolVersion,String> map = new HashMap<ProtocolVersion, String>();
+        map.put(ProtocolVersion.v8_0, MINA_TRANSPORT_CLASSNAME);
+        map.put(ProtocolVersion.v0_9, MINA_TRANSPORT_CLASSNAME);
+        map.put(ProtocolVersion.v0_91, MINA_TRANSPORT_CLASSNAME);
+        map.put(ProtocolVersion.v0_10, IO_TRANSPORT_CLASSNAME);
+
+        OUTGOING_PROTOCOL_TO_IMPLDEFAULTS_MAP = Collections.unmodifiableMap(map);
+    }
+
+    public static IncomingNetworkTransport getIncomingTransportInstance()
+    {
+        return (IncomingNetworkTransport) loadTransportClass(
+                System.getProperty(QPID_BROKER_TRANSPORT_PROPNAME, MINA_TRANSPORT_CLASSNAME));
+    }
+
+    public static OutgoingNetworkTransport getOutgoingTransportInstance(
+            final ProtocolVersion protocolVersion)
+    {
+
+        final String overrride = getOverrideClassNameFromSystemProperty(protocolVersion);
+        final String networkTransportClassName;
+        if (overrride != null)
+        {
+            networkTransportClassName = overrride;
+        }
+        else
+        {
+            networkTransportClassName = OUTGOING_PROTOCOL_TO_IMPLDEFAULTS_MAP.get(protocolVersion);
+        }
+
+        return (OutgoingNetworkTransport) loadTransportClass(networkTransportClassName);
+    }
+
+    private static NetworkTransport loadTransportClass(final String networkTransportClassName)
+    {
+        if (networkTransportClassName == null)
+        {
+            throw new IllegalArgumentException("transport class name must not be null");
+        }
+
+        try
+        {
+            final Class<?> clazz = Class.forName(networkTransportClassName);
+            return (NetworkTransport) clazz.newInstance();
+        }
+        catch (InstantiationException e)
+        {
+            throw new TransportException("Unable to instantiate transport class " + networkTransportClassName,
e);
+        }
+        catch (IllegalAccessException e)
+        {
+            throw new TransportException("Access exception " + networkTransportClassName,
e);
+        }
+        catch (ClassNotFoundException e)
+        {
+            throw new TransportException("Unable to load transport class " + networkTransportClassName,
e);
+        }
+    }
+
+    private static String getOverrideClassNameFromSystemProperty(final ProtocolVersion protocolVersion)
+    {
+        final String protocolSpecificSystemProperty;
+
+        if (ProtocolVersion.v0_10.equals(protocolVersion))
+        {
+            protocolSpecificSystemProperty = QPID_TRANSPORT_V0_10_PROPNAME;
+        }
+        else if (ProtocolVersion.v0_91.equals(protocolVersion))
+        {
+            protocolSpecificSystemProperty = QPID_TRANSPORT_V0_9_1_PROPNAME;
+        }
+        else if (ProtocolVersion.v0_9.equals(protocolVersion))
+        {
+            protocolSpecificSystemProperty = QPID_TRANSPORT_V0_9_PROPNAME;
+        }
+        else if (ProtocolVersion.v8_0.equals(protocolVersion))
+        {
+            protocolSpecificSystemProperty = QPID_TRANSPORT_V0_8_PROPNAME;
+        }
+        else
+        {
+            throw new IllegalArgumentException("Unknown ProtocolVersion " + protocolVersion);
+        }
+
+        return System.getProperty(protocolSpecificSystemProperty, System.getProperty(QPID_TRANSPORT_PROPNAME));
+    }
 }

Modified: qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java?rev=1146594&r1=1146593&r2=1146594&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java
(original)
+++ qpid/trunk/qpid/java/common/src/main/java/org/apache/qpid/transport/network/security/SecurityLayer.java
Thu Jul 14 08:15:31 2011
@@ -43,8 +43,8 @@ public class SecurityLayer
     Connection con;
     SSLSecurityLayer sslLayer;
     SASLSecurityLayer saslLayer;
-    
-    public void init(Connection con) throws TransportException
+
+    public SecurityLayer(Connection con)
     {
         this.con = con;
         this.settings = con.getConnectionSettings();
@@ -55,10 +55,9 @@ public class SecurityLayer
         if (settings.isUseSASLEncryption())
         {
             saslLayer = new SASLSecurityLayer();
-        }        
-        
+        }
     }
-    
+
     public Sender<ByteBuffer> sender(Sender<ByteBuffer> delegate)
     {
         Sender<ByteBuffer> sender = delegate;

Modified: qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java?rev=1146594&r1=1146593&r2=1146594&view=diff
==============================================================================
--- qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
(original)
+++ qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/test/utils/QpidTestCase.java
Thu Jul 14 08:15:31 2011
@@ -25,7 +25,9 @@ import java.io.File;
 import java.io.FileReader;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import junit.framework.TestCase;
 import junit.framework.TestResult;
@@ -37,6 +39,8 @@ public class QpidTestCase extends TestCa
 {
     protected static final Logger _logger = Logger.getLogger(QpidTestCase.class);
 
+    private final Map<String, String> _propertiesSetForTest = new HashMap<String,
String>();
+
     /**
      * Some tests are excluded when the property test.excludes is set to true.
      * An exclusion list is either a file (prop test.excludesfile) which contains one test
name
@@ -133,4 +137,49 @@ public class QpidTestCase extends TestCa
     {
         return AvailablePortFinder.getNextAvailable(10000);
     }
+
+    /**
+     * Set a System property for duration of this test only. The tearDown will
+     * guarantee to reset the property to its previous value after the test
+     * completes.
+     *
+     * @param property The property to set
+     * @param value the value to set it to.
+     */
+    protected void setTestSystemProperty(String property, String value)
+    {
+        if (!_propertiesSetForTest.containsKey(property))
+        {
+            // Record the current value so we can revert it later.
+            _propertiesSetForTest.put(property, System.getProperty(property));
+        }
+
+        System.setProperty(property, value);
+    }
+
+    /**
+     * Restore the System property values that were set by this test run.
+     */
+    protected void revertTestSystemProperties()
+    {
+        for (String key : _propertiesSetForTest.keySet())
+        {
+            String value = _propertiesSetForTest.get(key);
+            if (value != null)
+            {
+                System.setProperty(key, value);
+            }
+            else
+            {
+                System.clearProperty(key);
+            }
+        }
+
+        _propertiesSetForTest.clear();
+    }
+
+    protected void tearDown() throws java.lang.Exception
+    {
+        revertTestSystemProperties();
+    }
 }

Added: qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java?rev=1146594&view=auto
==============================================================================
--- qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java
(added)
+++ qpid/trunk/qpid/java/common/src/test/java/org/apache/qpid/transport/network/TransportTest.java
Thu Jul 14 08:15:31 2011
@@ -0,0 +1,157 @@
+/*
+ *
+ * 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.qpid.transport.network;
+
+
+import java.nio.ByteBuffer;
+
+import org.apache.qpid.framing.ProtocolVersion;
+import org.apache.qpid.protocol.ProtocolEngineFactory;
+import org.apache.qpid.ssl.SSLContextFactory;
+import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.transport.ConnectionSettings;
+import org.apache.qpid.transport.NetworkTransportConfiguration;
+import org.apache.qpid.transport.Receiver;
+import org.apache.qpid.transport.TransportException;
+import org.apache.qpid.transport.network.io.IoNetworkTransport;
+import org.apache.qpid.transport.network.mina.MinaNetworkTransport;
+
+public class TransportTest extends QpidTestCase
+{
+
+
+
+    public void testDefaultGetOutgoingTransportForv0_8() throws Exception
+    {
+        final OutgoingNetworkTransport networkTransport = Transport.getOutgoingTransportInstance(ProtocolVersion.v8_0);
+        assertNotNull(networkTransport);
+        assertTrue(networkTransport instanceof MinaNetworkTransport);
+    }
+
+    public void testGloballyOverriddenOutgoingTransportForv0_8() throws Exception
+    {
+        setTestSystemProperty(Transport.QPID_TRANSPORT_PROPNAME, TestOutgoingNetworkTransport.class.getName());
+
+        final OutgoingNetworkTransport networkTransport = Transport.getOutgoingTransportInstance(ProtocolVersion.v8_0);
+        assertNotNull(networkTransport);
+        assertTrue(networkTransport instanceof TestOutgoingNetworkTransport);
+    }
+
+    public void testProtocolSpecificOverriddenOutgoingTransportForv0_8() throws Exception
+    {
+        setTestSystemProperty(Transport.QPID_TRANSPORT_V0_8_PROPNAME, TestOutgoingNetworkTransport.class.getName());
+
+        final OutgoingNetworkTransport networkTransport = Transport.getOutgoingTransportInstance(ProtocolVersion.v8_0);
+        assertNotNull(networkTransport);
+        assertTrue(networkTransport instanceof TestOutgoingNetworkTransport);
+    }
+
+    public void testDefaultGetOutgoingTransportForv0_10() throws Exception
+    {
+        final OutgoingNetworkTransport networkTransport = Transport.getOutgoingTransportInstance(ProtocolVersion.v0_10);
+        assertNotNull(networkTransport);
+        assertTrue(networkTransport instanceof IoNetworkTransport);
+    }
+
+    public void testDefaultGetIncomingTransport() throws Exception
+    {
+        final IncomingNetworkTransport networkTransport = Transport.getIncomingTransportInstance();
+        assertNotNull(networkTransport);
+        assertTrue(networkTransport instanceof MinaNetworkTransport);
+    }
+
+    public void testOverriddenGetIncomingTransport() throws Exception
+    {
+        setTestSystemProperty(Transport.QPID_BROKER_TRANSPORT_PROPNAME, TestIncomingNetworkTransport.class.getName());
+
+        final IncomingNetworkTransport networkTransport = Transport.getIncomingTransportInstance();
+        assertNotNull(networkTransport);
+        assertTrue(networkTransport instanceof TestIncomingNetworkTransport);
+    }
+
+    public void testInvalidOutgoingTransportClassName() throws Exception
+    {
+        setTestSystemProperty(Transport.QPID_TRANSPORT_PROPNAME, "invalid");
+
+        try
+        {
+            Transport.getOutgoingTransportInstance(ProtocolVersion.v0_10);
+            fail("Should have failed to load the invalid class");
+        }
+        catch(TransportException te)
+        {
+            //expected, ignore
+        }
+    }
+
+    public void testInvalidOutgoingTransportProtocolVersion() throws Exception
+    {
+        try
+        {
+            Transport.getOutgoingTransportInstance(new ProtocolVersion((byte)0, (byte)0));
+            fail("Should have failed to load the transport for invalid protocol version");
+        }
+        catch(IllegalArgumentException iae)
+        {
+            //expected, ignore
+        }
+    }
+
+    public static class TestOutgoingNetworkTransport implements OutgoingNetworkTransport
+    {
+
+        public void close()
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        public NetworkConnection getConnection()
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        public NetworkConnection connect(ConnectionSettings settings,
+                Receiver<ByteBuffer> delegate, SSLContextFactory sslFactory)
+        {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    public static class TestIncomingNetworkTransport implements IncomingNetworkTransport
+    {
+
+        public void close()
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        public NetworkConnection getConnection()
+        {
+            throw new UnsupportedOperationException();
+        }
+
+        public void accept(NetworkTransportConfiguration config,
+                ProtocolEngineFactory factory, SSLContextFactory sslFactory)
+        {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

Modified: qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1146594&r1=1146593&r2=1146594&view=diff
==============================================================================
--- qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
(original)
+++ qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
Thu Jul 14 08:15:31 2011
@@ -91,7 +91,6 @@ public class QpidBrokerTestCase extends 
 
     protected long RECEIVE_TIMEOUT = 1000l;
 
-    private Map<String, String> _propertiesSetForTestOnly = new HashMap<String,
String>();
     private Map<String, String> _propertiesSetForBroker = new HashMap<String, String>();
     private Map<Logger, Level> _loggerLevelSetForTest = new HashMap<Logger, Level>();
 
@@ -875,20 +874,14 @@ public class QpidBrokerTestCase extends 
     }
 
     /**
-     * Set a System (-D) property for the external Broker of this test.
+     * Set a System  property for the client (and broker if using the same vm) of this test.
      *
      * @param property The property to set
      * @param value the value to set it to.
      */
     protected void setTestClientSystemProperty(String property, String value)
     {
-        if (!_propertiesSetForTestOnly.containsKey(property))
-        {
-            // Record the current value so we can revert it later.
-            _propertiesSetForTestOnly.put(property, System.getProperty(property));
-        }
-
-        System.setProperty(property, value);
+        setTestSystemProperty(property, value);
     }
 
     /**
@@ -896,20 +889,7 @@ public class QpidBrokerTestCase extends 
      */
     protected void revertSystemProperties()
     {
-        for (String key : _propertiesSetForTestOnly.keySet())
-        {
-            String value = _propertiesSetForTestOnly.get(key);
-            if (value != null)
-            {
-                System.setProperty(key, value);
-            }
-            else
-            {
-                System.clearProperty(key);
-            }
-        }
-
-        _propertiesSetForTestOnly.clear();
+        revertTestSystemProperties();
 
         // We don't change the current VMs settings for Broker only properties
         // so we can just clear this map
@@ -1145,7 +1125,8 @@ public class QpidBrokerTestCase extends 
                 c.close();
             }
         }
-        finally{
+        finally
+        {
             // Ensure any problems with close does not interfer with property resets
             revertSystemProperties();
             revertLoggingLevels();



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message