本文整理汇总了Java中org.jboss.arquillian.core.api.annotation.Observes类的典型用法代码示例。如果您正苦于以下问题:Java Observes类的具体用法?Java Observes怎么用?Java Observes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Observes类属于org.jboss.arquillian.core.api.annotation包,在下文中一共展示了Observes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTestSuite
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void startTestSuite(@Observes(precedence = Integer.MAX_VALUE) BeforeSuite managerProcessing) {
Reporter
.createReport(new TestSuiteReport(TEST_SUITE_NAME))
.inSection(new TestSuiteSection(DEFAULT_TEST_SUITE_ID))
.fire(sectionEvent);
// todo differentiate between loaded extensions and configs that are in arquillian.xml
// ReportBuilder extensionsReport = Reporter.createReport(new ConfigurationReport("Loaded extensions"));
// for (ExtensionDef extensionDef : descriptor.get().getExtensions()) {
// ReportBuilder extBuilder = Reporter
// .createReport(extensionDef.getExtensionName())
// .feedKeyValueListFromMap(extensionDef.getExtensionProperties());
// extensionsReport.addReport(extBuilder);
// }
// extensionsReport
// .inSection(new TestSuiteConfigurationSection("loaded-extension"))
// .fire(sectionEvent);
}
示例2: startTestClass
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void startTestClass(@Observes(precedence = Integer.MAX_VALUE) BeforeClass event) {
TestClass testClass = event.getTestClass();
boolean runAsClient = event.getTestClass().isAnnotationPresent(RunAsClient.class);
TestClassReport testClassReport = new TestClassReport(testClass.getName());
Reporter
.createReport(new ConfigurationReport(TEST_CLASS_CONFIGURATION))
.addKeyValueEntry(CLASS_RUNS_AS_CLIENT, runAsClient);
String reportMessage = ReportMessageParser.parseTestClassReportMessage(event.getTestClass().getJavaClass());
Reporter
.createReport(testClassReport)
.addKeyValueEntry(TEST_CLASS_REPORT_MESSAGE, reportMessage)
.inSection(new TestClassSection(testClass.getJavaClass(), DEFAULT_TEST_SUITE_ID))
.fire(sectionEvent);
}
示例3: startTestMethod
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void startTestMethod(@Observes(precedence = Integer.MAX_VALUE) Before event) {
Method testMethod = event.getTestMethod();
boolean runAsClient = event.getTestMethod().isAnnotationPresent(RunAsClient.class);
String deploymentName = "_DEFAULT_";
if (event.getTestMethod().isAnnotationPresent(OperateOnDeployment.class)) {
deploymentName = event.getTestMethod().getAnnotation(OperateOnDeployment.class).value();
}
Reporter
.createReport(new TestMethodReport(testMethod.getName()))
.addKeyValueEntry(TEST_METHOD_OPERATES_ON_DEPLOYMENT, deploymentName)
.addKeyValueEntry(TEST_METHOD_RUNS_AS_CLIENT, runAsClient)
.inSection(new TestMethodSection(testMethod))
.fire(sectionEvent);
}
示例4: stopNodesAndContainersForClass
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
/**
* Destroys test class level WildFly containers (and related Nodes) in test classes annotated with {@link WithWildFlyContainer}.
*/
public void stopNodesAndContainersForClass(@Observes StopClassContainers event, TestClass testClass, ContainerRegistry registry,
CloudsRegistry cloudProviderRegistry) throws Exception {
final Set<String> nodeNames = new HashSet<>();
WithNode[] withNodes = testClass.getJavaClass().getAnnotationsByType(WithNode.class);
if (withNodes != null) {
Arrays.stream(withNodes).forEach(wn -> nodeNames.add(wn.value()));
}
WithWildFlyContainer[] containers = testClass.getJavaClass().getAnnotationsByType(WithWildFlyContainer.class);
if (containers != null) {
for (WithWildFlyContainer wflyContainer : containers) {
final String nodeName = wflyContainer.value();
nodeNames.add(nodeName);
LOGGER.debug("Removing WildFly container configuration for class level node '{}'", nodeName);
cloudProviderRegistry.stopWildFlyContainerInRegistry(nodeName, registry, containerContext.get());
}
}
cloudProviderRegistry.cleanupNodes(node->nodeNames.contains(node.getName()));
}
示例5: stopNodesForSuite
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
/**
* Removes nodes created on suite level and destroys provider listed in "arquillian.suite.destroy.providers" cloud property.
*/
public void stopNodesForSuite(@Observes AfterSuite event, ContainerRegistry registry, CloudsRegistry cloudsRegistry)
throws LifecycleException {
try {
final Set<String> nodeNameSet = new HashSet<>();
processSuiteLeveNodes(nodeProperties -> {
LOGGER.debug("WildFly container {} will be destroyed", nodeProperties.getName());
nodeNameSet.add(nodeProperties.getName());
if (nodeProperties.getPropertyAsBoolean(ArquillianConfig.Node.CONTAINER_REGISTER, false)) {
try {
cloudsRegistry.stopWildFlyContainerInRegistry(nodeProperties.getName(), registry,
containerContext.get());
} catch (Exception e) {
throw new RuntimeException("Stopping WildFly container failed", e);
}
}
});
cloudsRegistry.cleanupNodes(node -> nodeNameSet.contains(node.getName()));
} finally {
iterateSuiteCsvProperty(ArquillianConfig.Suite.DESTROY_PROVIDERS, cloudsRegistry::destroyProvider);
}
}
示例6: publish
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void publish(@Observes AfterClass event, AlgeronConsumerConfiguration algeronConsumerConfiguration)
throws IOException {
if (algeronConsumerConfiguration.isPublishContracts()
&& algeronConsumerConfiguration.isPublishConfigurationSet()) {
final Map<String, Object> publishConfiguration = algeronConsumerConfiguration.getPublishConfiguration();
if (publishConfiguration.containsKey(PROVIDER)) {
final String providerName = (String) publishConfiguration.get(PROVIDER);
final org.arquillian.algeron.consumer.spi.publisher.ContractsPublisher contractsPublisher =
getContractPublisher(providerName);
contractsPublisher.configure(publishConfiguration);
contractsPublisher.publish();
} else {
logger.log(Level.WARNING, String.format(
"Publishing contracts are enabled, but configuration is not providing a %s property with provider name to be used.",
PROVIDER));
}
}
}
示例7: testPact
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void testPact(@Observes EventContext<Test> testEventContext) throws Throwable {
final Test event = testEventContext.getEvent();
final TestClass testClass = event.getTestClass();
final PactVerification pactVerification = event.getTestMethod().getAnnotation(PactVerification.class);
if (pactVerification == null) {
logger.log(Level.INFO,
String.format(
"Method %s is not annotated with %s annotation and it is going to be executed as normal junit test.",
event.getTestMethod().getName(), PactVerification.class.getName()));
testEventContext.proceed();
return;
}
executeConsumerTest(testEventContext, testClass, pactVerification);
}
示例8: storePactData
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void storePactData(@Observes PactFilesCommand pactFilesCommand) {
try {
final String name = pactFilesCommand.getName();
final byte[] content = pactFilesCommand.getContent();
File output = new File(getDestination(), name);
Files.write(output.toPath(), content);
pactFilesCommand.setResult("SUCCESS");
} catch (Exception e) {
pactFilesCommand.setResult("FAILURE");
pactFilesCommand.setThrowable(e);
}
}
示例9: testPact
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void testPact(@Observes(precedence = -50) EventContext<Test> testEventContext, Deployment deployment)
throws Throwable {
final Test event = testEventContext.getEvent();
final TestClass testClass = event.getTestClass();
// We need to check this because in case of embedded containers this class is executed too
if (RunModeUtils.isRunAsClient(deployment, testClass, event.getTestMethod())) {
final PactVerification pactVerification = event.getTestMethod().getAnnotation(PactVerification.class);
if (pactVerification == null) {
logger.log(Level.INFO,
String.format(
"Method %s is not annotated with %s annotation and it is going to be executed as normal junit test.",
event.getTestMethod().getName(), PactVerification.class.getName()));
testEventContext.proceed();
return;
}
executeConsumerTest(testEventContext, testClass, pactVerification);
} else {
// We are in container and this class is executed in client side so we should only pass the execution and incontainer class will do the job
testEventContext.proceed();
}
}
示例10: testPact
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void testPact(@Observes(precedence = -50) EventContext<Test> testEventContext) throws Throwable {
final Test event = testEventContext.getEvent();
final TestClass testClass = event.getTestClass();
final PactVerification pactVerification = event.getTestMethod().getAnnotation(PactVerification.class);
if (pactVerification == null) {
logger.log(Level.INFO,
String.format(
"Method %s is not annotated with %s annotation and it is going to be executed as normal junit test.",
event.getTestMethod().getName(), PactVerification.class.getName()));
testEventContext.proceed();
return;
}
final ConsumerProviderPair consumerProviderPair =
executeConsumerTest(testEventContext, testClass, pactVerification);
// Send results back to client
final String filename = getFilename(consumerProviderPair);
final byte[] content = loadPact(filename);
getCommandService().execute(new PactFilesCommand(filename, content));
}
示例11: create
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void create(@Observes PactProviderConfiguration pactProviderConfiguration) {
HttpTarget httpTarget;
if (pactProviderConfiguration.isTargetUrlSet()) {
httpTarget = new HttpTarget(pactProviderConfiguration.getTargetUrl(), pactProviderConfiguration.isInsecure());
} else {
httpTarget = new HttpTarget(
pactProviderConfiguration.getProtocol(),
pactProviderConfiguration.getHost(),
pactProviderConfiguration.getPort(),
pactProviderConfiguration.getPath(),
pactProviderConfiguration.isInsecure()
);
}
httpTarget.setInjector(injectorInstance.get());
targetInstanceProducer.set(httpTarget);
}
示例12: generate
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
@SuppressWarnings({"unused", "unchecked"})
public void generate(@Observes(precedence = 100) final GenerateDeployment event) throws Exception {
final Class testClass = event.getTestClass().getJavaClass();
this.container.setTestClass(testClass);
final List<Method> annotatedMethods = Stream.of(testClass.getDeclaredMethods())
.filter(m -> m.isAnnotationPresent(ArtifactDependencies.class))
.collect(Collectors.toList());
if (annotatedMethods.size() > 1) {
throw new IllegalArgumentException("Too many methods annotated with " + ArtifactDependencies.class.getName());
}
if (annotatedMethods.size() == 1) {
final Method dependencyMethod = annotatedMethods.get(0);
dependencyMethod.setAccessible(true);
validate(dependencyMethod);
this.container.setRequestedMavenArtifacts((List<String>) dependencyMethod.invoke(null));
}
}
示例13: start
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void start(@Observes final EventContext<ManagerStarted> starting) {
starting.proceed();
final ArquillianDescriptor descriptor = getDescriptorInstance();
Thread adocThread = new Thread(new Runnable() {
@Override
public void run() {
try {
long initialTime = System.currentTimeMillis();
initAsciidoctor(descriptor);
getLogger().info(String.format("Asciidoctor successfully initialized in %s milliseconds", System.currentTimeMillis() - initialTime));
}catch (Exception e){
getLogger().log(Level.SEVERE, "Could not initilize Asciidoctor instance", e);
}
}
}, "arquillian-asciidoctor-thread");
adocThread.setDaemon(true);
adocThread.start();
}
示例14: waitForDeployments
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
/**
* Wait for the template resources to come up after the test container has
* been started. This allows the test container and the template resources
* to come up in parallel.
*/
public void waitForDeployments(@Observes(precedence = -100) AfterStart event, OpenShiftAdapter client, TemplateDetails details, TestClass testClass, CECubeConfiguration configuration, OpenShiftClient openshiftClient) throws Exception {
if (testClass == null) {
// nothing to do, since we're not in ClassScoped context
return;
}
if (details == null) {
log.warning(String.format("No environment for %s", testClass.getName()));
return;
}
log.info(String.format("Waiting for environment for %s", testClass.getName()));
try {
for (List<? extends OpenShiftResource> resources : details.getResources()) {
delay(client, resources);
}
} catch (Throwable t) {
logEvents(openshiftClient, configuration);
throw new DeploymentException("Error waiting for template resources to deploy: " + testClass.getName(), t);
}
}
示例15: install
import org.jboss.arquillian.core.api.annotation.Observes; //导入依赖的package包/类
public void install(@Observes(precedence = 100) CubeDockerConfiguration configuration) {
DockerCompositions cubes = configuration.getDockerContainersContent();
ProxyManager installer = serviceLoaderInst.get().onlyOne(ProxyManager.class);
if (installer != null) {
Proxy proxy = installer.install(cubes);
proxyInst.set(proxy);
final CubeContainer cube = proxy.getCube();
cubes.add(proxy.getName(), cube);
System.out.println("PROXY INSTALLED");
System.out.println(ConfigUtil.dump(cubes));
}
}