Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2360 1c488680-804c-0410-94cd-c6b725194a0e
- Loading branch information
Showing
1 changed file
with
63 additions
and
0 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
tests/src/main/java/org/jboss/webbeans/test/AbstractStandaloneContainersImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package org.jboss.webbeans.test; | ||
|
||
import java.net.URL; | ||
|
||
import org.jboss.testharness.api.DeploymentException; | ||
import org.jboss.testharness.spi.StandaloneContainers; | ||
import org.jboss.webbeans.mock.MockServletLifecycle; | ||
import org.jboss.webbeans.mock.MockWebBeanDiscovery; | ||
|
||
public abstract class AbstractStandaloneContainersImpl implements StandaloneContainers | ||
{ | ||
|
||
private MockServletLifecycle lifecycle; | ||
|
||
public void deploy(Iterable<Class<?>> classes, Iterable<URL> beansXml) throws DeploymentException | ||
{ | ||
this.lifecycle = newLifecycle(); | ||
lifecycle.initialize(); | ||
try | ||
{ | ||
MockWebBeanDiscovery discovery = lifecycle.getWebBeanDiscovery(); | ||
discovery.setWebBeanClasses(classes); | ||
if (beansXml != null) | ||
{ | ||
discovery.setWebBeansXmlFiles(beansXml); | ||
} | ||
lifecycle.beginApplication(); | ||
} | ||
catch (Exception e) | ||
{ | ||
throw new DeploymentException("Error deploying beans", e); | ||
} | ||
lifecycle.beginSession(); | ||
lifecycle.beginRequest(); | ||
} | ||
|
||
protected abstract MockServletLifecycle newLifecycle(); | ||
|
||
public void deploy(Iterable<Class<?>> classes) throws DeploymentException | ||
{ | ||
deploy(classes, null); | ||
} | ||
|
||
public void cleanup() | ||
{ | ||
// Np-op | ||
|
||
} | ||
|
||
public void setup() | ||
{ | ||
// No-op | ||
} | ||
|
||
public void undeploy() | ||
{ | ||
lifecycle.endRequest(); | ||
lifecycle.endSession(); | ||
lifecycle.endApplication(); | ||
lifecycle = null; | ||
} | ||
|
||
} |