本文整理汇总了Java中org.jboss.arquillian.container.spi.Container类的典型用法代码示例。如果您正苦于以下问题:Java Container类的具体用法?Java Container怎么用?Java Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Container类属于org.jboss.arquillian.container.spi包,在下文中一共展示了Container类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureArquillianForRemoteWildfly
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
private void configureArquillianForRemoteWildfly(GenericContainer dockerContainer, ContainerRegistry registry) {
Integer wildflyHttpPort = dockerContainer.getMappedPort(WILDFLY_HTTP_PORT);
Integer wildflyManagementPort = dockerContainer.getMappedPort(WILDFLY_MANAGEMENT_PORT);
String containerIpAddress = dockerContainer.getContainerIpAddress();
Container arquillianContainer = registry.getContainers().iterator().next();
ContainerDef containerConfiguration = arquillianContainer.getContainerConfiguration();
containerConfiguration.property(ContainerConfiguration.MANAGEMENT_ADDRESS_KEY, containerIpAddress);
containerConfiguration.property(ContainerConfiguration.MANAGEMENT_PORT_KEY,
String.valueOf(wildflyManagementPort));
containerConfiguration.property(ContainerConfiguration.USERNAME_KEY, "admin");
containerConfiguration.property(ContainerConfiguration.PASSWORD_KEY, "Admin#007");
ProtocolDef protocolConfiguration = arquillianContainer
.getProtocolConfiguration(new ProtocolDescription(ServletProtocolDefinition.NAME));
protocolConfiguration.property(ServletProtocolDefinition.HOST_KEY, containerIpAddress);
protocolConfiguration.property(ServletProtocolDefinition.PORT_KEY, String.valueOf(wildflyHttpPort));
}
示例2: doLookup
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
@Override
public Object doLookup(ArquillianResource resource, Annotation... qualifiers) {
Container container = containerInst.get();
if (container == null) {
throw new IllegalStateException("No Container found in context, can't perform CubeID injection");
}
CubeRegistry cubeRegistry = cubeRegistryInst.get();
if (cubeRegistry == null) {
throw new IllegalStateException("No CubeRegistry found in context, can't perform CubeID injection");
}
Cube<?> cube = cubeRegistry.getCube(ContainerUtil.getCubeIDForContainer(container));
if (cube == null) {
throw new IllegalStateException(
String.format("No Cube found mapped to current Container[%s] with CubeID[%s]", container.getName(),
ContainerUtil.getCubeIDForContainer(container)));
}
return new CubeID(cube.getId());
}
示例3: stopCubeMappedContainer
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
public void stopCubeMappedContainer(@Observes AfterStop event, CubeRegistry cubeRegistry,
ContainerRegistry containerRegistry) {
Container container = ContainerUtil.getContainerByDeployableContainer(containerRegistry,
event.getDeployableContainer());
if (container == null) {
return;
}
Cube<?> cube = cubeRegistry.getCube(ContainerUtil.getCubeIDForContainer(container));
if (cube == null) {
return; // No Cube found matching Container name, not managed by Cube
}
controlEvent.fire(new StopCube(cube));
controlEvent.fire(new DestroyCube(cube));
}
示例4: getCubeID
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
public void getCubeID(@Observes CubeIDCommand command) {
Container container = containerInst.get();
if (container == null) {
throw new IllegalStateException("No Container found in context, can't perform CubeID injection");
}
CubeRegistry cubeRegistry = cubeRegistryInst.get();
if (cubeRegistry == null) {
throw new IllegalStateException("No CubeRegistry found in context, can't perform CubeID injection");
}
Cube<?> cube = cubeRegistry.getCube(ContainerUtil.getCubeIDForContainer(container));
if (cube == null) {
throw new IllegalStateException(
String.format("No Cube found mapped to current Container[%s] with CubeID[%s]", container.getName(),
ContainerUtil.getCubeIDForContainer(container)));
}
command.setResult(cube.getId());
}
示例5: shouldUpdateWithPortFromDocker
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
@Test // equal ip, different ports
public void shouldUpdateWithPortFromDocker() throws Exception {
Binding binding = new Binding(LOCALHOST);
binding.addPortBinding(EXPOSED_PORT, BOUND_PORT);
Mockito.when(cube.getMetadata(HasPortBindings.class)).thenReturn(new TestPortBindings(binding));
bind(ContainerScoped.class,
Container.class,
new ContainerImpl(CUBE_CONTAINER_NAME, deployableContainer, new ContainerDefImpl("arquillian.xml")));
ProtocolMetaData metadata = new ProtocolMetaData();
metadata.addContext(new HTTPContext(LOCALHOST, EXPOSED_PORT).add(new Servlet("A", "B")));
bind(DeploymentScoped.class, ProtocolMetaData.class, metadata);
fire(metadata);
ProtocolMetaData updated = getManager().getContext(DeploymentContext.class)
.getObjectStore().get(ProtocolMetaData.class);
Assert.assertEquals(BOUND_PORT.intValue(), updated.getContexts(HTTPContext.class).iterator().next().getPort());
Assert.assertEquals(LOCALHOST, updated.getContexts(HTTPContext.class).iterator().next().getHost());
assertEventFired(ProtocolMetaData.class, 1); // twice, but original fire is intercepted and never hit the Counter
}
示例6: shouldUpdateWithIPFromDocker
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
@Test // equal ports, different ip
public void shouldUpdateWithIPFromDocker() throws Exception {
Binding binding = new Binding(GATEWAY_IP);
binding.addPortBinding(EXPOSED_PORT, EXPOSED_PORT);
Mockito.when(cube.getMetadata(HasPortBindings.class)).thenReturn(new TestPortBindings(binding));
bind(ContainerScoped.class,
Container.class,
new ContainerImpl(CUBE_CONTAINER_NAME, deployableContainer, new ContainerDefImpl("arquillian.xml")));
ProtocolMetaData metadata = new ProtocolMetaData();
metadata.addContext(new HTTPContext(LOCALHOST, EXPOSED_PORT).add(new Servlet("A", "B")));
bind(DeploymentScoped.class, ProtocolMetaData.class, metadata);
fire(metadata);
ProtocolMetaData updated = getManager().getContext(DeploymentContext.class)
.getObjectStore().get(ProtocolMetaData.class);
Assert.assertEquals(EXPOSED_PORT.intValue(), updated.getContexts(HTTPContext.class).iterator().next().getPort());
Assert.assertEquals(GATEWAY_IP, updated.getContexts(HTTPContext.class).iterator().next().getHost());
assertEventFired(ProtocolMetaData.class, 1); // twice, but original fire is intercepted and never hit the Counter
}
示例7: shouldNotUpdateIfContainerNotMapped
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
@Test
public void shouldNotUpdateIfContainerNotMapped() throws Exception {
Binding binding = new Binding(GATEWAY_IP);
binding.addPortBinding(EXPOSED_PORT, EXPOSED_PORT);
Mockito.when(cube.getMetadata(HasPortBindings.class)).thenReturn(new TestPortBindings(binding));
bind(ContainerScoped.class,
Container.class,
new ContainerImpl("_UNMAPPED_", deployableContainer, new ContainerDefImpl("arquillian.xml")));
ProtocolMetaData metadata = new ProtocolMetaData();
metadata.addContext(new HTTPContext(LOCALHOST, EXPOSED_PORT).add(new Servlet("A", "B")));
bind(DeploymentScoped.class, ProtocolMetaData.class, metadata);
fire(metadata);
ProtocolMetaData updated = getManager().getContext(DeploymentContext.class)
.getObjectStore().get(ProtocolMetaData.class);
Assert.assertEquals(metadata.getContexts(HTTPContext.class).iterator().next(),
updated.getContexts(HTTPContext.class).iterator().next());
assertEventFired(ProtocolMetaData.class, 1);
}
示例8: lookupInContainerContext
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
/**
* Looks up the object in the containers context. The container used is provided by the {@link TargetsContainer}
* annotation.
*
* @param targetsContainer the target container
* @param resource the resource annotation
* @param qualifiers any qualifier annotations
*
* @return the object found in the context
*/
protected Object lookupInContainerContext(final TargetsContainer targetsContainer, final ArquillianResource resource, final Annotation... qualifiers) {
final ContainerRegistry registry = containerRegistryInstance.get();
final ContainerContext context = containerContext.get();
boolean contextActivated = false;
try {
final String name = targetsContainer.value();
final Container container = registry.getContainer(name);
if (container == null) {
throw new IllegalArgumentException(String.format("No container named %s found in the registry.", name));
}
context.activate(name);
contextActivated = true;
return doLookup(resource, qualifiers);
} finally {
if (contextActivated) {
context.deactivate();
}
}
}
示例9: getDomainController
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
private DomainManager getDomainController(final String containerQualifier, boolean requiresControllable) {
final ContainerRegistry registry = containerRegistry.get();
if (registry == null) {
throw new IllegalArgumentException("No container registry in context");
}
if (!containerExists(registry.getContainers(), containerQualifier)) {
throw new IllegalArgumentException("No container with the specified name exists");
}
if (requiresControllable && !isControllableContainer(registry.getContainers(), containerQualifier)) {
throw new IllegalArgumentException("Could not stop " + containerQualifier + " container. The container life cycle is controlled by Arquillian");
}
if (!isStarted(containerQualifier)) {
throw new IllegalArgumentException(String.format("Container %s has not been started.", containerQualifier));
}
final Container container = registry.getContainer(containerQualifier);
final DeployableContainer<?> deployableContainer = container.getDeployableContainer();
if (deployableContainer instanceof CommonDomainDeployableContainer) {
return CommonDomainDeployableContainer.class.cast(deployableContainer).getDomainManager();
}
throw new IllegalArgumentException(String.format("The container defined with %s is not a domain controller", containerQualifier));
}
示例10: lookupInContainerContext
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
/**
* Looks up the object in the containers context. The container used is provided by the {@link TargetsContainer}
* annotation.
*
* @param targetsContainer the target container
* @param resource the resource annotation
* @param qualifiers any qualifier annotations
*
* @return the object found in the context
*/
private Object lookupInContainerContext(final TargetsContainer targetsContainer, final ArquillianResource resource, final Annotation... qualifiers) {
final ContainerRegistry registry = containerRegistryInstance.get();
final ContainerContext context = containerContext.get();
boolean contextActivated = false;
try {
final String name = targetsContainer.value();
final Container container = registry.getContainer(name);
if (container == null) {
throw new IllegalArgumentException(String.format("No container named %s found in the registry.", name));
}
context.activate(name);
contextActivated = true;
return doLookup(resource, qualifiers);
} finally {
if (contextActivated) {
context.deactivate();
}
}
}
示例11: stopContainerWithTimeout
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
@SuppressWarnings("UnusedDeclaration")
public void stopContainerWithTimeout(@Observes final StopContainerWithTimeout stopEvent) throws Exception {
forContainer(stopEvent.getContainer(), new Operation<Container>() {
@Override
public void perform(Container container) throws Exception {
event.fire(new BeforeStop(container.getDeployableContainer()));
try {
if (container.getState().equals(Container.State.STARTED)) {
CommonDeployableContainer c = (CommonDeployableContainer) container.getDeployableContainer();
c.stop(stopEvent.getTimeout());
}
container.setState(Container.State.STOPPED);
} catch (LifecycleException e) {
container.setState(Container.State.STOPPED_FAILED);
throw e;
}
event.fire(new AfterStop(container.getDeployableContainer()));
}
});
}
示例12: handleBeforeDeployment
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
/**
* Executed before deployments to lazily execute the {@link ServerSetupTask#setup(ManagementClient, String) ServerSetupTask}.
* <p>
* This is lazily loaded for manual mode tests. The server may not have been started at the
* {@link org.jboss.arquillian.test.spi.event.suite.BeforeClass BeforeClass} event.
* </p>
*
* @param event the lifecycle event
* @param container the container the event is being invoked on
*
* @throws Throwable if an error occurs processing the event
*/
public synchronized void handleBeforeDeployment(@Observes BeforeDeploy event, Container container) throws Throwable {
final String containerName = container.getName();
if (setupTasks.containsKey(containerName)) {
setupTasks.get(containerName).deployments.add(event.getDeployment());
return;
}
final ClassContext classContext = classContextInstance.get();
if (classContext == null) {
return;
}
final Class<?> currentClass = classContext.getActiveId();
ServerSetup setup = currentClass.getAnnotation(ServerSetup.class);
if (setup == null) {
return;
}
final ManagementClient client = managementClient.get();
final ServerSetupTaskHolder holder = new ServerSetupTaskHolder(client);
holder.deployments.add(event.getDeployment());
setupTasks.put(containerName, holder);
holder.setup(setup, containerName);
}
示例13: handleAfterUndeploy
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
/**
* Executed after each undeploy for the container.
*
* @param afterDeploy the lifecycle event
* @param container the container the event is being invoked on
*
* @throws Exception if an error occurs processing the event
*/
public synchronized void handleAfterUndeploy(@Observes AfterUnDeploy afterDeploy, final Container container) throws Exception {
final String containerName = container.getName();
final ServerSetupTaskHolder holder = setupTasks.get(containerName);
if (holder == null) {
return;
}
// Remove the deployment
if (holder.deployments.remove(afterDeploy.getDeployment())) {
// If the deployments are now empty and the AfterClass has been invoked we need to ensure the tearDown() has
// happened. This should clean up any tasks left from managed deployments or unmanaged deployments that were
// not undeployed manually.
if (afterClassRun && holder.deployments.isEmpty()) {
holder.tearDown(containerName);
setupTasks.remove(containerName);
}
}
}
示例14: getMBeanServerConnection
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
private MBeanServerConnection getMBeanServerConnection(Container container) throws IOException {
Map<String, String> props = container.getContainerConfiguration().getContainerProperties();
String jmxServiceURL = props.get(PROPERTY_JMX_SERVICE_URL);
String jmxUsername = props.get(PROPERTY_JMX_USERNAME);
String jmxPassword = props.get(PROPERTY_JMX_PASSWORD);
MBeanServerConnection mbeanServer = null;
try {
JMXServiceURL serviceURL = new JMXServiceURL(jmxServiceURL);
Map<String, Object> env = new HashMap<String, Object>();
if (jmxUsername != null && jmxPassword != null) {
String[] credentials = new String[] { jmxUsername, jmxPassword };
env.put(JMXConnector.CREDENTIALS, credentials);
}
JMXConnector connector = JMXConnectorFactory.connect(serviceURL, env);
mbeanServer = connector.getMBeanServerConnection();
} catch (Exception ex) {
ex.printStackTrace();
}
return mbeanServer;
}
示例15: reportContainer
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
public void reportContainer(@Observes Container event) {
Map<String, String> containerProperties = event.getContainerConfiguration().getContainerProperties();
String containerId = event.getContainerConfiguration().isDefault() ? "_DEFAULT_" : event.getName();
Reporter.createReport(CONTAINER_REPORT)
.addKeyValueEntry(CONTAINER_NAME, event.getName())
.addReport(
Reporter.createReport(CONTAINER_CONFIGURATION_REPORT)
.feedKeyValueListFromMap(containerProperties))
.inSection(new TestSuiteConfigurationContainerSection(containerId, DEFAULT_TEST_SUITE_ID))
.fire(sectionEvent);
}