static boolean isClassPresent(String name) { try { loadClass(name); return true; } catch (Exception e) { return false; } }
@Override public <T> LoadableExtension.ExtensionBuilder service(Class<T> service, Class<? extends T> impl) { if (Builder.class.isAssignableFrom(service)) { BuilderRegistry.addServiceToBuilderRegistry(service, impl); } return this; }
static Class<?> loadClass(String className) { try { return Class.forName(className, true, getThreadContextClassLoader()); } catch (ClassNotFoundException e) { try { return Class.forName(className, true, SecurityActions.class.getClassLoader()); } catch (ClassNotFoundException e2) { throw new RuntimeException("Could not load class " + className, e2); } } }
public void reportDockerEnvironment(@Observes AfterAutoStart event, CubeDockerConfiguration cubeDockerConfiguration, DockerClientExecutor executor, ReporterConfiguration reporterConfiguration) { final ReportBuilder reportBuilder = Reporter.createReport(DOCKER_ENVIRONMENT) .addReport(createDockerInfoGroup(executor)); reportBuilder.addKeyValueEntry(DOCKER_COMPOSITION_SCHEMA, createDockerCompositionSchema(cubeDockerConfiguration, reporterConfiguration)); reportBuilder.addKeyValueEntry(NETWORK_TOPOLOGY_SCHEMA, createNetworkTopologyGraph(cubeDockerConfiguration, executor, reporterConfiguration)); reportBuilder .inSection(DockerContainerSection.standalone()) .fire(reportEvent); }
public void reportKubernetesConfiguration(@Observes Start start, Configuration configuration, org.arquillian.reporter.config.ReporterConfiguration reporterConfiguration) throws IOException { final ReportBuilder reportBuilder = Reporter.createReport(CONFIGURATION); Session session = start.getSession(); if (configuration != null) { reportBuilder.addEntries(getFilesForResourcesConfiguration(session, configuration, reporterConfiguration)); } Reporter.createReport(KUBERNETES_SECTION_NAME) .addReport(reportBuilder) .inSection(new KubernetesSection()).fire(sectionEvent); }
.contains(dockerCube.state()); final ReportBuilder reportBuilder = Reporter.createReport(DOCKER_CONTAINER_CONFIGURATION) .addKeyValueEntry(CONTAINER_NAME, dockerCube.getId()) .addKeyValueEntry(ERROR_DURING_LIFECYCLE, Boolean.toString(error)) .addKeyValueEntry(STARTING_TIME, String.format("%s ms", dockerCube.getStartingTimeInMillis())) .addKeyValueEntry(STOPPING_TIME, String.format("%s ms", dockerCube.getStoppingTimeInMillis())); reportBuilder.addKeyValueEntry(IMAGE_NAME, configuration.getImage().toString()); } else { reportBuilder.addKeyValueEntry(BUILD_LOCATION, configuration.getBuildImage().getDockerfileLocation()); reportBuilder.addKeyValueEntry(EXPOSED_PORTS, configuration.getExposedPorts().toString()); reportBuilder.addKeyValueEntry(PORT_BINDING, configuration.getPortBindings().toString()); reportBuilder.addKeyValueEntry(LINKS, configuration.getLinks().toString()); reportBuilder.addKeyValueEntry(VOLUMES, configuration.getVolumes().toString()); reportBuilder.addKeyValueEntry(BINDS, configuration.getBinds().toString()); reportBuilder.addKeyValueEntry(ENTRY_POINT, configuration.getEntryPoint().toString()); reportBuilder.addKeyValueEntry(NETWORK_MODE, configuration.getNetworkMode()); return reportBuilder.inSection(new DockerContainerSection(dockerCube.getId()));
public void reportScreencastRecording(@Observes AfterVideoRecorded event, ReporterConfiguration reporterConfiguration) { Path videoLocation = event.getVideoLocation(); if (videoLocation != null) { videoLocation = Paths.get(videoLocation.toString().replace("flv", "mp4")); final Path rootDir = Paths.get(reporterConfiguration.getRootDirectory()); final Path relativize = rootDir.relativize(videoLocation); final Method testMethod = getTestMethod(event); Reporter.createReport(new TestMethodReport(testMethod.getName())) .addKeyValueEntry(DockerEnvironmentReportKey.VIDEO_PATH, new FileEntry(relativize)) .inSection(new TestMethodSection(testMethod)) .fire(reportEvent); } }
private ReportBuilder createDockerInfoGroup(DockerClientExecutor executor) { Version version = executor.dockerHostVersion(); final ReportBuilder reportBuilder = Reporter.createReport(DOCKER_HOST_INFORMATION) .addKeyValueEntry(DOCKER_VERSION, version.getVersion()) .addKeyValueEntry(DOCKER_OS, version.getOperatingSystem()) .addKeyValueEntry(DOCKER_KERNEL, version.getKernelVersion()) .addKeyValueEntry(DOCKER_API_VERSION, version.getApiVersion()) .addKeyValueEntry(DOCKER_ARCH, version.getArch()); return reportBuilder; }
@Before public void setUp() { BuilderLoader.load(); }
public TestMethodReportBuilderImpl setResult(TestResult result) { if (result.getStatus() == TestResult.Status.FAILED && result.getThrowable() != null) { String stackTrace = getStackTrace(result.getThrowable()); FailureReport failureReport = new FailureReport(METHOD_FAILURE_REPORT); Reporter.createReport(failureReport).addKeyValueEntry(METHOD_FAILURE_REPORT_STACKTRACE, stackTrace); getReport().setFailureReport(failureReport); } getReport().setStatus(result.getStatus()); return this; }
ExtensionLoader extensionLoader = locateExtensionLoader(new JavaSPIExtensionLoader()); Collection<LoadableExtension> extensions = extensionLoader.load();
public void reportSessionStatus(@Observes AfterStart afterStart, KubernetesClient kubernetesClient) { Session session = afterStart.getSession(); if (session != null) { String namespace = session.getNamespace(); Reporter.createReport(SESSION_STATUS) .addKeyValueEntry(NAMESPACE, namespace) .addKeyValueEntry(MASTER_URL, String.valueOf(kubernetesClient.getMasterUrl())) .inSection(new KubernetesSection()) .asSubReport() .fire(sectionEvent); } } /*
public void reportKubernetesConfiguration(@Observes Start start, Configuration configuration, org.arquillian.reporter.config.ReporterConfiguration reporterConfiguration) throws IOException { final ReportBuilder reportBuilder = Reporter.createReport(CONFIGURATION); Session session = start.getSession(); if (configuration != null) { reportBuilder.addEntries(getFilesForResourcesConfiguration(session, configuration, reporterConfiguration)); } Reporter.createReport(KUBERNETES_SECTION_NAME) .addReport(reportBuilder) .inSection(new KubernetesSection()).fire(sectionEvent); }
@Before public void setUp() { BuilderLoader.load(); }
/** * Some environments need to handle their own ExtensionLoading and can't rely on Java's META-INF/services approach. * * @return configured ExtensionLoader if found or defaults to JavaSPIServiceLoader */ private static ExtensionLoader locateExtensionLoader(JavaSPIExtensionLoader serviceLoader) { Collection<ExtensionLoader> loaders = Collections.emptyList(); if (SecurityActions.getThreadContextClassLoader() != null) { loaders = serviceLoader.all(SecurityActions.getThreadContextClassLoader(), ExtensionLoader.class); } if (loaders.size() == 0) { loaders = serviceLoader.all(LoadableExtensionLoader.class.getClassLoader(), ExtensionLoader.class); } if (loaders.size() == 1) { return loaders.iterator().next(); } return serviceLoader; } }
public void reportSessionStatus(@Observes AfterStart afterStart, KubernetesClient kubernetesClient) { Session session = afterStart.getSession(); if (session != null) { String namespace = session.getNamespace(); Reporter.createReport(SESSION_STATUS) .addKeyValueEntry(NAMESPACE, namespace) .addKeyValueEntry(MASTER_URL, String.valueOf(kubernetesClient.getMasterUrl())) .inSection(new KubernetesSection()) .asSubReport() .fire(sectionEvent); } } /*
@Before public void setUpCubeDockerExecutorAndBuilder() throws IOException { configureDockerExecutor(); configureCube(); BuilderLoader.load(); }
public void reportContainerLogs(@Observes org.arquillian.cube.spi.event.lifecycle.BeforeStop beforeStop, DockerClientExecutor executor, ReporterConfiguration reporterConfiguration) throws IOException { final String cubeId = beforeStop.getCubeId(); if (cubeId != null) { final File logFile = new File(createContainerLogDirectory(new File(reporterConfiguration.getRootDirectory())), cubeId + ".log"); final Path rootDir = Paths.get(reporterConfiguration.getRootDirectory()); final Path relativePath = rootDir.relativize(logFile.toPath()); executor.copyLog(beforeStop.getCubeId(), false, true, true, true, -1, new FileOutputStream(logFile)); Reporter.createReport() .addKeyValueEntry(LOG_PATH, new FileEntry(relativePath)) .inSection(new DockerContainerSection(cubeId)) .fire(reportEvent); } }
public void observeFirstEvent(@Observes(precedence = 100) ManagerStarted event) { if (report.get() == null) { ExecutionReport executionReport = new ExecutionReport(); report.set(executionReport); BuilderLoader.load(); Collection<StringKey> allStringKeys = serviceLoader.get().all(StringKey.class); allStringKeys.forEach(StringKeysBuilder::buildStringKey); } }
@Override public Response filter(FilterableRequestSpecification requestSpec, FilterableResponseSpecification responseSpec, FilterContext ctx) { final Response response = ctx.next(requestSpec, responseSpec); final ByteArrayOutputStream responseLog = new ByteArrayOutputStream(); final PrintStream stream = new PrintStream(responseLog); ResponsePrinter.print(response, response, stream, LogDetail.ALL, true); final File logFile = new File(createLogDirectory(new File(reporterConfiguration.getRootDirectory())), "restassuredResponse.log"); writeContent(responseLog, logFile); final Path rootDir = Paths.get(reporterConfiguration.getRootDirectory()); final Path relativePath = rootDir.relativize(logFile.toPath()); Reporter.createReport(REST_RESPONSE_LOG) .addKeyValueEntry(LOG_PATH, new FileEntry(relativePath)) .inSection(new DockerLogSection()) .fire(reportEvent); final byte[] responseBody = response.asByteArray(); return cloneResponseIfNeeded(response, responseBody); }