2016-11-25 15:42:29 +01:00
|
|
|
package test.container;
|
|
|
|
|
|
|
|
import static org.gcube.smartgears.Constants.*;
|
|
|
|
import static org.gcube.smartgears.lifecycle.container.ContainerState.*;
|
|
|
|
import static org.junit.Assert.*;
|
|
|
|
|
|
|
|
import org.gcube.smartgears.context.application.ApplicationContext;
|
|
|
|
import org.junit.After;
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
|
|
import app.SomeApp;
|
|
|
|
|
|
|
|
public class StartupTest {
|
|
|
|
|
|
|
|
SomeApp app = new SomeApp();
|
|
|
|
|
|
|
|
@After
|
|
|
|
public void teardown() {
|
|
|
|
app.stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected=RuntimeException.class)
|
|
|
|
public void failsIfHomeIsNotConfigured() {
|
|
|
|
|
|
|
|
System.clearProperty(ghn_home_property);
|
|
|
|
|
|
|
|
app.start();
|
|
|
|
|
|
|
|
assertFalse(app.isActive());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected=RuntimeException.class)
|
|
|
|
public void failsIfInstallationFolderIsInvalid() {
|
|
|
|
|
|
|
|
System.setProperty(ghn_home_property,"foo");
|
|
|
|
|
|
|
|
app.start();
|
|
|
|
|
|
|
|
assertFalse(app.isActive());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test(expected=RuntimeException.class)
|
|
|
|
public void failsIfConfigurationIsInvalid() {
|
|
|
|
|
2022-03-21 11:17:07 +01:00
|
|
|
//app.containerConfiguration().hostname(null);
|
2016-11-25 15:42:29 +01:00
|
|
|
|
|
|
|
app.start();
|
|
|
|
|
|
|
|
assertFalse(app.isActive());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void leavesContainerToActive() {
|
|
|
|
|
|
|
|
ApplicationContext ctx = app.start();
|
|
|
|
|
|
|
|
assertEquals(active,ctx.container().lifecycle().state());
|
|
|
|
|
|
|
|
assertTrue(app.isActive());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|