mirror of https://github.com/apache/activemq.git
Fixed test case so that a System.exit call will not take down the JVM and cause the test suite to abort in Jenkins early
This commit is contained in:
parent
673c2928a1
commit
39a20bd788
|
@ -78,6 +78,11 @@
|
|||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.stefanbirkner</groupId>
|
||||
<artifactId>system-rules</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
|
|
|
@ -17,27 +17,43 @@
|
|||
|
||||
package org.apache.activemq.util;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
import org.apache.activemq.broker.BrokerService;
|
||||
import org.apache.activemq.broker.SuppressReplyException;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
|
||||
import org.junit.contrib.java.lang.system.internal.NoExitSecurityManager;
|
||||
|
||||
public class DefaultIOExceptionHandlerTest {
|
||||
|
||||
@Rule
|
||||
public final ExpectedSystemExit exit = ExpectedSystemExit.none();
|
||||
|
||||
DefaultIOExceptionHandler underTest = new DefaultIOExceptionHandler();
|
||||
|
||||
@Test
|
||||
@Test(timeout=20000)
|
||||
public void testHandleWithShutdownOnExit() throws Exception {
|
||||
exit.expectSystemExit();
|
||||
doTest(true);
|
||||
assertTrue(Wait.waitFor(new Wait.Condition() {
|
||||
@Override
|
||||
public boolean isSatisified() throws Exception {
|
||||
return ((NoExitSecurityManager)System.getSecurityManager()).isCheckExitCalled();
|
||||
}
|
||||
}, 10000));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(timeout=20000)
|
||||
public void testHandleWithOutShutdownOnExit() throws Exception {
|
||||
doTest(false);
|
||||
}
|
||||
|
|
7
pom.xml
7
pom.xml
|
@ -117,6 +117,7 @@
|
|||
<spring-version>4.1.8.RELEASE</spring-version>
|
||||
<spring-osgi-version>1.2.1</spring-osgi-version>
|
||||
<stax2-api-version>3.0.2</stax2-api-version>
|
||||
<system-rules-version>1.13.0</system-rules-version>
|
||||
<velocity-version>1.7</velocity-version>
|
||||
<woodstox-core-asl-version>4.2.0</woodstox-core-asl-version>
|
||||
<xalan-version>2.7.2</xalan-version>
|
||||
|
@ -995,6 +996,12 @@
|
|||
<version>${junit-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.stefanbirkner</groupId>
|
||||
<artifactId>system-rules</artifactId>
|
||||
<version>${system-rules-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
|
|
Loading…
Reference in New Issue