use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class AsyncContextTest method testStartFlushCompleteThrow.
@Test
public void testStartFlushCompleteThrow() throws Exception {
try (StacklessLogging stackless = new StacklessLogging(HttpChannel.class)) {
String request = "GET /ctx/startthrow?flush=true&complete=true HTTP/1.1\r\n" + "Host: localhost\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Connection: close\r\n" + "\r\n";
String responseString = _connector.getResponses(request);
BufferedReader br = new BufferedReader(new StringReader(responseString));
assertEquals("HTTP/1.1 200 OK", br.readLine());
readHeader(br);
Assert.assertEquals("error servlet", "completeBeforeThrow", br.readLine());
}
}
use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class SslContextFactoryTest method testNoKeyConfig.
@Test
public void testNoKeyConfig() throws Exception {
try (StacklessLogging stackless = new StacklessLogging(AbstractLifeCycle.class)) {
cf.setTrustStorePath("/foo");
cf.start();
Assert.fail();
} catch (IllegalStateException e) {
Assert.assertThat(e.toString(), Matchers.containsString("IllegalStateException: no valid keystore"));
}
}
use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class SchedulerTest method testTaskThrowsException.
@Test
public void testTaskThrowsException() throws Exception {
try (StacklessLogging stackless = new StacklessLogging(TimerScheduler.class)) {
long delay = 500;
_scheduler.schedule(new Runnable() {
@Override
public void run() {
throw new RuntimeException("Thrown by testTaskThrowsException");
}
}, delay, TimeUnit.MILLISECONDS);
TimeUnit.MILLISECONDS.sleep(2 * delay);
// Check whether after a task throwing an exception, the scheduler is still working
final CountDownLatch latch = new CountDownLatch(1);
_scheduler.schedule(new Runnable() {
@Override
public void run() {
latch.countDown();
}
}, delay, TimeUnit.MILLISECONDS);
Assert.assertTrue(latch.await(2 * delay, TimeUnit.MILLISECONDS));
}
}
use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class SweeperTest method testSweepThrows.
@Test
public void testSweepThrows() throws Exception {
try (StacklessLogging scope = new StacklessLogging(Sweeper.class)) {
long period = 500;
final CountDownLatch taskLatch = new CountDownLatch(2);
Sweeper sweeper = new Sweeper(scheduler, period) {
@Override
public void run() {
super.run();
taskLatch.countDown();
}
};
sweeper.start();
final CountDownLatch sweepLatch = new CountDownLatch(2);
sweeper.offer(new Sweeper.Sweepable() {
@Override
public boolean sweep() {
sweepLatch.countDown();
throw new NullPointerException("Test exception!");
}
});
Assert.assertTrue(sweepLatch.await(4 * period, TimeUnit.MILLISECONDS));
Assert.assertTrue(taskLatch.await(4 * period, TimeUnit.MILLISECONDS));
Assert.assertEquals(1, sweeper.getSize());
sweeper.stop();
}
}
use of org.eclipse.jetty.util.log.StacklessLogging in project jetty.project by eclipse.
the class SslContextFactoryTest method testResourceTsResourceKsWrongPW.
@Test
public void testResourceTsResourceKsWrongPW() throws Exception {
Resource keystoreResource = Resource.newSystemResource("keystore");
Resource truststoreResource = Resource.newSystemResource("keystore");
cf.setKeyStoreResource(keystoreResource);
cf.setTrustStoreResource(truststoreResource);
cf.setKeyStorePassword("storepwd");
cf.setKeyManagerPassword("wrong_keypwd");
cf.setTrustStorePassword("storepwd");
try (StacklessLogging stackless = new StacklessLogging(AbstractLifeCycle.class)) {
cf.start();
Assert.fail();
} catch (java.security.UnrecoverableKeyException e) {
Assert.assertThat(e.toString(), Matchers.containsString("UnrecoverableKeyException"));
}
}
Aggregations