public ShellResponse getResponse() { try { latch.await(60, TimeUnit.SECONDS); return response; } catch (InterruptedException e) { throw AbstractTestCase.failure(e); } } }
public static File assertTmpFile(String ext) { File tmp; try { tmp = File.createTempFile("crash", ext); } catch (IOException e) { throw failure("Could not create temporary file", e); } return tmp; }
public void cancel() { try { syncB.await(); } catch (Exception e) { throw failure(e); } } });
public static void assertJoin(Thread thread, long timeMillis) { long before = System.currentTimeMillis(); try { thread.join(timeMillis); } catch (InterruptedException e) { throw failure(e); } long after = System.currentTimeMillis(); if (after - before >= timeMillis) { throw failure("Join failed"); } }
@Override public void run(String request, ShellProcessContext context) throws Exception { try { syncA.await(); syncB.await(); } catch (Exception e) { throw failure(e); } }
public static <T> T assertType(Class<T> expectedType, Object o) { if (o == null) { throw failure("Was expecting the object " + o + " to not be null"); } else if (o.getClass().equals(expectedType)) { return expectedType.cast(o); } else { throw failure("Was expecting the object " + o + " to be an instance of " + expectedType.getName()); } }
public void publish(final Callable<TermEvent> event) { synchronized (lock) { if (closed) { throw AbstractTestCase.failure("closed"); } queue.addLast(event); lock.notifyAll(); } }
public static <T> T assertInstance(Class<T> expectedType, Object o) { if (expectedType.isInstance(o)) { return expectedType.cast(o); } else { throw failure("Was expecting the object " + o + " to be an instance of " + expectedType.getName()); } }
@Override public void execute(ShellProcessContext processContext) throws IllegalStateException { try { runnable.run(request, processContext); } catch (Exception e) { throw AbstractTestCase.failure(e); } } @Override
public static File toExploded(Archive archive, String ext) { File tmp = assertTmpFile(ext); if (tmp.delete()) { ExplodedExporter exporter = archive.as(ExplodedExporter.class); exporter.exportExploded(tmp.getParentFile(), tmp.getName()); tmp.deleteOnExit(); return tmp; } else { throw failure("Could not delete tmp file " + tmp.getAbsolutePath()); } } }
throw AbstractTestCase.failure(e);
public static void assertEndsWith(String suffix, String test) { assertNotNull(test); assertNotNull(suffix); if (!test.endsWith(suffix)) { throw failure("Was expected " + test + " to end with " + suffix); } }
public static File toFile(Archive archive, String ext) { File tmp = assertTmpFile(ext); if (tmp.delete()) { ZipExporter exporter = archive.as(ZipExporter.class); exporter.exportTo(tmp); tmp.deleteOnExit(); return tmp; } else { throw failure("Could not delete tmp file " + tmp.getAbsolutePath()); } }
throw AbstractTestCase.failure(e);