blob: 35645af56792c861764178eb392d48e66397dd4c [file] [log] [blame]
package org.eclipse.jetty.deploy;
import java.util.Collection;
import org.eclipse.jetty.deploy.test.XmlConfiguredJetty;
import org.junit.Assert;
import org.junit.Test;
public class DeploymentManagerTest
{
@Test
public void testReceiveApp() throws Exception
{
DeploymentManager depman = new DeploymentManager();
AppLifecycleEventCollector eventCollector = new AppLifecycleEventCollector();
MockAppProvider mockProvider = new MockAppProvider();
depman.addAppLifeCycleListener(eventCollector);
depman.addAppProvider(mockProvider);
// Start DepMan
depman.start();
// Trigger New App
mockProvider.findWebapp("foo-webapp-1.war");
// Test app tracking
Collection<App> apps = depman.getApps();
Assert.assertNotNull("Should never be null",apps);
Assert.assertEquals("Expected App Count",1,apps.size());
// Test app get
App actual = depman.getAppByOriginId("mock-foo-webapp-1.war");
Assert.assertNotNull("Should have gotten app (by id)",actual);
Assert.assertEquals("Should have gotten app (by id)","mock-foo-webapp-1.war",actual.getOriginId());
}
/**
* Test a startup / configuration of the DeploymentManager via the XMLConfiguration object.
*/
@Test
public void testXmlConfigured() throws Exception
{
XmlConfiguredJetty jetty = null;
try
{
jetty = new XmlConfiguredJetty();
jetty.addConfiguration("jetty.xml");
jetty.addConfiguration("jetty-deploymgr-contexts.xml");
// Should not throw an Exception
jetty.load();
// Start it
jetty.start();
}
finally
{
if (jetty != null)
{
try
{
jetty.stop();
}
catch (Exception ignore)
{
// ignore
}
}
}
}
}