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));
}
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));
}
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));
}
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);
}
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());
}
Aggregations