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


Java ProtocolMetaData.addContext方法代码示例

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


在下文中一共展示了ProtocolMetaData.addContext方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldUpdateWithPortFromDocker

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的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

示例2: shouldUpdateWithIPFromDocker

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的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

示例3: shouldNotUpdateIfContainerNotMapped

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的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

示例4: deploy

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的package包/类
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    // Get all the server groups we're deploying to
    final Set<String> serverGroups = getServerGroups(archive);
    if (!serverGroups.isEmpty()) {
        final ProtocolMetaData metaData = new ProtocolMetaData();
        final ArchiveDeployer deployer = archiveDeployerInst.get();
        final String uniqueName = deployer.deploy(archive, serverGroups);
        final Domain domain = domainInst.get();
        for (String serverGroupName : serverGroups) {
            for (Server server : domain.getServersInGroup(serverGroupName)) {
                metaData.addContext(new LazyHttpContext(server, uniqueName, managementClient));
            }
        }
        return metaData;
    }
    throw new DeploymentException("Could not determine the server-group to deploy the archive to.");
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:19,代码来源:CommonDomainDeployableContainer.java

示例5: deploy

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的package包/类
@Override
public synchronized ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    StartupTimeout startupTimeout = this.testClass.getAnnotation(StartupTimeout.class);
    if (startupTimeout != null) {
        setTimeout(startupTimeout.value());
    }

    this.delegateContainer = new UberjarSimpleContainer(this.containerContext.get(), this.deploymentContext.get(), this.testClass);

    try {
        this.delegateContainer
                .setJavaVmArguments(this.getJavaVmArguments())
                .requestedMavenArtifacts(this.requestedMavenArtifacts)
                .start(archive);
        // start wants to connect to the remote container, which isn't up until now, so
        // we override start above and call it here instead
        super.start();

        ProtocolMetaData metaData = new ProtocolMetaData();
        metaData.addContext(createDeploymentContext(archive.getId()));

        return metaData;
    } catch (Throwable e) {
        if (e instanceof LifecycleException) {
            e = e.getCause();
        }
        throw new DeploymentException(e.getMessage(), e);
    }
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm,代码行数:30,代码来源:WildFlySwarmContainer.java

示例6: deploy

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的package包/类
@Override
public ProtocolMetaData deploy(Archive<?> archive)
	throws DeploymentException {

	LiferayRemoteContainerConfiguration config =
		_configurationInstance.get();

	ProtocolMetaData protocolMetaData = super.deploy(archive);

	protocolMetaData.addContext(
		new HTTPContext(config.getHttpHost(), config.getHttpPort()));

	return protocolMetaData;
}
 
开发者ID:liferay-labs,项目名称:arquillian-liferay,代码行数:15,代码来源:LiferayRemoteDeployableContainer.java

示例7: deploy

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的package包/类
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    StartupTimeout startupTimeout = this.testClass.getAnnotation(StartupTimeout.class);
    if (startupTimeout != null) {
        setTimeout(startupTimeout.value());
    }


    if (this.testClass.getAnnotation(InVM.class) != null) {
        this.delegateContainer = new InVMSimpleContainer(this.testClass);
    } else {
        this.delegateContainer = new UberjarSimpleContainer(this.testClass);
    }
    try {
        this.delegateContainer
                .requestedMavenArtifacts(this.requestedMavenArtifacts)
                .start(archive);
        // start wants to connect to the remote container, which isn't up until now, so
        // we override start above and call it here instead
        super.start();

        ProtocolMetaData metaData = new ProtocolMetaData();
        metaData.addContext(createDeploymentContext(archive.getId()));

        return metaData;
    } catch (Exception e) {
        throw new DeploymentException(e.getMessage(), e);
    }
}
 
开发者ID:wildfly-swarm-archive,项目名称:ARCHIVE-wildfly-swarm,代码行数:30,代码来源:WildFlySwarmContainer.java

示例8: deploy

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的package包/类
@Override
public ProtocolMetaData deploy(Archive<?> archive)
	throws DeploymentException {

	ProtocolMetaData protocolMetaData = super.deploy(archive);

	protocolMetaData.addContext(
		new HTTPContext(config.getHttpHost(), config.getHttpPort()));

	return protocolMetaData;
}
 
开发者ID:arquillian,项目名称:arquillian-extension-liferay,代码行数:12,代码来源:LiferayRemoteDeployableContainer.java

示例9: deploy

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的package包/类
@Override
public ProtocolMetaData deploy(Archive<?> archive) throws DeploymentException {
    String uniqueName = deployer.deploy(archive, serverGroup.getName());

    ProtocolMetaData metaData = new ProtocolMetaData();
    for (Server server : domain.getServersInGroup(serverGroup)) {
        metaData.addContext(new LazyHttpContext(server, uniqueName, client));
    }
    return metaData;
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:11,代码来源:ServerGroupContainer.java

示例10: getProtocolMetaData

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的package包/类
/**
 * Gets the meta-data.
 *
 * @return the meta-data
 *
 * @throws IllegalStateException if this has been {@linkplain #close() closed}
 */
public ProtocolMetaData getProtocolMetaData(String deploymentName) {
    init();
    ProtocolMetaData metaData = new ProtocolMetaData();
    metaData.addContext(new JMXContext(getConnection()));
    if (undertowSubsystemPresent) {
        URI webURI = getWebUri();
        HTTPContext context = new HTTPContext(webURI.getHost(), webURI.getPort());
        metaData.addContext(context);

        try {
            final ModelNode operation = new ModelNode();
            operation.get(OP).set(READ_RESOURCE_OPERATION);
            operation.get(RECURSIVE_DEPTH).set(3); // /deployment=x/subdeployment=y/subsystem=undertow/servlet=*
            operation.get(INCLUDE_RUNTIME).set(true);
            ModelNode address = new ModelNode();
            address.add(DEPLOYMENT, deploymentName);
            operation.get(OP_ADDR).set(address);
            ModelNode deploymentNode = executeForResult(operation);

            if (isWebArchive(deploymentName)) {
                extractWebArchiveContexts(context, deploymentNode);
            } else if (isEnterpriseArchive(deploymentName)) {
                extractEnterpriseArchiveContexts(context, deploymentNode);
            }

        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
    return metaData;
}
 
开发者ID:wildfly,项目名称:wildfly-arquillian,代码行数:39,代码来源:ManagementClient.java

示例11: update

import org.jboss.arquillian.container.spi.client.protocol.metadata.ProtocolMetaData; //导入方法依赖的package包/类
public void update(@Observes EventContext<ProtocolMetaData> eventContext, Container container,
    CubeRegistry registry) {

    ProtocolMetaData originalMetaData = eventContext.getEvent();
    ProtocolMetaData updatedMetaData = new ProtocolMetaData();
    boolean updated = false;

    try {
        Cube<?> cube = registry.getCube(ContainerUtil.getCubeIDForContainer(container));
        if (cube == null) {
            return;
        }
        HasPortBindings portBindings = cube.getMetadata(HasPortBindings.class);
        if (portBindings == null) {
            return;
        }
        for (Object contextObj : originalMetaData.getContexts()) {
            if (contextObj instanceof HTTPContext) {
                HTTPContext context = (HTTPContext) contextObj;
                String ip = context.getHost();
                int port = context.getPort();
                final PortAddress mappedPort = portBindings.getMappedAddress(port);
                final String bindingIp;
                final Integer bindingPort;
                if (mappedPort != null) {
                    bindingIp = mappedPort.getIP();
                    bindingPort = mappedPort.getPort();
                } else {
                    continue;
                }
                if (bindingPort != null && port != bindingPort) {
                    updated = true;
                    port = bindingPort;
                }
                if (bindingIp != null && !bindingIp.equals(ip)) {
                    updated = true;
                    ip = bindingIp;
                }
                if (updated) {
                    HTTPContext newContext = new HTTPContext(ip, port);
                    for (Servlet servlet : context.getServlets()) {
                        newContext.add(servlet);
                    }
                    updatedMetaData.addContext(newContext);
                }
            } else {
                updatedMetaData.addContext(contextObj);
            }
        }
    } finally {
        if (updated) {
            protocolMetaDataProducer.set(updatedMetaData);
        } else {
            eventContext.proceed();
        }
    }
}
 
开发者ID:arquillian,项目名称:arquillian-cube,代码行数:58,代码来源:ProtocolMetadataUpdater.java


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