activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r1195046 - /activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java
Date Sat, 29 Oct 2011 21:44:27 GMT
Author: tabish
Date: Sat Oct 29 21:44:27 2011
New Revision: 1195046

URL: http://svn.apache.org/viewvc?rev=1195046&view=rev
Log:
fix for: https://issues.apache.org/jira/browse/AMQ-3547

Add an assertion to test that interrupted state is preserved.

Modified:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java?rev=1195046&r1=1195045&r2=1195046&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java (original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/bugs/AMQ3529Test.java Sat
Oct 29 21:44:27 2011
@@ -16,9 +16,7 @@
  */
 package org.apache.activemq.bugs;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.*;
 
 import javax.jms.Connection;
 import javax.jms.ConnectionFactory;
@@ -33,66 +31,68 @@ import org.junit.Test;
 
 public class AMQ3529Test {
 
-	private ConnectionFactory connectionFactory;
-	private Connection connection;
-	private Session session;
-	private BrokerService broker;
-	private String connectionUri;
-
-	@Before
-	public void startBroker() throws Exception {
-		broker = new BrokerService();
-		broker.setDeleteAllMessagesOnStartup(true);
-		broker.setPersistent(false);
-		broker.setUseJmx(false);
-		broker.addConnector("tcp://0.0.0.0:0");
-		broker.start();
-		broker.waitUntilStarted();
-
-		connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
-
-		connectionFactory = new ActiveMQConnectionFactory(connectionUri);
-	}
-
-	@After
-	public void stopBroker() throws Exception {
-		broker.stop();
-		broker.waitUntilStopped();
-	}
-
-	@Test(timeout = 60000)
-	public void testInterruptionAffects() throws Exception {
-		ThreadGroup tg = new ThreadGroup("tg");
-
-		assertEquals(0, tg.activeCount());
-
-		Thread client = new Thread(tg, "client") {
-
-			@Override
-			public void run() {
-				try {
-					connection = connectionFactory.createConnection();
-					session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-					assertNotNull(session);
-				} catch (JMSException e) {
-					fail(e.getMessage());
-				}
-				// next line is the nature of the test, if I remove this line, everything works OK
-				Thread.currentThread().interrupt();
-				try {
-					connection.close();
-				} catch (JMSException e) {
-				}
-			}
-		};
-		client.start();
-		client.join();
-		Thread.sleep(2000);
-		Thread[] remainThreads = new Thread[tg.activeCount()];
-		tg.enumerate(remainThreads);
-		for (Thread t : remainThreads) {
-			if (t.isAlive() && !t.isDaemon())
-				fail("Remaining thread: " + t.toString());
-		}
-	}
+    private ConnectionFactory connectionFactory;
+    private Connection connection;
+    private Session session;
+    private BrokerService broker;
+    private String connectionUri;
+
+    @Before
+    public void startBroker() throws Exception {
+        broker = new BrokerService();
+        broker.setDeleteAllMessagesOnStartup(true);
+        broker.setPersistent(false);
+        broker.setUseJmx(false);
+        broker.addConnector("tcp://0.0.0.0:0");
+        broker.start();
+        broker.waitUntilStarted();
+
+        connectionUri = broker.getTransportConnectors().get(0).getPublishableConnectString();
+
+        connectionFactory = new ActiveMQConnectionFactory(connectionUri);
+    }
+
+    @After
+    public void stopBroker() throws Exception {
+        broker.stop();
+        broker.waitUntilStopped();
+    }
+
+    @Test(timeout = 60000)
+    public void testInterruptionAffects() throws Exception {
+        ThreadGroup tg = new ThreadGroup("tg");
+
+        assertEquals(0, tg.activeCount());
+
+        Thread client = new Thread(tg, "client") {
+
+            @Override
+            public void run() {
+                try {
+                    connection = connectionFactory.createConnection();
+                    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+                    assertNotNull(session);
+                } catch (JMSException e) {
+                    fail(e.getMessage());
+                }
+                // next line is the nature of the test, if I remove this line, everything
works OK
+                Thread.currentThread().interrupt();
+                try {
+                    connection.close();
+                } catch (JMSException e) {
+                }
+
+                assertTrue(Thread.currentThread().isInterrupted());
+            }
+        };
+        client.start();
+        client.join();
+        Thread.sleep(2000);
+        Thread[] remainThreads = new Thread[tg.activeCount()];
+        tg.enumerate(remainThreads);
+        for (Thread t : remainThreads) {
+            if (t.isAlive() && !t.isDaemon())
+                fail("Remaining thread: " + t.toString());
+        }
+    }
 }



Mime
View raw message