Skip to content

Commit

Permalink
further support for deployment errors
Browse files Browse the repository at this point in the history
git-svn-id: http://anonsvn.jboss.org/repos/weld/ri/trunk@2866 1c488680-804c-0410-94cd-c6b725194a0e
  • Loading branch information
pmuir committed Jun 23, 2009
1 parent 8ec5a94 commit a8d907e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 32 deletions.
@@ -1 +1,2 @@
org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.servlet.ServletTestLauncher
org.jboss.testharness.api.TestLauncher=org.jboss.testharness.impl.runner.servlet.ServletTestLauncher
org.jboss.testharness.container.deploymentExceptionTransformer=org.jboss.webbeans.tck.jbossas.WebBeansProfileServiceDeploymentExceptionTransformer
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.webbeans;
package org.jboss.webbeans.tck.jbossas;

import java.util.Map.Entry;

Expand All @@ -34,10 +34,10 @@ public class WebBeansProfileServiceDeploymentExceptionTransformer implements Dep

public DeploymentException transform(DeploymentException exception)
{
Throwable failure = exception.getCause();
if (failure.getCause() instanceof IncompleteDeploymentException)
Throwable failure = exception.getCause().getCause();
if (failure instanceof IncompleteDeploymentException)
{
IncompleteDeploymentException incompleteDeploymentException = (IncompleteDeploymentException) failure.getCause();
IncompleteDeploymentException incompleteDeploymentException = (IncompleteDeploymentException) failure;
for (Entry<String, Throwable> entry : incompleteDeploymentException.getIncompleteDeployments().getContextsInError().entrySet())
{
if (entry.getKey().endsWith(exception.getName() + "/_WebBeansBootstrapBean"))
Expand Down
Expand Up @@ -14,12 +14,12 @@

public class ManagersImpl implements Managers
{

public BeanManager getManager()
{
return CurrentManager.rootManager();
}

public void setEnabledDeploymentTypes(List<Class<? extends Annotation>> enabledDeploymentTypes)
{
CurrentManager.rootManager().setEnabledDeploymentTypes(enabledDeploymentTypes);
Expand All @@ -32,35 +32,45 @@ public List<Class<? extends Annotation>> getEnabledDeploymentTypes()
return deploymentTypes;
}

public boolean isDefinitionError(Throwable throwable)
public boolean isDefinitionError(org.jboss.testharness.api.DeploymentException deploymentException)
{
return isDefinitionException(deploymentException.getCause());
}

private boolean isDefinitionException(Throwable t)
{
if (throwable == null)
if (t == null)
{
return false;
}
else if (DefinitionException.class.isAssignableFrom(throwable.getClass()))
else if (DefinitionException.class.isAssignableFrom(t.getClass()))
{
return true;
}
else
{
return isDefinitionError(throwable.getCause());
return isDefinitionException(t.getCause());
}
}

public boolean isDeploymentError(Throwable throwable)

public boolean isDeploymentError(org.jboss.testharness.api.DeploymentException deploymentException)
{
return isDeploymentException(deploymentException.getCause());
}

public boolean isDeploymentException(Throwable t)
{
if (throwable == null)
if (t == null)
{
return false;
}
else if (DeploymentException.class.isAssignableFrom(throwable.getClass()))
else if (DeploymentException.class.isAssignableFrom(t.getClass()))
{
return true;
}
else
{
return isDeploymentError(throwable.getCause());
return isDeploymentException(t.getCause());
}
}
}
Expand Up @@ -9,10 +9,12 @@

public abstract class AbstractStandaloneContainersImpl implements StandaloneContainers
{


private DeploymentException deploymentException;

private MockServletLifecycle lifecycle;
public void deploy(Iterable<Class<?>> classes, Iterable<URL> beansXml) throws DeploymentException

public boolean deploy(Iterable<Class<?>> classes, Iterable<URL> beansXml)
{
this.lifecycle = newLifecycle();
lifecycle.initialize();
Expand All @@ -28,12 +30,14 @@ public void deploy(Iterable<Class<?>> classes, Iterable<URL> beansXml) throws De
}
catch (Exception e)
{
throw new DeploymentException("Error deploying beans", e);
this.deploymentException = new DeploymentException("Error deploying beans", e);
return false;
}
lifecycle.beginSession();
lifecycle.beginRequest();
return true;
}

protected abstract MockServletLifecycle newLifecycle();

public void deploy(Iterable<Class<?>> classes) throws DeploymentException
Expand All @@ -44,20 +48,26 @@ public void deploy(Iterable<Class<?>> classes) throws DeploymentException
public void cleanup()
{
// Np-op

}

public void setup()
{
// No-op
}

public DeploymentException getDeploymentException()
{
return deploymentException;
}

public void undeploy()
{
lifecycle.endRequest();
lifecycle.endSession();
lifecycle.endApplication();
lifecycle = null;
deploymentException = null;
}

}
Expand Up @@ -27,9 +27,9 @@
)
public class BeansXmlParserTest extends AbstractWebBeansTest
{

// Quick unit tests for the parser
@Test
@Test(groups="incontainer-broken")
public void testDefaultDeploymentTypes()
{
Iterable<URL> urls = getResources("default-beans.xml");
Expand All @@ -43,13 +43,13 @@ public void testDefaultDeploymentTypes()
assert i == 1;
BeansXmlParser parser = new BeansXmlParser(new MockResourceLoader(), urls);
parser.parse();

assert parser.getEnabledDeploymentTypes().size() == 2;
assert parser.getEnabledDeploymentTypes().get(0).equals(Standard.class);
assert parser.getEnabledDeploymentTypes().get(1).equals(Production.class);
}
@Test

@Test(groups="incontainer-broken")
public void testUserDefinedDeploymentType()
{
Iterable<URL> urls = getResources("user-defined-beans.xml");
Expand All @@ -60,16 +60,16 @@ public void testUserDefinedDeploymentType()
assert parser.getEnabledDeploymentTypes().get(1).equals(Production.class);
assert parser.getEnabledDeploymentTypes().get(2).equals(AnotherDeploymentType.class);
}

/**
* Test case for WBRI-21.
*/
@Test(expectedExceptions=DeploymentException.class, description="WBRI-21")
@Test(expectedExceptions=DeploymentException.class, description="WBRI-21", groups="incontainer-broken")
public void testDuplicateDeployElement()
{
Iterable<URL> urls = getResources("duplicate-deployments-beans.xml");
BeansXmlParser parser = new BeansXmlParser(new MockResourceLoader(), urls);
parser.parse();
}

}

0 comments on commit a8d907e

Please sign in to comment.