Search in sources :

Example 71 with IServer

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);
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ConnectionsRegistry(org.jboss.tools.openshift.common.core.connection.ConnectionsRegistry) CDKOpenshiftUtility(org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility) ServiceManagerEnvironment(org.jboss.tools.openshift.cdk.server.core.internal.listeners.ServiceManagerEnvironment) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) Test(org.junit.Test)

Example 72 with IServer

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;
}
Also used : IServer(org.eclipse.wst.server.core.IServer)

Example 73 with IServer

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();
}
Also used : CDKRegistryProvider(org.jboss.tools.openshift.cdk.server.core.internal.registry.CDKRegistryProvider) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IStatus(org.eclipse.core.runtime.IStatus) CDKOpenshiftUtility(org.jboss.tools.openshift.cdk.server.core.internal.listeners.CDKOpenshiftUtility) ServiceManagerEnvironment(org.jboss.tools.openshift.cdk.server.core.internal.listeners.ServiceManagerEnvironment) IConnection(org.jboss.tools.openshift.common.core.connection.IConnection) ControllableServerBehavior(org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior) ConfigureDependentFrameworksListener(org.jboss.tools.openshift.cdk.server.core.internal.listeners.ConfigureDependentFrameworksListener) URISyntaxException(java.net.URISyntaxException) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) Test(org.junit.Test)

Example 74 with IServer

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());
}
Also used : IServer(org.eclipse.wst.server.core.IServer) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 75 with IServer

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));
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IModule(org.eclipse.wst.server.core.IModule) OpenShiftServerAdapterFactory(org.jboss.tools.openshift.internal.ui.server.OpenShiftServerAdapterFactory) IServerModule(org.eclipse.wst.server.ui.IServerModule) OpenShiftServer(org.jboss.tools.openshift.core.server.OpenShiftServer) IWebModule(org.eclipse.jst.server.core.IWebModule) Test(org.junit.Test)

Aggregations

IServer (org.eclipse.wst.server.core.IServer)183 CoreException (org.eclipse.core.runtime.CoreException)39 IModule (org.eclipse.wst.server.core.IModule)32 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)30 Test (org.junit.Test)30 IProject (org.eclipse.core.resources.IProject)25 IStatus (org.eclipse.core.runtime.IStatus)25 IServerWorkingCopy (org.eclipse.wst.server.core.IServerWorkingCopy)23 ArrayList (java.util.ArrayList)20 File (java.io.File)17 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 Status (org.eclipse.core.runtime.Status)12 Iterator (java.util.Iterator)11 IPath (org.eclipse.core.runtime.IPath)11 IServerType (org.eclipse.wst.server.core.IServerType)11 CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)11 IOException (java.io.IOException)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)10 Server (org.eclipse.wst.server.core.internal.Server)10 IFolder (org.eclipse.core.resources.IFolder)8