throw new TestContainerException(e); } catch (IOException e) { throw new TestContainerException(e);
/** * FIXME What is this doing, and what is the use case? Parameterized methods break JUnit's * default behaviour, and most of these non-standard signatures introduced in 2.0.0 have been * dropped since 2.3.0. * * @param testClassInstance * @param probe * @param s * @return test address */ private TestAddress delegateTest(Object testClassInstance, TestProbeBuilder probe, FrameworkMethod s) { try { Class<?>[] types = s.getMethod().getParameterTypes(); if (types.length == 1 && types[0].isAssignableFrom(TestProbeBuilder.class)) { // do some backtracking: return (TestAddress) s.getMethod().invoke(testClassInstance, probe); } else { return null; } } // CHECKSTYLE:SKIP : catch all wanted catch (Throwable e) { throw new TestContainerException("Problem delegating to test.", e); } }
private Exception parametersMethodReturnedWrongType() throws Exception { String className = getTestClass().getName(); String methodName = getParametersMethod().getName(); String message = MessageFormat.format("{0}.{1}() must return an Iterable of arrays.", className, methodName); return new TestContainerException(message); }
private void sendEvent(TestEvent event) { try { oos.writeObject(event); } catch (IOException exc) { throw new TestContainerException(exc); } }
private Class<?> loadClass(String className) { try { return ctx.getBundle().loadClass(className); } catch (ClassNotFoundException e) { throw new TestContainerException(e); } }
private void addToClasspath(List<String> toAdd, List<String> classpath) { if (toAdd == null) { return; } for (String path : toAdd) { if (!new File(path).exists()) { throw new TestContainerException("Invalid boot classpath library: " + path); } classpath.add(path); } }
public void call(Object... args) { if (!(findAndInvoke(args))) { throw new TestContainerException(" Test " + method + " not found in test class " + testClass.getName()); } }
@Override protected void after() { try { testContainer.stop(); } catch (IOException e) { throw new TestContainerException(e); } }
private void deployModule(UrlDeploymentOption option) { try { URL applUrl = new URL(option.getURL()); deployModule(option.getName(), applUrl.openStream()); } catch (MalformedURLException exc) { throw new TestContainerException("Problem deploying " + option, exc); } catch (IOException exc) { throw new TestContainerException("Problem deploying " + option, exc); } }
private void verifyThatBundlesAreResolved() { boolean hasUnresolvedBundles = Arrays.stream(framework.getBundleContext().getBundles()) .filter(b -> b.getState() == INSTALLED) .peek(b -> LOG.error("Bundle [{}] is not resolved", b)).count() > 0; ConfigurationManager cm = new ConfigurationManager(); boolean failOnUnresolved = Boolean.parseBoolean(cm.getProperty(EXAM_FAIL_ON_UNRESOLVED_KEY, "false")); if (hasUnresolvedBundles && failOnUnresolved) { throw new TestContainerException( "There are unresolved bundles. See previous ERROR log messages for details."); } }
@Override public synchronized void uninstallProbe() { Bundle bundle = framework.getBundleContext().getBundle(probeId); try { bundle.uninstall(); probeId = null; } catch (BundleException exc) { throw new TestContainerException(exc); } } }
public WarProbeOption getLatestWarProbeOption() { try { return subsystems.peek().getOption(WarProbeOption.class); } catch (ExamConfigurationException e) { throw new TestContainerException(e.getMessage(), e); } } }
/** * Undeploys all modules and shuts down the GlassFish runtime. */ public synchronized void cleanup() { undeployModules(); try { glassFish.stop(); } catch (GlassFishException exc) { throw new TestContainerException(exc); } }
/** * Creates exception for test failure and makes sure it is serializable. * @param message * @param ex * @return serializable exception */ private TestContainerException createTestContainerException(String message, Throwable ex) { return isSerializable(ex) ? new TestContainerException(message, ex) : new WrappedTestContainerException(message, ex); }
@Override public TestContainer create(ExamSystem system) { FrameworkFactory frameworkFactory = ServiceProviderFinder .loadUniqueServiceProvider(FrameworkFactory.class); try { return new NativeTestContainer(system, frameworkFactory); } catch (IOException exc) { throw new TestContainerException("Problem initializing container.", exc); } } }
@Override public void runTestClass(String description) { try (Socket socket = new Socket(InetAddress.getLocalHost(), getPort())) { ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream()); OutputStreamTestListener streamListener = new OutputStreamTestListener(oos); runTestWithJUnit(TestDescription.parse(description), streamListener); } catch (IOException exc) { new TestContainerException(exc); } }
private void deployModule(UrlDeploymentOption option) { try { URL applUrl = new URL(option.getURL()); deployModule(option.getName(), applUrl.openStream()); } catch (IOException exc) { throw new TestContainerException("Problem deploying " + option, exc); } }
public void cleanup() { undeployModules(); LOG.info("stopping Tomcat"); try { tomcat.stop(); tomcat.destroy(); } catch (LifecycleException exc) { throw new TestContainerException(exc); } }
@Override public void runTest(TestDescription description, TestListener listener) throws InterruptedException { long serviceTimeout = determineExamServiceTimeout(); ProbeInvoker probeInvokerService = probeInvoker.waitForService(serviceTimeout); if (probeInvokerService == null) { throw new TestContainerException( "can't fetch ProbeInvoker within " + serviceTimeout + "ms"); } probeInvokerService.runTest(description, listener); }
@Override public TestProbeProvider build() { try { TinyBundle bundle = prepareProbeBundle(createExtraIgnores()); return new DefaultTestProbeProvider(store, store.store(bundle.build(withClassicBuilder()))); } catch (IOException e) { throw new TestContainerException(e); } }