Search in sources :

Example 16 with CDKServer

use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer in project jbosstools-openshift by jbosstools.

the class CDK3LaunchController method initialize.

@Override
public void initialize(ILaunchConfigurationWorkingCopy wc) throws CoreException {
    final IServer s = getServerFromLaunch(wc);
    final CDKServer cdkServer = (CDKServer) s.loadAdapter(CDKServer.class, new NullProgressMonitor());
    // for testing purposes.
    // we can't mock final methods like getServer(), so we need to be creative
    initialize(wc, cdkServer.getUsername(), cdkServer.getServer());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Example 17 with CDKServer

use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer in project jbosstools-openshift by jbosstools.

the class CDK32LaunchControllerTest method testSetupWithMinishiftHome.

@Test
public void testSetupWithMinishiftHome() throws Exception {
    ILaunchConfigurationWorkingCopy wc = mock(ILaunchConfigurationWorkingCopy.class);
    when(wc.getAttribute(any(String.class), any(String.class))).thenAnswer(AdditionalAnswers.returnsSecondArg());
    when(wc.getName()).thenReturn(NAME);
    String userName = "Drumpf";
    IPath msHome = CDKTestActivator.getDefault().getStateLocation().append("test927");
    msHome.toFile().mkdirs();
    IServer server = mockServerWithMSHome(msHome);
    ArgumentCaptor<String> keyCaptor = ArgumentCaptor.forClass(String.class);
    Class<Map<String, String>> mapClass = (Class<Map<String, String>>) (Class) Map.class;
    ArgumentCaptor<Map<String, String>> valCaptor = ArgumentCaptor.forClass(mapClass);
    CDKServer cdkServer = (CDKServer) server.loadAdapter(CDKServer.class, new NullProgressMonitor());
    CDK3TestLaunchController controller = new CDK3TestLaunchController(server, cdkServer);
    controller.setupLaunchConfiguration(wc, new NullProgressMonitor());
    verify(wc, Mockito.times(2)).setAttribute(keyCaptor.capture(), valCaptor.capture());
    List<String> allKeys = keyCaptor.getAllValues();
    List<Map<String, String>> allVals = valCaptor.getAllValues();
    Map<String, String> latest = allVals.get(allVals.size() - 1);
    String val1 = latest.get("MINISHIFT_HOME");
    assertEquals(msHome.toOSString(), val1);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) IPath(org.eclipse.core.runtime.IPath) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Map(java.util.Map) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer) Test(org.junit.Test)

Example 18 with CDKServer

use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer in project jbosstools-openshift by jbosstools.

the class CDKCredentialSection method createSection.

@Override
public void createSection(Composite parent) {
    super.createSection(parent);
    CDKServer cdkServer = (CDKServer) server.getOriginal().loadAdapter(CDKServer.class, new NullProgressMonitor());
    FormToolkit toolkit = new FormToolkit(parent.getDisplay());
    Composite composite = createWidgets(parent, cdkServer, toolkit);
    toolkit.paintBordersFor(composite);
    section.setClient(composite);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) ExpandableComposite(org.eclipse.ui.forms.widgets.ExpandableComposite) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Example 19 with CDKServer

use of org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer in project jbosstools-openshift by jbosstools.

the class CDKLaunchControllerTest method mockServer.

private IServer mockServer() {
    IServer server = mock(IServer.class);
    when(server.getAttribute(CDKServer.PROP_PASS_CREDENTIALS, false)).thenReturn(Boolean.TRUE);
    when(server.getAttribute(CDKServer.PROP_USER_ENV_VAR, CDKConstants.CDK_ENV_SUB_USERNAME)).thenReturn(CDKConstants.CDK_ENV_SUB_USERNAME);
    CDKServer cdk = mock(CDKServer.class);
    when(cdk.passCredentials()).thenReturn(Boolean.TRUE);
    when(cdk.getUserEnvironmentKey()).thenReturn(CDKConstants.CDK_ENV_SUB_USERNAME);
    when(server.loadAdapter(eq(CDKServer.class), any(IProgressMonitor.class))).thenReturn(cdk);
    return server;
}
Also used : IServer(org.eclipse.wst.server.core.IServer) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CDKServer(org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)

Aggregations

CDKServer (org.jboss.tools.openshift.cdk.server.core.internal.adapter.CDKServer)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)17 IServer (org.eclipse.wst.server.core.IServer)11 CoreException (org.eclipse.core.runtime.CoreException)5 HashMap (java.util.HashMap)4 IStatus (org.eclipse.core.runtime.IStatus)4 Status (org.eclipse.core.runtime.Status)4 IDebugEventSetListener (org.eclipse.debug.core.IDebugEventSetListener)3 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)3 IProcess (org.eclipse.debug.core.model.IProcess)3 File (java.io.File)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 Path (org.eclipse.core.runtime.Path)2 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)2 Server (org.eclipse.wst.server.core.internal.Server)2 ControllableServerBehavior (org.jboss.ide.eclipse.as.wtp.core.server.behavior.ControllableServerBehavior)2 UsernameChangedException (org.jboss.tools.foundation.core.credentials.UsernameChangedException)2 Test (org.junit.Test)2 IOException (java.io.IOException)1 Map (java.util.Map)1