当前位置: 首页>>代码示例>>Java>>正文


Java Container.getContainerConfiguration方法代码示例

本文整理汇总了Java中org.jboss.arquillian.container.spi.Container.getContainerConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java Container.getContainerConfiguration方法的具体用法?Java Container.getContainerConfiguration怎么用?Java Container.getContainerConfiguration使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jboss.arquillian.container.spi.Container的用法示例。


在下文中一共展示了Container.getContainerConfiguration方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: remapContainer

import org.jboss.arquillian.container.spi.Container; //导入方法依赖的package包/类
public void remapContainer(@Observes BeforeSetup event, CubeRegistry cubeRegistry,
    ContainerRegistry containerRegistry) throws InstantiationException, IllegalAccessException {

    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
    }

    HasPortBindings bindings = cube.getMetadata(HasPortBindings.class);
    if (bindings == null) {
        return;
    }

    ContainerDef containerConfiguration = container.getContainerConfiguration();
    //Get the port property
    List<String> portPropertiesFromArquillianConfigurationFile =
        filterArquillianConfigurationPropertiesByPortAttribute(containerConfiguration);
    //Get the AddressProperty property
    List<String> addressPropertiesFromArquillianConfigurationFile =
        filterArquillianConfigurationPropertiesByAddressAttribute(containerConfiguration);

    Class<?> configurationClass = container.getDeployableContainer().getConfigurationClass();
    //Get the port property
    List<PropertyDescriptor> configurationClassPortFields =
        filterConfigurationClassPropertiesByPortAttribute(configurationClass);
    //Get the Address property
    List<PropertyDescriptor> configurationClassAddressFields =
        filterConfigurationClassPropertiesByAddressAttribute(configurationClass);

    Object newConfigurationInstance = configurationClass.newInstance();

    for (PropertyDescriptor configurationClassPortField : configurationClassPortFields) {
        int containerPort = getDefaultPortFromConfigurationInstance(newConfigurationInstance,
            configurationClass, configurationClassPortField);
        mappingForPort = bindings.getMappedAddress(containerPort);

        if (!portPropertiesFromArquillianConfigurationFile.contains(configurationClassPortField.getName()) && (
            configurationClassPortField.getPropertyType().equals(Integer.class)
                || configurationClassPortField.getPropertyType().equals(int.class))) {
            // This means that port has not configured in arquillian.xml and it will use default value.
            // In this case is when remapping should be activated to adequate the situation according to
            // Arquillian Cube exposed ports.
            if (mappingForPort != null) {
                containerConfiguration.overrideProperty(configurationClassPortField.getName(),
                    Integer.toString(mappingForPort.getPort()));
            }
        }
    }

    for (PropertyDescriptor configurationClassAddressField : configurationClassAddressFields) {
        if (!addressPropertiesFromArquillianConfigurationFile.contains(configurationClassAddressField.getName()) && (
            configurationClassAddressField.getPropertyType().equals(String.class)
                || configurationClassAddressField.getPropertyType().equals(String.class))) {
            // If a property called portForwardBindAddress on openshift qualifier on arquillian.xml exists it will overrides the
            // arquillian default|defined managementAddress with the IP address given on this property.
            if (mappingForPort != null) {
                containerConfiguration.overrideProperty(configurationClassAddressField.getName(),
                    mappingForPort.getIP());
            }
        }
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:69,代码来源:ContainerConfigurationController.java


注:本文中的org.jboss.arquillian.container.spi.Container.getContainerConfiguration方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。