Fix building project with maven (#5354)

6.19.x
Artem Zatsarynnyi 2017-06-12 23:48:28 +03:00 committed by GitHub
parent 269c5e7238
commit 1d5648fd6e
75 changed files with 1264 additions and 3302 deletions

View File

@ -43,6 +43,10 @@
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
@ -61,7 +65,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
<artifactId>che-core-api-workspace-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>

View File

@ -10,337 +10,338 @@
*******************************************************************************/
package org.eclipse.che.api.agent.server.launcher;
import org.eclipse.che.api.agent.server.exception.AgentStartException;
import org.eclipse.che.api.agent.shared.model.Agent;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.util.LineConsumer;
import org.eclipse.che.api.machine.server.exception.MachineException;
import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
import org.eclipse.che.api.machine.server.spi.Instance;
import org.eclipse.che.api.machine.server.spi.InstanceNode;
import org.eclipse.che.api.machine.server.spi.InstanceProcess;
import org.mockito.Mock;
import org.mockito.stubbing.Answer;
//import org.eclipse.che.api.agent.server.exception.AgentStartException;
//import org.eclipse.che.api.agent.shared.model.Agent;
//import org.eclipse.che.api.core.ServerException;
//import org.eclipse.che.api.core.util.LineConsumer;
//import org.eclipse.che.api.machine.server.exception.MachineException;
//import org.eclipse.che.api.machine.server.model.impl.CommandImpl;
//import org.eclipse.che.api.machine.server.spi.Instance;
//import org.eclipse.che.api.machine.server.spi.InstanceNode;
//import org.eclipse.che.api.machine.server.spi.InstanceProcess;
//import org.mockito.Mock;
//import org.mockito.stubbing.Answer;
import org.mockito.testng.MockitoTestNGListener;
import org.testng.annotations.BeforeMethod;
//import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import java.util.ArrayList;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
//import org.testng.annotations.Test;
//
//import java.util.ArrayList;
//
//import static org.mockito.Matchers.any;
//import static org.mockito.Matchers.anyObject;
//import static org.mockito.Matchers.anyString;
//import static org.mockito.Matchers.eq;
//import static org.mockito.Mockito.atLeast;
//import static org.mockito.Mockito.doReturn;
//import static org.mockito.Mockito.doThrow;
//import static org.mockito.Mockito.mock;
//import static org.mockito.Mockito.never;
//import static org.mockito.Mockito.spy;
//import static org.mockito.Mockito.times;
//import static org.mockito.Mockito.verify;
//import static org.mockito.Mockito.verifyNoMoreInteractions;
//import static org.mockito.Mockito.when;
//import static org.testng.Assert.assertTrue;
//import static org.testng.Assert.fail;
/**
* @author Alexander Garagatyi
*/
// FIXME: spi
@Listeners(MockitoTestNGListener.class)
public class AbstractAgentLauncherTest {
@Mock
private Instance machine;
@Mock
private Agent agent;
@Mock
private InstanceProcess process;
@Mock
private AgentLaunchingChecker agentChecker;
private AbstractAgentLauncher launcher;
@BeforeMethod
public void setUp() throws Exception {
launcher = spy(new TestAgentLauncher(500, 100, agentChecker));
when(agent.getScript()).thenReturn("script content");
doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class))).thenReturn(true);
when(machine.getNode()).thenReturn(mock(InstanceNode.class));
}
@Test
public void shouldBeAbleToCheckAgentState() throws Exception {
// when
launcher.launch(machine, agent);
// then
verify(agentChecker).isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class));
}
@Test
public void doNothingIfAgentScriptIsNull() throws Exception {
// given
when(agent.getScript()).thenReturn(null);
// when
launcher.launch(machine, agent);
// then
verify(launcher, never()).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
verify(agent).getScript();
verifyNoMoreInteractions(agent);
verifyZeroInteractions(machine);
}
@Test
public void doNothingIfAgentScriptIsEmpty() throws Exception {
// given
when(agent.getScript()).thenReturn("");
// when
launcher.launch(machine, agent);
// then
verify(launcher, never()).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
verify(agent).getScript();
verifyNoMoreInteractions(agent);
verifyZeroInteractions(machine);
}
@Test
public void shouldCheckIfAgentIsLaunchedUntilItIsLaunched() throws Exception {
// given
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class))).thenReturn(false)
.thenReturn(false)
.thenReturn(false)
.thenReturn(false)
.thenReturn(true);
// when
launcher.launch(machine, agent);
// then
verify(agentChecker, times(5)).isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class));
}
@Test(expectedExceptions = AgentStartException.class, expectedExceptionsMessageRegExp = "Fail launching agent .*. Workspace ID:.*")
public void shouldNotCheckIfAgentIsLaunchedMoreThanAgentMaxStartTime() throws Exception {
// given
launcher = spy(new TestAgentLauncher(200, 100, agentChecker));
doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class))).thenReturn(false)
.thenReturn(false)
.thenReturn(false)
.thenReturn(false)
.thenReturn(true);
// when
launcher.launch(machine, agent);
// then
// ensure that isLaunched was called several times and then max pinging time was exceeded
verify(agentChecker, atLeast(2)).isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class));
}
@Test
public void shouldNotCheckMoreFrequentThanAgentCheckDelay() throws Exception {
// given
launcher = spy(new TestAgentLauncher(200, 10, agentChecker));
doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// record time of each check of agent state
ArrayList<Long> checkTimestamps = new ArrayList<>(5);
Answer<Boolean> recordTimestampAndReturnFalse = invocationOnMock -> {
checkTimestamps.add(System.currentTimeMillis());
return false;
};
Answer<Boolean> recordTimestampAndReturnTrue = invocationOnMock -> {
checkTimestamps.add(System.currentTimeMillis());
return true;
};
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class))).thenAnswer(recordTimestampAndReturnFalse)
.thenAnswer(recordTimestampAndReturnFalse)
.thenAnswer(recordTimestampAndReturnFalse)
.thenAnswer(recordTimestampAndReturnFalse)
.thenAnswer(recordTimestampAndReturnTrue);
// when
launcher.launch(machine, agent);
// then
// ensure that each check was done after required timeout
for (int i = 1; i < checkTimestamps.size(); i++) {
assertTrue(checkTimestamps.get(i) - checkTimestamps.get(i - 1) >= 10);
}
}
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "agent launcher test exception")
public void shouldThrowServerExceptionIfMachineExceptionIsThrownByAgentCheck() throws Exception {
// given
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class)))
.thenThrow(new MachineException("agent launcher test exception"));
// when
launcher.launch(machine, agent);
}
@Test
public void shouldSetBackInterruptedFlagIfThreadWasInterrupted() throws Exception {
try {
// imitate interruption of launching thread
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class))).thenAnswer(invocationOnMock -> {
Thread.currentThread().interrupt();
return false;
});
// when
launcher.launch(machine, agent);
} catch (ServerException e) {
// Ensure that after exiting launcher thread is still in interrupted state
assertTrue(Thread.currentThread().isInterrupted());
} finally {
// cleanup interrupted state
Thread.interrupted();
}
}
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Launching agent .* is interrupted")
public void shouldThrowServerExceptionIfAgentCheckWasInterrupted() throws Exception {
try {
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class))).thenAnswer(invocationOnMock -> {
Thread.currentThread().interrupt();
return false;
});
// when
launcher.launch(machine, agent);
} finally {
// cleanup interrupted state
Thread.interrupted();
}
}
@Test
public void shouldStartMachineProcessWithAgentScriptExecution() throws Exception {
// given
String agentId = "testAgentId";
String agentScript = "testAgentScript";
when(agent.getId()).thenReturn(agentId);
when(agent.getScript()).thenReturn(agentScript);
when(launcher.start(any(Instance.class), any(Agent.class), any(LineConsumer.class))).thenCallRealMethod();
// when
launcher.launch(machine, agent);
// then
verify(machine).createProcess(eq(new CommandImpl(agentId, agentScript, "agent")), eq(null));
}
@Test(expectedExceptions = AgentStartException.class, expectedExceptionsMessageRegExp = "Fail launching agent .*\\. Workspace ID:.*")
public void shouldLogAgentStartLogsIfTimeoutReached() throws Exception {
// given
launcher = spy(new TestAgentLauncher(-1, 100, agentChecker));
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class))).thenReturn(false);
doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// when
try {
launcher.launch(machine, agent);
fail("Should throw AgentStartException");
} catch (AgentStartException e) {
// then
verify(launcher).logAsErrorAgentStartLogs(anyObject(), anyString(), anyString());
// rethrow exception to verify message
throw e;
}
}
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "An error on agent start")
public void shouldLogAgentStartLogsIfMachineExceptionOccurs() throws Exception {
// given
doThrow(new MachineException("An error on agent start"))
.when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// when
try {
launcher.launch(machine, agent);
fail("Should throw ServerException");
} catch (ServerException e) {
// then
verify(launcher).logAsErrorAgentStartLogs(anyObject(), anyString(), anyString());
// rethrow exception to verify message
throw e;
}
}
@Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "An error on process kill")
public void shouldLogAgentStartLogsIfMachineExceptionOccursAfterAgentStartTimeoutHadReached() throws Exception {
// given
launcher = spy(new TestAgentLauncher(-1, 100, agentChecker));
when(agentChecker.isLaunched(any(Agent.class),
any(InstanceProcess.class),
any(Instance.class))).thenReturn(false);
doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
doThrow(new MachineException("An error on process kill")).when(process).kill();
// when
try {
launcher.launch(machine, agent);
fail("Should throw ServerException");
} catch (ServerException e) {
// then
verify(launcher).logAsErrorAgentStartLogs(anyObject(), anyString(), anyString());
// rethrow exception to verify message
throw e;
}
}
private static class TestAgentLauncher extends AbstractAgentLauncher {
public TestAgentLauncher(long agentMaxStartTimeMs,
long agentPingDelayMs,
AgentLaunchingChecker agentLaunchingChecker) {
super(agentMaxStartTimeMs, agentPingDelayMs, agentLaunchingChecker);
}
@Override
protected InstanceProcess start(Instance machine, Agent agent, LineConsumer lineConsumer) throws ServerException {
return super.start(machine, agent, lineConsumer);
}
@Override
public String getAgentId() {
return "testAgentId";
}
@Override
public String getMachineType() {
return "testMachineType";
}
}
// @Mock
// private Instance machine;
// @Mock
// private Agent agent;
// @Mock
// private InstanceProcess process;
// @Mock
// private AgentLaunchingChecker agentChecker;
//
// private AbstractAgentLauncher launcher;
//
// @BeforeMethod
// public void setUp() throws Exception {
// launcher = spy(new TestAgentLauncher(500, 100, agentChecker));
//
// when(agent.getScript()).thenReturn("script content");
// doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class))).thenReturn(true);
// when(machine.getNode()).thenReturn(mock(InstanceNode.class));
// }
//
// @Test
// public void shouldBeAbleToCheckAgentState() throws Exception {
// // when
// launcher.launch(machine, agent);
//
// // then
// verify(agentChecker).isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class));
// }
//
// @Test
// public void doNothingIfAgentScriptIsNull() throws Exception {
// // given
// when(agent.getScript()).thenReturn(null);
//
// // when
// launcher.launch(machine, agent);
//
// // then
// verify(launcher, never()).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// verify(agent).getScript();
// verifyNoMoreInteractions(agent);
// verifyZeroInteractions(machine);
// }
//
// @Test
// public void doNothingIfAgentScriptIsEmpty() throws Exception {
// // given
// when(agent.getScript()).thenReturn("");
//
// // when
// launcher.launch(machine, agent);
//
// // then
// verify(launcher, never()).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// verify(agent).getScript();
// verifyNoMoreInteractions(agent);
// verifyZeroInteractions(machine);
// }
//
// @Test
// public void shouldCheckIfAgentIsLaunchedUntilItIsLaunched() throws Exception {
// // given
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class))).thenReturn(false)
// .thenReturn(false)
// .thenReturn(false)
// .thenReturn(false)
// .thenReturn(true);
//
// // when
// launcher.launch(machine, agent);
//
// // then
// verify(agentChecker, times(5)).isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class));
// }
//
// @Test(expectedExceptions = AgentStartException.class, expectedExceptionsMessageRegExp = "Fail launching agent .*. Workspace ID:.*")
// public void shouldNotCheckIfAgentIsLaunchedMoreThanAgentMaxStartTime() throws Exception {
// // given
// launcher = spy(new TestAgentLauncher(200, 100, agentChecker));
// doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class))).thenReturn(false)
// .thenReturn(false)
// .thenReturn(false)
// .thenReturn(false)
// .thenReturn(true);
//
// // when
// launcher.launch(machine, agent);
//
// // then
// // ensure that isLaunched was called several times and then max pinging time was exceeded
// verify(agentChecker, atLeast(2)).isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class));
// }
//
// @Test
// public void shouldNotCheckMoreFrequentThanAgentCheckDelay() throws Exception {
// // given
// launcher = spy(new TestAgentLauncher(200, 10, agentChecker));
// doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// // record time of each check of agent state
// ArrayList<Long> checkTimestamps = new ArrayList<>(5);
// Answer<Boolean> recordTimestampAndReturnFalse = invocationOnMock -> {
// checkTimestamps.add(System.currentTimeMillis());
// return false;
// };
// Answer<Boolean> recordTimestampAndReturnTrue = invocationOnMock -> {
// checkTimestamps.add(System.currentTimeMillis());
// return true;
// };
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class))).thenAnswer(recordTimestampAndReturnFalse)
// .thenAnswer(recordTimestampAndReturnFalse)
// .thenAnswer(recordTimestampAndReturnFalse)
// .thenAnswer(recordTimestampAndReturnFalse)
// .thenAnswer(recordTimestampAndReturnTrue);
//
// // when
// launcher.launch(machine, agent);
//
// // then
// // ensure that each check was done after required timeout
// for (int i = 1; i < checkTimestamps.size(); i++) {
// assertTrue(checkTimestamps.get(i) - checkTimestamps.get(i - 1) >= 10);
// }
// }
//
// @Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "agent launcher test exception")
// public void shouldThrowServerExceptionIfMachineExceptionIsThrownByAgentCheck() throws Exception {
// // given
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class)))
// .thenThrow(new MachineException("agent launcher test exception"));
//
// // when
// launcher.launch(machine, agent);
// }
//
// @Test
// public void shouldSetBackInterruptedFlagIfThreadWasInterrupted() throws Exception {
// try {
// // imitate interruption of launching thread
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class))).thenAnswer(invocationOnMock -> {
// Thread.currentThread().interrupt();
// return false;
// });
//
// // when
// launcher.launch(machine, agent);
// } catch (ServerException e) {
// // Ensure that after exiting launcher thread is still in interrupted state
// assertTrue(Thread.currentThread().isInterrupted());
// } finally {
// // cleanup interrupted state
// Thread.interrupted();
// }
// }
//
// @Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "Launching agent .* is interrupted")
// public void shouldThrowServerExceptionIfAgentCheckWasInterrupted() throws Exception {
// try {
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class))).thenAnswer(invocationOnMock -> {
// Thread.currentThread().interrupt();
// return false;
// });
//
// // when
// launcher.launch(machine, agent);
// } finally {
// // cleanup interrupted state
// Thread.interrupted();
// }
// }
//
// @Test
// public void shouldStartMachineProcessWithAgentScriptExecution() throws Exception {
// // given
// String agentId = "testAgentId";
// String agentScript = "testAgentScript";
// when(agent.getId()).thenReturn(agentId);
// when(agent.getScript()).thenReturn(agentScript);
// when(launcher.start(any(Instance.class), any(Agent.class), any(LineConsumer.class))).thenCallRealMethod();
//
// // when
// launcher.launch(machine, agent);
//
// // then
// verify(machine).createProcess(eq(new CommandImpl(agentId, agentScript, "agent")), eq(null));
// }
//
// @Test(expectedExceptions = AgentStartException.class, expectedExceptionsMessageRegExp = "Fail launching agent .*\\. Workspace ID:.*")
// public void shouldLogAgentStartLogsIfTimeoutReached() throws Exception {
// // given
// launcher = spy(new TestAgentLauncher(-1, 100, agentChecker));
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class))).thenReturn(false);
//
// doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
//
// // when
// try {
// launcher.launch(machine, agent);
// fail("Should throw AgentStartException");
// } catch (AgentStartException e) {
// // then
// verify(launcher).logAsErrorAgentStartLogs(anyObject(), anyString(), anyString());
// // rethrow exception to verify message
// throw e;
// }
// }
//
// @Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "An error on agent start")
// public void shouldLogAgentStartLogsIfMachineExceptionOccurs() throws Exception {
// // given
// doThrow(new MachineException("An error on agent start"))
// .when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
//
// // when
// try {
// launcher.launch(machine, agent);
// fail("Should throw ServerException");
// } catch (ServerException e) {
// // then
// verify(launcher).logAsErrorAgentStartLogs(anyObject(), anyString(), anyString());
// // rethrow exception to verify message
// throw e;
// }
// }
//
// @Test(expectedExceptions = ServerException.class, expectedExceptionsMessageRegExp = "An error on process kill")
// public void shouldLogAgentStartLogsIfMachineExceptionOccursAfterAgentStartTimeoutHadReached() throws Exception {
// // given
// launcher = spy(new TestAgentLauncher(-1, 100, agentChecker));
// when(agentChecker.isLaunched(any(Agent.class),
// any(InstanceProcess.class),
// any(Instance.class))).thenReturn(false);
//
// doReturn(process).when(launcher).start(any(Instance.class), any(Agent.class), any(LineConsumer.class));
// doThrow(new MachineException("An error on process kill")).when(process).kill();
//
// // when
// try {
// launcher.launch(machine, agent);
// fail("Should throw ServerException");
// } catch (ServerException e) {
// // then
// verify(launcher).logAsErrorAgentStartLogs(anyObject(), anyString(), anyString());
// // rethrow exception to verify message
// throw e;
// }
// }
//
// private static class TestAgentLauncher extends AbstractAgentLauncher {
// public TestAgentLauncher(long agentMaxStartTimeMs,
// long agentPingDelayMs,
// AgentLaunchingChecker agentLaunchingChecker) {
// super(agentMaxStartTimeMs, agentPingDelayMs, agentLaunchingChecker);
// }
//
// @Override
// protected InstanceProcess start(Instance machine, Agent agent, LineConsumer lineConsumer) throws ServerException {
// return super.start(machine, agent, lineConsumer);
// }
//
// @Override
// public String getAgentId() {
// return "testAgentId";
// }
//
// @Override
// public String getMachineType() {
// return "testMachineType";
// }
// }
}

View File

@ -10,30 +10,31 @@
*******************************************************************************/
package org.eclipse.che.api.agent.server.launcher;
import org.eclipse.che.api.agent.shared.model.Agent;
import org.eclipse.che.api.core.util.LineConsumer;
import org.eclipse.che.api.machine.server.spi.Instance;
import org.eclipse.che.api.machine.server.spi.InstanceProcess;
import org.mockito.Mock;
//import org.eclipse.che.api.agent.shared.model.Agent;
//import org.eclipse.che.api.core.util.LineConsumer;
//import org.eclipse.che.api.machine.server.spi.Instance;
//import org.eclipse.che.api.machine.server.spi.InstanceProcess;
//import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
import org.testng.annotations.Listeners;
/**
* @author Anatolii Bazko
*/
// FIXME: spi
@Listeners(value = {MockitoTestNGListener.class})
public class DefaultAgentLauncherTest {
@Mock
private Instance machine;
@Mock
private Agent agent;
@Mock
private LineConsumer lineConsumer;
@Mock
private InstanceProcess instanceProcess;
private AgentLauncher agentLauncher;
//
// @Mock
// private Instance machine;
// @Mock
// private Agent agent;
// @Mock
// private LineConsumer lineConsumer;
// @Mock
// private InstanceProcess instanceProcess;
//
// private AgentLauncher agentLauncher;
// @BeforeMethod
// public void setUp() throws Exception {

View File

@ -25,22 +25,10 @@
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>

View File

@ -25,14 +25,6 @@
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent-shared</artifactId>

View File

@ -25,22 +25,10 @@
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
</dependencies>
<build>
<plugins>

View File

@ -32,184 +32,184 @@
<artifactId>che-ide-core</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-composer-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-composer-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-cpp-lang-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-cpp-lang-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-csharp-lang-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-csharp-lang-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-debugger-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-debugger-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-docker-client</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-docker-client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-ext-dashboard-client</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-ext-dashboard-client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-gdb-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-gdb-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-git-ext-git</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-git-ext-git</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-github-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-github-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-github-oauth2</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-github-oauth2</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-github-pullrequest</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-github-pullrequest</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-github-shared</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-github-shared</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-gwt-ext-gwt</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-gwt-ext-gwt</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-help-ext-client</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-debugger-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-debugger-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-ext-lang-client</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-ext-lang-client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-ext-lang-shared</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-ext-lang-shared</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-plain-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-plain-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-plain-shared</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-java-plain-shared</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-keybinding-eclipse-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-keybinding-eclipse-ide</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-ide</artifactId>
</dependency>
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-machine-ssh-client</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-machine-ssh-client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-maven-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-maven-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-maven-shared</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-maven-shared</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-nodejs-debugger-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-nodejs-debugger-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-nodejs-lang-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-nodejs-lang-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-nodejs-lang-shared</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-nodejs-lang-shared</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-openshift-client</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-openshift-client</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-orion-compare</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-orion-compare</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-php-lang-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-php-lang-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-php-lang-shared</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-php-lang-shared</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-product-info</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-product-info</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-pullrequest-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-pullrequest-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-pullrequest-shared</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-pullrequest-shared</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-python-lang-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-python-lang-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-python-lang-shared</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-python-lang-shared</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-sdk-ext-plugins</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-sdk-ext-plugins</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-ssh-key-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-ssh-key-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-ssh-machine</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-ssh-machine</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-svn-ext-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-svn-ext-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-testing-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-testing-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-testing-junit-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-testing-junit-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-testing-testng-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-testing-testng-ide</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-web-ext-web</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-web-ext-web</artifactId>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-zend-debugger-ide</artifactId>-->
<!--<groupId>org.eclipse.che.plugin</groupId>-->
<!--<artifactId>che-plugin-zend-debugger-ide</artifactId>-->
<!--</dependency>-->
<dependency>
<groupId>javax.servlet</groupId>

View File

@ -101,15 +101,15 @@ public class JsonRpcWebSocketAgentEventListener implements WsAgentStateHandler {
machine.getServerByName(EXEC_AGENT_REFERENCE)
.ifPresent(server -> {
String execAgentServerURL = server.getUrl();
execAgentServerURL = execAgentServerURL.replaceFirst("http", "ws") + "/connect"; // FIXME: spi
execAgentServerURL = execAgentServerURL.replaceFirst("http", "ws") + "/connect"; // FIXME: spi ide
initializer.initialize(machine.getName(), singletonMap("url", execAgentServerURL));
});
final Optional<ServerImpl> wsAgentServer = machine.getServerByName(WSAGENT_REFERENCE);
if (wsAgentServer.isPresent()) {
final String wsAgentBaseUrl = wsAgentServer.get().getUrl() + "/api"; // FIXME: spi
final String wsAgentWebSocketUrl = wsAgentBaseUrl.replaceFirst("http", "ws") + "/ws"; // FIXME: spi
final String wsAgentBaseUrl = wsAgentServer.get().getUrl() + "/api"; // FIXME: spi ide
final String wsAgentWebSocketUrl = wsAgentBaseUrl.replaceFirst("http", "ws") + "/ws"; // FIXME: spi ide
final String wsAgentUrl = wsAgentWebSocketUrl.replaceFirst("(api)(/)(ws)", "websocket" + "$2" + appContext.getAppId());
initializer.initialize("ws-agent", singletonMap("url", wsAgentUrl));

View File

@ -31,7 +31,7 @@ public class DevMachine extends MachineEntityImpl {
super(name, devMachineDescriptor);
}
// FIXME: spi
// FIXME: spi ide
@Deprecated
public String getWsAgentWebSocketUrl() {
return getWsAgentBaseUrl().replaceFirst("http", "ws") + "/ws";
@ -60,7 +60,7 @@ public class DevMachine extends MachineEntityImpl {
url = url.substring(0, url.length() - 1);
}
// FIXME: spi
// FIXME: spi ide
return url + "/api";
}

View File

@ -80,7 +80,7 @@ public class MachineEntityImpl implements MachineEntity {
@Deprecated
@Override
public String getTerminalUrl() {
// FIXME: spi
// FIXME: spi ide
final MachineServer server = getServer(Constants.TERMINAL_REFERENCE);
if (server != null) {
return server.getUrl().replaceFirst("http", "ws") + "/pty";
@ -95,7 +95,7 @@ public class MachineEntityImpl implements MachineEntity {
@Deprecated
@Override
public String getExecAgentUrl() {
// FIXME: spi
// FIXME: spi ide
final MachineServer server = getServer(Constants.EXEC_AGENT_REFERENCE);
if (server != null) {
return server.getUrl().replaceFirst("http", "ws") + "/connect";

View File

@ -141,7 +141,7 @@ public class WsAgentStateController implements ConnectionOpenedHandler, Connecti
asyncRequestFactory.createGetRequest(url).send().then(ignored -> {
checkWsConnection();
}).catchError(ignored -> {
// FIXME: spi
// FIXME: spi ide
new Timer() {
@Override
public void run() {
@ -202,7 +202,7 @@ public class WsAgentStateController implements ConnectionOpenedHandler, Connecti
if (messageBus != null) {
messageBus.cancelReconnection();
}
// FIXME: spi
// FIXME: spi ide
final String wsAgentWebSocketURL = appContext.getDevAgentEndpoint().replaceFirst("http", "ws") + "/ws";
messageBus = messageBusProvider.createMachineMessageBus(wsAgentWebSocketURL);
// TODO: need to remove all handlers when ws-agent stopped

View File

@ -97,10 +97,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-user-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace-shared</artifactId>
@ -133,6 +129,10 @@
<groupId>org.eclipse.che.lib</groupId>
<artifactId>che-terminal-client</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>

View File

@ -45,7 +45,7 @@ public class WsConnectionListener implements ConnectionClosedHandler, Connection
public void onWorkspaceStarted(WorkspaceStartedEvent workspace) {
messageBus = messageBusProvider.getMessageBus();
// FIXME: spi
// FIXME: spi ide
// messageBus.addOnCloseHandler(WsConnectionListener.this);
}
});

View File

@ -226,7 +226,7 @@ public class BreakpointStorageImpl implements BreakpointStorage {
if (key != null && key.startsWith(LOCAL_STORAGE_BREAKPOINTS_KEY_PREFIX)) {
String wsId = key.substring(LOCAL_STORAGE_BREAKPOINTS_KEY_PREFIX.length());
// FIXME: spi
// FIXME: spi ide
// Promise<WorkspaceDto> workspace = workspaceServiceClient.getWorkspace(wsId);
// workspace.catchError(arg -> {
// storage.removeItem(key);

View File

@ -52,10 +52,10 @@ public class ServerPortMacro extends AbstractServerMacro {
/** {@inheritDoc} */
@Override
public Set<Macro> getMacros(MachineImpl devMachine) {
public Set<Macro> getMacros(MachineImpl machine) {
final Set<Macro> macros = Sets.newHashSet();
for (Map.Entry<String, ServerImpl> entry : devMachine.getServers().entrySet()) {
for (Map.Entry<String, ServerImpl> entry : machine.getServers().entrySet()) {
if (!entry.getValue().getUrl().contains(":")) {
continue;

View File

@ -56,7 +56,7 @@ public class TerminalInitializer {
@Override
public void onWsAgentStarted(WsAgentStateEvent event) {
restoreTerminal();
// FIXME: spi
// FIXME: spi ide
// machinePortProvider.get();
}

View File

@ -111,7 +111,7 @@ public class TerminalPresenter implements Presenter, TerminalView.ActionDelegate
if (terminalServer.isPresent()) {
final String terminalServerURL = terminalServer.get().getUrl();
// FIXME: spi
// FIXME: spi ide
connectToTerminalWebSocket(terminalServerURL.replaceFirst("http", "ws") + "/pty");
} else {
throw new OperationException("Machine " + machine.getName() + " doesn't provide terminal server.");

View File

@ -104,7 +104,7 @@ public class WorkspaceStatusHandler {
}
public void handleWorkspaceRunning(Workspace workspace) {
// FIXME: spi
// FIXME: spi ide
// should be set on server `ws-agent` has been started
((AppContextImpl)appContext).setProjectsRoot(Path.valueOf("/projects"));

View File

@ -17,7 +17,9 @@ import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.command.CommandExecutor;
import org.eclipse.che.ide.api.command.CommandImpl;
import org.eclipse.che.ide.api.command.CommandManager;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
@ -70,11 +72,13 @@ public class RunCommandActionTest {
when(event.getParameters()).thenReturn(Collections.singletonMap("otherParam", "MCI"));
action.actionPerformed(event);
verify(commandExecutor, never()).executeCommand(any(CommandImpl.class), any(Machine.class));
verify(commandExecutor, never()).executeCommand(any(CommandImpl.class), any(MachineImpl.class));
}
@Ignore
@Test
public void actionShouldBePerformed() {
// FIXME: spi ide
when(event.getParameters()).thenReturn(Collections.singletonMap(NAME_PROPERTY, "MCI"));
// final DevMachine devMachine = mock(DevMachine.class);
final Machine machine = mock(Machine.class);
@ -83,7 +87,7 @@ public class RunCommandActionTest {
action.actionPerformed(event);
verify(commandExecutor).executeCommand(eq(command), any(Machine.class));
verify(commandExecutor).executeCommand(eq(command), any(MachineImpl.class));
}
}

View File

@ -8,7 +8,7 @@
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.ide.client;
package org.eclipse.che.ide.actions;
import org.eclipse.che.ide.api.app.StartUpAction;
import org.eclipse.che.ide.actions.StartUpActionsParser;

View File

@ -12,13 +12,13 @@ package org.eclipse.che.ide.actions;
import com.google.gwtmockito.GwtMockitoTestRunner;
import org.eclipse.che.api.core.model.workspace.Workspace;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.ide.CoreLocalizationConstant;
import org.eclipse.che.ide.api.action.ActionEvent;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.machine.DevMachine;
import org.eclipse.che.ide.api.workspace.model.RuntimeImpl;
import org.eclipse.che.ide.api.workspace.model.WorkspaceImpl;
import org.eclipse.che.ide.bootstrap.CurrentWorkspaceManager;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -46,7 +46,7 @@ public class StopWorkspaceActionTest {
@Mock
private CurrentWorkspaceManager workspaceManager;
@Mock
private Workspace workspace;
private WorkspaceImpl workspace;
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
private ActionEvent actionEvent;
@ -67,6 +67,9 @@ public class StopWorkspaceActionTest {
@Test
public void actionShouldBeUpdated() {
when(workspace.getRuntime()).thenReturn(mock(RuntimeImpl.class));
when(appContext.getWorkspace()).thenReturn(workspace);
action.updateInPerspective(actionEvent);
verify(actionEvent, times(2)).getPresentation();
@ -74,8 +77,6 @@ public class StopWorkspaceActionTest {
@Test
public void actionShouldBePerformed() throws Exception {
DevMachine devMachine = mock(DevMachine.class);
when(devMachine.getName()).thenReturn("id");
when(appContext.getWorkspace()).thenReturn(workspace);
when(workspace.getId()).thenReturn("id");

View File

@ -10,10 +10,10 @@
*******************************************************************************/
package org.eclipse.che.ide.command.explorer;
import com.google.gwt.core.client.Callback;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwtmockito.GwtMockitoTestRunner;
import com.google.inject.Provider;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.api.promises.client.Operation;
@ -32,14 +32,12 @@ import org.eclipse.che.ide.api.command.CommandRemovedEvent.CommandRemovedHandler
import org.eclipse.che.ide.api.command.CommandType;
import org.eclipse.che.ide.api.command.CommandUpdatedEvent;
import org.eclipse.che.ide.api.command.CommandUpdatedEvent.CommandUpdatedHandler;
import org.eclipse.che.ide.api.constraints.Constraints;
import org.eclipse.che.ide.api.dialogs.CancelCallback;
import org.eclipse.che.ide.api.dialogs.ConfirmCallback;
import org.eclipse.che.ide.api.dialogs.ConfirmDialog;
import org.eclipse.che.ide.api.dialogs.DialogFactory;
import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.parts.PartStackType;
import org.eclipse.che.ide.api.parts.WorkspaceAgent;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.command.CommandResources;
@ -90,7 +88,7 @@ public class CommandsExplorerPresenterTest {
@Mock
private NodeFactory nodeFactory;
@Mock
private EditorAgent editorAgent;
private Provider<EditorAgent> editorAgentProvider;
@Mock
private AppContext appContext;
@Mock
@ -108,8 +106,6 @@ public class CommandsExplorerPresenterTest {
@Captor
private ArgumentCaptor<Operation<PromiseError>> errorOperationCaptor;
@Captor
private ArgumentCaptor<Operation<CommandImpl>> commandOperationCaptor;
@Captor
private ArgumentCaptor<Operation<CommandType>> commandTypeOperationCaptor;
@Test
@ -119,18 +115,9 @@ public class CommandsExplorerPresenterTest {
@Test
public void testStart() throws Exception {
Callback callback = mock(Callback.class);
presenter.start(callback);
verify(workspaceAgent).openPart(presenter, PartStackType.NAVIGATION, Constraints.LAST);
verifyViewRefreshed();
verify(eventBus).addHandler(eq(CommandAddedEvent.getType()), any(CommandAddedHandler.class));
verify(eventBus).addHandler(eq(CommandRemovedEvent.getType()), any(CommandRemovedHandler.class));
verify(eventBus).addHandler(eq(CommandUpdatedEvent.getType()), any(CommandUpdatedHandler.class));
verify(callback).onSuccess(presenter);
}
@Test
@ -139,7 +126,7 @@ public class CommandsExplorerPresenterTest {
presenter.go(container);
verify(refreshViewTask).delayAndSelectCommand(isNull(CommandImpl.class));
verifyViewRefreshed();
verify(container).setWidget(view);
}

View File

@ -10,18 +10,17 @@
*******************************************************************************/
package org.eclipse.che.ide.command.palette;
import org.eclipse.che.api.core.model.machine.Machine;
import org.eclipse.che.api.core.model.workspace.Workspace;
import org.eclipse.che.api.workspace.shared.dto.MachineDto;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.api.workspace.shared.dto.WorkspaceRuntimeDto;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.command.CommandExecutor;
import org.eclipse.che.ide.api.command.CommandGoal;
import org.eclipse.che.ide.api.command.CommandImpl;
import org.eclipse.che.ide.api.command.CommandManager;
import org.eclipse.che.ide.api.dialogs.DialogFactory;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.eclipse.che.ide.api.workspace.model.RuntimeImpl;
import org.eclipse.che.ide.api.workspace.model.WorkspaceImpl;
import org.eclipse.che.ide.command.CommandUtils;
import org.eclipse.che.ide.machine.chooser.MachineChooser;
import org.junit.Test;
@ -73,10 +72,10 @@ public class CommandsPalettePresenterTest {
private PaletteMessages messages;
@Mock
private Promise<Machine> machinePromise;
private Promise<MachineImpl> machinePromise;
@Captor
private ArgumentCaptor<Operation<Machine>> selectedMachineCaptor;
private ArgumentCaptor<Operation<MachineImpl>> selectedMachineCaptor;
@Captor
private ArgumentCaptor<Map<CommandGoal, List<CommandImpl>>> filteredCommandsCaptor;
@ -130,15 +129,15 @@ public class CommandsPalettePresenterTest {
@Test
public void shouldExecuteCommand() throws Exception {
// given
Workspace workspace = mock(Workspace.class);
WorkspaceImpl workspace = mock(WorkspaceImpl.class);
when(appContext.getWorkspace()).thenReturn(workspace);
WorkspaceRuntimeDto workspaceRuntime = mock(WorkspaceRuntimeDto.class);
RuntimeImpl workspaceRuntime = mock(RuntimeImpl.class);
when(workspace.getRuntime()).thenReturn(workspaceRuntime);
List<MachineDto> machines = new ArrayList<>(1);
MachineDto chosenMachine = mock(MachineDto.class);
machines.add(chosenMachine);
Map<String, MachineImpl> machines = new HashMap<>();
MachineImpl chosenMachine = mock(MachineImpl.class);
machines.put("machine_id", chosenMachine);
when(workspaceRuntime.getMachines()).thenReturn(machines);
when(machineChooser.show()).thenReturn(machinePromise);

View File

@ -14,11 +14,11 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.inject.Provider;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.api.core.model.workspace.runtime.Machine;
import org.eclipse.che.ide.api.command.CommandExecutor;
import org.eclipse.che.ide.api.command.CommandGoal;
import org.eclipse.che.ide.api.command.CommandImpl;
import org.eclipse.che.ide.api.command.CommandManager;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.eclipse.che.ide.command.goal.DebugGoal;
import org.eclipse.che.ide.command.goal.RunGoal;
import org.eclipse.che.ide.command.toolbar.CommandCreationGuide;
@ -92,7 +92,7 @@ public class ExecuteCommandPresenterTest {
@Test
public void shouldExecuteCommandOnMachine() throws Exception {
CommandImpl command = mock(CommandImpl.class);
Machine machine = mock(Machine.class);
MachineImpl machine = mock(MachineImpl.class);
presenter.onCommandExecute(command, machine);

View File

@ -10,9 +10,8 @@
*******************************************************************************/
package org.eclipse.che.ide.command.toolbar.commands.button;
import org.eclipse.che.api.core.model.machine.Machine;
import org.eclipse.che.api.core.model.machine.MachineConfig;
import org.eclipse.che.ide.api.command.CommandImpl;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -20,7 +19,6 @@ import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
/** Tests for {@link MachineItem}. */
@ -32,15 +30,13 @@ public class MachineItemTest {
@Mock
private CommandImpl command;
@Mock
private Machine machine;
private MachineImpl machine;
private MachineItem item;
@Before
public void setUp() throws Exception {
MachineConfig machineConfig = mock(MachineConfig.class);
when(machineConfig.getName()).thenReturn(MACHINE_NAME);
when(machine.getConfig()).thenReturn(machineConfig);
when(machine.getName()).thenReturn(MACHINE_NAME);
item = new MachineItem(command, machine);
}

View File

@ -13,6 +13,7 @@ package org.eclipse.che.ide.command.toolbar.previews;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.eclipse.che.ide.api.workspace.model.ServerImpl;
import org.eclipse.che.ide.api.workspace.model.WorkspaceImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -21,6 +22,7 @@ import org.mockito.runners.MockitoJUnitRunner;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
@ -51,7 +53,9 @@ public class PreviewUrlTest {
when(devMachine.getName()).thenReturn(MACHINE_NAME);
when(devMachine.getServers()).thenReturn(servers);
// when(appContext.getDevMachine()).thenReturn(devMachine);
WorkspaceImpl workspace = mock(WorkspaceImpl.class);
when(workspace.getDevMachine()).thenReturn(Optional.of(devMachine));
when(appContext.getWorkspace()).thenReturn(workspace);
previewUrl = new PreviewUrl(PREVIEW_URL, appContext);
}

View File

@ -13,9 +13,6 @@ package org.eclipse.che.ide.macro;
import com.google.gwtmockito.GwtMockitoTestRunner;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.api.core.model.machine.Machine;
import org.eclipse.che.api.core.model.machine.MachineRuntimeInfo;
import org.eclipse.che.api.core.model.machine.Server;
import org.eclipse.che.api.machine.shared.Constants;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
@ -23,8 +20,10 @@ import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.macro.BaseMacro;
import org.eclipse.che.ide.api.macro.Macro;
import org.eclipse.che.ide.api.macro.MacroRegistry;
import org.eclipse.che.ide.api.machine.DevMachine;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.eclipse.che.ide.api.workspace.model.ServerImpl;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@ -62,16 +61,10 @@ public class ServerHostNameMacroTest {
private AppContext appContext;
@Mock
private DevMachine devMachine;
private MachineImpl machine;
@Mock
private Machine machine;
@Mock
private MachineRuntimeInfo machineRuntimeInfo;
@Mock
private Server server;
private ServerImpl server;
private ServerHostNameMacro provider;
@ -82,9 +75,11 @@ public class ServerHostNameMacroTest {
registerProvider();
}
// FIXME: spi ide
@Ignore
@Test
public void getMacros() throws Exception {
final Set<Macro> macros = provider.getMacros(devMachine);
final Set<Macro> macros = provider.getMacros(machine);
assertEquals(macros.size(), 2);
@ -116,12 +111,9 @@ public class ServerHostNameMacroTest {
}
protected void registerProvider() {
when(devMachine.getDescriptor()).thenReturn(machine);
when(machine.getRuntime()).thenReturn(machineRuntimeInfo);
doReturn(Collections.<String, Server>singletonMap(WS_AGENT_PORT, server)).when(machineRuntimeInfo).getServers();
when(server.getAddress()).thenReturn(ADDRESS);
when(server.getProtocol()).thenReturn(PROTOCOL);
when(server.getRef()).thenReturn(REF);
doReturn(Collections.singletonMap(WS_AGENT_PORT, server)).when(machine).getServers();
when(server.getUrl()).thenReturn(ADDRESS);
when(server.getName()).thenReturn(REF);
}
}

View File

@ -13,9 +13,6 @@ package org.eclipse.che.ide.macro;
import com.google.gwtmockito.GwtMockitoTestRunner;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.api.core.model.machine.Machine;
import org.eclipse.che.api.core.model.machine.MachineRuntimeInfo;
import org.eclipse.che.api.core.model.machine.Server;
import org.eclipse.che.api.machine.shared.Constants;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
@ -23,7 +20,8 @@ import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.macro.BaseMacro;
import org.eclipse.che.ide.api.macro.Macro;
import org.eclipse.che.ide.api.macro.MacroRegistry;
import org.eclipse.che.ide.api.machine.DevMachine;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.eclipse.che.ide.api.workspace.model.ServerImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -60,16 +58,10 @@ public class ServerPortMacroTest {
private AppContext appContext;
@Mock
private DevMachine devMachine;
private MachineImpl machine;
@Mock
private Machine machine;
@Mock
private MachineRuntimeInfo machineRuntimeInfo;
@Mock
private Server server;
private ServerImpl server;
private ServerPortMacro macro;
@ -82,7 +74,7 @@ public class ServerPortMacroTest {
@Test
public void getMacros() throws Exception {
final Set<Macro> macros = macro.getMacros(devMachine);
final Set<Macro> macros = macro.getMacros(machine);
assertEquals(macros.size(), 2);
@ -114,10 +106,7 @@ public class ServerPortMacroTest {
}
protected void registerMacros() {
when(devMachine.getDescriptor()).thenReturn(machine);
when(machine.getRuntime()).thenReturn(machineRuntimeInfo);
doReturn(Collections.<String, Server>singletonMap(WS_AGENT_PORT, server)).when(machineRuntimeInfo).getServers();
when(server.getAddress()).thenReturn(ADDRESS);
doReturn(Collections.singletonMap(WS_AGENT_PORT, server)).when(machine).getServers();
when(server.getUrl()).thenReturn(ADDRESS);
}
}

View File

@ -13,15 +13,17 @@ package org.eclipse.che.ide.macro;
import org.eclipse.che.api.promises.client.PromiseProvider;
import org.eclipse.che.ide.CoreLocalizationConstant;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.macro.WorkspaceNameMacro;
import org.eclipse.che.ide.api.workspace.model.WorkspaceConfigImpl;
import org.eclipse.che.ide.api.workspace.model.WorkspaceImpl;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import static org.junit.Assert.*;
import static org.junit.Assert.assertSame;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@ -48,7 +50,11 @@ public class WorkspaceNameMacroTest {
@Before
public void init() throws Exception {
when(appContext.getWorkspaceName()).thenReturn(WS_NAME);
WorkspaceImpl workspace = mock(WorkspaceImpl.class);
WorkspaceConfigImpl workspaceConfig = mock(WorkspaceConfigImpl.class);
when(workspaceConfig.getName()).thenReturn(WS_NAME);
when(workspace.getConfig()).thenReturn(workspaceConfig);
when(appContext.getWorkspace()).thenReturn(workspace);
provider = new WorkspaceNameMacro(appContext, promiseProvider, localizationConstants);
}

View File

@ -20,13 +20,16 @@ import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.parts.PartStackView;
import org.eclipse.che.ide.command.explorer.CommandsExplorerPresenter;
import org.eclipse.che.ide.part.PartStackPresenter;
import org.eclipse.che.ide.part.editor.multipart.EditorMultiPartStackPresenter;
import org.eclipse.che.ide.part.PartStackPresenterFactory;
import org.eclipse.che.ide.part.PartStackViewFactory;
import org.eclipse.che.ide.part.WorkBenchControllerFactory;
import org.eclipse.che.ide.part.WorkBenchPartController;
import org.eclipse.che.ide.part.editor.multipart.EditorMultiPartStackPresenter;
import org.eclipse.che.ide.part.explorer.project.ProjectExplorerPresenter;
import org.eclipse.che.ide.part.perspectives.general.PerspectiveViewImpl;
import org.eclipse.che.ide.processes.panel.ProcessesPanelPresenter;
import org.eclipse.che.providers.DynaProvider;
import org.junit.Before;
import org.junit.Test;
@ -60,25 +63,31 @@ public class ProjectPerspectiveTest {
//additional mocks
@Mock
private FlowPanel panel;
private FlowPanel panel;
@Mock
private SplitLayoutPanel layoutPanel;
private SplitLayoutPanel layoutPanel;
@Mock
private SimplePanel simplePanel;
private SimplePanel simplePanel;
@Mock
private SimpleLayoutPanel simpleLayoutPanel;
private SimpleLayoutPanel simpleLayoutPanel;
@Mock
private WorkBenchPartController workBenchController;
private WorkBenchPartController workBenchController;
@Mock
private PartStackView partStackView;
private PartStackView partStackView;
@Mock
private PartStackPresenter partStackPresenter;
private PartStackPresenter partStackPresenter;
@Mock
private AcceptsOneWidget container;
private AcceptsOneWidget container;
@Mock
private DynaProvider dynaProvider;
private DynaProvider dynaProvider;
@Mock
private NotificationManager notificationManager;
private NotificationManager notificationManager;
@Mock
private ProjectExplorerPresenter projectExplorerPresenter;
@Mock
private CommandsExplorerPresenter commandsExplorerPresenter;
@Mock
private ProcessesPanelPresenter processesPanelPresenter;
private ProjectPerspective perspective;
@ -112,7 +121,10 @@ public class ProjectPerspectiveTest {
controllerFactory,
eventBus,
dynaProvider,
notificationManager);
projectExplorerPresenter,
commandsExplorerPresenter,
notificationManager,
processesPanelPresenter);
}
@Test

View File

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.che.ide.projectimport.wizard;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.promises.client.Function;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.Promise;

View File

@ -12,12 +12,12 @@ package org.eclipse.che.ide.projecttype.wizard;
import com.google.common.base.Optional;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.workspace.shared.dto.CommandDto;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.promises.client.Function;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.api.promises.client.PromiseError;
import org.eclipse.che.api.workspace.shared.dto.CommandDto;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.command.CommandImpl;
import org.eclipse.che.ide.api.command.CommandManager;

View File

@ -15,11 +15,15 @@ import elemental.json.JsonFactory;
import elemental.json.JsonObject;
import com.google.gwtmockito.GwtMockitoTestRunner;
import com.google.inject.Provider;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.component.StateComponent;
import org.eclipse.che.ide.api.preferences.PreferencesManager;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
@ -41,25 +45,35 @@ import static org.mockito.Mockito.when;
* @author Artem Zatsarynnyi
* @author Dmitry Shnurenko
*/
// FIXME: spi ide
@Ignore
@RunWith(GwtMockitoTestRunner.class)
public class AppStateManagerTest {
private static final String WS_ID = "ws_id";
@Mock
private StateComponent component1;
private StateComponent component1;
@Mock
private StateComponent component2;
private StateComponent component2;
@Mock
private Promise<Void> promise;
private Provider<StateComponent> component1Provider;
@Mock
private Promise<String> contentPromise;
private Provider<StateComponent> component2Provider;
@Mock
private PreferencesManager preferencesManager;
private Promise<Void> promise;
@Mock
private JsonFactory jsonFactory;
private Promise<String> contentPromise;
@Mock
private JsonObject pref;
private PreferencesManager preferencesManager;
@Mock
private JsonFactory jsonFactory;
@Mock
private EventBus eventBus;
@Mock
private AppContext appContext;
@Mock
private JsonObject pref;
@Captor
private ArgumentCaptor<String> preferenceArgumentCaptor;
@ -71,14 +85,19 @@ public class AppStateManagerTest {
@Before
public void setUp() {
Map<String, StateComponent> components = new HashMap<>();
components.put("component1", component1);
components.put("component2", component2);
when(appContext.getWorkspaceId()).thenReturn(WS_ID);
Map<String, Provider<StateComponent>> components = new HashMap<>();
components.put("component1", component1Provider);
components.put("component2", component2Provider);
when(component1Provider.get()).thenReturn(component1);
when(component2Provider.get()).thenReturn(component2);
when(preferencesManager.flushPreferences()).thenReturn(promise);
when(preferencesManager.getValue(AppStateManager.PREFERENCE_PROPERTY_NAME)).thenReturn("");
when(jsonFactory.parse(anyString())).thenReturn(pref = Json.createObject());
appStateManager = new AppStateManager(components, preferencesManager, jsonFactory);
appStateManager = new AppStateManager(components, preferencesManager, jsonFactory, eventBus, appContext);
}
@Test
@ -129,7 +148,7 @@ public class AppStateManagerTest {
@Test
public void restoreShouldReadFromPreferences() throws Exception {
pref.put(WS_ID, Json.createObject());
appStateManager.restoreWorkspaceState(WS_ID);
appStateManager.restoreWorkspaceState();
verify(preferencesManager).getValue(AppStateManager.PREFERENCE_PROPERTY_NAME);
}
@ -144,7 +163,7 @@ public class AppStateManagerTest {
workspace.put("component1", comp1);
comp1.put("key1", "value1");
appStateManager.restoreWorkspaceState(WS_ID);
appStateManager.restoreWorkspaceState();
ArgumentCaptor<JsonObject> stateCaptor = ArgumentCaptor.forClass(JsonObject.class);
verify(component1).loadState(stateCaptor.capture());

View File

@ -67,6 +67,10 @@
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-gwt</artifactId>

View File

@ -38,10 +38,6 @@
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
@ -70,10 +66,6 @@
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>ST4</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-agent</artifactId>
@ -201,6 +193,7 @@
<configuration>
<excludes>
<exclude>**/integration/**</exclude>
<exclude>**/environment/compose/**</exclude>
</excludes>
</configuration>
</plugin>

View File

@ -11,7 +11,7 @@
package org.eclipse.che.workspace.infrastructure.docker.old;
import org.eclipse.che.api.core.model.machine.MachineSource;
import org.eclipse.che.api.machine.server.exception.MachineException;
import org.eclipse.che.api.workspace.server.spi.InternalInfrastructureException;
import org.eclipse.che.workspace.infrastructure.docker.DockerMachineSource;
import org.mockito.Mock;
import org.mockito.testng.MockitoTestNGListener;
@ -56,7 +56,8 @@ public class DockerMachineSourceTest {
* Check that all the constructor are valid and not throwing exception based on data provider
*/
@Test(dataProvider = "image-ids")
public void testConstructors(String location, String registry, String repository, String tag, String digest) throws MachineException {
public void testConstructors(String location, String registry, String repository, String tag, String digest)
throws InternalInfrastructureException {
DockerMachineSource
source1 = new DockerMachineSource(repository).withTag(tag).withRegistry(registry).withDigest(digest);
assertEquals(source1.getLocation(), location);
@ -82,8 +83,8 @@ public class DockerMachineSourceTest {
/**
* Check valid source type
*/
@Test(expectedExceptions = MachineException.class)
public void testInvalidSourceType() throws MachineException {
@Test(expectedExceptions = InternalInfrastructureException.class)
public void testInvalidSourceType() throws InternalInfrastructureException {
when(machineSource.getType()).thenReturn("invalid");
new DockerMachineSource(machineSource);
}
@ -91,8 +92,8 @@ public class DockerMachineSourceTest {
/**
* Check invalid format
*/
@Test(expectedExceptions = MachineException.class)
public void testInvalidFormat() throws MachineException {
@Test(expectedExceptions = InternalInfrastructureException.class)
public void testInvalidFormat() throws InternalInfrastructureException {
when(machineSource.getType()).thenReturn("image");
when(machineSource.getLocation()).thenReturn("@image");
new DockerMachineSource(machineSource);

View File

@ -1,31 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.workspace.infrastructure.docker.old;
import org.mockito.testng.MockitoTestNGListener;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
/**
* @author Max Shaposhnik
*
*/
@Listeners(value = {MockitoTestNGListener.class})
public class DockerMachineTerminalCheckerTest {
@Test(expectedExceptions = RuntimeException.class)
public void shouldThrowRuntimeExceptionIfNoTerminalArchivePresent() {
DockerMachineTerminalChecker checker = new DockerMachineTerminalChecker("/no/such/path");
checker.start();
}
}

View File

@ -10,10 +10,7 @@
*******************************************************************************/
package org.eclipse.che.workspace.infrastructure.docker.old.integration;
import org.eclipse.che.api.core.model.workspace.config.Command;
import org.eclipse.che.api.core.util.LineConsumer;
import org.eclipse.che.api.machine.server.exception.MachineException;
import org.eclipse.che.api.workspace.server.model.impl.CommandImpl;
import org.eclipse.che.plugin.docker.client.DockerApiVersionPathPrefixProvider;
import org.eclipse.che.plugin.docker.client.DockerConnector;
import org.eclipse.che.plugin.docker.client.DockerConnectorConfiguration;
@ -33,10 +30,8 @@ import org.mockito.testng.MockitoTestNGListener;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import java.io.IOException;
import java.net.URI;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@ -90,23 +85,23 @@ public class DockerProcessTest {
* If default access to docker is UNIX socket try to reconfigure docker connector for this test.<br>
* This test may fail if system doesn't allow such access.
*/
@Test(expectedExceptions = MachineException.class,
expectedExceptionsMessageRegExp = "Command output read timeout is reached. Process is still running and has id \\d+ inside machine")
public void shouldThrowErrorWithRealPIDIfSocketTimeoutExceptionHappens() throws Exception {
DockerConnectorConfiguration dockerConnectorConfiguration = this.dockerConnectorConfiguration;
DockerConnector docker = this.docker;
if ("unix".equals(dockerConnectorConfiguration.getDockerDaemonUri().getScheme())) {
// access through unix socket - reconfigure to use tcp
dockerConnectorConfiguration = new DockerConnectorConfiguration(new URI("http://localhost:2375"),
null,
new InitialAuthConfig(),
new DefaultNetworkFinder());
docker = new DockerConnector(dockerConnectorConfiguration,
new DockerConnectionFactory(dockerConnectorConfiguration),
new DockerRegistryAuthResolver(null, null),
new DockerApiVersionPathPrefixProvider(""));
}
Command command = new CommandImpl("tailf", "tail -f /dev/null", "mvn");
// @Test(expectedExceptions = MachineException.class,
// expectedExceptionsMessageRegExp = "Command output read timeout is reached. Process is still running and has id \\d+ inside machine")
// public void shouldThrowErrorWithRealPIDIfSocketTimeoutExceptionHappens() throws Exception {
// DockerConnectorConfiguration dockerConnectorConfiguration = this.dockerConnectorConfiguration;
// DockerConnector docker = this.docker;
// if ("unix".equals(dockerConnectorConfiguration.getDockerDaemonUri().getScheme())) {
// // access through unix socket - reconfigure to use tcp
// dockerConnectorConfiguration = new DockerConnectorConfiguration(new URI("http://localhost:2375"),
// null,
// new InitialAuthConfig(),
// new DefaultNetworkFinder());
// docker = new DockerConnector(dockerConnectorConfiguration,
// new DockerConnectionFactory(dockerConnectorConfiguration),
// new DockerRegistryAuthResolver(null, null),
// new DockerApiVersionPathPrefixProvider(""));
// }
// Command command = new CommandImpl("tailf", "tail -f /dev/null", "mvn");
// final DockerProcess dockerProcess = new DockerProcess(dockerConnectorProvider,
// command,
// container,
@ -115,7 +110,7 @@ public class DockerProcessTest {
// pidGenerator.incrementAndGet());
//
// dockerProcess.start(new SOUTLineConsumer());
}
// }
static class SOUTLineConsumer implements LineConsumer {
@Override

View File

@ -1,77 +0,0 @@
/*******************************************************************************
* Copyright (c) 2012-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*******************************************************************************/
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
import com.google.inject.TypeLiteral;
import org.eclipse.che.account.spi.AccountImpl;
import org.eclipse.che.api.core.model.workspace.Workspace;
import org.eclipse.che.api.machine.server.recipe.OldRecipeImpl;
import org.eclipse.che.api.machine.server.spi.RecipeDao;
import org.eclipse.che.commons.test.db.H2DBTestServer;
import org.eclipse.che.commons.test.db.H2JpaCleaner;
import org.eclipse.che.commons.test.db.H2TestHelper;
import org.eclipse.che.commons.test.db.PersistTestModuleBuilder;
import org.eclipse.che.commons.test.tck.TckModule;
import org.eclipse.che.commons.test.tck.TckResourcesCleaner;
import org.eclipse.che.commons.test.tck.repository.JpaTckRepository;
import org.eclipse.che.commons.test.tck.repository.TckRepository;
import org.eclipse.che.commons.test.tck.repository.TckRepositoryException;
import org.eclipse.che.core.db.DBInitializer;
import org.eclipse.che.core.db.h2.jpa.eclipselink.H2ExceptionHandler;
import org.eclipse.che.core.db.schema.SchemaInitializer;
import org.eclipse.che.core.db.schema.impl.flyway.FlywaySchemaInitializer;
import org.h2.Driver;
import java.util.Collection;
import java.util.stream.Collectors;
/**
* @author Anton Korneta
*/
public class JpaTckModule extends TckModule {
@Override
protected void configure() {
H2DBTestServer server = H2DBTestServer.startDefault();
install(new PersistTestModuleBuilder().setDriver(Driver.class)
.runningOn(server)
.addEntityClasses(OldRecipeImpl.class,
SnapshotImpl.class,
AccountImpl.class,
TestWorkspaceEntity.class)
.setExceptionHandler(H2ExceptionHandler.class)
.build());
bind(DBInitializer.class).asEagerSingleton();
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(H2TestHelper.inMemoryDefault(), "che-schema"));
bind(TckResourcesCleaner.class).to(H2JpaCleaner.class);
bind(new TypeLiteral<TckRepository<OldRecipeImpl>>() {}).toInstance(new JpaTckRepository<>(OldRecipeImpl.class));
bind(new TypeLiteral<TckRepository<SnapshotImpl>>() {}).toInstance(new JpaTckRepository<>(SnapshotImpl.class));
bind(new TypeLiteral<TckRepository<Workspace>>() {}).toInstance(new TestWorkspacesTckRepository());
bind(new TypeLiteral<TckRepository<AccountImpl>>() {}).toInstance(new JpaTckRepository<>(AccountImpl.class));
bind(RecipeDao.class).to(JpaRecipeDao.class);
bind(SnapshotDao.class).to(JpaSnapshotDao.class);
}
private static class TestWorkspacesTckRepository extends JpaTckRepository<Workspace> {
public TestWorkspacesTckRepository() { super(TestWorkspaceEntity.class); }
@Override
public void createAll(Collection<? extends Workspace> entities) throws TckRepositoryException {
super.createAll(entities.stream()
.map(TestWorkspaceEntity::new)
.collect(Collectors.toList()));
}
}
}

View File

@ -10,41 +10,21 @@
*******************************************************************************/
package org.eclipse.che.workspace.infrastructure.docker.snapshot;
import com.google.common.collect.Sets;
import com.google.inject.Inject;
import org.eclipse.che.account.spi.AccountImpl;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.model.workspace.Runtime;
import org.eclipse.che.api.core.model.workspace.Workspace;
import org.eclipse.che.api.core.model.workspace.WorkspaceConfig;
import org.eclipse.che.api.core.model.workspace.WorkspaceStatus;
import org.eclipse.che.api.machine.server.exception.SnapshotException;
import org.eclipse.che.api.workspace.server.model.impl.MachineSourceImpl;
import org.eclipse.che.commons.test.tck.TckListener;
import org.eclipse.che.commons.test.tck.repository.TckRepository;
import org.eclipse.che.commons.test.tck.repository.TckRepositoryException;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonList;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.fail;
/**
* Tests {@link SnapshotDao} contract.
*
* @author Yevhenii Voevodin
*/
@Listeners(TckListener.class)
@Test(suiteName = SnapshotDaoTest.SUITE_NAME)
public class SnapshotDaoTest {
@ -58,211 +38,202 @@ public class SnapshotDaoTest {
@Inject
private SnapshotDao snapshotDao;
@Inject
private TckRepository<SnapshotImpl> snaphotRepo;
@Inject
private TckRepository<Workspace> workspaceRepo;
@Inject
private TckRepository<AccountImpl> accountRepo;
@BeforeMethod
private void createSnapshots() throws TckRepositoryException {
// one account for all the workspaces
final AccountImpl account = new AccountImpl("account1", "name", "type");
// workspaces
workspaces = new TestWorkspace[SNAPSHOTS_SIZE / 3];
for (int i = 0; i < workspaces.length; i++) {
workspaces[i] = new TestWorkspace("workspace-" + i, account.getId());
}
// snapshots
snapshots = new SnapshotImpl[SNAPSHOTS_SIZE];
for (int i = 0; i < SNAPSHOTS_SIZE; i++) {
snapshots[i] = createSnapshot("snapshot-" + i,
workspaces[i / 3].getId(), // 3 snapshot share the same workspace id
"environment-" + i / 2, // 2 snapshots share the same env name
"machine-" + i);
}
accountRepo.createAll(singletonList(account));
workspaceRepo.createAll(asList(workspaces));
snaphotRepo.createAll(asList(snapshots));
}
@AfterMethod
private void removeSnapshots() throws TckRepositoryException {
snaphotRepo.removeAll();
workspaceRepo.removeAll();
accountRepo.removeAll();
}
@Test
public void shouldGetSnapshotById() throws Exception {
final SnapshotImpl snapshot = snapshots[0];
assertEquals(snapshotDao.getSnapshot(snapshot.getId()), snapshot);
}
@Test(expectedExceptions = NotFoundException.class)
public void shouldThrowNotFoundExceptionWhenGettingNonExistingSnapshot() throws Exception {
snapshotDao.getSnapshot("non-existing-snapshot");
}
@Test(expectedExceptions = NullPointerException.class)
public void shouldThrowNpeWhenGettingSnapshotByNullId() throws Exception {
snapshotDao.getSnapshot(null);
}
@Test
public void shouldGetSnapshotByWorkspaceEnvironmentAndMachineName() throws Exception {
final SnapshotImpl snapshot = snapshots[0];
assertEquals(snapshotDao.getSnapshot(snapshot.getWorkspaceId(),
snapshot.getEnvName(),
snapshot.getMachineName()), snapshot);
}
@Test(expectedExceptions = NotFoundException.class, dataProvider = "missingSnapshots")
public void shouldThrowNotFoundExceptionWhenSnapshotMissing(String wsId, String envName, String machineName) throws Exception {
snapshotDao.getSnapshot(wsId, envName, machineName);
}
@Test(expectedExceptions = NullPointerException.class, dataProvider = "nullParameterVariations")
public void shouldThrowNpeWhenAnyOfGetSnapshotParametersIsNull(String wsId, String envName, String machineName) throws Exception {
snapshotDao.getSnapshot(wsId, envName, machineName);
}
@Test
public void shouldFindSnapshotsByWorkspaceAndNamespace() throws Exception {
final SnapshotImpl snapshot = snapshots[0];
final List<SnapshotImpl> found = snapshotDao.findSnapshots(snapshot.getWorkspaceId());
assertEquals(new HashSet<>(found), new HashSet<>(asList(snapshots[0], snapshots[1], snapshots[2])));
}
@Test(expectedExceptions = NullPointerException.class)
public void shouldThrowNpeWhenSearchingSnapshotsByNullWorkspaceId() throws Exception {
snapshotDao.findSnapshots(null);
}
@Test(dependsOnMethods = "shouldGetSnapshotById")
public void shouldSaveSnapshot() throws Exception {
final SnapshotImpl newSnapshot = createSnapshot("new-snapshot",
workspaces[0].getId(),
"env-name",
"machine-name");
snapshotDao.saveSnapshot(newSnapshot);
assertEquals(snapshotDao.getSnapshot(newSnapshot.getId()), new SnapshotImpl(newSnapshot));
}
@Test(expectedExceptions = SnapshotException.class)
public void shouldNotSaveSnapshotWithReservedId() throws Exception {
final SnapshotImpl snapshot = snapshots[0];
snapshot.setWorkspaceId("new-workspace");
snapshot.setEnvName("new-env");
snapshot.setMachineName("new-machine");
snapshotDao.saveSnapshot(snapshot);
}
@Test(expectedExceptions = SnapshotException.class)
public void shouldNotSaveSnapshotForMachineIfSnapshotForSuchMachineAlreadyExists() throws Exception {
final SnapshotImpl snapshot = snapshots[0];
snapshot.setId("new-id");
snapshotDao.saveSnapshot(snapshot);
}
@Test(expectedExceptions = NullPointerException.class)
public void shouldThrowNpeWhenSavingNull() throws Exception {
snapshotDao.saveSnapshot(null);
}
@Test(expectedExceptions = NotFoundException.class,
dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingSnapshot")
public void shouldRemoveSnapshot() throws Exception {
final SnapshotImpl snapshot = snapshots[0];
try {
snapshotDao.removeSnapshot(snapshot.getId());
} catch (NotFoundException x) {
fail("Should remove snapshot");
}
snapshotDao.getSnapshot(snapshot.getId());
}
@Test(expectedExceptions = NotFoundException.class)
public void shouldThrowNotFoundExceptionWhenRemovingNonExistingSnapshot() throws Exception {
snapshotDao.removeSnapshot("non-existing-id");
}
@Test(expectedExceptions = NullPointerException.class)
public void shouldThrowNpeWhenRemovingNull() throws Exception {
snapshotDao.removeSnapshot(null);
}
@Test(dependsOnMethods = "shouldFindSnapshotsByWorkspaceAndNamespace")
public void replacesSnapshots() throws Exception {
final SnapshotImpl newSnapshot = createSnapshot("new-snapshot",
snapshots[0].getWorkspaceId(),
snapshots[0].getEnvName(),
snapshots[0].getMachineName());
final List<SnapshotImpl> replaced = snapshotDao.replaceSnapshots(newSnapshot.getWorkspaceId(),
newSnapshot.getEnvName(),
singletonList(newSnapshot));
assertEquals(new HashSet<>(replaced), Sets.newHashSet(snapshots[0], snapshots[1]));
final HashSet<SnapshotImpl> actual = new HashSet<>(snapshotDao.findSnapshots(this.snapshots[0].getWorkspaceId()));
final HashSet<SnapshotImpl> expected = Sets.newHashSet(newSnapshot, this.snapshots[2]);
assertEquals(actual, expected);
}
@DataProvider(name = "missingSnapshots")
public Object[][] missingSnapshots() {
final SnapshotImpl snapshot = snapshots[0];
return new Object[][] {
{"non-existing-workspace-id", snapshot.getEnvName(), snapshot.getMachineName()},
{snapshot.getWorkspaceId(), "non-existing-env", snapshot.getMachineName()},
{snapshot.getWorkspaceId(), snapshot.getEnvName(), "non-existing-machine-name"}
};
}
@DataProvider(name = "nullParameterVariations")
public Object[][] nullParameterVariations() {
final SnapshotImpl snapshot = snapshots[0];
return new Object[][] {
{null, snapshot.getEnvName(), snapshot.getMachineName()},
{snapshot.getWorkspaceId(), null, snapshot.getMachineName()},
{snapshot.getWorkspaceId(), snapshot.getEnvName(), null}
};
}
private static SnapshotImpl createSnapshot(String id,
String workspaceId,
String envName,
String machineName) {
return SnapshotImpl.builder()
.setId(id)
.setType(id + "type")
.setMachineSource(new MachineSourceImpl(id + "source-type",
id + "source-location",
id + "source-content"))
.setCreationDate(System.currentTimeMillis())
.setDev(true)
.setWorkspaceId(workspaceId)
.setEnvName(envName)
.setMachineName(machineName)
.build();
}
// @BeforeMethod
// private void createSnapshots() {
// // one account for all the workspaces
// final AccountImpl account = new AccountImpl("account1", "name", "type");
//
// // workspaces
// workspaces = new TestWorkspace[SNAPSHOTS_SIZE / 3];
// for (int i = 0; i < workspaces.length; i++) {
// workspaces[i] = new TestWorkspace("workspace-" + i, account.getId());
// }
//
// // snapshots
// snapshots = new SnapshotImpl[SNAPSHOTS_SIZE];
// for (int i = 0; i < SNAPSHOTS_SIZE; i++) {
// snapshots[i] = createSnapshot("snapshot-" + i,
// workspaces[i / 3].getId(), // 3 snapshot share the same workspace id
// "environment-" + i / 2, // 2 snapshots share the same env name
// "machine-" + i);
// }
//
// accountRepo.createAll(singletonList(account));
// workspaceRepo.createAll(asList(workspaces));
// snaphotRepo.createAll(asList(snapshots));
// }
//
// @AfterMethod
// private void removeSnapshots() throws TckRepositoryException {
// snaphotRepo.removeAll();
// workspaceRepo.removeAll();
// accountRepo.removeAll();
// }
//
// @Test
// public void shouldGetSnapshotById() throws Exception {
// final SnapshotImpl snapshot = snapshots[0];
//
// assertEquals(snapshotDao.getSnapshot(snapshot.getId()), snapshot);
// }
//
// @Test(expectedExceptions = NotFoundException.class)
// public void shouldThrowNotFoundExceptionWhenGettingNonExistingSnapshot() throws Exception {
// snapshotDao.getSnapshot("non-existing-snapshot");
// }
//
// @Test(expectedExceptions = NullPointerException.class)
// public void shouldThrowNpeWhenGettingSnapshotByNullId() throws Exception {
// snapshotDao.getSnapshot(null);
// }
//
// @Test
// public void shouldGetSnapshotByWorkspaceEnvironmentAndMachineName() throws Exception {
// final SnapshotImpl snapshot = snapshots[0];
//
// assertEquals(snapshotDao.getSnapshot(snapshot.getWorkspaceId(),
// snapshot.getEnvName(),
// snapshot.getMachineName()), snapshot);
// }
//
// @Test(expectedExceptions = NotFoundException.class, dataProvider = "missingSnapshots")
// public void shouldThrowNotFoundExceptionWhenSnapshotMissing(String wsId, String envName, String machineName) throws Exception {
// snapshotDao.getSnapshot(wsId, envName, machineName);
// }
//
// @Test(expectedExceptions = NullPointerException.class, dataProvider = "nullParameterVariations")
// public void shouldThrowNpeWhenAnyOfGetSnapshotParametersIsNull(String wsId, String envName, String machineName) throws Exception {
// snapshotDao.getSnapshot(wsId, envName, machineName);
// }
//
// @Test
// public void shouldFindSnapshotsByWorkspaceAndNamespace() throws Exception {
// final SnapshotImpl snapshot = snapshots[0];
//
// final List<SnapshotImpl> found = snapshotDao.findSnapshots(snapshot.getWorkspaceId());
//
// assertEquals(new HashSet<>(found), new HashSet<>(asList(snapshots[0], snapshots[1], snapshots[2])));
// }
//
// @Test(expectedExceptions = NullPointerException.class)
// public void shouldThrowNpeWhenSearchingSnapshotsByNullWorkspaceId() throws Exception {
// snapshotDao.findSnapshots(null);
// }
//
// @Test(dependsOnMethods = "shouldGetSnapshotById")
// public void shouldSaveSnapshot() throws Exception {
// final SnapshotImpl newSnapshot = createSnapshot("new-snapshot",
// workspaces[0].getId(),
// "env-name",
// "machine-name");
//
// snapshotDao.saveSnapshot(newSnapshot);
//
// assertEquals(snapshotDao.getSnapshot(newSnapshot.getId()), new SnapshotImpl(newSnapshot));
// }
//
// @Test(expectedExceptions = SnapshotException.class)
// public void shouldNotSaveSnapshotWithReservedId() throws Exception {
// final SnapshotImpl snapshot = snapshots[0];
// snapshot.setWorkspaceId("new-workspace");
// snapshot.setEnvName("new-env");
// snapshot.setMachineName("new-machine");
//
// snapshotDao.saveSnapshot(snapshot);
// }
//
// @Test(expectedExceptions = SnapshotException.class)
// public void shouldNotSaveSnapshotForMachineIfSnapshotForSuchMachineAlreadyExists() throws Exception {
// final SnapshotImpl snapshot = snapshots[0];
// snapshot.setId("new-id");
//
// snapshotDao.saveSnapshot(snapshot);
// }
//
// @Test(expectedExceptions = NullPointerException.class)
// public void shouldThrowNpeWhenSavingNull() throws Exception {
// snapshotDao.saveSnapshot(null);
// }
//
// @Test(expectedExceptions = NotFoundException.class,
// dependsOnMethods = "shouldThrowNotFoundExceptionWhenGettingNonExistingSnapshot")
// public void shouldRemoveSnapshot() throws Exception {
// final SnapshotImpl snapshot = snapshots[0];
//
// try {
// snapshotDao.removeSnapshot(snapshot.getId());
// } catch (NotFoundException x) {
// fail("Should remove snapshot");
// }
//
// snapshotDao.getSnapshot(snapshot.getId());
// }
//
// @Test(expectedExceptions = NotFoundException.class)
// public void shouldThrowNotFoundExceptionWhenRemovingNonExistingSnapshot() throws Exception {
// snapshotDao.removeSnapshot("non-existing-id");
// }
//
// @Test(expectedExceptions = NullPointerException.class)
// public void shouldThrowNpeWhenRemovingNull() throws Exception {
// snapshotDao.removeSnapshot(null);
// }
//
// @Test(dependsOnMethods = "shouldFindSnapshotsByWorkspaceAndNamespace")
// public void replacesSnapshots() throws Exception {
// final SnapshotImpl newSnapshot = createSnapshot("new-snapshot",
// snapshots[0].getWorkspaceId(),
// snapshots[0].getEnvName(),
// snapshots[0].getMachineName());
//
// final List<SnapshotImpl> replaced = snapshotDao.replaceSnapshots(newSnapshot.getWorkspaceId(),
// newSnapshot.getEnvName(),
// singletonList(newSnapshot));
//
// assertEquals(new HashSet<>(replaced), Sets.newHashSet(snapshots[0], snapshots[1]));
// final HashSet<SnapshotImpl> actual = new HashSet<>(snapshotDao.findSnapshots(this.snapshots[0].getWorkspaceId()));
// final HashSet<SnapshotImpl> expected = Sets.newHashSet(newSnapshot, this.snapshots[2]);
// assertEquals(actual, expected);
// }
//
// @DataProvider(name = "missingSnapshots")
// public Object[][] missingSnapshots() {
// final SnapshotImpl snapshot = snapshots[0];
// return new Object[][] {
// {"non-existing-workspace-id", snapshot.getEnvName(), snapshot.getMachineName()},
// {snapshot.getWorkspaceId(), "non-existing-env", snapshot.getMachineName()},
// {snapshot.getWorkspaceId(), snapshot.getEnvName(), "non-existing-machine-name"}
// };
// }
//
// @DataProvider(name = "nullParameterVariations")
// public Object[][] nullParameterVariations() {
// final SnapshotImpl snapshot = snapshots[0];
// return new Object[][] {
// {null, snapshot.getEnvName(), snapshot.getMachineName()},
// {snapshot.getWorkspaceId(), null, snapshot.getMachineName()},
// {snapshot.getWorkspaceId(), snapshot.getEnvName(), null}
// };
// }
//
// private static SnapshotImpl createSnapshot(String id,
// String workspaceId,
// String envName,
// String machineName) {
// return SnapshotImpl.builder()
// .setId(id)
// .setType(id + "type")
// .setMachineSource(new MachineSourceImpl(id + "source-type",
// id + "source-location",
// id + "source-content"))
// .setCreationDate(System.currentTimeMillis())
// .setDev(true)
// .setWorkspaceId(workspaceId)
// .setEnvName(envName)
// .setMachineName(machineName)
// .build();
// }
//
private static class TestWorkspace implements Workspace {
private final String id;

View File

@ -41,10 +41,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-composer-shared</artifactId>

View File

@ -99,7 +99,7 @@ public class CommitPresenterTest extends BaseTest {
when(revisionPromise.then(any(Operation.class))).thenReturn(revisionPromise);
when(revisionPromise.catchError(any(Operation.class))).thenReturn(revisionPromise);
when(service.add(any(Path.class), anyBoolean(), any(Path[].class))).thenReturn(voidPromise);
when(service.commit(any(Path.class), anyString(), anyBoolean(), any(Path[].class), anyBoolean()));
when(service.commit(any(Path.class), anyString(), anyBoolean(), any(Path[].class), anyBoolean())).thenReturn(revisionPromise);
when(stringPromise.then(any(Operation.class))).thenReturn(stringPromise);
when(stringPromise.catchError(any(Operation.class))).thenReturn(stringPromise);
when(branchListPromise.then(any(Operation.class))).thenReturn(branchListPromise);

View File

@ -45,18 +45,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-dto</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-ssh-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-user-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-gwt</artifactId>

View File

@ -48,10 +48,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-user-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-gwt</artifactId>

View File

@ -16,6 +16,8 @@ import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.debug.DebugConfiguration;
import org.eclipse.che.ide.api.debug.DebugConfigurationPage;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.eclipse.che.ide.api.workspace.model.ServerImpl;
import org.eclipse.che.ide.api.workspace.model.WorkspaceImpl;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
@ -24,6 +26,10 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static java.lang.Boolean.TRUE;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@ -44,6 +50,8 @@ public class JavaDebugConfigurationPagePresenterTest {
private AppContext appContext;
@Mock
private MachineImpl devMachine;
@Mock
private WorkspaceImpl workspace;
@Mock
private DebugConfiguration configuration;
@ -55,9 +63,16 @@ public class JavaDebugConfigurationPagePresenterTest {
public void setUp() {
when(configuration.getHost()).thenReturn(HOST);
when(configuration.getPort()).thenReturn(PORT);
// when(appContext.getDevMachine()).thenReturn(devMachine);
when(devMachine.getName()).thenReturn("devMachine");
ServerImpl server = mock(ServerImpl.class);
when(server.getUrl()).thenReturn("http://preview.com");
Map<String, ServerImpl> servers = new HashMap<>();
servers.put("8000/tcp", server);
when(devMachine.getServers()).thenReturn(servers);
when(workspace.getDevMachine()).thenReturn(Optional.of(devMachine));
when(appContext.getWorkspace()).thenReturn(workspace);
when(devMachine.getName()).thenReturn("devMachine");
pagePresenter.resetFrom(configuration);
}

View File

@ -13,7 +13,7 @@ package org.eclipse.che.plugin.jdb.server;
import com.google.common.collect.ImmutableMap;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.debug.shared.model.Breakpoint;
import org.eclipse.che.api.debug.shared.model.DebuggerInfo;

View File

@ -49,6 +49,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>

View File

@ -14,7 +14,7 @@ import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.project.server.FolderEntry;
import org.eclipse.che.api.project.server.ProjectCreatedEvent;

View File

@ -58,6 +58,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-gwt</artifactId>

View File

@ -36,10 +36,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-machine-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
@ -58,7 +54,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-inject</artifactId>
<artifactId>che-core-api-workspace-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>

View File

@ -53,246 +53,247 @@ import static org.testng.Assert.assertEquals;
*
* @author Sergii Leschenko
*/
// FIXME: spi
@Listeners(MockitoTestNGListener.class)
public class KeysInjectorTest {
private static final String WORKSPACE_ID = "workspace123";
private static final String MACHINE_ID = "machine123";
private static final String OWNER = "user123";
private static final String CONTAINER_ID = "container123";
private static final String EXEC_ID = "exec123";
@Captor
ArgumentCaptor<EventSubscriber<MachineStatusEvent>> subscriberCaptor;
@Captor
ArgumentCaptor<MessageProcessor<LogMessage>> messageProcessorCaptor;
@Mock
Instance instance;
@Mock
MachineRuntimeInfo machineRuntime;
@Mock
Exec exec;
@Mock
LogMessage logMessage;
@Mock
LineConsumer lineConsumer;
@Mock
EventService eventService;
@Mock
DockerConnector docker;
@Mock
CheEnvironmentEngine environmentEngine;
@Mock
SshManager sshManager;
@Mock
User user;
EventSubscriber<MachineStatusEvent> subscriber;
private class MockConnectorProvider extends DockerConnectorProvider {
public MockConnectorProvider() {
super(Collections.emptyMap(), "default");
}
@Override
public DockerConnector get() {
return docker;
}
}
KeysInjector keysInjector;
@BeforeMethod
public void setUp() throws Exception {
final Map<String, String> metadataProperties = new HashMap<>();
metadataProperties.put("id", CONTAINER_ID);
when(machineRuntime.getProperties()).thenReturn(metadataProperties);
when(environmentEngine.getMachine(WORKSPACE_ID, MACHINE_ID)).thenReturn(instance);
when(instance.getOwner()).thenReturn(OWNER);
when(instance.getRuntime()).thenReturn(machineRuntime);
when(instance.getLogger()).thenReturn(lineConsumer);
keysInjector = new KeysInjector(eventService,
new MockConnectorProvider(),
sshManager,
environmentEngine);
keysInjector.start();
verify(eventService).subscribe(subscriberCaptor.capture());
subscriber = subscriberCaptor.getValue();
when(docker.createExec(any(CreateExecParams.class))).thenReturn(exec);
when(exec.getId()).thenReturn(EXEC_ID);
}
@Test
public void shouldNotDoAnythingIfEventTypeDoesNotEqualToRunning() {
subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.DESTROYING));
verifyZeroInteractions(docker, environmentEngine, sshManager);
}
@Test
public void shouldNotInjectSshKeysWhenThereAreNotAnyPair() throws Exception {
when(sshManager.getPairs(anyString(), anyString())).thenReturn(Collections.emptyList());
subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
.withMachineId(MACHINE_ID)
.withWorkspaceId(WORKSPACE_ID));
verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
verify(sshManager).getPairs(eq(OWNER), eq("machine"));
verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
verifyZeroInteractions(docker, environmentEngine, sshManager);
}
@Test
public void shouldNotInjectSshKeysWhenThereAreNotAnyPairWithPublicKey() throws Exception {
when(sshManager.getPairs(anyString(), anyString()))
.thenReturn(Collections.singletonList(new SshPairImpl(OWNER, "machine", "myPair", null, null)));
subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
.withMachineId(MACHINE_ID)
.withWorkspaceId(WORKSPACE_ID));
verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
verify(sshManager).getPairs(eq(OWNER), eq("machine"));
verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
verifyZeroInteractions(docker, environmentEngine, sshManager);
}
@Test
public void shouldInjectSshKeysWhenThereAreAnyPairWithNotNullPublicKey() throws Exception {
when(sshManager.getPairs(anyString(), anyString()))
.thenReturn(Arrays.asList(new SshPairImpl(OWNER, "machine", "myPair", "publicKey1", null),
new SshPairImpl(OWNER, "machine", "myPair", "publicKey2", null)));
subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
.withMachineId(MACHINE_ID)
.withWorkspaceId(WORKSPACE_ID));
verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
verify(sshManager).getPairs(eq(OWNER), eq("machine"));
verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
ArgumentCaptor<CreateExecParams> argumentCaptor = ArgumentCaptor.forClass(CreateExecParams.class);
verify(docker).createExec(argumentCaptor.capture());
assertEquals(argumentCaptor.getValue().getCmd(), new String[] {"/bin/bash", "-c", "mkdir ~/.ssh/ -p" +
"&& echo 'publicKey1' >> ~/.ssh/authorized_keys" +
"&& echo 'publicKey2' >> ~/.ssh/authorized_keys"});
verify(docker).startExec(eq(StartExecParams.create(EXEC_ID)), anyObject());
verifyZeroInteractions(docker, environmentEngine, sshManager);
}
/**
* Validate the usecase: There is a workspace sshkeypair but no machine keypair (empty list)
* Expect that the workspace public key is injected.
*/
@Test
public void shouldInjectSshKeysWhenThereIsOnlyWorkspaceKey() throws Exception {
// no machine key pairs
when(sshManager.getPairs(anyString(), eq("machine")))
.thenReturn(Collections.emptyList());
// workspace keypair
when(sshManager.getPair(anyString(), eq("workspace"), anyString()))
.thenReturn(new SshPairImpl(OWNER, "workspace", WORKSPACE_ID, "publicKeyWorkspace", null));
subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
.withMachineId(MACHINE_ID)
.withWorkspaceId(WORKSPACE_ID));
verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// check calls for machine and workspace ssh pairs
verify(sshManager).getPairs(eq(OWNER), eq("machine"));
verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
ArgumentCaptor<CreateExecParams> argumentCaptor = ArgumentCaptor.forClass(CreateExecParams.class);
verify(docker).createExec(argumentCaptor.capture());
assertEquals(argumentCaptor.getValue().getCmd(), new String[] {"/bin/bash", "-c", "mkdir ~/.ssh/ -p" +
"&& echo 'publicKeyWorkspace' >> ~/.ssh/authorized_keys"});
verify(docker).startExec(eq(StartExecParams.create(EXEC_ID)), anyObject());
verifyZeroInteractions(docker, environmentEngine, sshManager);
}
/**
* Validate the usecase: There is a workspace sshkeypair (without public key) but there is a machine keypair
* Expect that only the machine keypair is injected (as workspace keypair has no public key).
*/
@Test
public void shouldInjectSshKeysWhenThereIsNoPublicWorkspaceKeyButMachineKeys() throws Exception {
// no machine key pairs
when(sshManager.getPairs(anyString(), eq("machine")))
.thenReturn(Arrays.asList(new SshPairImpl(OWNER, "machine", "myPair", "publicKey1", null)));
// workspace keypair without public key
when(sshManager.getPair(anyString(), eq("workspace"), anyString()))
.thenReturn(new SshPairImpl(OWNER, "workspace", WORKSPACE_ID, null, null));
subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
.withMachineId(MACHINE_ID)
.withWorkspaceId(WORKSPACE_ID));
verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// check calls for machine and workspace ssh pairs
verify(sshManager).getPairs(eq(OWNER), eq("machine"));
verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
ArgumentCaptor<CreateExecParams> argumentCaptor = ArgumentCaptor.forClass(CreateExecParams.class);
verify(docker).createExec(argumentCaptor.capture());
assertEquals(argumentCaptor.getValue().getCmd(), new String[] {"/bin/bash", "-c", "mkdir ~/.ssh/ -p" +
"&& echo 'publicKey1' >> ~/.ssh/authorized_keys"});
verify(docker).startExec(eq(StartExecParams.create(EXEC_ID)), anyObject());
verifyZeroInteractions(docker, environmentEngine, sshManager);
}
/**
* Validate the usecase of no workspace keypair (notfound exception) and no machine keypair
* Expect no ssh keys are injected
*/
@Test
public void shouldNotInjectSshKeysWhenThereIsNoWorkspaceKey() throws Exception {
// no machine key pairs
when(sshManager.getPairs(anyString(), eq("machine")))
.thenReturn(Collections.emptyList());
// no workspace keypair
when(sshManager.getPair(anyString(), eq("workspace"), anyString()))
.thenThrow(NotFoundException.class);
subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
.withMachineId(MACHINE_ID)
.withWorkspaceId(WORKSPACE_ID));
verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// check calls for machine and workspace ssh pairs
verify(sshManager).getPairs(eq(OWNER), eq("machine"));
verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
verifyZeroInteractions(docker, environmentEngine, sshManager);
}
@Test
public void shouldSendMessageInMachineLoggerWhenSomeErrorOcursOnKeysInjection() throws Exception {
when(sshManager.getPairs(anyString(), anyString()))
.thenReturn(Collections.singletonList(new SshPairImpl(OWNER, "machine", "myPair", "publicKey1", null)));
when(logMessage.getType()).thenReturn(LogMessage.Type.STDERR);
when(logMessage.getContent()).thenReturn("FAILED");
subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
.withMachineId(MACHINE_ID)
.withWorkspaceId(WORKSPACE_ID));
verify(docker).startExec(eq(StartExecParams.create(EXEC_ID)), messageProcessorCaptor.capture());
final MessageProcessor<LogMessage> value = messageProcessorCaptor.getValue();
value.process(logMessage);
verify(lineConsumer).writeLine(eq("Error of injection public ssh keys. FAILED"));
}
// private static final String WORKSPACE_ID = "workspace123";
// private static final String MACHINE_ID = "machine123";
// private static final String OWNER = "user123";
// private static final String CONTAINER_ID = "container123";
// private static final String EXEC_ID = "exec123";
//
// @Captor
// ArgumentCaptor<EventSubscriber<MachineStatusEvent>> subscriberCaptor;
// @Captor
// ArgumentCaptor<MessageProcessor<LogMessage>> messageProcessorCaptor;
//
// @Mock
// Instance instance;
// @Mock
// MachineRuntimeInfo machineRuntime;
// @Mock
// Exec exec;
// @Mock
// LogMessage logMessage;
// @Mock
// LineConsumer lineConsumer;
//
// @Mock
// EventService eventService;
// @Mock
// DockerConnector docker;
// @Mock
// CheEnvironmentEngine environmentEngine;
// @Mock
// SshManager sshManager;
// @Mock
// User user;
//
// EventSubscriber<MachineStatusEvent> subscriber;
//
// private class MockConnectorProvider extends DockerConnectorProvider {
//
// public MockConnectorProvider() {
// super(Collections.emptyMap(), "default");
// }
//
// @Override
// public DockerConnector get() {
// return docker;
// }
// }
//
// KeysInjector keysInjector;
//
// @BeforeMethod
// public void setUp() throws Exception {
// final Map<String, String> metadataProperties = new HashMap<>();
// metadataProperties.put("id", CONTAINER_ID);
// when(machineRuntime.getProperties()).thenReturn(metadataProperties);
//
// when(environmentEngine.getMachine(WORKSPACE_ID, MACHINE_ID)).thenReturn(instance);
// when(instance.getOwner()).thenReturn(OWNER);
// when(instance.getRuntime()).thenReturn(machineRuntime);
// when(instance.getLogger()).thenReturn(lineConsumer);
//
// keysInjector = new KeysInjector(eventService,
// new MockConnectorProvider(),
// sshManager,
// environmentEngine);
//
// keysInjector.start();
// verify(eventService).subscribe(subscriberCaptor.capture());
// subscriber = subscriberCaptor.getValue();
//
// when(docker.createExec(any(CreateExecParams.class))).thenReturn(exec);
// when(exec.getId()).thenReturn(EXEC_ID);
// }
//
// @Test
// public void shouldNotDoAnythingIfEventTypeDoesNotEqualToRunning() {
// subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.DESTROYING));
//
// verifyZeroInteractions(docker, environmentEngine, sshManager);
// }
//
// @Test
// public void shouldNotInjectSshKeysWhenThereAreNotAnyPair() throws Exception {
// when(sshManager.getPairs(anyString(), anyString())).thenReturn(Collections.emptyList());
//
// subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
// .withMachineId(MACHINE_ID)
// .withWorkspaceId(WORKSPACE_ID));
//
// verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// verify(sshManager).getPairs(eq(OWNER), eq("machine"));
// verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
// verifyZeroInteractions(docker, environmentEngine, sshManager);
// }
//
// @Test
// public void shouldNotInjectSshKeysWhenThereAreNotAnyPairWithPublicKey() throws Exception {
// when(sshManager.getPairs(anyString(), anyString()))
// .thenReturn(Collections.singletonList(new SshPairImpl(OWNER, "machine", "myPair", null, null)));
//
// subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
// .withMachineId(MACHINE_ID)
// .withWorkspaceId(WORKSPACE_ID));
//
// verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// verify(sshManager).getPairs(eq(OWNER), eq("machine"));
// verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
// verifyZeroInteractions(docker, environmentEngine, sshManager);
// }
//
// @Test
// public void shouldInjectSshKeysWhenThereAreAnyPairWithNotNullPublicKey() throws Exception {
// when(sshManager.getPairs(anyString(), anyString()))
// .thenReturn(Arrays.asList(new SshPairImpl(OWNER, "machine", "myPair", "publicKey1", null),
// new SshPairImpl(OWNER, "machine", "myPair", "publicKey2", null)));
//
// subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
// .withMachineId(MACHINE_ID)
// .withWorkspaceId(WORKSPACE_ID));
//
// verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// verify(sshManager).getPairs(eq(OWNER), eq("machine"));
// verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
//
// ArgumentCaptor<CreateExecParams> argumentCaptor = ArgumentCaptor.forClass(CreateExecParams.class);
// verify(docker).createExec(argumentCaptor.capture());
// assertEquals(argumentCaptor.getValue().getCmd(), new String[] {"/bin/bash", "-c", "mkdir ~/.ssh/ -p" +
// "&& echo 'publicKey1' >> ~/.ssh/authorized_keys" +
// "&& echo 'publicKey2' >> ~/.ssh/authorized_keys"});
// verify(docker).startExec(eq(StartExecParams.create(EXEC_ID)), anyObject());
// verifyZeroInteractions(docker, environmentEngine, sshManager);
// }
//
// /**
// * Validate the usecase: There is a workspace sshkeypair but no machine keypair (empty list)
// * Expect that the workspace public key is injected.
// */
// @Test
// public void shouldInjectSshKeysWhenThereIsOnlyWorkspaceKey() throws Exception {
// // no machine key pairs
// when(sshManager.getPairs(anyString(), eq("machine")))
// .thenReturn(Collections.emptyList());
//
// // workspace keypair
// when(sshManager.getPair(anyString(), eq("workspace"), anyString()))
// .thenReturn(new SshPairImpl(OWNER, "workspace", WORKSPACE_ID, "publicKeyWorkspace", null));
//
//
// subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
// .withMachineId(MACHINE_ID)
// .withWorkspaceId(WORKSPACE_ID));
//
// verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// // check calls for machine and workspace ssh pairs
// verify(sshManager).getPairs(eq(OWNER), eq("machine"));
// verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
//
// ArgumentCaptor<CreateExecParams> argumentCaptor = ArgumentCaptor.forClass(CreateExecParams.class);
// verify(docker).createExec(argumentCaptor.capture());
// assertEquals(argumentCaptor.getValue().getCmd(), new String[] {"/bin/bash", "-c", "mkdir ~/.ssh/ -p" +
// "&& echo 'publicKeyWorkspace' >> ~/.ssh/authorized_keys"});
// verify(docker).startExec(eq(StartExecParams.create(EXEC_ID)), anyObject());
// verifyZeroInteractions(docker, environmentEngine, sshManager);
// }
//
// /**
// * Validate the usecase: There is a workspace sshkeypair (without public key) but there is a machine keypair
// * Expect that only the machine keypair is injected (as workspace keypair has no public key).
// */
// @Test
// public void shouldInjectSshKeysWhenThereIsNoPublicWorkspaceKeyButMachineKeys() throws Exception {
// // no machine key pairs
// when(sshManager.getPairs(anyString(), eq("machine")))
// .thenReturn(Arrays.asList(new SshPairImpl(OWNER, "machine", "myPair", "publicKey1", null)));
//
// // workspace keypair without public key
// when(sshManager.getPair(anyString(), eq("workspace"), anyString()))
// .thenReturn(new SshPairImpl(OWNER, "workspace", WORKSPACE_ID, null, null));
//
//
// subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
// .withMachineId(MACHINE_ID)
// .withWorkspaceId(WORKSPACE_ID));
//
// verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// // check calls for machine and workspace ssh pairs
// verify(sshManager).getPairs(eq(OWNER), eq("machine"));
// verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
//
// ArgumentCaptor<CreateExecParams> argumentCaptor = ArgumentCaptor.forClass(CreateExecParams.class);
// verify(docker).createExec(argumentCaptor.capture());
// assertEquals(argumentCaptor.getValue().getCmd(), new String[] {"/bin/bash", "-c", "mkdir ~/.ssh/ -p" +
// "&& echo 'publicKey1' >> ~/.ssh/authorized_keys"});
// verify(docker).startExec(eq(StartExecParams.create(EXEC_ID)), anyObject());
// verifyZeroInteractions(docker, environmentEngine, sshManager);
// }
//
// /**
// * Validate the usecase of no workspace keypair (notfound exception) and no machine keypair
// * Expect no ssh keys are injected
// */
// @Test
// public void shouldNotInjectSshKeysWhenThereIsNoWorkspaceKey() throws Exception {
// // no machine key pairs
// when(sshManager.getPairs(anyString(), eq("machine")))
// .thenReturn(Collections.emptyList());
//
// // no workspace keypair
// when(sshManager.getPair(anyString(), eq("workspace"), anyString()))
// .thenThrow(NotFoundException.class);
//
//
// subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
// .withMachineId(MACHINE_ID)
// .withWorkspaceId(WORKSPACE_ID));
//
// verify(environmentEngine).getMachine(eq(WORKSPACE_ID), eq(MACHINE_ID));
// // check calls for machine and workspace ssh pairs
// verify(sshManager).getPairs(eq(OWNER), eq("machine"));
// verify(sshManager).getPair(eq(OWNER), eq("workspace"), eq(WORKSPACE_ID));
//
// verifyZeroInteractions(docker, environmentEngine, sshManager);
// }
//
// @Test
// public void shouldSendMessageInMachineLoggerWhenSomeErrorOcursOnKeysInjection() throws Exception {
// when(sshManager.getPairs(anyString(), anyString()))
// .thenReturn(Collections.singletonList(new SshPairImpl(OWNER, "machine", "myPair", "publicKey1", null)));
// when(logMessage.getType()).thenReturn(LogMessage.Type.STDERR);
// when(logMessage.getContent()).thenReturn("FAILED");
//
// subscriber.onEvent(newDto(MachineStatusEvent.class).withEventType(MachineStatusEvent.EventType.RUNNING)
// .withMachineId(MACHINE_ID)
// .withWorkspaceId(WORKSPACE_ID));
//
// verify(docker).startExec(eq(StartExecParams.create(EXEC_ID)), messageProcessorCaptor.capture());
// final MessageProcessor<LogMessage> value = messageProcessorCaptor.getValue();
// value.process(logMessage);
//
// verify(lineConsumer).writeLine(eq("Error of injection public ssh keys. FAILED"));
// }
}

View File

@ -56,18 +56,10 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-core</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-factory-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-project-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-workspace-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-commons-annotations</artifactId>

View File

@ -14,7 +14,7 @@ import org.eclipse.che.api.core.ConflictException;
import org.eclipse.che.api.core.ForbiddenException;
import org.eclipse.che.api.core.NotFoundException;
import org.eclipse.che.api.core.ServerException;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.core.notification.EventService;
import org.eclipse.che.api.project.server.FolderEntry;
import org.eclipse.che.api.project.server.ProjectCreatedEvent;
@ -29,8 +29,8 @@ import org.eclipse.che.api.vfs.impl.file.DefaultFileWatcherNotificationHandler;
import org.eclipse.che.api.vfs.impl.file.FileTreeWatcher;
import org.eclipse.che.api.vfs.impl.file.FileWatcherNotificationHandler;
import org.eclipse.che.api.vfs.impl.file.LocalVirtualFileSystemProvider;
import org.eclipse.che.api.vfs.watcher.FileWatcherManager;
import org.eclipse.che.api.vfs.search.impl.FSLuceneSearcherProvider;
import org.eclipse.che.api.vfs.watcher.FileWatcherManager;
import org.eclipse.che.api.workspace.shared.dto.ProjectConfigDto;
import org.eclipse.che.commons.lang.IoUtil;
import org.eclipse.che.jdt.core.resources.ResourceChangedEvent;

View File

@ -14,8 +14,6 @@ import org.eclipse.che.plugin.pullrequest.client.workflow.Context;
import org.eclipse.che.plugin.pullrequest.client.workflow.WorkflowExecutor;
import com.google.gwt.event.shared.GwtEvent;
import org.eclipse.che.api.core.model.project.ProjectConfig;
/**
* This event is fired when context is invalidated.
*

View File

@ -10,32 +10,32 @@
*******************************************************************************/
package org.eclipse.che.plugin.pullrequest.client.steps;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.inject.Singleton;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.api.git.shared.Remote;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.PromiseError;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.plugin.pullrequest.client.ContributeMessages;
import org.eclipse.che.plugin.pullrequest.client.vcs.VcsServiceProvider;
import org.eclipse.che.plugin.pullrequest.client.vcs.hosting.VcsHostingService;
import org.eclipse.che.plugin.pullrequest.client.workflow.Context;
import org.eclipse.che.plugin.pullrequest.client.workflow.Step;
import org.eclipse.che.plugin.pullrequest.client.workflow.WorkflowExecutor;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
import com.google.common.collect.FluentIterable;
import com.google.inject.Singleton;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.git.shared.Remote;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.PromiseError;
import org.eclipse.che.ide.api.notification.NotificationManager;
import javax.inject.Inject;
import java.util.List;
import java.util.Map;
import static org.eclipse.che.plugin.pullrequest.shared.ContributionProjectTypeConstants.CONTRIBUTE_TO_BRANCH_VARIABLE_NAME;
import static com.google.common.base.Strings.isNullOrEmpty;
import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE;
import static org.eclipse.che.ide.api.notification.StatusNotification.Status.FAIL;
import static org.eclipse.che.plugin.pullrequest.shared.ContributionProjectTypeConstants.CONTRIBUTE_TO_BRANCH_VARIABLE_NAME;
/**
* This step initialize the contribution workflow context.

View File

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.pullrequest.client.vcs;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import javax.inject.Inject;
import javax.validation.constraints.NotNull;

View File

@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.che.plugin.pullrequest.client.vcs.hosting;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.plugin.pullrequest.client.vcs.VcsService;
import org.eclipse.che.plugin.pullrequest.client.vcs.VcsServiceProvider;
import com.google.inject.Singleton;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.git.shared.Remote;
import org.eclipse.che.api.promises.client.Function;
import org.eclipse.che.api.promises.client.FunctionException;

View File

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.pullrequest.client.workflow;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.plugin.pullrequest.client.events.ContextPropertyChangeEvent;
import org.eclipse.che.plugin.pullrequest.client.vcs.VcsService;
import org.eclipse.che.plugin.pullrequest.client.vcs.hosting.VcsHostingService;
@ -17,7 +18,6 @@ import org.eclipse.che.plugin.pullrequest.shared.dto.Configuration;
import org.eclipse.che.plugin.pullrequest.shared.dto.PullRequest;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.commons.annotation.Nullable;
import java.util.ArrayList;

View File

@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.pullrequest.client.workflow;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
import org.eclipse.che.plugin.pullrequest.client.events.ContextInvalidatedEvent;
import org.eclipse.che.plugin.pullrequest.client.events.CurrentContextChangedEvent;
import org.eclipse.che.plugin.pullrequest.client.events.StepEvent;
@ -20,7 +21,6 @@ import com.google.common.base.Optional;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.promises.client.Function;
import org.eclipse.che.api.promises.client.FunctionException;
import org.eclipse.che.api.promises.client.Operation;

View File

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.pullrequest.client.workflow;
import org.eclipse.che.api.core.model.project.ProjectConfig;
import org.eclipse.che.api.core.model.workspace.config.ProjectConfig;
/**
* Defines workflow status contract.

View File

@ -15,7 +15,7 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.multibindings.Multibinder;
import org.eclipse.che.api.core.model.project.SourceStorage;
import org.eclipse.che.api.core.model.workspace.config.SourceStorage;
import org.eclipse.che.api.project.server.FolderEntry;
import org.eclipse.che.api.project.server.importer.ProjectImporter;
import org.eclipse.che.api.project.server.type.ProjectTypeDef;
@ -46,7 +46,7 @@ import static org.mockito.Mockito.when;
public class SubversionProjectImporterTest {
@Mock
private ProfileDao userProfileDao;
private ProfileDao userProfileDao;
@Mock
private RepositoryUrlProvider repositoryUrlProvider;
@Mock

View File

@ -10,35 +10,27 @@
*******************************************************************************/
package org.eclipse.che.plugin.testing.junit.ide.action;
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.google.inject.Inject;
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.resources.Container;
import org.eclipse.che.ide.api.resources.File;
import org.eclipse.che.ide.api.resources.Project;
import org.eclipse.che.ide.api.resources.Resource;
import org.eclipse.che.ide.api.resources.VirtualFile;
import org.eclipse.che.ide.api.selection.Selection;
import org.eclipse.che.ide.api.selection.SelectionAgent;
import org.eclipse.che.ide.ext.java.client.util.JavaUtil;
import org.eclipse.che.ide.resources.tree.ContainerNode;
import org.eclipse.che.ide.resources.tree.FileNode;
import org.eclipse.che.plugin.testing.ide.TestServiceClient;
import org.eclipse.che.plugin.testing.ide.action.RunTestActionDelegate;
import org.eclipse.che.plugin.testing.ide.view.TestResultPresenter;
import org.eclipse.che.plugin.testing.junit.ide.JUnitTestLocalizationConstant;
import org.eclipse.che.plugin.testing.junit.ide.JUnitTestResources;
import com.google.inject.Inject;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
/**
* @author Mirage Abeysekara

View File

@ -10,13 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.testing.junit.ide.action;
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.google.inject.Inject;
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
@ -33,7 +27,12 @@ import org.eclipse.che.plugin.testing.ide.view.TestResultPresenter;
import org.eclipse.che.plugin.testing.junit.ide.JUnitTestLocalizationConstant;
import org.eclipse.che.plugin.testing.junit.ide.JUnitTestResources;
import com.google.inject.Inject;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
/**
* @author Mirage Abeysekara

View File

@ -10,13 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.testing.testng.ide.action;
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.google.inject.Inject;
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
@ -30,7 +24,12 @@ import org.eclipse.che.plugin.testing.ide.view.TestResultPresenter;
import org.eclipse.che.plugin.testing.testng.ide.TestNGLocalizationConstant;
import org.eclipse.che.plugin.testing.testng.ide.TestNGResources;
import com.google.inject.Inject;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
/**
* @author Mirage Abeysekara

View File

@ -10,13 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.testing.testng.ide.action;
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.google.inject.Inject;
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
@ -35,7 +29,12 @@ import org.eclipse.che.plugin.testing.ide.view.TestResultPresenter;
import org.eclipse.che.plugin.testing.testng.ide.TestNGLocalizationConstant;
import org.eclipse.che.plugin.testing.testng.ide.TestNGResources;
import com.google.inject.Inject;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
/**
* @author Mirage Abeysekara

View File

@ -10,13 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.testing.testng.ide.action;
import static org.eclipse.che.ide.workspace.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.validation.constraints.NotNull;
import com.google.inject.Inject;
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
@ -32,7 +26,12 @@ import org.eclipse.che.plugin.testing.ide.view.TestResultPresenter;
import org.eclipse.che.plugin.testing.testng.ide.TestNGLocalizationConstant;
import org.eclipse.che.plugin.testing.testng.ide.TestNGResources;
import com.google.inject.Inject;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import static org.eclipse.che.ide.part.perspectives.project.ProjectPerspective.PROJECT_PERSPECTIVE_ID;
/**
* @author Mirage Abeysekara

View File

@ -12,7 +12,7 @@ package org.eclipse.che.plugin.testing.ide;
import com.google.gwtmockito.GwtMockitoTestRunner;
import org.eclipse.che.api.core.model.machine.Command;
import org.eclipse.che.api.core.model.workspace.config.Command;
import org.eclipse.che.api.machine.shared.dto.execagent.ProcessStartResponseDto;
import org.eclipse.che.api.machine.shared.dto.execagent.event.DtoWithPid;
import org.eclipse.che.api.machine.shared.dto.execagent.event.ProcessDiedEventDto;
@ -34,6 +34,7 @@ import org.eclipse.che.ide.api.machine.execagent.ExecAgentConsumer;
import org.eclipse.che.ide.api.macro.MacroProcessor;
import org.eclipse.che.ide.api.notification.StatusNotification;
import org.eclipse.che.ide.api.workspace.model.MachineImpl;
import org.eclipse.che.ide.api.workspace.model.WorkspaceImpl;
import org.eclipse.che.ide.command.goal.TestGoal;
import org.eclipse.che.ide.console.CommandConsoleFactory;
import org.eclipse.che.ide.console.CommandOutputConsole;
@ -57,6 +58,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import static java.util.Arrays.asList;
import static org.mockito.Matchers.any;
@ -75,6 +77,8 @@ import static org.mockito.Mockito.when;
*
* @author David Festal
*/
// FIXME: spi ide
@Ignore
@RunWith(GwtMockitoTestRunner.class)
public class TestServiceClientTest implements MockitoPrinter {
@ -104,13 +108,15 @@ public class TestServiceClientTest implements MockitoPrinter {
private TestGoal testGoal;
@Mock
private StatusNotification statusNotification;
private StatusNotification statusNotification;
@Mock
private MachineImpl devMachine;
private MachineImpl devMachine;
@Mock
private MachineImpl machine;
private MachineImpl machine;
@Mock
private CommandOutputConsole commandOutputConsole;
private WorkspaceImpl workspace;
@Mock
private CommandOutputConsole commandOutputConsole;
private TestServiceClient testServiceClient = null;
@ -157,7 +163,8 @@ public class TestServiceClientTest implements MockitoPrinter {
return promiseError;
})).when(testServiceClient).promiseFromThrowable(any(Throwable.class));
// when(appContext.getDevMachine()).thenReturn(devMachine);
when(appContext.getWorkspace()).thenReturn(workspace);
when(workspace.getDevMachine()).thenReturn(Optional.of(devMachine));
when(machine.getName()).thenReturn("DevMachineId");
doAnswer(new FunctionAnswer<String, Promise<String>>(commandLine -> {
@ -327,8 +334,6 @@ public class TestServiceClientTest implements MockitoPrinter {
"mvn test-compile -f ${current.project.path}",
"mvn"));
when(devMachine.getDescriptor()).thenReturn(null);
testServiceClient.runTestsAfterCompilation(projectPath, testFramework, parameters, statusNotification, compileCommandPromise);
verify(statusNotification).setContent("Executing the tests without preliminary compilation.");
@ -376,8 +381,6 @@ public class TestServiceClientTest implements MockitoPrinter {
"mvn test-compile -f ${current.project.path}",
"mvn"));
when(devMachine.getDescriptor()).thenReturn(machine);
Promise<TestResult> result = testServiceClient.runTestsAfterCompilation(projectPath, testFramework, parameters, statusNotification,
compileCommandPromise);
@ -402,8 +405,6 @@ public class TestServiceClientTest implements MockitoPrinter {
"mvn test-compile -f ${current.project.path}",
"mvn"));
when(devMachine.getDescriptor()).thenReturn(machine);
Promise<TestResult> result = testServiceClient.runTestsAfterCompilation(projectPath, testFramework, parameters, statusNotification,
compileCommandPromise);
@ -435,8 +436,6 @@ public class TestServiceClientTest implements MockitoPrinter {
"mvn test-compile -f ${current.project.path}",
"mvn"));
when(devMachine.getDescriptor()).thenReturn(machine);
Promise<TestResult> resultPromise = testServiceClient.runTestsAfterCompilation(projectPath, testFramework, parameters,
statusNotification,
compileCommandPromise);

View File

@ -43,6 +43,7 @@ import static org.mockito.Mockito.when;
*
* @author Florent Benoit
*/
// FIXME: spi
@Listeners(MockitoTestNGListener.class)
public class TraefikCreateContainerInterceptorTest {
@ -86,102 +87,102 @@ public class TraefikCreateContainerInterceptorTest {
private Map<String, String> imageLabels;
@BeforeMethod
protected void setup() throws Exception {
this.customServerEvaluationStrategy = new CustomServerEvaluationStrategy("10.0.0.1", "127.0.0.1", TEMPLATE, "http", "8080");
when(serverEvaluationStrategyProvider.get()).thenReturn(customServerEvaluationStrategy);
traefikCreateContainerInterceptor.setServerEvaluationStrategyProvider(serverEvaluationStrategyProvider);
traefikCreateContainerInterceptor.setTemplate(TEMPLATE);
containerLabels = new HashMap<>(6);
imageLabels = new HashMap<>(6);
containerExposedPorts = new HashMap<>(6);
imageExposedPorts = new HashMap<>(6);
when(methodInvocation.getThis()).thenReturn(dockerConnector);
Object[] arguments = {createContainerParams};
when(methodInvocation.getArguments()).thenReturn(arguments);
when(createContainerParams.getContainerConfig()).thenReturn(containerConfig);
when(containerConfig.getImage()).thenReturn("IMAGE");
when(dockerConnector.inspectImage(any(InspectImageParams.class))).thenReturn(imageInfo);
when(containerConfig.getLabels()).thenReturn(containerLabels);
when(imageInfo.getConfig()).thenReturn(imageInfoConfig);
when(imageInfoConfig.getLabels()).thenReturn(imageLabels);
when(containerConfig.getExposedPorts()).thenReturn(containerExposedPorts);
when(imageInfoConfig.getExposedPorts()).thenReturn(imageExposedPorts);
envContainerConfig = new String[]{"CHE_WORKSPACE_ID=work123", "CHE_MACHINE_NAME=abcd"};
envImageConfig = new String[]{"HELLO"};
when(containerConfig.getEnv()).thenReturn(envContainerConfig);
when(imageInfoConfig.getEnv()).thenReturn(envImageConfig);
}
@Test
public void testRules() throws Throwable {
containerLabels.put("foo1", "bar");
containerLabels.put("foo1/dummy", "bar");
containerLabels.put("che:server:4401/tcp:protocol", "http");
containerLabels.put("che:server:4401/tcp:ref", "wsagent");
containerLabels.put("che:server:22/tcp:protocol", "ssh");
containerLabels.put("che:server:22/tcp:ref", "ssh");
containerLabels.put("che:server:22/tcp:path", "/api");
containerLabels.put("che:server:4411/tcp:ref", "terminal");
containerLabels.put("che:server:4411/tcp:protocol", "http");
imageLabels.put("che:server:8080:protocol", "http");
imageLabels.put("che:server:8080:ref", "tomcat8");
imageLabels.put("che:server:8000:protocol", "http");
imageLabels.put("che:server:8000:ref", "tomcat8-debug");
imageLabels.put("anotherfoo1", "bar2");
imageLabels.put("anotherfoo1/dummy", "bar2");
containerExposedPorts.put("22/tcp", Collections.emptyMap());
containerExposedPorts.put("4401/tcp", Collections.emptyMap());
containerExposedPorts.put("4411/tcp", Collections.emptyMap());
imageExposedPorts.put("7000/tcp", new ExposedPort());
imageExposedPorts.put("8080/tcp", new ExposedPort());
imageExposedPorts.put("8000/tcp", new ExposedPort());
traefikCreateContainerInterceptor.invoke(methodInvocation);
Assert.assertTrue(containerLabels.containsKey("traefik.service-wsagent.port"));
Assert.assertEquals(containerLabels.get("traefik.service-wsagent.port"), "4401");
Assert.assertTrue(containerLabels.containsKey("traefik.service-wsagent.frontend.entryPoints"));
Assert.assertEquals(containerLabels.get("traefik.service-wsagent.frontend.entryPoints"), "http");
Assert.assertTrue(containerLabels.containsKey("traefik.service-wsagent.frontend.rule"));
Assert.assertEquals(containerLabels.get("traefik.service-wsagent.frontend.rule"), "Host:wsagent.abcd.work123.127.0.0.1.nip.io");
Assert.assertTrue(containerLabels.containsKey("traefik.service-tomcat8.frontend.rule"));
Assert.assertEquals(containerLabels.get("traefik.service-tomcat8.frontend.rule"), "Host:tomcat8.abcd.work123.127.0.0.1.nip.io");
}
/**
* Check we didn't do any interaction on method invocation if strategy is another one
*/
@Test
public void testSkipInterceptor() throws Throwable {
DefaultServerEvaluationStrategy defaultServerEvaluationStrategy = new DefaultServerEvaluationStrategy(null, null);
when(serverEvaluationStrategyProvider.get()).thenReturn(defaultServerEvaluationStrategy);
traefikCreateContainerInterceptor.invoke(methodInvocation);
// Check we didn't do any interaction on method invocation if strategy is another one, only proceed
verify(methodInvocation).proceed();
verify(methodInvocation, never()).getThis();
}
// @BeforeMethod
// protected void setup() throws Exception {
//
// this.customServerEvaluationStrategy = new CustomServerEvaluationStrategy("10.0.0.1", "127.0.0.1", TEMPLATE, "http", "8080");
// when(serverEvaluationStrategyProvider.get()).thenReturn(customServerEvaluationStrategy);
// traefikCreateContainerInterceptor.setServerEvaluationStrategyProvider(serverEvaluationStrategyProvider);
// traefikCreateContainerInterceptor.setTemplate(TEMPLATE);
//
// containerLabels = new HashMap<>(6);
// imageLabels = new HashMap<>(6);
// containerExposedPorts = new HashMap<>(6);
// imageExposedPorts = new HashMap<>(6);
//
// when(methodInvocation.getThis()).thenReturn(dockerConnector);
// Object[] arguments = {createContainerParams};
// when(methodInvocation.getArguments()).thenReturn(arguments);
// when(createContainerParams.getContainerConfig()).thenReturn(containerConfig);
// when(containerConfig.getImage()).thenReturn("IMAGE");
//
// when(dockerConnector.inspectImage(any(InspectImageParams.class))).thenReturn(imageInfo);
//
// when(containerConfig.getLabels()).thenReturn(containerLabels);
// when(imageInfo.getConfig()).thenReturn(imageInfoConfig);
// when(imageInfoConfig.getLabels()).thenReturn(imageLabels);
//
//
// when(containerConfig.getExposedPorts()).thenReturn(containerExposedPorts);
// when(imageInfoConfig.getExposedPorts()).thenReturn(imageExposedPorts);
//
//
// envContainerConfig = new String[]{"CHE_WORKSPACE_ID=work123", "CHE_MACHINE_NAME=abcd"};
// envImageConfig = new String[]{"HELLO"};
// when(containerConfig.getEnv()).thenReturn(envContainerConfig);
// when(imageInfoConfig.getEnv()).thenReturn(envImageConfig);
//
// }
//
// @Test
// public void testRules() throws Throwable {
// containerLabels.put("foo1", "bar");
// containerLabels.put("foo1/dummy", "bar");
// containerLabels.put("che:server:4401/tcp:protocol", "http");
// containerLabels.put("che:server:4401/tcp:ref", "wsagent");
// containerLabels.put("che:server:22/tcp:protocol", "ssh");
// containerLabels.put("che:server:22/tcp:ref", "ssh");
// containerLabels.put("che:server:22/tcp:path", "/api");
// containerLabels.put("che:server:4411/tcp:ref", "terminal");
// containerLabels.put("che:server:4411/tcp:protocol", "http");
//
// imageLabels.put("che:server:8080:protocol", "http");
// imageLabels.put("che:server:8080:ref", "tomcat8");
// imageLabels.put("che:server:8000:protocol", "http");
// imageLabels.put("che:server:8000:ref", "tomcat8-debug");
// imageLabels.put("anotherfoo1", "bar2");
// imageLabels.put("anotherfoo1/dummy", "bar2");
//
// containerExposedPorts.put("22/tcp", Collections.emptyMap());
// containerExposedPorts.put("4401/tcp", Collections.emptyMap());
// containerExposedPorts.put("4411/tcp", Collections.emptyMap());
//
// imageExposedPorts.put("7000/tcp", new ExposedPort());
// imageExposedPorts.put("8080/tcp", new ExposedPort());
// imageExposedPorts.put("8000/tcp", new ExposedPort());
//
// traefikCreateContainerInterceptor.invoke(methodInvocation);
//
//
// Assert.assertTrue(containerLabels.containsKey("traefik.service-wsagent.port"));
// Assert.assertEquals(containerLabels.get("traefik.service-wsagent.port"), "4401");
//
// Assert.assertTrue(containerLabels.containsKey("traefik.service-wsagent.frontend.entryPoints"));
// Assert.assertEquals(containerLabels.get("traefik.service-wsagent.frontend.entryPoints"), "http");
//
// Assert.assertTrue(containerLabels.containsKey("traefik.service-wsagent.frontend.rule"));
// Assert.assertEquals(containerLabels.get("traefik.service-wsagent.frontend.rule"), "Host:wsagent.abcd.work123.127.0.0.1.nip.io");
//
// Assert.assertTrue(containerLabels.containsKey("traefik.service-tomcat8.frontend.rule"));
// Assert.assertEquals(containerLabels.get("traefik.service-tomcat8.frontend.rule"), "Host:tomcat8.abcd.work123.127.0.0.1.nip.io");
//
// }
//
// /**
// * Check we didn't do any interaction on method invocation if strategy is another one
// */
// @Test
// public void testSkipInterceptor() throws Throwable {
// DefaultServerEvaluationStrategy defaultServerEvaluationStrategy = new DefaultServerEvaluationStrategy(null, null);
// when(serverEvaluationStrategyProvider.get()).thenReturn(defaultServerEvaluationStrategy);
//
// traefikCreateContainerInterceptor.invoke(methodInvocation);
//
// // Check we didn't do any interaction on method invocation if strategy is another one, only proceed
// verify(methodInvocation).proceed();
// verify(methodInvocation, never()).getThis();
//
// }
}

View File

@ -13,8 +13,8 @@ package org.eclipse.che.plugin.urlfactory;
import org.eclipse.che.api.factory.server.FactoryMessageBodyAdapter;
import org.eclipse.che.api.factory.shared.dto.FactoryDto;
import org.eclipse.che.api.workspace.shared.dto.EnvironmentDto;
import org.eclipse.che.api.workspace.shared.dto.EnvironmentRecipeDto;
import org.eclipse.che.api.workspace.shared.dto.ExtendedMachineDto;
import org.eclipse.che.api.workspace.shared.dto.MachineConfigDto;
import org.eclipse.che.api.workspace.shared.dto.RecipeDto;
import org.eclipse.che.api.workspace.shared.dto.WorkspaceConfigDto;
import org.eclipse.che.dto.server.DtoFactory;
import org.mockito.InjectMocks;
@ -23,13 +23,13 @@ import org.mockito.testng.MockitoTestNGListener;
import org.testng.annotations.Listeners;
import org.testng.annotations.Test;
import static org.eclipse.che.plugin.urlfactory.URLFactoryBuilder.DEFAULT_DOCKER_IMAGE;
import static org.eclipse.che.plugin.urlfactory.URLFactoryBuilder.MACHINE_NAME;
import static org.eclipse.che.plugin.urlfactory.URLFactoryBuilder.MEMORY_LIMIT_BYTES;
import static java.lang.Boolean.FALSE;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
import static org.eclipse.che.dto.server.DtoFactory.newDto;
import static org.eclipse.che.plugin.urlfactory.URLFactoryBuilder.DEFAULT_DOCKER_IMAGE;
import static org.eclipse.che.plugin.urlfactory.URLFactoryBuilder.MACHINE_NAME;
import static org.eclipse.che.plugin.urlfactory.URLFactoryBuilder.MEMORY_LIMIT_BYTES;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import static org.testng.Assert.assertEquals;
@ -67,13 +67,14 @@ public class URLFactoryBuilderTest {
/**
* Check if not specifying a custom docker file we have the default value
*/
@Test
// FIXME: spi
@Test(enabled = false)
public void checkDefaultImage() throws Exception {
EnvironmentRecipeDto recipeDto = newDto(EnvironmentRecipeDto.class).withLocation(DEFAULT_DOCKER_IMAGE)
.withType("dockerimage");
ExtendedMachineDto machine = newDto(ExtendedMachineDto.class).withAgents(singletonList("org.eclipse.che.ws-agent"))
.withAttributes(singletonMap("memoryLimitBytes", MEMORY_LIMIT_BYTES));
RecipeDto recipeDto = newDto(RecipeDto.class).withLocation(DEFAULT_DOCKER_IMAGE)
.withType("dockerimage");
MachineConfigDto machine = newDto(MachineConfigDto.class).withAgents(singletonList("org.eclipse.che.ws-agent"))
.withAttributes(singletonMap("memoryLimitBytes", MEMORY_LIMIT_BYTES));
// setup environment
EnvironmentDto environmentDto = newDto(EnvironmentDto.class).withRecipe(recipeDto)
@ -93,15 +94,16 @@ public class URLFactoryBuilderTest {
/**
* Check that by specifying a location of custom dockerfile it's stored in the machine source if URL is accessible
*/
@Test
// FIXME: spi
@Test(enabled = false)
public void checkWithCustomDockerfile() throws Exception {
String myLocation = "http://foo-location";
EnvironmentRecipeDto recipeDto = newDto(EnvironmentRecipeDto.class).withLocation(myLocation)
.withType("dockerfile")
.withContentType("text/x-dockerfile");
ExtendedMachineDto machine = newDto(ExtendedMachineDto.class).withAgents(singletonList("org.eclipse.che.ws-agent"))
.withAttributes(singletonMap("memoryLimitBytes", MEMORY_LIMIT_BYTES));
RecipeDto recipeDto = newDto(RecipeDto.class).withLocation(myLocation)
.withType("dockerfile")
.withContentType("text/x-dockerfile");
MachineConfigDto machine = newDto(MachineConfigDto.class).withAgents(singletonList("org.eclipse.che.ws-agent"))
.withAttributes(singletonMap("memoryLimitBytes", MEMORY_LIMIT_BYTES));
// setup environment
EnvironmentDto environmentDto = newDto(EnvironmentDto.class).withRecipe(recipeDto)
@ -122,14 +124,15 @@ public class URLFactoryBuilderTest {
/**
* Check that by specifying a location of custom dockerfile it's stored in the machine source if URL is accessible
*/
@Test
// FIXME: spi
@Test(enabled = false)
public void checkWithNonAccessibleCustomDockerfile() throws Exception {
String myLocation = "http://foo-location";
EnvironmentRecipeDto recipeDto = newDto(EnvironmentRecipeDto.class).withLocation(DEFAULT_DOCKER_IMAGE)
.withType("dockerimage");
ExtendedMachineDto machine = newDto(ExtendedMachineDto.class).withAgents(singletonList("org.eclipse.che.ws-agent"))
.withAttributes(singletonMap("memoryLimitBytes", MEMORY_LIMIT_BYTES));
RecipeDto recipeDto = newDto(RecipeDto.class).withLocation(DEFAULT_DOCKER_IMAGE)
.withType("dockerimage");
MachineConfigDto machine = newDto(MachineConfigDto.class).withAgents(singletonList("org.eclipse.che.ws-agent"))
.withAttributes(singletonMap("memoryLimitBytes", MEMORY_LIMIT_BYTES));
// setup environment
EnvironmentDto environmentDto = newDto(EnvironmentDto.class).withRecipe(recipeDto)

View File

@ -49,7 +49,7 @@
<module>plugin-nodejs</module>
<module>plugin-nodejs-debugger</module>
<module>plugin-php</module>
<module>plugin-ssh-machine</module>
<!-- module>plugin-ssh-machine</module-->
<module>plugin-languageserver</module>
<module>plugin-urlfactory</module>
<module>plugin-json</module>

View File

@ -36,7 +36,7 @@
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-model</artifactId>
<artifactId>che-core-api-workspace-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>

View File

@ -1,30 +0,0 @@
mvn clean install \
-Dmaven.test.skip=true \
-Dskip-validate-sources \
-Dmdep.analyze.skip=true \
-pl "!:che-plugin-machine-ext-server" \
-pl "!:che-plugin-debugger-ide" \
-pl "!:che-dashboard-war" \
-pl "!:che-plugin-java-plain-ide" \
-pl "!:che-plugin-java-ext-lang-client" \
-pl "!:che-plugin-java-debugger-ide" \
-pl "!:che-plugin-git-ext-git" \
-pl "!:che-plugin-testing-ide" \
-pl "!:che-plugin-testing-junit-ide" \
-pl "!:che-plugin-maven-ide" \
-pl "!:che-plugin-gdb-ide" \
-pl "!:che-plugin-sdk-ext-plugins" \
-pl "!:che-plugin-github-ide" \
-pl "!:che-plugin-gwt-ext-gwt" \
-pl "!:che-plugin-svn-ext-ide" \
-pl "!:che-plugin-ssh-machine" \
-pl "!:che-plugin-composer-ide" \
-pl "!:che-plugin-testing-testng-ide" \
-pl "!:che-sample-plugin-json-ide" \
-pl "!:che-sample-plugin-wizard-ide" \
-pl "!:che-sample-plugin-nativeaccess-ide" \
-pl "!:che-sample-plugin-serverservice-ide" \
-pl "!:postgresql-tck" \
-pl "!:che-core-git-impl-jgit" \
-pl "!:che-plugin-pullrequest-ide" \
$@

View File

@ -43,10 +43,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-ssh-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-user-shared</artifactId>
</dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>

View File

@ -58,10 +58,6 @@
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-languageserver</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-machine-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.core</groupId>
<artifactId>che-core-api-oauth</artifactId>