Search in sources :

Example 1 with InfinispanServerRule

use of org.infinispan.server.test.junit4.InfinispanServerRule in project infinispan by infinispan.

the class StartupFailureIT method testAddressAlreadyBound.

@Test
public void testAddressAlreadyBound() throws Throwable {
    try (ServerSocket serverSocket = new ServerSocket(11222)) {
        AtomicBoolean ran = new AtomicBoolean();
        InfinispanServerRule rule = InfinispanServerRuleBuilder.server(false);
        Statement serverStatement = rule.apply(new Statement() {

            @Override
            public void evaluate() throws Throwable {
                ran.set(true);
            }
        }, Description.createTestDescription(StartupFailureIT.class, "testAddressAlreadyBound"));
        try {
            serverStatement.evaluate();
        } catch (Throwable e) {
        // Expected?
        }
        assertFalse(ran.get());
    }
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) InfinispanServerRule(org.infinispan.server.test.junit4.InfinispanServerRule) Statement(org.junit.runners.model.Statement) ServerSocket(java.net.ServerSocket) Test(org.junit.Test)

Aggregations

ServerSocket (java.net.ServerSocket)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 InfinispanServerRule (org.infinispan.server.test.junit4.InfinispanServerRule)1 Test (org.junit.Test)1 Statement (org.junit.runners.model.Statement)1