use of org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtilityTest method testOpenshiftConnectionAdded.
@Test
public void testOpenshiftConnectionAdded() throws Exception {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IServer s = mockServer("openshift33");
createCDKFile("Basic", null, null);
ServiceManagerEnvironment adb = createLoader(s);
ConnectionsRegistry registry = (ConnectionsRegistry) mock(ConnectionsRegistry.class);
IConnection con = util.createOpenshiftConnection(adb, registry);
assertNotNull(con);
verify(registry).add(con);
}
use of org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility in project jbosstools-openshift by jbosstools.
the class CDKRegistryTest method testRegistryURL.
@Test
public void testRegistryURL() throws Exception {
ConfigureDependentFrameworksListener configureListener = (ConfigureDependentFrameworksListener) CDKCoreActivator.getDefault().getConfigureDependentFrameworksListener();
configureListener.disable();
CredentialService.getCredentialModel().addDomain("redhat.com", "redhat.com", true);
CredentialService.getCredentialModel().addCredentials(CredentialService.getCredentialModel().getDomain("redhat.com"), "user", "password");
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
createCDKFile("Basic", null, null);
IServer cdkServer = createServer("openshift33");
ServiceManagerEnvironment adb = createLoader(cdkServer);
IConnection con = util.createOpenshiftConnection(adb, ConnectionsRegistrySingleton.getInstance());
assertNotNull(con);
// Can't test the registry provider model bc it hides the internal details
CDKRegistryProvider prov = new CDKRegistryProvider() {
protected ServiceManagerEnvironment getServiceManagerEnvironment(IServer server) {
try {
return createLoader(server);
} catch (Exception e) {
fail(e.getMessage());
}
return null;
}
};
IStatus reg = prov.getRegistryURL(con);
assertNotNull(reg);
assertFalse(reg.isOK());
ControllableServerBehavior beh = (ControllableServerBehavior) cdkServer.loadAdapter(ControllableServerBehavior.class, new NullProgressMonitor());
beh.setServerStarted();
reg = prov.getRegistryURL(con);
assertNotNull(reg);
assertTrue(reg.isOK());
configureListener.enable();
beh.setServerStopped();
}
use of org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtilityTest method testOpenshiftRegistryDefault.
@Test
public void testOpenshiftRegistryDefault() throws Exception {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IServer s = mockServer("openshift36");
createCDKFile("Basic", null, null);
ServiceManagerEnvironment adb = createLoader(s, "10.1.2.2", "2376", null);
ConnectionsRegistry registry = (ConnectionsRegistry) mock(ConnectionsRegistry.class);
IConnection con = util.createOpenshiftConnection(adb, registry);
assertNotNull(con);
Object o = ((Connection) con).getExtendedProperties().get(ICommonAttributes.IMAGE_REGISTRY_URL_KEY);
assertEquals("https://hub.openshift.rhel-cdk.10.1.2.2.xip.io", o);
}
use of org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtilityTest method testOpenshiftConnectionCredentials.
@Test
public void testOpenshiftConnectionCredentials() throws Exception {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IServer s = mockServer("openshift33");
createCDKFile("Basic", null, null);
ServiceManagerEnvironment adb = createLoader(s);
IConnection con = util.createOpenshiftConnection(adb, null);
assertNotNull(con);
assertEquals(con.getUsername(), "openshift-dev");
assertEquals(con.getPassword(), "devel");
createCDKFile("Basic", "test", null);
adb = createLoader(s);
con = util.createOpenshiftConnection(adb, null);
assertNotNull(con);
assertEquals(con.getUsername(), "test");
assertEquals(con.getPassword(), null);
createCDKFile("Basic", "test", "pass");
adb = createLoader(s);
con = util.createOpenshiftConnection(adb, null);
assertNotNull(con);
assertEquals(con.getUsername(), "test");
assertEquals(con.getPassword(), "pass");
}
use of org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtilityTest method testOpenshiftRegistry.
@Test
public void testOpenshiftRegistry() throws Exception {
CDKOpenshiftUtility util = new CDKOpenshiftUtility();
IServer s = mockServer("openshift35");
createCDKFile("Basic", null, null);
ServiceManagerEnvironment adb = createLoader(s, "10.1.2.2", "2376", "https://custom.url");
ConnectionsRegistry registry = (ConnectionsRegistry) mock(ConnectionsRegistry.class);
IConnection con = util.createOpenshiftConnection(adb, registry);
assertNotNull(con);
Object o = ((Connection) con).getExtendedProperties().get(ICommonAttributes.IMAGE_REGISTRY_URL_KEY);
assertEquals(o, "https://custom.url");
}
Aggregations