Search in sources :

Example 6 with PortSpecAdapter

use of org.jboss.tools.openshift.internal.core.models.PortSpecAdapter in project jbosstools-openshift by jbosstools.

the class PortSpecAdapterTest method testFullPortSpec.

@Test
public void testFullPortSpec() {
    String spec = "8080/tcp";
    IPort port = new PortSpecAdapter(spec);
    assertEquals(8080, port.getContainerPort());
    assertEquals("TCP", port.getProtocol());
    assertEquals("8080-tcp", port.getName());
}
Also used : IPort(com.openshift.restclient.model.IPort) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter) Test(org.junit.Test)

Example 7 with PortSpecAdapter

use of org.jboss.tools.openshift.internal.core.models.PortSpecAdapter in project jbosstools-openshift by jbosstools.

the class OpenShiftDebugMode method addReplaceDebugPort.

private boolean addReplaceDebugPort(int debugPort, IPort existing, Set<IPort> ports) {
    boolean modified = false;
    if (matchesPort(debugPort, existing)) {
        ports.remove(existing);
        modified = true;
    }
    PortSpecAdapter newPort = new PortSpecAdapter(DEBUG_PORT_NAME, DEBUG_PORT_PROTOCOL, debugPort);
    // use bit-wise OR to avoid short-circuit
    modified = modified | ports.add(newPort);
    return modified;
}
Also used : PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)

Example 8 with PortSpecAdapter

use of org.jboss.tools.openshift.internal.core.models.PortSpecAdapter in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModelTest method checkThatRemoveANonExistingServicePortIsNotEffective.

@Test
public void checkThatRemoveANonExistingServicePortIsNotEffective() {
    // assume Docker image is on local
    final IDockerImageInfo dockerImageInfo = Mockito.mock(IDockerImageInfo.class, Mockito.RETURNS_DEEP_STUBS);
    when(dockerConnection.hasImage(WILDFLY_IMAGE, LATEST_TAG)).thenReturn(true);
    when(dockerConnection.getImageInfo(WILDFLY_IMAGE_URI)).thenReturn(dockerImageInfo);
    when(dockerImageInfo.config().env()).thenReturn(Collections.emptyList());
    when(dockerImageInfo.config().exposedPorts()).thenReturn(new HashSet<>(Arrays.asList("8080/tcp", "9990/tcp")));
    when(dockerImageInfo.config().volumes()).thenReturn(Collections.emptySet());
    when(dockerImageInfo.containerConfig()).thenReturn(null);
    mockSingleImage(dockerConnection, WILDFLY_IMAGE, LATEST_TAG);
    // when
    model.setImageName(WILDFLY_IMAGE_URI);
    final boolean result = model.initializeContainerInfo();
    // then
    assertThat(result).isTrue();
    IServicePort port = new ServicePortAdapter();
    port.setName("9000-tcp");
    port.setProtocol("TCP");
    port.setPort(9000);
    port.setTargetPort(9000);
    model.removeServicePort(port);
    assertThat(model.getServicePorts()).hasSize(2);
    ServicePortAdapter first = new ServicePortAdapter(new PortSpecAdapter("8080-tcp", "TCP", 8080));
    first.setRoutePort(true);
    assertThat(model.getServicePorts()).isEqualTo(Arrays.asList(first, new ServicePortAdapter(new PortSpecAdapter("9990-tcp", "TCP", 9990))));
}
Also used : ServicePortAdapter(org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter) IServicePort(com.openshift.restclient.model.IServicePort) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter) IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo) Test(org.junit.Test)

Example 9 with PortSpecAdapter

use of org.jboss.tools.openshift.internal.core.models.PortSpecAdapter in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModelTest method checkThatRemoveAnExistingServicePortIsEffective.

@Test
public void checkThatRemoveAnExistingServicePortIsEffective() {
    // assume Docker image is on local
    final IDockerImageInfo dockerImageInfo = Mockito.mock(IDockerImageInfo.class, Mockito.RETURNS_DEEP_STUBS);
    when(dockerConnection.hasImage(WILDFLY_IMAGE, LATEST_TAG)).thenReturn(true);
    when(dockerConnection.getImageInfo(WILDFLY_IMAGE_URI)).thenReturn(dockerImageInfo);
    when(dockerImageInfo.config().env()).thenReturn(Collections.emptyList());
    when(dockerImageInfo.config().exposedPorts()).thenReturn(new HashSet<>(Arrays.asList("8080/tcp", "9990/tcp")));
    when(dockerImageInfo.config().volumes()).thenReturn(Collections.emptySet());
    when(dockerImageInfo.containerConfig()).thenReturn(null);
    mockSingleImage(dockerConnection, WILDFLY_IMAGE, LATEST_TAG);
    // when
    model.setImageName(WILDFLY_IMAGE_URI);
    final boolean result = model.initializeContainerInfo();
    // then
    assertThat(result).isTrue();
    model.removeServicePort(model.getServicePorts().get(0));
    assertThat(model.getServicePorts()).hasSize(1);
    assertThat(model.getServicePorts()).isEqualTo(Collections.singletonList(new ServicePortAdapter(new PortSpecAdapter("9990-tcp", "TCP", 9990))));
}
Also used : ServicePortAdapter(org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter) IDockerImageInfo(org.eclipse.linuxtools.docker.core.IDockerImageInfo) Test(org.junit.Test)

Aggregations

PortSpecAdapter (org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)9 Test (org.junit.Test)7 IDockerImageInfo (org.eclipse.linuxtools.docker.core.IDockerImageInfo)4 IPort (com.openshift.restclient.model.IPort)3 ServicePortAdapter (org.jboss.tools.openshift.internal.ui.wizard.deployimage.ServicePortAdapter)3 EnvironmentVariable (org.jboss.tools.openshift.internal.ui.wizard.common.EnvironmentVariable)2 IImageStreamImportCapability (com.openshift.restclient.capability.resources.IImageStreamImportCapability)1 DockerImageURI (com.openshift.restclient.images.DockerImageURI)1 IContainer (com.openshift.restclient.model.IContainer)1 IServicePort (com.openshift.restclient.model.IServicePort)1 IStatus (com.openshift.restclient.model.IStatus)1 IImageStreamImport (com.openshift.restclient.model.image.IImageStreamImport)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1