Skip to content

Commit

Permalink
Add pom and code for running CDI TCK
Browse files Browse the repository at this point in the history
Signed-off-by: Arjan Tijms <arjan.tijms@gmail.com>
  • Loading branch information
arjantijms committed May 17, 2022
1 parent 32ab589 commit 4f1810f
Show file tree
Hide file tree
Showing 7 changed files with 621 additions and 0 deletions.
416 changes: 416 additions & 0 deletions appserver/tests/tck/cdi/pom.xml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* Copyright (c) 2013, 2020 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.jboss.weld.tck.glassfish;

import java.util.List;

import jakarta.enterprise.inject.spi.DefinitionException;
import jakarta.enterprise.inject.spi.DeploymentException;

import org.apache.commons.lang.exception.ExceptionUtils;
import org.jboss.arquillian.container.spi.client.container.DeploymentExceptionTransformer;

/**
*
* See AS7-1197 for more details.
*
* @see org.jboss.weld.tck.glassfish.GlassFishExtension
* @author J J Snyder (j.j.snyder@oracle.com)
*/
public class GlassFishDeploymentExceptionTransformer implements DeploymentExceptionTransformer {

private static final String[] DEPLOYMENT_EXCEPTION_FRAGMENTS = new String[] {
"org.jboss.weld.exceptions.DeploymentException",
"org.jboss.weld.exceptions.UnserializableDependencyException",
"org.jboss.weld.exceptions.InconsistentSpecializationException",
"CDI deployment failure:",
"org.jboss.weld.exceptions.NullableDependencyException" };

private static final String[] DEFINITION_EXCEPTION_FRAGMENTS = new String[]
{ "CDI definition failure:",
"org.jboss.weld.exceptions.DefinitionException" };

public Throwable transform(Throwable throwable) {

// Arquillian sometimes returns InvocationException with nested AS7
// exception and sometimes AS7 exception itself
@SuppressWarnings("unchecked")
List<Throwable> throwableList = ExceptionUtils.getThrowableList(throwable);
if (throwableList.size() < 1)
return throwable;

Throwable root = null;

if (throwableList.size() == 1) {
root = throwable;
} else {
root = ExceptionUtils.getRootCause(throwable);
}

if (root instanceof DeploymentException || root instanceof DefinitionException) {
return root;
}
if (isFragmentFound(DEPLOYMENT_EXCEPTION_FRAGMENTS, root)) {
return new DeploymentException(root);
}
if (isFragmentFound(DEFINITION_EXCEPTION_FRAGMENTS, root)) {
return new DefinitionException(root);
}
return throwable;
}

private boolean isFragmentFound(String[] fragments, Throwable rootException) {
for (String fragment : fragments) {
if (rootException.getMessage().contains(fragment)) {
return true;
}
}
return false;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package org.jboss.weld.tck.glassfish;

import org.jboss.arquillian.container.spi.client.container.DeploymentExceptionTransformer;
import org.jboss.arquillian.core.spi.LoadableExtension;

/**
* Registers the exception transformer to properly identify deployment failures.
*
* @author J J Snyder (j.j.snyder@oracle.com)
*/
public class GlassFishExtension implements LoadableExtension {

private static final String GLASSFISH_CLIENTUTILS_CLASS = "org.omnifaces.arquillian.container.glassfish.clientutils.GlassFishClientUtil";

@Override
public void register(ExtensionBuilder builder) {
if (Validate.classExists(GLASSFISH_CLIENTUTILS_CLASS)) {
builder.service(DeploymentExceptionTransformer.class, GlassFishDeploymentExceptionTransformer.class);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.jboss.weld.tck.glassfish.GlassFishExtension
77 changes: 77 additions & 0 deletions appserver/tests/tck/cdi/src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!--
Copyright (c) 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.
This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.
SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-->

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">

<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<!-- The default pattern: Date Priority [Category] Message\n -->
<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{2}] %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.StringMatchFilter">
<param name="AcceptOnMatch" value="false" />
<param name="StringToMatch" value="Failure while notifying an observer of event [a]" />
</filter>
<filter class="org.apache.log4j.varia.StringMatchFilter">
<param name="AcceptOnMatch" value="false" />
<param name="StringToMatch" value="Error destroying org.jboss.weld.bean-test-ManagedBean-class org.jboss.jsr299.tck.tests.implementation.simple.lifecycle.Cod" />
</filter>
</appender>

<!-- ############### Embedded EJB3 ################# -->
<category name="org.jboss">
<priority value="ERROR"/>
</category>

<category name="org.jboss.test">
<priority value="ERROR"/>
</category>

<category name="com.arjuna">
<priority value="ERROR"/>
</category>

<!-- ############### Hibernate logging ################# -->

<category name="org.hibernate">
<priority value="ERROR"/>
</category>


<!-- ############### Weld logging ################### -->

<category name="org.jboss.weld">
<priority value="WARN"/>
</category>

<category name="org.jboss.weld.tck">
<priority value="INFO"/>
</category>

<category name="org.jboss.testharness">
<priority value="INFO"/>
</category>

<root>
<priority value="INFO"/>
<appender-ref ref="CONSOLE"/>
</root>

</log4j:configuration>
3 changes: 3 additions & 0 deletions appserver/tests/tck/cdi/src/test/resources/password.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AS_ADMIN_MASTERPASSWORD=
AS_ADMIN_PASSWORD=
AS_ADMIN_USERPASSWORD=
1 change: 1 addition & 0 deletions appserver/tests/tck/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<module>faces</module>
<module>authentication</module>
<module>authorization</module>
<module>cdi</module>
</modules>

<build>
Expand Down

0 comments on commit 4f1810f

Please sign in to comment.