use of org.eclipse.wst.server.core.IServer 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.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.
the class CDKOpenshiftUtilityTest method mockServer.
private IServer mockServer(String name) {
IServer server = mock(IServer.class);
when(server.getName()).thenReturn(name);
when(server.getAttribute(CDKServer.PROP_FOLDER, (String) null)).thenReturn(getDotCDKFolder());
return server;
}
use of org.eclipse.wst.server.core.IServer 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.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.
the class CDKLaunchControllerTest method testInitialize.
@Test
public void testInitialize() throws Exception {
ILaunchConfigurationWorkingCopy wc = mock(ILaunchConfigurationWorkingCopy.class);
String userName = "Drumpf";
IServer server = mockServer();
controller.initialize(wc, userName, server);
Map<String, String> env = Collections.singletonMap(CDKConstants.CDK_ENV_SUB_USERNAME, userName);
verify(wc).setAttribute(CDKLaunchController.FLAG_INITIALIZED, Boolean.TRUE);
verify(wc).setAttribute(eq(IExternalLaunchConstants.ENVIRONMENT_VARS_KEY), eq(env));
verify(wc).setAttribute(IExternalLaunchConstants.ATTR_ARGS, "up --no-color");
verify(wc).setAttribute(eq(IExternalLaunchConstants.ATTR_LOCATION), anyString());
}
use of org.eclipse.wst.server.core.IServer in project jbosstools-openshift by jbosstools.
the class OpenShiftServerAdapterFactoryTest method testLoadWebModule.
@Test
public void testLoadWebModule() {
OpenShiftServerAdapterFactory factory = new OpenShiftServerAdapterFactory();
IServer server = mock(IServer.class);
OpenShiftServer realServer = mock(OpenShiftServer.class);
when(server.loadAdapter(eq(OpenShiftServer.class), isA(IProgressMonitor.class))).thenReturn(realServer);
IServerModule serverModule = factory.getAdapter(server, IServerModule.class);
assertNotNull(serverModule);
IModule[] module = serverModule.getModule();
assertNotNull(module);
assertNotNull(module[0].loadAdapter(IWebModule.class, null));
}
Aggregations