simplified test

This commit is contained in:
Greg Wilkins 2017-08-10 15:11:45 +10:00
parent 08c49a30c0
commit 7179ac0b61
1 changed files with 0 additions and 81 deletions

View File

@ -46,9 +46,6 @@ import org.junit.runner.RunWith;
@RunWith(AdvancedRunner.class)
public class LocalAsyncContextTest
{
private final AtomicReference<Throwable> _completed0 = new AtomicReference<>();
private final AtomicReference<Throwable> _completed1 = new AtomicReference<>();
private final AtomicBoolean _broken = new AtomicBoolean(false);
protected Server _server;
protected SuspendHandler _handler;
protected Connector _connector;
@ -72,8 +69,6 @@ public class LocalAsyncContextTest
public void reset()
{
_completed0.set(null);
_completed1.set(null);
}
protected Connector initConnector()
@ -86,8 +81,6 @@ public class LocalAsyncContextTest
{
_server.stop();
_server.join();
if (_broken.get())
Assert.fail();
}
@Test
@ -100,9 +93,6 @@ public class LocalAsyncContextTest
_handler.setCompleteAfter(-1);
response = process(null);
check(response, "TIMEOUT");
spinAssertEquals(1, () -> _completed0.get() == null ? 0 : 1);
spinAssertEquals(1, () -> _completed1.get() == null ? 0 : 1);
}
@Test
@ -231,9 +221,6 @@ public class LocalAsyncContextTest
_handler.setCompleteAfter2(-1);
response = process(null);
check(response, "STARTASYNC", "DISPATCHED", "startasync", "STARTASYNC2", "DISPATCHED");
spinAssertEquals(1, () -> _completed0.get() == null ? 0 : 1);
spinAssertEquals(0, () -> _completed1.get() == null ? 0 : 1);
}
protected void check(String response, String... content)
@ -343,7 +330,6 @@ public class LocalAsyncContextTest
final AsyncContext asyncContext = baseRequest.startAsync();
response.getOutputStream().println("STARTASYNC");
asyncContext.addListener(__asyncListener);
asyncContext.addListener(__asyncListener1);
if (_suspendFor > 0)
asyncContext.setTimeout(_suspendFor);
@ -485,33 +471,11 @@ public class LocalAsyncContextTest
@Override
public void onComplete(AsyncEvent event) throws IOException
{
Throwable complete = new Throwable();
if (!_completed0.compareAndSet(null, complete))
{
System.err.println("First onCompleted0:");
_completed0.get().printStackTrace();
System.err.println("Second onCompleted0:");
complete.printStackTrace();
_completed0.set(null);
_broken.set(true);
throw new IllegalStateException();
}
}
@Override
public void onError(AsyncEvent event) throws IOException
{
Throwable complete = new Throwable();
if (!_completed0.compareAndSet(null, complete))
{
System.err.println("First onError0:");
_completed0.get().printStackTrace();
System.err.println("Second onError0:");
complete.printStackTrace();
_completed0.set(null);
_broken.set(true);
throw new IllegalStateException();
}
}
@Override
@ -529,51 +493,6 @@ public class LocalAsyncContextTest
}
};
private AsyncListener __asyncListener1 = new AsyncListener()
{
@Override
public void onComplete(AsyncEvent event) throws IOException
{
Throwable complete = new Throwable();
if (!_completed1.compareAndSet(null, complete))
{
System.err.println("First onCompleted1:");
_completed1.get().printStackTrace();
System.err.println("Second onCompleted1:");
complete.printStackTrace();
_completed1.set(null);
_broken.set(true);
throw new IllegalStateException();
}
}
@Override
public void onError(AsyncEvent event) throws IOException
{
Throwable complete = new Throwable();
if (!_completed1.compareAndSet(null, complete))
{
System.err.println("First onError1:");
_completed1.get().printStackTrace();
System.err.println("Second onError1:");
complete.printStackTrace();
_completed1.set(null);
_broken.set(true);
throw new IllegalStateException();
}
}
@Override
public void onStartAsync(AsyncEvent event) throws IOException
{
}
@Override
public void onTimeout(AsyncEvent event) throws IOException
{
}
};
static <T> void spinAssertEquals(T expected, Supplier<T> actualSupplier)
{
spinAssertEquals(expected, actualSupplier, 10, TimeUnit.SECONDS);