本文整理汇总了Java中org.jboss.arquillian.container.spi.Container类的典型用法代码示例。如果您正苦于以下问题:Java Container类的具体用法?Java Container怎么用?Java Container使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Container类属于org.jboss.arquillian.container.spi包,在下文中一共展示了Container类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:kaiwinter,项目名称:testcontainers-examples,代码行数:19,代码来源:WildflyMariaDBDockerExtension.java
示例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());
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:19,代码来源:CubeIDResourceProvider.java
示例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));
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:17,代码来源:CubeContainerLifecycleController.java
示例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());
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:18,代码来源:CubeRemoteCommandObserver.java
示例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
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:25,代码来源:ProtocolMetaDataUpdaterTestCase.java
示例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
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:25,代码来源:ProtocolMetaDataUpdaterTestCase.java
示例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);
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:24,代码来源:ProtocolMetaDataUpdaterTestCase.java
示例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();
}
}
}
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:30,代码来源:AbstractTargetsContainerProvider.java
示例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));
}
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:25,代码来源:ClientDomainContainerController.java
示例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();
}
}
}
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:30,代码来源:AbstractTargetsContainerProvider.java
示例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()));
}
});
}
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:21,代码来源:WildFlyContainerLifecycleController.java
示例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);
}
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:38,代码来源:ServerSetupObserver.java
示例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);
}
}
}
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:27,代码来源:ServerSetupObserver.java
示例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;
}
开发者ID:tdiesler,项目名称:gravia,代码行数:23,代码来源:ManagedContainerSetupObserver.java
示例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);
}
开发者ID:arquillian,项目名称:arquillian-reporter,代码行数:14,代码来源:ArquillianCoreReporterLifecycleManager.java
示例16: stopWildFlyContainerInRegistry
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
public void stopWildFlyContainerInRegistry(final String nodeName, ContainerRegistry registry,
ContainerContext containerContext) throws LifecycleException {
Container container = registry.getContainer(nodeName);
if (container != null) {
LOGGER.debug("Stoping container {}", nodeName);
try {
containerContext.activate(container.getName());
container.stop();
} finally {
containerContext.deactivate();
}
} else {
LOGGER.warn("Container {} was not found, so it can't be destroyed.", nodeName);
}
}
开发者ID:wildfly-extras,项目名称:sunstone,代码行数:16,代码来源:CloudsRegistry.java
示例17: toContainersName
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
private static List<String> toContainersName(List<Container> containers) {
List<String> containerNames = new ArrayList<>();
for (Container container : containers) {
containerNames.add(ContainerUtil.getCubeIDForContainer(container));
}
return containerNames;
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:10,代码来源:CubeDockerAutoStartConfigurator.java
示例18: applyDockerServerIpChange
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
public void applyDockerServerIpChange(@Observes BeforeSetup event, CubeRegistry cubeRegistry,
ContainerRegistry containerRegistry)
throws InstantiationException, IllegalAccessException, MalformedURLException {
Container container = ContainerUtil.getContainerByDeployableContainer(containerRegistry,
event.getDeployableContainer());
if (container == null) {
return;
}
Cube<?> cube = cubeRegistry.getCube(org.arquillian.cube.impl.util.ContainerUtil.getCubeIDForContainer(container));
if (cube == null) {
return; // No Cube found matching Container name, not managed by Cube
}
HasPortBindings portBindings = cube.getMetadata(HasPortBindings.class);
if (portBindings == null) {
return;
}
ContainerDef containerConfiguration = container.getContainerConfiguration();
boolean foundAttribute =
resolveConfigurationPropertiesWithDockerServerIp(containerConfiguration, portBindings.getContainerIP());
//if user doesn't configured in arquillian.xml the host then we can override the default value.
if (!foundAttribute) {
Class<?> configurationClass = container.getDeployableContainer().getConfigurationClass();
List<PropertyDescriptor> configurationClassHostOrAddressFields =
filterConfigurationClassPropertiesByHostOrAddressAttribute(configurationClass);
for (PropertyDescriptor propertyDescriptor : configurationClassHostOrAddressFields) {
//we get default address value and we replace to boot2docker ip
containerConfiguration.overrideProperty(propertyDescriptor.getName(), portBindings.getContainerIP());
}
}
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:35,代码来源:DockerServerIPConfigurator.java
示例19: getContainerByDeployableContainer
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
public static Container getContainerByDeployableContainer(ContainerRegistry registry, DeployableContainer<?> dc) {
for (Container container : registry.getContainers()) {
if (dc == container.getDeployableContainer()) {
return container;
}
}
return null;
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:9,代码来源:ContainerUtil.java
示例20: startCubeMappedContainer
import org.jboss.arquillian.container.spi.Container; //导入依赖的package包/类
public void startCubeMappedContainer(@Observes BeforeStart event, CubeRegistry cubeRegistry,
ContainerRegistry containerRegistry, CubeConfiguration cubeConfiguration) {
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
}
ConnectionMode connectionMode = cubeConfiguration.getConnectionMode();
if (connectionMode.isAllowReconnect() && cube.isRunningOnRemote()) {
controlEvent.fire(new PreRunningCube(cube));
return;
}
controlEvent.fire(new CreateCube(cube));
controlEvent.fire(new StartCube(cube));
if (connectionMode.isAllowReconnect() && !connectionMode.isStoppable()) {
// If we allow reconnections and containers are none stoppable which means that they will be able to be
// reused in next executions then at this point we can assume that the container is a prerunning container.
controlEvent.fire(new PreRunningCube(cube));
}
}
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:30,代码来源:CubeContainerLifecycleController.java
注:本文中的org.jboss.arquillian.container.spi.Container类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论