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