private void writeEvent(TestEvent event) { try { oos.writeObject(event); } catch (IOException exc) { throw Exceptions.unchecked(exc); } }
private void writeEvent(TestEvent event) { try { oos.writeObject(event); } catch (IOException exc) { throw Exceptions.unchecked(exc); } }
@Override public long installBundle(final String bundleLocation, final byte[] bundle) throws BundleException { LOG.trace("Install bundle [ location=" + bundleLocation + "] from byte array"); try (ByteArrayInputStream inp = new ByteArrayInputStream(bundle)) { return bundleContext.installBundle(bundleLocation, inp).getBundleId(); } catch (IOException exc) { throw Exceptions.unchecked(exc); } }
/** * Delegates the call to remote bundle context. */ @Override public Object invoke(final Object proxy, final Method method, final Object[] params) { try { return getRemoteBundleContext().remoteCall(method.getDeclaringClass(), method.getName(), method.getParameterTypes(), filter, timeout, params); } catch (InvocationTargetException exc) { throw Exceptions.unchecked(exc.getCause()); } catch (RemoteException | NoSuchMethodException | IllegalAccessException | NoSuchServiceException exc) { throw Exceptions.unchecked(exc); } } });
/** * @return * @throws IOException * @throws ExecutionException * @throws InterruptedException */ private ObjectInputStream openObjectInputStream() throws IOException { if (serverSocket != null) { Socket socket = serverSocket.accept(); return new ObjectInputStream(socket.getInputStream()); } else { try { return new ObjectInputStream(isFuture.get()); } catch (InterruptedException | ExecutionException exc) { throw Exceptions.unchecked(exc); } } }
@Override public void runTest(final TestDescription description, final TestListener listener) { ClassLoader classLoader = ctx.getBundle().adapt(BundleWiring.class).getClassLoader(); ClassLoader oldClassloader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(classLoader); runTestWithTestNG(description, listener); } // CHECKSTYLE:SKIP - doWithClassLoader API catch (Exception exc) { throw Exceptions.unchecked(exc); } finally { Thread.currentThread().setContextClassLoader(oldClassloader); } }
@Override public void delegateClassBlock(RunNotifier notifier) { TestListener listener = new JUnitTestListener(notifier); try { stagedReactor.runTest(new TestDescription(testClass.getName()), listener); } // CHECKSTYLE:SKIP : StagedExamReactor API catch (Exception exc) { throw Exceptions.unchecked(exc); } }
@Override public void delegateClassBlock(RunNotifier notifier) { TestListener listener = new JUnitTestListener(notifier); try { stagedReactor.runTest(new TestDescription(testClass.getName(), null, 0), listener); } // CHECKSTYLE:SKIP : StagedExamReactor API catch (Exception exc) { throw Exceptions.unchecked(exc); } }
@Override public void runTestClass(TestDescription description) { try { getRemoteBundleContext().remoteCall(ProbeInvoker.class, "runTestClass", new Class<?>[] { String.class }, null, rmiLookupTimeout, new Object[] { description.toString() }); } catch (RemoteException | NoSuchMethodException | IllegalAccessException | InvocationTargetException | NoSuchServiceException exc) { throw Exceptions.unchecked(exc); } } }
@Override public void delegateMethodBlock(FrameworkMethod method, RunNotifier notifier) { TestDescription description = new TestDescription(testClass.getName(), method.getName()); LOG.debug("Invoke {}", description); try { JUnitTestListener testListener = new JUnitTestListener(notifier); stagedReactor.runTest(description, testListener); } // CHECKSTYLE:SKIP : StagedExamReactor API catch (Exception e) { Throwable t = ExceptionHelper.unwind(e); throw Exceptions.unchecked(t); } }
/** * @param base the base to set * @throws InitializationError */ public void setBase(ExtensibleSuite base) throws InitializationError { this.base = base; manager = ReactorManager.getInstance(); ExamReactor reactor = manager.prepareReactor(testClass, null); try { addTestsToReactor(reactor, null); stagedReactor = manager.stageReactor(); } catch (IOException | ExamConfigurationException exc) { throw Exceptions.unchecked(exc); } }
@Override public void onBeforeClass(ITestClass testClass, IMethodInstance mi) { Object testClassInstance = mi.getInstance(); Class<?> klass = testClassInstance.getClass(); stagedReactor = stageReactorForClass(klass, testClassInstance); if (!useProbeInvoker) { manager.inject(testClassInstance); } manager.beforeClass(stagedReactor, testClassInstance); resultListener = new TestNGTestListener(); if (!restartPerMethod()) { TestDescription description = new TestDescription(testClass.getName()); try { stagedReactor.runTest(description, resultListener); } // CHECKSTYLE:SKIP - catch all wanted catch (Exception exc) { throw Exceptions.unchecked(exc); } } }
private void runSuite(OutputStream os, Class<?> clazz, String methodName, String indexName) throws IOException { InjectorFactory injectorFactory = ServiceProviderFinder .loadUniqueServiceProvider(InjectorFactory.class); injectorFactory.setContext(getServletContext()); Injector injector = injectorFactory.createInjector(); Integer index = null; if (indexName != null) { index = Integer.parseInt(indexName); } try { ParentRunner<?> runner = createRunner(clazz, injector, index); if (methodName != null) { Description method = Description.createTestDescription(clazz, methodName); runner.filter(Filter.matchMethodDescription(method)); } ObjectOutputStream oos = new ObjectOutputStream(os); JUnitCore junit = new JUnitCore(); junit.addListener(new ContainerTestListener(oos)); junit.run(runner); } catch (InitializationError | NoTestsRemainException exc) { throw Exceptions.unchecked(exc); } }
private void runTestWithJUnit(TestDescription description, TestListener listener) { try { ParentRunner<?> runner = createRunner(description); if (description.getMethodName() != null) { Description methodName = Description .createTestDescription(description.getClassName(), description.getMethodName()); runner.filter(Filter.matchMethodDescription(methodName)); } JUnitCore junit = new JUnitCore(); junit.addListener(new ProbeRunListener(listener)); junit.run(runner); } catch (InitializationError | NoTestsRemainException exc) { throw Exceptions.unchecked(exc); } }