-
1. Facing troubles with Arquillian + Seam2 + JBossAS5.1 Managed
aslak Jan 19, 2011 7:37 PM (in response to michaelschuetz)Can you provide the test cases that shows the issue so I can reproduce?
-
2. Re: Facing troubles with Arquillian + Seam2 + JBossAS5.1 Managed
michaelschuetz Jan 19, 2011 8:15 PM (in response to aslak)Sure, Thanks Aslak.
public class XATransactionTest extends AbstractItTest {
private static final String EAR_NAME = "xaTransactionTest";
@Deployment
public static Archive<?> getDeployment() {
return getTestArchive(EAR_NAME, new String[]{"com.acme.common:commons-jsonservice:0.1",
"com.acme.common:commons-jms:0.1"},
new String[]{"net.sf.json-lib:json-lib:2.3:jdk15"},
XATransactionTest.class, MyService.class, MyServiceBean.class,
MyDao.class, MyDaoBean.class, My.class,
MessageFilterRegistrationSender.class, MessageFilterRegistrationSenderBean.class, MessageFilter.class,
RegistrationMessageCreator.class, XATransactionTestService.class, XATransactionTestServiceBean.class);
}
@EJB
private XATransactionTestService xaTransactionTestService;
@Test
public void testHeuristicMixedException() {
Exception caughtException = null;
try {
xaTransactionTestService.accessXAResources();
} catch (Exception e) {
caughtException = e;
}
assertNotNull(caughtException);
StringWriter writer = new StringWriter();
PrintWriter printWriter = new PrintWriter(writer);
caughtException.printStackTrace(printWriter);
printWriter.close();
LOG.info(writer.toString());
assertTrue(caughtException.getCause() instanceof HeuristicMixedException);
}
}
###
@Stateless
@LocalBinding(jndiBinding = "test/XATransactionTestServiceBean/local")
public class XATransactionTestServiceBean implements XATransactionTestService {
@EJB
private MyService myService;
@EJB
private MessageFilterRegistrationSender messageFilterRegistrationSender;
@Override
public void accessXAResources() {
myService.getAll();
messageFilterRegistrationSender.sendRegisteredIDsRequest();
}
}
-
3. Re: Facing troubles with Arquillian + Seam2 + JBossAS5.1 Managed
michaelschuetz Jan 19, 2011 8:28 PM (in response to michaelschuetz)BTW, "EAR_NAME" will be replaced in components.xml. See method in AbstractItTest:
private static Asset getComponentsXML(final String earName) {
return new Asset() {
@Override
public InputStream openStream() {
try {
final InputStream inputStream = AbstractItTest.class.getResourceAsStream("/war/components.xml");
final InputStreamReader streamReader = new InputStreamReader(inputStream, "UTF-8");
final ReplacingReader replacingReader =
new ReplacingReader(streamReader, Collections.singletonMap("earName", earName));
return new ReaderInputStream(replacingReader, "UTF-8");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
};
}
The other stuff is basic Arquillian Seam2 glue code.
Cheers