Search in sources :

Example 1 with IPort

use of com.openshift.restclient.model.IPort in project jbosstools-openshift by jbosstools.

the class OpenShiftDebugModeTest method shouldReplaceContainerDebugPortIfExistingPortDiffersFromRequestedPort.

@Test
public void shouldReplaceContainerDebugPortIfExistingPortDiffersFromRequestedPort() throws CoreException, UnsupportedEncodingException, MalformedURLException {
    // given
    mockGetEnvironmentVariables(asList(createEnvironmentVariable(KEY_DEVMODE, Boolean.FALSE.toString()), createEnvironmentVariable(KEY_DEBUGPORT, VALUE_DEBUGPORT)), dc);
    // has container port 88, should have port matching env var
    Set<IPort> ports = singleton(createPort(toInt(String.valueOf("88"))));
    IContainer container = createContainer("someDc-container1", ports);
    mockGetContainers(asList(container), dc);
    context.setDebugEnabled(true);
    // when
    debugMode.execute(new NullProgressMonitor());
    // then
    verify(container, atLeastOnce()).setPorts(and(// new set of ports contains requested port
    argThat(aSetThatContainsPort(toInt(VALUE_DEBUGPORT))), // but not previously existing port
    argThat(not(aSetThatContainsPort(88)))));
    // send updated dc
    verify(debugMode, times(1)).send(eq(dc), eq(connection), any(IProgressMonitor.class));
}
Also used : IPort(com.openshift.restclient.model.IPort) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IContainer(com.openshift.restclient.model.IContainer) Test(org.junit.Test)

Example 2 with IPort

use of com.openshift.restclient.model.IPort in project jbosstools-openshift by jbosstools.

the class OpenShiftDebugModeTest method shouldAddContainerDebugPortGivenNoPortExistsYet.

@Test
public void shouldAddContainerDebugPortGivenNoPortExistsYet() throws CoreException, UnsupportedEncodingException, MalformedURLException {
    // given
    mockGetEnvironmentVariables(asList(createEnvironmentVariable(KEY_DEVMODE, Boolean.FALSE.toString())), dc);
    final IPort existingContainerPort = new PortSpecAdapter("papaSmurf", "transport", 42);
    Set<IPort> ports = singleton(existingContainerPort);
    IContainer container = createContainer("someDc-container1", ports);
    mockGetContainers(asList(container), dc);
    context.setDebugEnabled(true);
    // when
    debugMode.execute(new NullProgressMonitor());
    // then
    verify(container, atLeastOnce()).setPorts(argThat(aSetEqualTo(existingContainerPort, createPort(toInt(VALUE_DEBUGPORT)))));
    // send updated dc
    verify(debugMode, times(1)).send(eq(dc), eq(connection), any(IProgressMonitor.class));
}
Also used : IPort(com.openshift.restclient.model.IPort) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter) IContainer(com.openshift.restclient.model.IContainer) Test(org.junit.Test)

Example 3 with IPort

use of com.openshift.restclient.model.IPort in project jbosstools-openshift by jbosstools.

the class OpenShiftDebugModeTest method shouldNotReplaceContainerDebugPortGivenExistingPortMatchesRequestedPort.

@Test
public void shouldNotReplaceContainerDebugPortGivenExistingPortMatchesRequestedPort() throws CoreException, UnsupportedEncodingException, MalformedURLException {
    // given
    mockGetEnvironmentVariables(asList(createEnvironmentVariable(KEY_DEVMODE, Boolean.FALSE.toString()), createEnvironmentVariable(KEY_DEBUGPORT, VALUE_DEBUGPORT)), dc);
    Set<IPort> ports = singleton(createPort(toInt(VALUE_DEBUGPORT)));
    IContainer container = createContainer("someDc-container1", ports);
    mockGetContainers(asList(container), dc);
    context.setDebugEnabled(true);
    // when
    debugMode.execute(new NullProgressMonitor());
    // then
    verify(container, never()).setPorts(any());
    // send updated dc
    verify(debugMode, times(1)).send(eq(dc), eq(connection), any(IProgressMonitor.class));
}
Also used : IPort(com.openshift.restclient.model.IPort) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IContainer(com.openshift.restclient.model.IContainer) Test(org.junit.Test)

Example 4 with IPort

use of com.openshift.restclient.model.IPort in project jbosstools-openshift by jbosstools.

the class DeployImageWizardModel method initExposedPorts.

private void initExposedPorts() {
    List<IPort> portSpecs = Collections.emptyList();
    if (imageMeta != null && !CollectionUtils.isEmpty(imageMeta.exposedPorts())) {
        portSpecs = imageMeta.exposedPorts().stream().map(spec -> new PortSpecAdapter(spec)).collect(Collectors.toList());
    }
    setPortSpecs(portSpecs);
}
Also used : IPort(com.openshift.restclient.model.IPort) PortSpecAdapter(org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)

Example 5 with IPort

use of com.openshift.restclient.model.IPort 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)

Aggregations

IPort (com.openshift.restclient.model.IPort)9 Test (org.junit.Test)5 IContainer (com.openshift.restclient.model.IContainer)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 PortSpecAdapter (org.jboss.tools.openshift.internal.core.models.PortSpecAdapter)3 HashSet (java.util.HashSet)2 IPortForwardable (com.openshift.restclient.capability.resources.IPortForwardable)1 PortPair (com.openshift.restclient.capability.resources.IPortForwardable.PortPair)1 IPod (com.openshift.restclient.model.IPod)1 IServicePort (com.openshift.restclient.model.IServicePort)1 ArrayList (java.util.ArrayList)1 PortForwardingWizardModel (org.jboss.tools.openshift.internal.ui.portforwading.PortForwardingWizardModel)1 Before (org.junit.Before)1