Author: ritchiem
Date: Wed Jun  4 07:57:37 2008
New Revision: 663142

URL: http://svn.apache.org/viewvc?rev=663142&view=rev
Log:
Merged revisions 663125 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.x

........
  r663125 | ritchiem | 2008-06-04 15:32:49 +0100 (Wed, 04 Jun 2008) | 6 lines
  
  QPID-1119 : M2x commit : Addition of a System property to 
AMQProtocolHandler.java to allow the syncWait default to be changed. To perform 
this a new SlowMessageStore has been added to the systest package. This allows 
all MessageStore methods to have a pre and/or post delay applied. This delay 
can be configured dynamically if you have a handle to the Store or via the XML 
configuration. The SlowMessageStore can also be used to wrap any existing 
MessageStore (Testing only carried out with the default MemoryMessageStore) 
  To make testing easier on M2x VMTestCase has been modified to allow the test 
to simply configure logging levels and systemProperties. These are then 
reverted after the test has completed.
  
  These changes will naturally need more work to before they are merged to 
trunk which uses totally different methods for ClientProperties and for running 
tests.
  
  systests/pom.xml didn't have amqj.logging.level as a systemProperty hence 
setting it did nothing for the tests.
........

Added:
    
incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
      - copied unchanged from r663125, 
incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/server/store/SlowMessageStore.java
    
incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/
      - copied from r663125, 
incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/
    
incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
      - copied unchanged from r663125, 
incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitDelayTest.java
    
incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitTimeoutDelayTest.java
      - copied unchanged from r663125, 
incubator/qpid/branches/M2.x/java/systests/src/main/java/org/apache/qpid/test/client/timeouts/SyncWaitTimeoutDelayTest.java
Modified:
    incubator/qpid/branches/M2.1.x/   (props changed)
    
incubator/qpid/branches/M2.1.x/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
    incubator/qpid/branches/M2.1.x/java/systests/pom.xml
    
incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java

Propchange: incubator/qpid/branches/M2.1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: 
incubator/qpid/branches/M2.1.x/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1.x/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java?rev=663142&r1=663141&r2=663142&view=diff
==============================================================================
--- 
incubator/qpid/branches/M2.1.x/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
 (original)
+++ 
incubator/qpid/branches/M2.1.x/java/client/src/main/java/org/apache/qpid/client/protocol/AMQProtocolHandler.java
 Wed Jun  4 07:57:37 2008
@@ -158,7 +158,7 @@
     private FailoverException _lastFailoverException;
 
     /** Defines the default timeout to use for synchronous protocol commands. 
*/
-    private final long DEFAULT_SYNC_TIMEOUT = 1000 * 30;
+    private final long DEFAULT_SYNC_TIMEOUT = 
Long.getLong("amqj.default_syncwrite_timeout", 1000 * 30);
 
     /** Default buffer size for pending messages reads */
     private static final String DEFAULT_READ_BUFFER_LIMIT = "262144";

Modified: incubator/qpid/branches/M2.1.x/java/systests/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1.x/java/systests/pom.xml?rev=663142&r1=663141&r2=663142&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1.x/java/systests/pom.xml (original)
+++ incubator/qpid/branches/M2.1.x/java/systests/pom.xml Wed Jun  4 07:57:37 
2008
@@ -96,6 +96,10 @@
                             <name>QPID_HOME</name>
                             
<value>${basedir}/${topDirectoryLocation}/broker</value>
                         </property>                        
+                        <property>
+                            <name>amqj.logging.level</name>
+                            <value>${amqj.logging.level}</value>
+                        </property>
                     </systemProperties>
 
                     <excludes>

Modified: 
incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
URL: 
http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java?rev=663142&r1=663141&r2=663142&view=diff
==============================================================================
--- 
incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
 (original)
+++ 
incubator/qpid/branches/M2.1.x/java/systests/src/main/java/org/apache/qpid/test/VMTestCase.java
 Wed Jun  4 07:57:37 2008
@@ -21,6 +21,8 @@
 package org.apache.qpid.test;
 
 import junit.framework.TestCase;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.client.AMQDestination;
 import org.apache.qpid.client.AMQSession;
@@ -46,6 +48,8 @@
 import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.LinkedList;
+import java.util.concurrent.ConcurrentHashMap;
 
 public class VMTestCase extends TestCase
 {
@@ -61,6 +65,16 @@
     protected final Map<String, String> _queues = new HashMap<String, 
String>();
     protected final Map<String, String> _topics = new HashMap<String, 
String>();
 
+    protected static final String ALL = "org.apache.qpid";
+    protected static final String BROKER = "org.apache.qpid.server";
+    protected static final String CLIENT = "org.apache.qpid.client";
+    protected static final String COMMON = "org.apache.qpid.common";
+    protected static final String FRAMING = "org.apache.qpid.framing";
+    protected static final String TEST = "org.apache.qpid.test";
+
+    private LinkedList<LogState> _logStates = new LinkedList<LogState>();
+    private Map<String, String> _setProperties = new HashMap<String, String>();
+
     protected void setUp() throws Exception
     {
         super.setUp();
@@ -116,6 +130,11 @@
 //        checkQueuesClean();
 
         stopVMBroker(1);
+
+        revertLogging();
+
+        revertSystemProperties();
+
         super.tearDown();
     }
 
@@ -159,7 +178,7 @@
 
     public void startVMBroker(int vmID) throws Exception
     {
-        startVMBroker(vmID, null);
+        startVMBroker(vmID, (File) null);
     }
 
     /** FIXME: for now vmID must be unique client is responsible for this. */
@@ -204,10 +223,85 @@
         }
     }
 
+    public void startVMBroker(int vmID, ConfigurationFileApplicationRegistry 
config) throws Exception
+    {
+        ApplicationRegistry.initialise(config, vmID);
+        startVMBroker(vmID);
+    }
+
     public void stopVMBroker(int inVMid)
     {
         TransportConnection.killVMBroker(inVMid);
         ApplicationRegistry.remove(inVMid);
     }
 
+    protected void setLoggingLevel(String loggerName, Level level)
+    {
+        Logger logger = Logger.getLogger(loggerName);
+
+        Level currentLevel = logger.getLevel();
+
+        _logStates.push(new LogState(logger, currentLevel));
+
+        logger.setLevel(level);
+    }
+
+    protected void revertLogging()
+    {
+        for (LogState state : _logStates)
+        {
+            state.getLogger().setLevel(state.getLevel());
+        }
+
+        _logStates.clear();
+    }
+
+    protected class LogState
+    {
+        private Logger _logger;
+        private Level _level;
+
+        public LogState(Logger logger, Level level)
+        {
+            _logger = logger;
+            _level = level;
+        }
+
+        public Logger getLogger()
+        {
+            return _logger;
+        }
+
+        public Level getLevel()
+        {
+            return _level;
+        }
+    }
+
+    protected void setSystemProperty(String property, String value)
+    {
+        if (!_setProperties.containsKey(property))
+        {
+            _setProperties.put(property, System.getProperty(property));
+        }
+
+        System.setProperty(property, value);
+    }
+
+    protected void revertSystemProperties()
+    {
+        for (String key : _setProperties.keySet())
+        {
+            String value = _setProperties.get(key);
+            if (value != null)
+            {
+                System.setProperty(key, value);
+            }
+            else
+            {
+                System.clearProperty(key);
+            }
+        }
+    }
+
 }


Reply via email to