repo
stringlengths 1
191
⌀ | file
stringlengths 23
351
| code
stringlengths 0
5.32M
| file_length
int64 0
5.32M
| avg_line_length
float64 0
2.9k
| max_line_length
int64 0
288k
| extension_type
stringclasses 1
value |
---|---|---|---|---|---|---|
null |
wildfly-main/testsuite/integration/iiop/src/test/java/org/jboss/as/test/iiopssl/basic/IIOPSslStatelessRemote.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.iiopssl.basic;
import jakarta.ejb.EJBObject;
import java.rmi.RemoteException;
/**
* @author Bartosz Spyrko-Smietanko
*/
public interface IIOPSslStatelessRemote extends EJBObject {
String hello() throws RemoteException;
}
| 1,281 | 34.611111 | 70 |
java
|
null |
wildfly-main/testsuite/integration/iiop/src/test/java/org/jboss/as/test/iiopssl/basic/IIOPSslInvocationTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.iiopssl.basic;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.network.NetworkUtils;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.as.test.shared.PropertiesValueResolver;
import org.jboss.as.test.shared.integration.ejb.security.Util;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.security.auth.login.LoginException;
import java.io.IOException;
import java.util.Properties;
/**
* A simple IIOP over SSL invocation for one server to another
*/
@RunWith(Arquillian.class)
public class IIOPSslInvocationTestCase {
@Deployment(name = "server", testable = false)
@TargetsContainer("iiop-server")
public static Archive<?> deployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "server.jar");
jar.addClasses(IIOPSslStatelessBean.class, IIOPSslStatelessHome.class, IIOPSslStatelessRemote.class)
.addAsManifestResource(IIOPSslInvocationTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml");
return jar;
}
@Deployment(name = "client", testable = true)
@TargetsContainer("iiop-client")
public static Archive<?> clientDeployment() {
/*
* The @EJB annotation doesn't allow to specify the address dynamically. So, istead of
* @EJB(lookup = "corbaname:iiop:localhost:3628#IIOPTransactionalStatelessBean")
* private IIOPTransactionalHome home;
* we need to do this trick to get the ${node0} sys prop into ejb-jar.xml
* and have it injected that way.
*/
String ejbJar = FileUtils.readFile(IIOPSslInvocationTestCase.class, "ejb-jar.xml");
final Properties properties = new Properties();
properties.putAll(System.getProperties());
if (properties.containsKey("node1")) {
properties.put("node1", NetworkUtils.formatPossibleIpv6Address((String) properties.get("node1")));
}
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "client.jar");
jar.addClasses(ClientEjb.class, IIOPSslStatelessHome.class, IIOPSslStatelessRemote.class, IIOPSslInvocationTestCase.class, Util.class, NetworkUtils.class)
.addAsManifestResource(IIOPSslInvocationTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml")
.addAsManifestResource(new StringAsset(PropertiesValueResolver.replaceProperties(ejbJar, properties)), "ejb-jar.xml");
return jar;
}
@Test
@OperateOnDeployment("client")
public void testSuccessfulInvocation() throws IOException, NamingException, LoginException {
final ClientEjb ejb = client();
Assert.assertEquals("hello", ejb.getRemoteMessage());
}
@Test
@OperateOnDeployment("client")
public void testManualSslLookup() throws Exception {
final ClientEjb ejb = client();
Assert.assertEquals("hello", ejb.lookupSsl(3629));
}
@Test
@OperateOnDeployment("client")
public void testManualCleartextLookup() throws Exception {
try {
final ClientEjb ejb = client();
Assert.assertEquals("hello", ejb.lookup(3628));
Assert.fail("Connection on CLEAR-TEXT port should be refused");
} catch(NamingException e) {}
}
private ClientEjb client() throws NamingException {
final InitialContext context = new InitialContext();
return (ClientEjb) context.lookup("java:module/" + ClientEjb.class.getSimpleName());
}
}
| 5,023 | 41.576271 | 162 |
java
|
null |
wildfly-main/testsuite/integration/iiop/src/test/java/org/jboss/as/test/iiopssl/basic/IIOPSslStatelessBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.iiopssl.basic;
import jakarta.ejb.RemoteHome;
import jakarta.ejb.SessionContext;
import jakarta.ejb.Stateless;
/**
* @author Bartosz Spyrko-Smietanko
*/
@RemoteHome(IIOPSslStatelessHome.class)
@Stateless
public class IIOPSslStatelessBean {
public String hello() {
return "hello";
}
public void ejbCreate() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void ejbRemove() {
}
public void setSessionContext(SessionContext context) {
}
}
| 1,580 | 25.35 | 70 |
java
|
null |
wildfly-main/testsuite/integration/iiop/src/test/java/org/jboss/as/test/iiopssl/basic/ClientEjb.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.iiopssl.basic;
import org.jboss.as.network.NetworkUtils;
import jakarta.ejb.Stateless;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;
import java.rmi.RemoteException;
/**
* @author Bartosz Spyrko-Smietanko
* @author <a href="mailto:[email protected]">Tomasz Adamski</a>
*/
@Stateless
public class ClientEjb {
private IIOPSslStatelessHome statelessHome;
public String getRemoteMessage() throws RemoteException {
IIOPSslStatelessRemote ejb = statelessHome.create();
return ejb.hello();
}
public String lookup(int port) throws NamingException, RemoteException {
final InitialContext ctx = new InitialContext();
final String hostname = NetworkUtils.formatPossibleIpv6Address(System.getProperty("node1"));
final Object value = ctx.lookup("corbaname:iiop:"+hostname+":" + port + "#IIOPSslStatelessBean");
final Object narrow = PortableRemoteObject.narrow(value, IIOPSslStatelessHome.class);
return ((IIOPSslStatelessHome)narrow).create().hello();
}
public String lookupSsl(int port) throws NamingException, RemoteException {
final InitialContext ctx = new InitialContext();
final String hostname = NetworkUtils.formatPossibleIpv6Address(System.getProperty("node1"));
final Object value = ctx.lookup("corbaname:ssliop:1.2@"+hostname+":" + port + "#IIOPSslStatelessBean");
final Object narrow = PortableRemoteObject.narrow(value, IIOPSslStatelessHome.class);
return ((IIOPSslStatelessHome)narrow).create().hello();
}
}
| 2,664 | 40 | 111 |
java
|
null |
wildfly-main/testsuite/integration/iiop/src/test/java/org/jboss/as/test/iiopssl/basic/IIOPSslStatelessHome.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.iiopssl.basic;
import jakarta.ejb.EJBHome;
import java.rmi.RemoteException;
/**
* @author Bartosz Spyrko-Smietanko
*/
public interface IIOPSslStatelessHome extends EJBHome {
IIOPSslStatelessRemote create() throws RemoteException;
}
| 1,292 | 34.916667 | 70 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/txbridge/fromjta/FirstClient.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.txbridge.fromjta;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import org.jboss.as.test.txbridge.fromjta.service.FirstServiceAT;
import java.net.URL;
public class FirstClient {
public static FirstServiceAT newInstance() throws Exception {
URL wsdlLocation = new URL("http://localhost:8080/test/FirstServiceATService/FirstServiceAT?wsdl");
QName serviceName = new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/first", "FirstServiceATService");
QName portName = new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/first", "FirstServiceAT");
Service service = Service.create(wsdlLocation, serviceName);
FirstServiceAT client = service.getPort(portName, FirstServiceAT.class);
return client;
}
}
| 1,848 | 39.195652 | 123 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/txbridge/fromjta/BridgeFromJTATestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.txbridge.fromjta;
import javax.naming.InitialContext;
import jakarta.transaction.UserTransaction;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.txbridge.fromjta.service.FirstServiceAT;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* <p>
* Simple set of starting Jakarta Transactions transaction and getting it bridged to the XTS-AT.
* <p>
* Test ported from https://github.com/jbosstm/quickstart repository.
*/
@RunWith(Arquillian.class)
public class BridgeFromJTATestCase {
private static final Logger log = Logger.getLogger(BridgeFromJTATestCase.class);
private static final String DEPLOYMENT = "fromjta-bridge";
private static final String ManifestMF =
"Manifest-Version: 1.0\nDependencies: org.jboss.xts\n";
private static final String persistentXml =
"<persistence>\n" +
" <persistence-unit name=\"first\">\n" +
" <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>\n" +
" <properties>\n" +
" <property name=\"hibernate.hbm2ddl.auto\" value=\"create-drop\"/>\n" +
" </properties>\n" +
" </persistence-unit>\n" +
"</persistence>";
private UserTransaction ut;
private FirstServiceAT firstClient;
@Deployment(name = DEPLOYMENT)
public static Archive<?> createDeployment() {
return DeploymentHelper.getInstance().getWebArchiveWithPermissions("test")
.addPackages(true, BridgeFromJTATestCase.class.getPackage())
.addAsManifestResource(new StringAsset(ManifestMF), "MANIFEST.MF")
.addAsWebInfResource(new StringAsset(persistentXml), "classes/META-INF/persistence.xml" );
}
@Before
public void setupTest() throws Exception {
ut = (UserTransaction) new InitialContext().lookup("java:comp/UserTransaction");
firstClient = FirstClient.newInstance();
}
@After
public void teardownTest() throws Exception {
tryRollback(ut);
try {
ut.begin();
firstClient.resetCounter();
ut.commit();
} finally {
tryRollback(ut);
}
}
/**
* Test starts the Jakarta Transactions transaction while calling the 'incrementCounter' on the stub.
* Expecting the interceptor bridges from Jakarta Transactions to WS-AT.
* The commit of the Jakarta Transactions transaction should cause the commit of the WS-AT transaction as well.
*/
@Test
public void testCommit() throws Exception {
ut.begin();
firstClient.incrementCounter(1);
ut.commit();
// second Jakarta Transactions checks if the counter was really incremented
ut.begin();
int counter = firstClient.getCounter();
ut.commit();
Assert.assertEquals("Bridged Jakarta Transactions transaction should commit the WS-AT and the counter is expected to be incremented",
1, counter);
}
/**
* Test starts the Jakarta Transactions transaction while calling the 'incrementCounter' on the stub.
* Expecting the interceptor bridges from Jakarta Transactions to WS-AT.
* The rollback of the Jakarta Transactions transaction should cause the rollback of the WS-AT transaction as well.
*/
@Test
public void testRollback() throws Exception {
ut.begin();
firstClient.incrementCounter(1);
ut.rollback();
// second Jakarta Transactions checks if the counter was not incremented
ut.begin();
int counter = firstClient.getCounter();
ut.commit();
Assert.assertEquals("Asserting that the counters were *not* incremented successfully", 0, counter);
}
private void tryRollback(UserTransaction ut) {
try {
ut.rollback();
} catch (Throwable th2) {
log.trace("Cannot rollback transaction " + ut, th2);
}
}
}
| 5,315 | 36.971429 | 141 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/txbridge/fromjta/service/FirstCounterEntity.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.txbridge.fromjta.service;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import java.io.Serializable;
/**
* Entity to verify the transaction participant
* is handled correctly when transaction is bridged
* from Jakarta Transactions to WS-AT.
*/
@Entity
public class FirstCounterEntity implements Serializable {
private static final long serialVersionUID = 1L;
private int id;
private int counter;
public FirstCounterEntity() {
}
public FirstCounterEntity(int id, int initialCounterValue) {
this.id = id;
this.counter = initialCounterValue;
}
@Id
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getCounter() {
return counter;
}
public void setCounter(int counter) {
this.counter = counter;
}
public void incrementCounter(int howMany) {
setCounter(getCounter() + howMany);
}
}
| 2,026 | 28.376812 | 70 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/txbridge/fromjta/service/FirstServiceATImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.txbridge.fromjta.service;
import jakarta.ejb.Remote;
import jakarta.ejb.Stateless;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.persistence.EntityManager;
import jakarta.persistence.PersistenceContext;
import org.jboss.logging.Logger;
@Stateless
@Remote(FirstServiceAT.class)
@WebService(serviceName = "FirstServiceATService", portName = "FirstServiceAT",
name = "FirstServiceAT", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@TransactionAttribute(TransactionAttributeType.MANDATORY)
public class FirstServiceATImpl implements FirstServiceAT {
private static final Logger log = Logger.getLogger(FirstServiceATImpl.class);
private static final int ENTITY_ID = 1;
@PersistenceContext
protected EntityManager em;
/**
* Increment the first counter. This is done by updating the counter within Jakarta Transactions transaction.
* The Jakarta Transactions transaction was automatically bridged from the WS-AT transaction.
*/
@WebMethod
public void incrementCounter(int num) {
log.trace("Service invoked to increment the counter by '" + num + "'");
FirstCounterEntity entityFirst = lookupCounterEntity();
entityFirst.incrementCounter(num);
em.merge(entityFirst);
}
@WebMethod
public int getCounter() {
log.trace("Service getCounter was invoked");
FirstCounterEntity firstCounterEntity = lookupCounterEntity();
if (firstCounterEntity == null) {
return -1;
}
return firstCounterEntity.getCounter();
}
@WebMethod
public void resetCounter() {
FirstCounterEntity entityFirst = lookupCounterEntity();
entityFirst.setCounter(0);
em.merge(entityFirst);
}
private FirstCounterEntity lookupCounterEntity() {
FirstCounterEntity entityFirst = em.find(FirstCounterEntity.class, ENTITY_ID);
if (entityFirst == null) {
entityFirst = new FirstCounterEntity(ENTITY_ID, 0);
em.persist(entityFirst);
}
return entityFirst;
}
}
| 3,337 | 36.505618 | 113 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/txbridge/fromjta/service/FirstServiceAT.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.txbridge.fromjta.service;
import jakarta.ejb.Remote;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
/**
* Interface to a simple First. Provides simple methods to manipulate with counter.
*/
@WebService(name = "FirstServiceAT", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@Remote
public interface FirstServiceAT {
/**
* Create a new booking
*/
@WebMethod
public void incrementCounter(int numSeats);
/**
* Obtain the number of existing bookings
*/
@WebMethod
public int getCounter();
/**
* Reset the booking count to zero
*/
@WebMethod
public void resetCounter();
}
| 1,817 | 30.894737 | 114 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/txbridge/fromjta/service/FirstServiceATService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.txbridge.fromjta.service;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import jakarta.xml.ws.WebEndpoint;
import jakarta.xml.ws.WebServiceClient;
import jakarta.xml.ws.WebServiceFeature;
import org.jboss.logging.Logger;
import java.net.MalformedURLException;
import java.net.URL;
/**
* This class was generated by the JAX-WS RI. JAX-WS RI 2.1.6 in JDK 6 Generated source version: 2.1
*/
@WebServiceClient(name = "FirstServiceATService", targetNamespace = "http://www.jboss.com/jbossas/test/txbridge/fromjta/first")
public class FirstServiceATService extends Service {
private static final Logger log = Logger.getLogger(FirstServiceATService.class.getName());
private static final URL FIRSTSERVICEATSERVICE_WSDL_LOCATION;
static {
URL url = null;
try {
URL baseUrl;
baseUrl = FirstServiceATService.class.getResource(".");
url = new URL(baseUrl, "FirstServiceAT.wsdl");
} catch (MalformedURLException e) {
log.warn("Failed to create URL for the wsdl Location: 'FirstServiceAT.wsdl', retrying as a local file", e);
}
FIRSTSERVICEATSERVICE_WSDL_LOCATION = url;
}
public FirstServiceATService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public FirstServiceATService() {
super(FIRSTSERVICEATSERVICE_WSDL_LOCATION,
new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceATService"));
}
@WebEndpoint(name = "FirstServiceAT")
public FirstServiceAT getFirstServiceAT() {
return super.getPort(
new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceAT"),
FirstServiceAT.class);
}
/**
* @param features A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy.
* Supported features not in the <code>features</code> parameter will have their default values.
*/
@WebEndpoint(name = "FirstServiceAT")
public FirstServiceAT getFirstServiceAT(WebServiceFeature... features) {
return super.getPort(
new QName("http://www.jboss.com/jbossas/test/txbridge/fromjta/First", "FirstServiceAT"),
FirstServiceAT.class, features);
}
}
| 3,354 | 38.470588 | 127 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/util/EventLog.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.util;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jakarta.ejb.Singleton;
import org.jboss.logging.Logger;
/**
* Singleton class to gather information on processing from the webservices.
* This log is called from test class to check the actions which were done.
*/
@Singleton
public class EventLog implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(EventLog.class);
// Event logs for a name
private volatile Map<String, List<EventLogEvent>> eventLog = new HashMap<String, List<EventLogEvent>>();
private static final String GENERAL_EVENTLOG_NAME = "general";
/**
* Method checks whether the eventLogName exists in the datastore.
* In case that it exists - do nothing.
* In case that it does not exists - it creates the key with empty list of logged events.
*
* @param eventLogName name of key for events
*/
public void foundEventLogName(String eventLogName) {
getListToModify(eventLogName, eventLog);
}
public void addEvent(String eventLogName, EventLogEvent event) {
log.debug("Adding event " + event + " to logger " + this);
getListToModify(eventLogName, eventLog).add(event);
}
public List<EventLogEvent> getEventLog(String eventLogName) {
eventLogName = eventLogName == null ? GENERAL_EVENTLOG_NAME : eventLogName;
return eventLog.get(eventLogName);
}
public void clear() {
eventLog.clear();
}
public static String asString(List<EventLogEvent> events) {
String result = "";
for (EventLogEvent logEvent : events) {
result += logEvent.name() + ",";
}
return result;
}
// --- helper method
private <T> List<T> getListToModify(String eventLogName, Map<String, List<T>> map) {
eventLogName = eventLogName == null ? GENERAL_EVENTLOG_NAME : eventLogName;
if (map.containsKey(eventLogName)) {
return map.get(eventLogName);
} else {
List<T> newList = new ArrayList<T>();
map.put(eventLogName, newList);
return newList;
}
}
}
| 3,334 | 33.739583 | 108 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/util/DeploymentHelper.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.util;
import java.io.File;
import java.io.FilePermission;
import java.lang.reflect.ReflectPermission;
import java.util.PropertyPermission;
import org.jboss.as.test.shared.integration.ejb.security.PermissionUtils;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.Asset;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public class DeploymentHelper {
private static final DeploymentHelper INSTANCE = new DeploymentHelper();
private DeploymentHelper() {
}
public static DeploymentHelper getInstance() {
return INSTANCE;
}
public JavaArchive getJavaArchive(final String archiveName) {
final JavaArchive javaArchive = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
return javaArchive;
}
public WebArchive getWebArchive(final String archiveName) {
final WebArchive webArchive = ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
return webArchive;
}
public WebArchive getWebArchiveWithPermissions(final String archiveName) {
return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
.addAsWebInfResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"))
.addAsManifestResource(createPermissions(), "permissions.xml");
}
public static Asset createPermissions() {
return PermissionUtils.createPermissionsXmlAsset(
// This is technically not required given the <<ALL FILES>>. However, if that is fixed then this
// will be required.
new FilePermission(System.getProperties()
.getProperty("jbossas.ts.integ.dir") + File.separator + "xts" + File.separator
+ "xcatalog", "read"),
// The only reason to use <<ALL FILES>> is because the activation API cannot load the
// implementation via a service loader without read permissions to the JAR. (jakarta.activation.FactoryFinder)
new FilePermission("<<ALL FILES>>", "read"),
// Required for the org.jboss.arquillian.core.impl.RuntimeLogger
new PropertyPermission("arquillian.debug", "read"),
// Required for org.jboss.arquillian.container.test.spi.util.ServiceLoader
new ReflectPermission("suppressAccessChecks"),
// Required for org.junit.internal.MethodSorter
new RuntimePermission("accessDeclaredMembers"),
// Required for the activation API service loader (jakarta.activation.FactoryFinder)
new RuntimePermission("getClassLoader"),
// Permissions for port access
new PropertyPermission("management.address", "read"),
new PropertyPermission("node0", "read"),
new PropertyPermission("jboss.http.port", "read")
);
}
}
| 4,357 | 43.469388 | 127 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/util/ServiceCommand.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.util;
/**
* Commands used to control controller actions.
*/
public enum ServiceCommand {
DO_COMMIT,
VOTE_ROLLBACK,
VOTE_ROLLBACK_PRE_PREPARE,
VOTE_READONLY_DURABLE,
VOTE_READONLY_VOLATILE,
ROLLBACK_ONLY,
APPLICATION_EXCEPTION,
SYSTEM_EXCEPTION_ON_COMPLETE,
DO_COMPLETE,
CANNOT_COMPLETE,
REUSE_BA_PARTICIPANT;
/**
* Utility method which just check array on existence of a ServiceCommand
*/
public static boolean isPresent(ServiceCommand expectedServiceCommand, ServiceCommand[] serviceCommands) {
for (ServiceCommand foundServiceCommand : serviceCommands) {
if (foundServiceCommand == expectedServiceCommand) {
return true;
}
}
return false;
}
}
| 1,833 | 33.603774 | 110 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/util/EventLogEvent.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.util;
/**
* XTS callbacks which could be logged to event log and then checked in tests.
*/
public enum EventLogEvent {
// XTS AT callbacks events
BEFORE_PREPARE, // volatile participant
PREPARE, // durable participant
ERROR,
ROLLBACK, // durable participant
VOLATILE_ROLLBACK, // volatile participant
COMMIT, // durable participant
VOLATILE_COMMIT, // volatile participant
@Deprecated UNKNOWN,
// XTS BA callbacks events
COMPLETE,
CONFIRM_COMPLETED,
CONFIRM_FAILED, // method confirmCompleted called with false
CLOSE,
CANCEL,
COMPENSATE
}
| 1,662 | 33.645833 | 78 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/coordinatorcompletion/service/BACoordinationCompletionParticipant.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.coordinatorcompletion.service;
import com.arjuna.wst.BusinessAgreementWithCoordinatorCompletionParticipant;
import com.arjuna.wst.FaultedException;
import com.arjuna.wst.SystemException;
import com.arjuna.wst.WrongStateException;
import com.arjuna.wst11.ConfirmCompletedParticipant;
import org.jboss.as.test.xts.base.BaseFunctionalTest;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.EventLogEvent;
import org.jboss.as.test.xts.util.ServiceCommand;
import org.jboss.logging.Logger;
import java.io.Serializable;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
/**
* A coordinator completion participant which only logs invoked methods. The log {@link EventLog} is then checked at the end of every test.
*
* @see BaseFunctionalTest#assertEventLog
*/
public class BACoordinationCompletionParticipant implements BusinessAgreementWithCoordinatorCompletionParticipant, ConfirmCompletedParticipant,
Serializable {
private static final Logger log = Logger.getLogger(BACoordinationCompletionParticipant.class);
private static final long serialVersionUID = 1L;
// The ID of the corresponding transaction
private String txID;
// table of currently active participants
private static HashMap<String, Set<BACoordinationCompletionParticipant>> participants = new HashMap<String, Set<BACoordinationCompletionParticipant>>();
private String participantName;
// Service command which define behaving of the participant
private ServiceCommand[] serviceCommands;
// Where to log participant activity
private EventLog eventLog;
/**
* Participant instances are related to business method calls in a one to one manner.
*
* @param txID The ID of the current Business Activity
* @param value the value to remove from the set during compensation
*/
public BACoordinationCompletionParticipant(ServiceCommand[] serviceCommands, EventLog eventLog, String txID, String value) {
this.txID = txID;
this.serviceCommands = serviceCommands;
this.eventLog = eventLog;
this.participantName = value;
}
@Override
public String status() {
return null;
}
/**
* The transaction has completed successfully. The participant previously informed the coordinator that it was ready to
* complete.
*
* @throws com.arjuna.wst.WrongStateException never in this implementation.
* @throws com.arjuna.wst.SystemException never in this implementation.
*/
public void close() throws WrongStateException, SystemException {
// Nothing to do here as the item has already been added to the set
eventLog.addEvent(participantName, EventLogEvent.CLOSE);
log.trace("[BA COORDINATOR COMPL SERVICE] Participant close() - logged: " + EventLogEvent.CLOSE);
// The participant knows that this BA is now finished and can throw away any temporary state
removeParticipant(txID, this);
}
/**
* The transaction has canceled, and the participant should undo any work. The participant cannot have informed the
* coordinator that it has completed.
*
* @throws com.arjuna.wst.WrongStateException never in this implementation.
* @throws com.arjuna.wst.SystemException never in this implementation.
*/
public void cancel() throws WrongStateException, SystemException {
eventLog.addEvent(participantName, EventLogEvent.CANCEL);
log.trace("[BA COORDINATOR COMPL SERVICE] Participant cancel() - logged: " + EventLogEvent.CANCEL);
// the participant should compensate any work done within this BA here
removeParticipant(txID, this);
}
/**
* The transaction has cancelled. The participant previously informed the coordinator that it had finished work but could
* compensate later if required, and it is now requested to do so.
*
* @throws com.arjuna.wst.WrongStateException never in this implementation.
* @throws com.arjuna.wst.SystemException if unable to perform the compensating transaction.
*/
public void compensate() throws FaultedException, WrongStateException, SystemException {
eventLog.addEvent(participantName, EventLogEvent.COMPENSATE);
log.trace("[BA COORDINATOR COMPL SERVICE] Participant compensate() - logged: " + EventLogEvent.COMPENSATE);
// there will be carrying out some compensation action here
removeParticipant(txID, this);
}
@Deprecated
public void unknown() throws SystemException {
eventLog.addEvent(participantName, EventLogEvent.UNKNOWN);
log.trace("[BA COORDINATOR COMPL SERVICE] Participant unknown() - logged: " + EventLogEvent.UNKNOWN);
removeParticipant(txID, this);
}
public void error() throws SystemException {
eventLog.addEvent(participantName, EventLogEvent.ERROR);
log.trace("[BA COORDINATOR COMPL SERVICE] Participant error() - logged: " + EventLogEvent.ERROR);
removeParticipant(txID, this);
}
public void complete() throws WrongStateException, SystemException {
// This tells the participant that the BA completed, but may be compensated later
eventLog.addEvent(participantName, EventLogEvent.COMPLETE);
log.trace("[BA COORDINATOR COMPL SERVICE] Participant complete() - logged: " + EventLogEvent.COMPLETE);
if (ServiceCommand.isPresent(ServiceCommand.SYSTEM_EXCEPTION_ON_COMPLETE, serviceCommands)) {
log.trace("[BA COORDINATOR COMPL SERVICE] Participant complete() - intentionally throwing " + SystemException.class.getName());
throw new SystemException("Intentionally throwing system exception to get compensation method on run");
}
}
/**
* Method called to perform commit or rollback of prepared changes to the underlying manager state after the participant
* recovery record has been written
*
* @param confirmed true if the log record has been written and changes should be rolled forward and false if it has not
* been written and changes should be rolled back
*/
public void confirmCompleted(boolean confirmed) {
if (confirmed) {
// This tells the participant that compensation information has been logged and that it is safe to commit any changes
eventLog.addEvent(participantName, EventLogEvent.CONFIRM_COMPLETED);
log.trace("[BA COORDINATOR COMPL SERVICE] Participant confirmCompleted(true) - logged: " + EventLogEvent.CONFIRM_COMPLETED);
} else {
// A compensation action will follow here
eventLog.addEvent(participantName, EventLogEvent.CONFIRM_FAILED);
log.trace("[BA COORDINATOR COMPL SERVICE] Participant confirmCompleted(false) - logged: " + EventLogEvent.CONFIRM_FAILED);
}
}
/************************************************************************/
/* tracking active participants */
/************************************************************************/
/**
* keep track of a participant
*
* @param txID the participant's transaction id
* @param participant The participant associated with this BA
*/
public static synchronized void recordParticipant(String txID, BACoordinationCompletionParticipant participant) {
getParticipantSet(txID).add(participant);
}
/**
* forget about a participant
*
* @param txID the participant's transaction id
*/
public static void removeParticipant(String txID, BACoordinationCompletionParticipant participant) {
getParticipantSet(txID).remove(participant);
if (getParticipantSet(txID).isEmpty()) {
participants.remove(txID);
}
}
/**
* lookup a participant
*
* @param txID the participant's transaction id
* @return the participant
*/
public static synchronized BACoordinationCompletionParticipant getSomeParticipant(String txID) {
Iterator<BACoordinationCompletionParticipant> i = getParticipantSet(txID).iterator();
if (i.hasNext()) {
return i.next();
}
return null;
}
private static Set<BACoordinationCompletionParticipant> getParticipantSet(String txID) {
if (participants.containsKey(txID)) {
return participants.get(txID);
} else {
Set<BACoordinationCompletionParticipant> set = new HashSet<BACoordinationCompletionParticipant>();
participants.put(txID, set);
return set;
}
}
}
| 9,738 | 44.297674 | 156 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/coordinatorcompletion/service/BACoordinatorCompletionService2.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.coordinatorcompletion.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "BACoordinatorCompletionService2",
portName = "BACoordinatorCompletion", name = "BACoordinatorCompletion",
targetNamespace = "http://www.jboss.com/jbossas/test/xts/ba/coordinatorcompletion/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "BACoordinatorCompletionService2", urlPatterns = {"/BACoordinatorCompletionService2"})
public class BACoordinatorCompletionService2 extends BACoordinatorCompletionSuperService {
public static final String SERVICE_EVENTLOG_NAME = "bacoordinator_completition_service2";
@WebMethod
public void saveData(ServiceCommand... serviceCommands) throws TestApplicationException {
super.saveData(SERVICE_EVENTLOG_NAME, serviceCommands);
}
}
| 2,177 | 44.375 | 105 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/coordinatorcompletion/service/BACoordinatorCompletionService3.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.coordinatorcompletion.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "BACoordinatorCompletionService3",
portName = "BACoordinatorCompletion", name = "BACoordinatorCompletion",
targetNamespace = "http://www.jboss.com/jbossas/test/xts/ba/coordinatorcompletion/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "BACoordinatorCompletionService3", urlPatterns = {"/BACoordinatorCompletionService3"})
public class BACoordinatorCompletionService3 extends BACoordinatorCompletionSuperService {
public static final String SERVICE_EVENTLOG_NAME = "bacoordinator_completition_service3";
@WebMethod
public void saveData(ServiceCommand... serviceCommands) throws TestApplicationException {
super.saveData(SERVICE_EVENTLOG_NAME, serviceCommands);
}
}
| 2,177 | 44.375 | 105 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/coordinatorcompletion/service/BACoordinatorCompletionService1.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.coordinatorcompletion.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "BACoordinatorCompletionService1",
portName = "BACoordinatorCompletion", name = "BACoordinatorCompletion",
targetNamespace = "http://www.jboss.com/jbossas/test/xts/ba/coordinatorcompletion/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "BACoordinatorCompletionService1", urlPatterns = {"/BACoordinatorCompletionService1"})
public class BACoordinatorCompletionService1 extends BACoordinatorCompletionSuperService {
public static final String SERVICE_EVENTLOG_NAME = "bacoordinator_completition_service1";
@WebMethod
public void saveData(ServiceCommand... serviceCommands) throws TestApplicationException {
super.saveData(SERVICE_EVENTLOG_NAME, serviceCommands);
}
}
| 2,177 | 44.375 | 105 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/coordinatorcompletion/service/BACoordinatorCompletion.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.coordinatorcompletion.service;
import jakarta.jws.WebMethod;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
public interface BACoordinatorCompletion {
@WebMethod
void saveData(ServiceCommand... serviceCommands) throws TestApplicationException;
}
| 1,380 | 38.457143 | 85 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/coordinatorcompletion/service/BACoordinatorCompletionSuperService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.coordinatorcompletion.service;
import jakarta.inject.Inject;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.ServiceCommand;
import org.jboss.logging.Logger;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.mw.wst11.BusinessActivityManager;
import com.arjuna.mw.wst11.BusinessActivityManagerFactory;
import com.arjuna.wst.SystemException;
import com.arjuna.wst11.BAParticipantManager;
import static org.jboss.as.test.xts.util.ServiceCommand.*;
/**
* Service implemenation - this implemetation is inherited by web services.
*/
public abstract class BACoordinatorCompletionSuperService implements BACoordinatorCompletion {
private static final Logger log = Logger.getLogger(BACoordinatorCompletionSuperService.class);
@Inject
private EventLog eventLog;
/**
* Add an item to a set and enroll a Participant if necessary then pass the call through to the business logic.
*
* @param value the value to add to the set.
* @throws AlreadyInSetException if value is already in the set
* @throws SetServiceException if an error occurred when attempting to add the item to the set.
*/
public void saveData(String value, ServiceCommand... serviceCommands) throws TestApplicationException {
log.trace("[BA COORDINATOR COMPL SERVICE] web method saveData('" + value + "')");
eventLog.foundEventLogName(value);
BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();
// transaction context associated with this thread
String transactionId;
try {
transactionId = activityManager.currentTransaction().toString();
} catch (SystemException e) {
throw new RuntimeException("Unable to lookup existing business activity", e);
}
// Lookup existing participant or register new participant (
BACoordinationCompletionParticipant participantBA = BACoordinationCompletionParticipant.getSomeParticipant(transactionId);
if (participantBA != null && ServiceCommand.isPresent(REUSE_BA_PARTICIPANT, serviceCommands)) {
log.trace("[BA COORDINATOR COMPL SERVICE] Re-using the existing participant, already registered for this BA - command set to: " +
REUSE_BA_PARTICIPANT);
} else {
try {
// enlist the Participant for this service:
participantBA = new BACoordinationCompletionParticipant(serviceCommands, eventLog, transactionId, value);
BACoordinationCompletionParticipant.recordParticipant(transactionId, participantBA);
log.trace("[BA COORDINATOR COMPL SERVICE] Enlisting a participant into the BA");
BAParticipantManager baParticipantManager = activityManager.enlistForBusinessAgreementWithCoordinatorCompletion(participantBA,
"BACoordinatorCompletition:" + new Uid().toString());
if (ServiceCommand.isPresent(CANNOT_COMPLETE, serviceCommands)) {
baParticipantManager.cannotComplete();
return;
}
if (ServiceCommand.isPresent(DO_COMPLETE, serviceCommands)) {
throw new RuntimeException("Only ParticipantCompletion participants are supposed to call complete. " +
"CoordinatorCompletion participants need to wait to be notified by the coordinator.");
}
} catch (Exception e) {
log.error("[BA COORDINATOR COMPL SERVICE] Participant enlistment failed", e);
throw new RuntimeException("Error enlisting participant", e);
}
}
if (ServiceCommand.isPresent(APPLICATION_EXCEPTION, serviceCommands)) {
throw new TestApplicationException("Intentionally thrown Application Exception - service command set to: " + APPLICATION_EXCEPTION);
}
// invoke the back-end business logic
log.trace("[BA COORDINATOR COMPL SERVICE] Invoking the back-end business logic - saving value: " + value);
}
}
| 5,248 | 46.718182 | 144 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/coordinatorcompletion/client/BACoordinatorCompletionTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.coordinatorcompletion.client;
import static org.jboss.as.test.xts.util.EventLogEvent.CANCEL;
import static org.jboss.as.test.xts.util.EventLogEvent.CLOSE;
import static org.jboss.as.test.xts.util.EventLogEvent.COMPENSATE;
import static org.jboss.as.test.xts.util.EventLogEvent.COMPLETE;
import static org.jboss.as.test.xts.util.EventLogEvent.CONFIRM_COMPLETED;
import static org.jboss.as.test.xts.util.ServiceCommand.APPLICATION_EXCEPTION;
import static org.jboss.as.test.xts.util.ServiceCommand.CANNOT_COMPLETE;
import static org.jboss.as.test.xts.util.ServiceCommand.SYSTEM_EXCEPTION_ON_COMPLETE;
import jakarta.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.xts.base.BaseFunctionalTest;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.EventLogEvent;
import org.jboss.as.test.xts.wsba.coordinatorcompletion.service.BACoordinatorCompletion;
import org.jboss.as.test.xts.wsba.coordinatorcompletion.service.BACoordinatorCompletionService1;
import org.jboss.as.test.xts.wsba.coordinatorcompletion.service.BACoordinatorCompletionService2;
import org.jboss.as.test.xts.wsba.coordinatorcompletion.service.BACoordinatorCompletionService3;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.arjuna.mw.wst11.UserBusinessActivity;
import com.arjuna.mw.wst11.UserBusinessActivityFactory;
/**
* XTS business activities - coordinator completition test case
*/
@RunWith(Arquillian.class)
public class BACoordinatorCompletionTestCase extends BaseFunctionalTest {
private UserBusinessActivity uba;
private BACoordinatorCompletion client1, client2, client3;
@Inject
private EventLog eventLog;
public static final String ARCHIVE_NAME = "wsba-coordinatorcompletition-test";
@Deployment
public static WebArchive createTestArchive() {
return DeploymentHelper.getInstance().getWebArchiveWithPermissions(ARCHIVE_NAME)
.addPackage(BACoordinatorCompletion.class.getPackage())
.addPackage(BACoordinatorCompletionClient.class.getPackage())
.addPackage(EventLog.class.getPackage())
.addPackage(BaseFunctionalTest.class.getPackage())
.addAsResource("context-handlers.xml")
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts,org.jboss.jts\n"), "MANIFEST.MF");
}
@Before
public void setupTest() throws Exception {
uba = UserBusinessActivityFactory.userBusinessActivity();
client1 = BACoordinatorCompletionClient.newInstance("BACoordinatorCompletionService1");
client2 = BACoordinatorCompletionClient.newInstance("BACoordinatorCompletionService2");
client3 = BACoordinatorCompletionClient.newInstance("BACoordinatorCompletionService3");
}
protected EventLog getEventLog() {
return eventLog;
}
@After
public void teardownTest() throws Exception {
getEventLog().clear();
cancelIfActive(uba);
}
@Test
public void testWSBACoordinatorSingle() throws Exception {
uba.begin();
client1.saveData();
uba.close();
assertEventLogClient1(COMPLETE, CONFIRM_COMPLETED, CLOSE);
}
@Test
public void testWSBACoordinatorSimple() throws Exception {
uba.begin();
client1.saveData();
client2.saveData();
client3.saveData();
uba.close();
assertEventLogClient1(COMPLETE, CONFIRM_COMPLETED, CLOSE);
assertEventLogClient2(COMPLETE, CONFIRM_COMPLETED, CLOSE);
assertEventLogClient3(COMPLETE, CONFIRM_COMPLETED, CLOSE);
}
@Test
public void testWSBACoordinatorCannotComplete() throws Exception {
try {
uba.begin();
client1.saveData();
client2.saveData(CANNOT_COMPLETE);
client3.saveData();
Assert.fail("Exception should have been thrown by now");
} catch (jakarta.xml.ws.soap.SOAPFaultException sfe) {
// This is OK - exception expected
// P2 set transaction status to ABORT_ONLY
// P3 enlist is failed with WrongStateException and can't be done
// It needs call uba.cancel() to rollback the transaction
uba.cancel();
} finally {
assertEventLogClient1(CANCEL);
assertEventLogClient2();
assertEventLogClient3();
}
}
@Test
public void testWSBACoordinatorClientCancel() throws Exception {
uba.begin();
client1.saveData();
client2.saveData();
client3.saveData();
uba.cancel();
assertEventLogClient1(CANCEL);
assertEventLogClient2(CANCEL);
assertEventLogClient3(CANCEL);
}
@Test
public void testWSBACoordinatorApplicationException() throws Exception {
try {
uba.begin();
client1.saveData();
client2.saveData(APPLICATION_EXCEPTION);
Assert.fail("Exception should have been thrown by now");
} catch (TestApplicationException e) {
// This is OK - exception expected
} finally {
client3.saveData();
// TM can't know this application exception, so it needs cancel.
uba.cancel();
}
assertEventLogClient1(CANCEL);
assertEventLogClient2(CANCEL);
assertEventLogClient3(CANCEL);
}
@Test
public void testWSBACoordinatorCompletionFailToComplete() throws Exception {
try {
uba.begin();
client1.saveData();
client2.saveData(SYSTEM_EXCEPTION_ON_COMPLETE);
client3.saveData();
uba.close();
Assert.fail("Exception should have been thrown by now");
} catch (com.arjuna.wst.TransactionRolledBackException trbe) {
// This is OK - exception expected
} finally {
assertEventLogClient1(COMPLETE, CONFIRM_COMPLETED, COMPENSATE);
assertEventLogClient2(COMPLETE, CANCEL);
assertEventLogClient3(CANCEL);
}
}
// --- assert methods
// --- they take event log names from the service called by particular client
private void assertEventLogClient1(EventLogEvent... expectedOrder) {
assertEventLog(BACoordinatorCompletionService1.SERVICE_EVENTLOG_NAME, expectedOrder);
}
private void assertEventLogClient2(EventLogEvent... expectedOrder) {
assertEventLog(BACoordinatorCompletionService2.SERVICE_EVENTLOG_NAME, expectedOrder);
}
private void assertEventLogClient3(EventLogEvent... expectedOrder) {
assertEventLog(BACoordinatorCompletionService3.SERVICE_EVENTLOG_NAME, expectedOrder);
}
}
| 8,126 | 37.885167 | 118 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/coordinatorcompletion/client/BACoordinatorCompletionClient.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.coordinatorcompletion.client;
import org.jboss.as.test.xts.wsba.coordinatorcompletion.service.BACoordinatorCompletion;
import org.jboss.logging.Logger;
import io.undertow.util.NetworkUtils;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import java.net.URL;
/**
* Coordinator completition client
*/
public class BACoordinatorCompletionClient {
private static final Logger log = Logger.getLogger(BACoordinatorCompletionClient.class);
private static final String NODE0_ADDR = NetworkUtils.formatPossibleIpv6Address(System.getProperty("node0", "localhost"));
private static final int NODE0_PORT = 8080;
private static final String TARGET_NAMESPACE = "http://www.jboss.com/jbossas/test/xts/ba/coordinatorcompletion/";
private static final String DEFAULT_PORT_NAME = "BACoordinatorCompletion";
public static BACoordinatorCompletion newInstance(String serviceNamespaceName) throws Exception {
return BACoordinatorCompletionClient.newInstance(serviceNamespaceName, serviceNamespaceName);
}
public static BACoordinatorCompletion newInstance(String serviceUrl, String serviceNamespaceName) throws Exception {
URL wsdlLocation = new URL("http://" + NODE0_ADDR + ":" + NODE0_PORT + "/" + BACoordinatorCompletionTestCase.ARCHIVE_NAME + "/" + serviceUrl + "?wsdl");
log.trace("wsdlLocation for service: " + wsdlLocation);
QName serviceName = new QName(TARGET_NAMESPACE, serviceNamespaceName);
QName portName = new QName(TARGET_NAMESPACE, DEFAULT_PORT_NAME);
Service service = Service.create(wsdlLocation, serviceName);
BACoordinatorCompletion client = service.getPort(portName, BACoordinatorCompletion.class);
return client;
}
}
| 2,809 | 41.575758 | 160 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/participantcompletion/service/BAParticipantCompletionService1.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.participantcompletion.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "BAParticipantCompletionService1",
portName = "BAParticipantCompletion", name = "BAParticipantCompletion",
targetNamespace = "http://www.jboss.com/jbossas/test/xts/ba/participantcompletion/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "BAParticipantCompletionService1", urlPatterns = {"/BAParticipantCompletionService1"})
public class BAParticipantCompletionService1 extends BAParticipantCompletionSuperService {
public static final String SERVICE_EVENTLOG_NAME = "baparticipant_completition_service1";
@WebMethod
public void saveData(ServiceCommand... serviceCommands) throws TestApplicationException {
super.saveData(SERVICE_EVENTLOG_NAME, serviceCommands);
}
}
| 2,177 | 44.375 | 105 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/participantcompletion/service/BAParticipantCompletionSuperService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.participantcompletion.service;
import java.util.HashMap;
import java.util.Map;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.ServiceCommand;
import org.jboss.logging.Logger;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.mw.wst11.BusinessActivityManager;
import com.arjuna.mw.wst11.BusinessActivityManagerFactory;
import com.arjuna.wst.SystemException;
import com.arjuna.wst11.BAParticipantManager;
import jakarta.inject.Inject;
import static org.jboss.as.test.xts.util.ServiceCommand.*;
/**
* Service implemenation - this implemetation is inherited by web services.
*/
public abstract class BAParticipantCompletionSuperService implements BAParticipantCompletion {
private static final Logger log = Logger.getLogger(BAParticipantCompletionSuperService.class);
// for tests this is not needed - but the code operating with participant registry should be synchronized
private static final Map<String, BAParticipantManager> participantRegistry = new HashMap<String, BAParticipantManager>();
@Inject
private EventLog eventLog;
/**
* Add an item to a set Enrolls a Participant if necessary and passes the call through to the business logic.
*
* @param value the value to add to the set.
* @throws
* @throws AlreadyInSetException if value is already in the set
* @throws SetServiceException if an error occurred when attempting to add the item to the set.
*/
public void saveData(String value, ServiceCommand... serviceCommands) throws TestApplicationException {
log.trace("[BA PARTICIPANT COMPL SERVICE] invoked saveData('" + value + "')");
eventLog.foundEventLogName(value);
BAParticipantManager participantManager;
BusinessActivityManager activityManager = BusinessActivityManagerFactory.businessActivityManager();
String txid;
try {
txid = activityManager.currentTransaction().toString();
} catch (SystemException se) {
throw new RuntimeException("Error on getting TX id from BusinessActivityManager", se);
}
if (participantRegistry.containsKey(txid) && ServiceCommand.isPresent(REUSE_BA_PARTICIPANT, serviceCommands)) {
log.trace("[BA PARTICIPANT COMPL SERVICE] Reusing BA participant manager - command: " + REUSE_BA_PARTICIPANT);
participantManager = participantRegistry.get(txid);
} else {
try {
// Enlist the Participant for this service:
BAParticipantCompletionParticipant participant = new BAParticipantCompletionParticipant(serviceCommands, eventLog, value);
log.trace("[BA PARTICIPANT COMPL SERVICE] Enlisting a participant into the BA");
participantManager = activityManager.enlistForBusinessAgreementWithParticipantCompletion(participant,
"BAParticipantCompletition:" + new Uid().toString());
participantRegistry.put(txid, participantManager);
} catch (Exception e) {
log.error("[BA PARTICIPANT COMPL SERVICE] Participant enlistment failed", e);
throw new RuntimeException("Error enlisting participant", e);
}
}
if (ServiceCommand.isPresent(APPLICATION_EXCEPTION, serviceCommands)) {
throw new TestApplicationException("Intentionally thrown Application Exception - service command set to: " + APPLICATION_EXCEPTION);
}
// There could be invoked some back-end business logic here
/*
* This service employs the participant completion protocol which means it decides when it wants to commit local
* changes. If the local changes (adding the item to the set) succeeded, we notify the coordinator that we have
* completed. Otherwise, we notify the coordinator that we cannot complete. If any other participant fails or the client
* decides to cancel we can rely upon being told to compensate.
*/
log.trace("[BA PARTICIPANT COMPL SERVICE] Prepare the backend resource and if successful notify the coordinator that we have completed our work");
if (ServiceCommand.isPresent(DO_COMPLETE, serviceCommands)) {
try {
// Tell the coordinator manager we have finished our work
log.trace("[BA PARTICIPANT COMPL SERVICE] Prepare successful, notifying coordinator of completion");
participantManager.completed();
} catch (Exception e) {
/* Failed to notify the coordinator that we have finished our work. Compensate the work and throw an Exception
* to notify the client that the add operation failed. */
log.error("[BA PARTICIPANT COMPL SERVICE] 'completed' callback failed");
throw new RuntimeException("Error when notifying the coordinator that the work is completed", e);
}
}
if (ServiceCommand.isPresent(CANNOT_COMPLETE, serviceCommands)) {
try {
// Tell the participant manager we cannot complete. This will force the activity to fail.
log.trace("[BA PARTICIPANT COMPL SERVICE] Prepared fail, notifying coordinator that we cannot complete");
participantManager.cannotComplete();
return;
} catch (Exception e) {
log.error("[BA PARTICIPANT COMPL SERVICE] 'cannotComplete' callback failed");
throw new RuntimeException("Error when notifying the coordinator that the work is cannot be completed", e);
}
}
}
}
| 6,775 | 48.823529 | 154 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/participantcompletion/service/BAParticipantCompletionService2.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.participantcompletion.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "BAParticipantCompletionService2",
portName = "BAParticipantCompletion", name = "BAParticipantCompletion",
targetNamespace = "http://www.jboss.com/jbossas/test/xts/ba/participantcompletion/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "BAParticipantCompletionService2", urlPatterns = {"/BAParticipantCompletionService2"})
public class BAParticipantCompletionService2 extends BAParticipantCompletionSuperService {
public static final String SERVICE_EVENTLOG_NAME = "baparticipant_completition_service2";
@WebMethod
public void saveData(ServiceCommand... serviceCommands) throws TestApplicationException {
super.saveData(SERVICE_EVENTLOG_NAME, serviceCommands);
}
}
| 2,177 | 44.375 | 105 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/participantcompletion/service/BAParticipantCompletionParticipant.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.participantcompletion.service;
import com.arjuna.wst.BusinessAgreementWithParticipantCompletionParticipant;
import com.arjuna.wst.FaultedException;
import com.arjuna.wst.SystemException;
import com.arjuna.wst.WrongStateException;
import com.arjuna.wst11.ConfirmCompletedParticipant;
import org.jboss.as.test.xts.base.BaseFunctionalTest;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.EventLogEvent;
import org.jboss.as.test.xts.util.ServiceCommand;
import org.jboss.logging.Logger;
import java.io.Serializable;
/**
* A participant completion participant which only logs invoked methods. The log {@link EventLog} is then checked at the end of every test.
*
* @see BaseFunctionalTest#assertEventLog
*/
public class BAParticipantCompletionParticipant
implements BusinessAgreementWithParticipantCompletionParticipant, ConfirmCompletedParticipant, Serializable {
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(BAParticipantCompletionParticipant.class);
private String participantName;
// Where to log participant activity
private EventLog eventLog;
/**
* Participant instances are related to business method calls in a one to one manner.
*
* @param value the value to remove from the set during compensation
*/
public BAParticipantCompletionParticipant(ServiceCommand[] serviceCommands, EventLog eventLog, String value) {
this.participantName = value;
this.eventLog = eventLog;
}
public String status() {
return null;
}
/**
* The transaction has completed successfully. The participant previously informed the coordinator that it was ready to
* complete.
*
* @throws com.arjuna.wst.WrongStateException never in this implementation.
* @throws com.arjuna.wst.SystemException never in this implementation.
*/
public void close() throws WrongStateException, SystemException {
eventLog.addEvent(participantName, EventLogEvent.CLOSE);
// The participant knows that this BA is now finished and can throw away any temporary state
// nothing to do here as the item has already been added to the set
log.trace("[BA PARTICIPANT COMPL SERVICE] Participant close() - logged: " + EventLogEvent.CLOSE);
}
/**
* The transaction has canceled, and the participant should undo any work. The participant cannot have informed the
* coordinator that it has completed.
*
* @throws com.arjuna.wst.WrongStateException never in this implementation.
* @throws com.arjuna.wst.SystemException never in this implementation.
*/
public void cancel() throws WrongStateException, SystemException {
eventLog.addEvent(participantName, EventLogEvent.CANCEL);
// The participant should compensate any work done within this BA
log.trace("[BA PARTICIPANT COMPL SERVICE] Participant cancel() - logged: " + EventLogEvent.CANCEL);
// A compensate work will be carrying here
}
/**
* The transaction has cancelled. The participant previously informed the coordinator that it had finished work but could
* compensate later if required, and it is now requested to do so.
*
* @throws com.arjuna.wst.WrongStateException never in this implementation.
* @throws com.arjuna.wst.SystemException if unable to perform the compensating transaction.
*/
public void compensate() throws FaultedException, WrongStateException, SystemException {
eventLog.addEvent(participantName, EventLogEvent.COMPENSATE);
log.trace("[BA PARTICIPANT COMPL SERVICE] Participant compensate() - logged: " + EventLogEvent.COMPENSATE);
// A compensate work will be carrying here
}
@Deprecated
public void unknown() throws SystemException {
eventLog.addEvent(participantName, EventLogEvent.UNKNOWN);
log.trace("[BA PARTICIPANT COMPL SERVICE] Participant unknown() - logged: " + EventLogEvent.UNKNOWN);
}
public void error() throws SystemException {
eventLog.addEvent(participantName, EventLogEvent.ERROR);
log.trace("[BA PARTICIPANT COMPL SERVICE] Participant error() - logged: " + EventLogEvent.ERROR);
// A compensate work will be carrying here
}
/**
* method called to perform commit or rollback of prepared changes to the underlying manager state after the participant
* recovery record has been written
*
* @param confirmed true if the log record has been written and changes should be rolled forward and false if it has not
* been written and changes should be rolled back
*/
public void confirmCompleted(boolean confirmed) {
log.trace("[BA PARTICIPANT COMPL SERVICE] Participant confirmCompleted(" + Boolean.toString(confirmed) + ")");
if (confirmed) {
// This tells the participant that compensation information has been logged and that it is safe to commit any changes
eventLog.addEvent(participantName, EventLogEvent.CONFIRM_COMPLETED);
log.trace("[BA PARTICIPANT COMPL SERVICE] Participant confirmCompleted(true) - logged: " + EventLogEvent.CONFIRM_COMPLETED);
} else {
eventLog.addEvent(participantName, EventLogEvent.CONFIRM_FAILED);
log.trace("[BA PARTICIPANT COMPL SERVICE] Participant confirmCompleted(false) - logged: " + EventLogEvent.CONFIRM_FAILED);
}
}
}
| 6,582 | 45.034965 | 139 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/participantcompletion/service/BAParticipantCompletionService3.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.participantcompletion.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "BAParticipantCompletionService3",
portName = "BAParticipantCompletion", name = "BAParticipantCompletion",
targetNamespace = "http://www.jboss.com/jbossas/test/xts/ba/participantcompletion/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "BAParticipantCompletionService3", urlPatterns = {"/BAParticipantCompletionService3"})
public class BAParticipantCompletionService3 extends BAParticipantCompletionSuperService {
public static final String SERVICE_EVENTLOG_NAME = "baparticipant_completition_service3";
@WebMethod
public void saveData(ServiceCommand... serviceCommands) throws TestApplicationException {
super.saveData(SERVICE_EVENTLOG_NAME, serviceCommands);
}
}
| 2,177 | 44.375 | 105 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/participantcompletion/service/BAParticipantCompletion.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.participantcompletion.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.ejb.Remote;
import jakarta.jws.WebMethod;
@Remote
public interface BAParticipantCompletion {
@WebMethod
void saveData(ServiceCommand... serviceCommands) throws TestApplicationException;
}
| 1,416 | 36.289474 | 85 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/participantcompletion/client/BAParticipantCompletionClient.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.participantcompletion.client;
import io.undertow.util.NetworkUtils;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import org.jboss.as.test.xts.wsba.participantcompletion.service.BAParticipantCompletion;
import org.jboss.logging.Logger;
import java.net.URL;
/**
* Service implemenation - this implemetation is inherited by annotated web services.
*/
public class BAParticipantCompletionClient {
private static final Logger log = Logger.getLogger(BAParticipantCompletionClient.class);
private static final String NODE0_ADDR = NetworkUtils.formatPossibleIpv6Address(System.getProperty("node0", "localhost"));
private static final int NODE0_PORT = 8080;
private static final String TARGET_NAMESPACE = "http://www.jboss.com/jbossas/test/xts/ba/participantcompletion/";
private static final String DEFAULT_PORT_NAME = "BAParticipantCompletion";
public static BAParticipantCompletion newInstance(String serviceNamespaceName) throws Exception {
return BAParticipantCompletionClient.newInstance(serviceNamespaceName, serviceNamespaceName);
}
public static BAParticipantCompletion newInstance(String serviceUrl, String serviceNamespaceName) throws Exception {
URL wsdlLocation = new URL("http://" + NODE0_ADDR + ":" + NODE0_PORT + "/" + BAParticipantCompletionTestCase.ARCHIVE_NAME + "/" + serviceUrl + "?wsdl");
log.trace("wsdlLocation for service: " + wsdlLocation);
QName serviceName = new QName(TARGET_NAMESPACE, serviceNamespaceName);
QName portName = new QName(TARGET_NAMESPACE, DEFAULT_PORT_NAME);
Service service = Service.create(wsdlLocation, serviceName);
BAParticipantCompletion client = service.getPort(portName, BAParticipantCompletion.class);
return client;
}
}
| 2,859 | 43 | 160 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsba/participantcompletion/client/BAParticipantCompletionTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsba.participantcompletion.client;
import static org.jboss.as.test.xts.util.EventLogEvent.CANCEL;
import static org.jboss.as.test.xts.util.EventLogEvent.CLOSE;
import static org.jboss.as.test.xts.util.EventLogEvent.COMPENSATE;
import static org.jboss.as.test.xts.util.EventLogEvent.CONFIRM_COMPLETED;
import static org.jboss.as.test.xts.util.ServiceCommand.APPLICATION_EXCEPTION;
import static org.jboss.as.test.xts.util.ServiceCommand.CANNOT_COMPLETE;
import static org.jboss.as.test.xts.util.ServiceCommand.DO_COMPLETE;
import jakarta.inject.Inject;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.xts.base.BaseFunctionalTest;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.EventLogEvent;
import org.jboss.as.test.xts.wsba.participantcompletion.service.BAParticipantCompletion;
import org.jboss.as.test.xts.wsba.participantcompletion.service.BAParticipantCompletionService1;
import org.jboss.as.test.xts.wsba.participantcompletion.service.BAParticipantCompletionService2;
import org.jboss.as.test.xts.wsba.participantcompletion.service.BAParticipantCompletionService3;
import org.jboss.jbossts.xts.bytemanSupport.BMScript;
import org.jboss.jbossts.xts.bytemanSupport.participantCompletion.ParticipantCompletionCoordinatorRules;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.arjuna.mw.wst11.UserBusinessActivity;
import com.arjuna.mw.wst11.UserBusinessActivityFactory;
import com.arjuna.wst.TransactionRolledBackException;
/**
* XTS business activities - participant completition test case
*/
@RunWith(Arquillian.class)
public class BAParticipantCompletionTestCase extends BaseFunctionalTest {
UserBusinessActivity uba;
BAParticipantCompletion client1, client2, client3;
@Inject
private EventLog eventLog;
public static final String ARCHIVE_NAME = "wsba-participantcompletition-test";
@Deployment
public static Archive<?> createTestArchive() {
return DeploymentHelper.getInstance().getWebArchive(ARCHIVE_NAME)
.addPackage(BAParticipantCompletion.class.getPackage())
.addPackage(BAParticipantCompletionClient.class.getPackage())
.addPackage(EventLog.class.getPackage())
.addPackage(BaseFunctionalTest.class.getPackage())
.addClass(ParticipantCompletionCoordinatorRules.class)
.addAsResource("context-handlers.xml")
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts,org.jboss.jts\n"), "MANIFEST.MF");
}
@BeforeClass()
public static void submitBytemanScript() throws Exception {
BMScript.submit(ParticipantCompletionCoordinatorRules.RESOURCE_PATH);
}
@AfterClass()
public static void removeBytemanScript() {
BMScript.remove(ParticipantCompletionCoordinatorRules.RESOURCE_PATH);
}
@Before
public void setupTest() throws Exception {
uba = UserBusinessActivityFactory.userBusinessActivity();
client1 = BAParticipantCompletionClient.newInstance("BAParticipantCompletionService1");
client2 = BAParticipantCompletionClient.newInstance("BAParticipantCompletionService2");
client3 = BAParticipantCompletionClient.newInstance("BAParticipantCompletionService3");
}
protected EventLog getEventLog() {
return eventLog;
}
@After
public void teardownTest() throws Exception {
getEventLog().clear();
cancelIfActive(uba);
}
@Test
public void testWSBAParticipantCompleteSingle() throws Exception {
ParticipantCompletionCoordinatorRules.setParticipantCount(1);
uba.begin();
client1.saveData(DO_COMPLETE);
uba.close();
assertEventLogClient1(CONFIRM_COMPLETED, CLOSE);
}
@Test
public void testWSBAParticipantCompleteSimple() throws Exception {
ParticipantCompletionCoordinatorRules.setParticipantCount(3);
uba.begin();
client1.saveData(DO_COMPLETE);
client2.saveData(DO_COMPLETE);
client3.saveData(DO_COMPLETE);
uba.close();
assertEventLogClient1(CONFIRM_COMPLETED, CLOSE);
assertEventLogClient2(CONFIRM_COMPLETED, CLOSE);
assertEventLogClient3(CONFIRM_COMPLETED, CLOSE);
}
@Test
public void testWSBAParticipantDoNotComplete() throws Exception {
ParticipantCompletionCoordinatorRules.setParticipantCount(3);
try {
uba.begin();
client1.saveData(DO_COMPLETE);
client2.saveData(DO_COMPLETE);
client3.saveData(); // this participant does not inform about correct completition
uba.close();
Assert.fail("Exception should have been thrown by now");
} catch (TransactionRolledBackException e) {
// we expect this :)
}
assertEventLogClient1(CONFIRM_COMPLETED, COMPENSATE);
assertEventLogClient2(CONFIRM_COMPLETED, COMPENSATE);
assertEventLogClient3(CANCEL);
}
@Test
public void testWSBAParticipantClientCancelNotComplete() throws Exception {
ParticipantCompletionCoordinatorRules.setParticipantCount(3);
uba.begin();
client1.saveData(DO_COMPLETE);
client2.saveData();
client3.saveData(DO_COMPLETE);
uba.cancel();
assertEventLogClient1(CONFIRM_COMPLETED, COMPENSATE);
assertEventLogClient2(CANCEL);
assertEventLogClient3(CONFIRM_COMPLETED, COMPENSATE);
}
@Test
public void testWSBAParticipantCannotComplete() throws Exception {
ParticipantCompletionCoordinatorRules.setParticipantCount(3);
try {
uba.begin();
client1.saveData(DO_COMPLETE);
client2.saveData(CANNOT_COMPLETE);
client3.saveData(DO_COMPLETE);
Assert.fail("Exception should have been thrown by now");
} catch (jakarta.xml.ws.soap.SOAPFaultException sfe) {
// Exception is expected - enlisting participant #3 can't be done
}
try {
uba.close();
} catch (TransactionRolledBackException e) {
// Exception is expected - rollback on close because of cannotComplete
}
assertEventLogClient1(CONFIRM_COMPLETED, COMPENSATE);
assertEventLogClient2();
assertEventLogClient3();
}
@Test
public void testWSBAParticipantClientCancel() throws Exception {
ParticipantCompletionCoordinatorRules.setParticipantCount(3);
uba.begin();
client1.saveData(DO_COMPLETE);
client2.saveData(DO_COMPLETE);
client3.saveData(DO_COMPLETE);
uba.cancel();
assertEventLogClient1(CONFIRM_COMPLETED, COMPENSATE);
assertEventLogClient2(CONFIRM_COMPLETED, COMPENSATE);
assertEventLogClient3(CONFIRM_COMPLETED, COMPENSATE);
}
@Test
public void testWSBAParticipantApplicationException() throws Exception {
ParticipantCompletionCoordinatorRules.setParticipantCount(3);
try {
uba.begin();
client1.saveData(DO_COMPLETE);
client2.saveData(APPLICATION_EXCEPTION);
Assert.fail("Exception should have been thrown by now");
} catch (TestApplicationException e) {
// Exception is expected
}
try {
client3.saveData(DO_COMPLETE);
uba.close();
Assert.fail("Exception should have been thrown by now");
} catch (com.arjuna.wst.TransactionRolledBackException tre) {
// Exception is expected to be throws from close() method
}
assertEventLogClient1(CONFIRM_COMPLETED, COMPENSATE);
assertEventLogClient2(CANCEL);
assertEventLogClient3(CONFIRM_COMPLETED, COMPENSATE);
}
// --- assert methods
// --- they take event log names from the service called by particular client
private void assertEventLogClient1(EventLogEvent... expectedOrder) {
assertEventLog(BAParticipantCompletionService1.SERVICE_EVENTLOG_NAME, expectedOrder);
}
private void assertEventLogClient2(EventLogEvent... expectedOrder) {
assertEventLog(BAParticipantCompletionService2.SERVICE_EVENTLOG_NAME, expectedOrder);
}
private void assertEventLogClient3(EventLogEvent... expectedOrder) {
assertEventLog(BAParticipantCompletionService3.SERVICE_EVENTLOG_NAME, expectedOrder);
}
}
| 9,880 | 37.150579 | 118 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/base/TestApplicationException.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.base;
import java.io.Serializable;
@SuppressWarnings("serial")
public class TestApplicationException extends Exception implements Serializable {
public TestApplicationException(String message, Throwable e) {
super(message, e);
}
public TestApplicationException(String message) {
super(message);
}
}
| 1,390 | 34.666667 | 81 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/base/BaseFunctionalTest.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.base;
import java.util.Arrays;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.EventLogEvent;
import org.junit.Assert;
import com.arjuna.mw.wst11.UserBusinessActivity;
/**
* Shared functionality with XTS test cases.
*/
public abstract class BaseFunctionalTest {
@ArquillianResource
private InitialContext iniCtx;
// ABSTRACT methods used from children classes
protected abstract EventLog getEventLog();
// ---- Work with transactions
public void rollbackIfActive(com.arjuna.mw.wst11.UserTransaction ut) {
try {
ut.rollback();
} catch (Throwable th2) {
// do nothing, not active
}
}
public void rollbackIfActive(jakarta.transaction.UserTransaction ut) {
try {
ut.rollback();
} catch (Throwable th2) {
// do nothing, not active
}
}
public void cancelIfActive(UserBusinessActivity uba) {
try {
uba.cancel();
} catch (Throwable e) {
// do nothing, not active
}
}
protected <T> T lookup(Class<T> beanType, String archiveName) {
try {
return beanType.cast(iniCtx.lookup("java:global/" + archiveName + "/" + beanType.getSimpleName() + "!"
+ beanType.getName()));
} catch (NamingException ne) {
throw new RuntimeException(ne);
}
}
// ---- Test result checking
protected void assertEventLog(String eventLogName, EventLogEvent... expectedOrder) {
Assert.assertEquals("Another status order expected for the " + eventLogName, Arrays.asList(expectedOrder), getEventLog().getEventLog(eventLogName));
}
}
| 2,903 | 32 | 156 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/base/BaseServiceInterface.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.base;
import org.jboss.as.test.xts.util.EventLog;
/**
* Base interface which is inherited by other service interfaces.
* This interface is used in test cases to check results of tests.
*/
public interface BaseServiceInterface {
EventLog getEventLog();
void clearEventLog();
}
| 1,345 | 35.378378 | 70 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/service/ATVolatileParticipant.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.service;
import com.arjuna.wst.Aborted;
import com.arjuna.wst.Prepared;
import com.arjuna.wst.ReadOnly;
import com.arjuna.wst.SystemException;
import com.arjuna.wst.Volatile2PCParticipant;
import com.arjuna.wst.Vote;
import com.arjuna.wst.WrongStateException;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.EventLogEvent;
import org.jboss.as.test.xts.util.ServiceCommand;
import org.jboss.logging.Logger;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A WS-T Atomic Transaction volatile participant.
*/
public class ATVolatileParticipant implements Volatile2PCParticipant, Serializable {
private static final Logger log = Logger.getLogger(ATVolatileParticipant.class);
private static final long serialVersionUID = 1L;
// Is participant already enlisted to transaction?
private static Map<String, List<ATVolatileParticipant>> activeParticipants = new HashMap<String, List<ATVolatileParticipant>>();
String transactionId;
private String eventLogName;
// Service command which define behaving of the participant
private ServiceCommand[] serviceCommands;
// Where to log participant activity
private EventLog eventLog;
/**
* Creates a new participant for this transaction. Participants and transaction instances have a one-to-one mapping.
*
* @param serviceCommands service commands for interrupting of the processing
* @param eventLogName name for event log - differentiate calls on the same web service/creating participant
* @param eventLog event log that info about processing will be put into
* @param transactionId transaction id works for logging active participants
*/
public ATVolatileParticipant(ServiceCommand[] serviceCommands, String eventLogName, EventLog eventLog, String transactionId) {
this.serviceCommands = serviceCommands;
this.eventLog = eventLog;
this.eventLogName = eventLogName;
addParticipant(transactionId);
}
/**
* Invokes the volatile prepare step of the business logic.
*
* @return in dependence of command passed to constructor @see{ServiceCommand}
* @throws com.arjuna.wst.WrongStateException
* @throws com.arjuna.wst.SystemException
*/
@Override
// TODO: added option for System Exception would be thrown?
public Vote prepare() throws WrongStateException, SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.BEFORE_PREPARE);
log.trace("[AT SERVICE] Volatile participant prepare() - logged: " + EventLogEvent.BEFORE_PREPARE);
if (ServiceCommand.isPresent(ServiceCommand.VOTE_ROLLBACK_PRE_PREPARE, serviceCommands)) {
log.trace("[AT SERVICE] Volatile participant prepare(): " + Aborted.class.getSimpleName());
return new Aborted();
} else if (ServiceCommand.isPresent(ServiceCommand.VOTE_READONLY_VOLATILE, serviceCommands)) {
log.trace("[AT SERVICE] Volatile participant prepare(): " + ReadOnly.class.getSimpleName());
return new ReadOnly();
} else {
log.trace("[AT SERVICE] Volatile participant prepare(): " + Prepared.class.getSimpleName());
return new Prepared();
}
}
/**
* Invokes the volatile commit step of the business logic.
* All participants voted 'prepared', so coordinator tells the volatile participant that commit has been done.
*
* @throws com.arjuna.wst.WrongStateException
* @throws com.arjuna.wst.SystemException
*/
@Override
public void commit() throws WrongStateException, SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.VOLATILE_COMMIT);
log.trace("[AT SERVICE] Volatile participant commit() - logged: " + EventLogEvent.VOLATILE_COMMIT);
}
/**
* Invokes the volatile rollback operation on the business logic.
* One or more participants voted 'aborted' or a failure occurred, so coordinator tells the volatile participant that rollback has been done.
*
* @throws com.arjuna.wst.WrongStateException
* @throws com.arjuna.wst.SystemException
*/
@Override
public void rollback() throws WrongStateException, SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.VOLATILE_ROLLBACK);
log.trace("[AT SERVICE] Volatile participant rollback() - logged: " + EventLogEvent.VOLATILE_ROLLBACK);
}
@SuppressWarnings("deprecation")
@Override
public void unknown() throws SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.UNKNOWN);
log.trace("[AT SERVICE] Volatile participant unknown() - logged: " + EventLogEvent.UNKNOWN);
}
/**
* This should not happen for volatile participant.
*/
@Override
public void error() throws SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.ERROR);
log.trace("[AT SERVICE] Volatile participant error() - logged: " + EventLogEvent.ERROR);
}
// --- private helper methods ---
private void addParticipant(String transactionId) {
if (activeParticipants.containsKey(transactionId)) {
if (activeParticipants.get(transactionId).contains(this)) {
throw new RuntimeException(this.getClass().getName() + " can't be enlisted to transaction " + transactionId + " because it already is enlisted.");
}
activeParticipants.get(transactionId).add(this);
} else {
List<ATVolatileParticipant> participants = new ArrayList<ATVolatileParticipant>();
participants.add(this);
activeParticipants.put(transactionId, participants);
}
}
}
| 6,857 | 42.405063 | 162 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/service/ATService3.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "ATService3", portName = "AT", name = "AT", targetNamespace = "http://www.jboss.com/jbossas/test/xts/wsat/at/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "ATService3", urlPatterns = {"/ATService3"})
public class ATService3 extends ATSuperService {
public static final String LOG_NAME = "service3";
@WebMethod
public void invoke(ServiceCommand... serviceCommands) throws TestApplicationException {
super.invokeWithCallName(LOG_NAME, serviceCommands);
}
}
| 1,931 | 40.106383 | 137 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/service/ATService2.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "ATService2", portName = "AT", name = "AT", targetNamespace = "http://www.jboss.com/jbossas/test/xts/wsat/at/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "ATService2", urlPatterns = {"/ATService2"})
public class ATService2 extends ATSuperService {
public static final String LOG_NAME = "service2";
@WebMethod
public void invoke(ServiceCommand... serviceCommands) throws TestApplicationException {
super.invokeWithCallName(LOG_NAME, serviceCommands);
}
}
| 1,931 | 40.106383 | 137 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/service/AT.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.service;
import jakarta.jws.WebMethod;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
/**
* WS-AT simple web service interface
*/
public interface AT {
@WebMethod
void invoke(ServiceCommand... serviceCommands) throws TestApplicationException;
}
| 1,382 | 34.461538 | 83 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/service/ATService1.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.service;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.ServiceCommand;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.servlet.annotation.WebServlet;
@WebService(serviceName = "ATService1", portName = "AT", name = "AT", targetNamespace = "http://www.jboss.com/jbossas/test/xts/wsat/at/")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
@WebServlet(name = "ATService1", urlPatterns = {"/ATService1"})
public class ATService1 extends ATSuperService {
public static final String LOG_NAME = "service1";
@WebMethod
public void invoke(ServiceCommand... serviceCommands) throws TestApplicationException {
super.invokeWithCallName(LOG_NAME, serviceCommands);
}
}
| 1,931 | 40.106383 | 137 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/service/ATDurableParticipant.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.service;
import com.arjuna.wst.Aborted;
import com.arjuna.wst.Durable2PCParticipant;
import com.arjuna.wst.ReadOnly;
import com.arjuna.wst.SystemException;
import com.arjuna.wst.Vote;
import com.arjuna.wst.WrongStateException;
import com.arjuna.wst.Prepared;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.EventLogEvent;
import org.jboss.as.test.xts.util.ServiceCommand;
import org.jboss.logging.Logger;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* A WS-T Atomic Transaction durable participant.
*/
public class ATDurableParticipant implements Durable2PCParticipant, Serializable {
private static final Logger log = Logger.getLogger(ATDurableParticipant.class);
private static final long serialVersionUID = 1L;
// Is participant already enlisted to transaction?
private static Map<String, List<ATDurableParticipant>> activeParticipants = new HashMap<String, List<ATDurableParticipant>>();
private String transactionId;
private String eventLogName;
// Service command which define behaving of the participant
private ServiceCommand[] serviceCommands;
// Where to log participant activity
private EventLog eventLog;
/**
* Creates a new participant for this transaction. Participants and transaction instances have a one-to-one mapping.
*
* @param serviceCommands service commands for interrupting of the processing
* @param eventLogName name for event log - differentiate calls on the same web service/creating participant
* @param eventLog event log that info about processing will be put into
* @param transactionId transaction id works for logging active participants
*/
public ATDurableParticipant(ServiceCommand[] serviceCommands, String eventLogName, EventLog eventLog, String transactionId) {
this.serviceCommands = serviceCommands;
this.eventLog = eventLog;
this.eventLogName = eventLogName;
addParticipant(transactionId);
}
/**
* Invokes the volatile prepare step of the business logic.
*
* @return in dependence of command passed to constructor @see{ServiceCommand}
* @throws com.arjuna.wst.WrongStateException
* @throws com.arjuna.wst.SystemException
*/
@Override
// TODO: added option for System Exception would be thrown?
public Vote prepare() throws WrongStateException, SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.PREPARE);
log.debugf("[AT SERVICE] Durable participant prepare() - logged: %s", EventLogEvent.PREPARE);
if(ServiceCommand.isPresent(ServiceCommand.VOTE_ROLLBACK, serviceCommands)) {
log.trace("[AT SERVICE] Durable participant prepare(): " + Aborted.class.getSimpleName());
return new Aborted();
} else if(ServiceCommand.isPresent(ServiceCommand.VOTE_READONLY_DURABLE, serviceCommands)) {
log.trace("[AT SERVICE] Durable participant prepare(): " + ReadOnly.class.getSimpleName());
return new ReadOnly();
} else {
log.trace("[AT SERVICE] Durable participant prepare(): " + Prepared.class.getSimpleName());
return new Prepared();
}
}
/**
* Invokes the volatile commit step of the business logic.
* All participants voted 'prepared', so coordinator tells the volatile participant that commit has been done.
*
* @throws com.arjuna.wst.WrongStateException
* @throws com.arjuna.wst.SystemException
*/
@Override
public void commit() throws WrongStateException, SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.COMMIT);
log.trace("[AT SERVICE] Durable participant commit() - logged: " + EventLogEvent.COMMIT);
activeParticipants.remove(transactionId);
}
/**
* Invokes the volatile rollback operation on the business logic.
* One or more participants voted 'aborted' or a failure occurred, so coordinator tells the volatile participant that rollback has been done.
*
* @throws com.arjuna.wst.WrongStateException
* @throws com.arjuna.wst.SystemException
*/
@Override
public void rollback() throws WrongStateException, SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.ROLLBACK);
log.trace("[AT SERVICE] Durable participant rollback() - logged: " + EventLogEvent.ROLLBACK);
activeParticipants.remove(transactionId);
}
@SuppressWarnings("deprecation")
@Override
public void unknown() throws SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.UNKNOWN);
log.trace("[AT SERVICE] Durable participant unknown() - logged: " + EventLogEvent.UNKNOWN);
}
/**
* This should not happen for volatile participant.
*/
@Override
public void error() throws SystemException {
eventLog.addEvent(eventLogName, EventLogEvent.ERROR);
log.trace("[AT SERVICE] Durable participant error() - logged: " + EventLogEvent.ERROR);
}
// --- helper methods ---
private void addParticipant(String transactionId) {
if(activeParticipants.containsKey(transactionId)) {
if(activeParticipants.get(transactionId).contains(this)) {
throw new RuntimeException(this.getClass().getName() + " can't be enlisted to transaction " + transactionId + " because it already is enlisted.");
}
activeParticipants.get(transactionId).add(this);
} else {
List<ATDurableParticipant> participants = new ArrayList<ATDurableParticipant>();
participants.add(this);
activeParticipants.put(transactionId, participants);
}
}
}
| 6,867 | 41.658385 | 162 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/service/ATSuperService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.service;
import jakarta.inject.Inject;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.ServiceCommand;
import static org.jboss.as.test.xts.util.ServiceCommand.*;
import org.jboss.logging.Logger;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.mw.wst11.TransactionManager;
import com.arjuna.mw.wst11.TransactionManagerFactory;
import com.arjuna.mw.wst11.UserTransaction;
import com.arjuna.mw.wst11.UserTransactionFactory;
import com.arjuna.wst.UnknownTransactionException;
import com.arjuna.wst.WrongStateException;
/**
* Service implemenation - this implemetation is inherited by annotated web services.
*/
public abstract class ATSuperService implements AT {
private static final Logger log = Logger.getLogger(ATSuperService.class);
@Inject
private EventLog eventLog;
/**
* Adding 2 participants - Volatile and Durable
*
* @param callName call name works for differentiate several calls to the same webservice
* if you don't want care pass null (or overloaded method :)
* @param serviceCommands service commands that service will react on
* @throws WrongStateException
* @throws com.arjuna.wst.SystemException
* @throws UnknownTransactionException
* @throws SecurityException
* @throws jakarta.transaction.SystemException
* @throws IllegalStateException
*/
public void invokeWithCallName(String callName, ServiceCommand[] serviceCommands) throws TestApplicationException {
log.debugf("[AT SERVICE] web method invoke(%s) with eventLog %s", callName, eventLog);
eventLog.foundEventLogName(callName);
UserTransaction userTransaction;
try {
userTransaction = UserTransactionFactory.userTransaction();
String transactionId = userTransaction.transactionIdentifier();
log.debug("RestaurantServiceAT transaction id =" + transactionId);
// Enlist the Durable Participant for this service
TransactionManager transactionManager = TransactionManagerFactory.transactionManager();
ATDurableParticipant durableParticipant = new ATDurableParticipant(serviceCommands, callName, eventLog, transactionId);
log.trace("[SERVICE] Enlisting a Durable2PC participant into the AT");
transactionManager.enlistForDurableTwoPhase(durableParticipant, "ATServiceDurable:" + new Uid().toString());
// Enlist the Volatile Participant for this service
ATVolatileParticipant volatileParticipant = new ATVolatileParticipant(serviceCommands, callName, eventLog, transactionId);
log.trace("[SERVICE] Enlisting a VolatilePC participant into the AT");
transactionManager.enlistForVolatileTwoPhase(volatileParticipant, "ATServiceVolatile:" + new Uid().toString());
} catch (Exception e) {
throw new RuntimeException("Error when enlisting participants", e);
}
if (ServiceCommand.isPresent(APPLICATION_EXCEPTION, serviceCommands)) {
throw new TestApplicationException("Intentionally thrown Application Exception - service command was set to: " + APPLICATION_EXCEPTION);
}
if (ServiceCommand.isPresent(ROLLBACK_ONLY, serviceCommands)) {
log.trace("Intentionally the service settings transaction to rollback only - service command was set to: " + ROLLBACK_ONLY);
try {
userTransaction.rollback();
} catch (Exception e) {
throw new RuntimeException("The rollback is not possible", e);
}
}
// There will be some business logic here normally
log.trace("|AT SERVICE] I'm working on nothing...");
}
}
| 4,888 | 44.691589 | 148 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/client/ATTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.client;
import static org.jboss.as.test.xts.util.EventLogEvent.BEFORE_PREPARE;
import static org.jboss.as.test.xts.util.EventLogEvent.COMMIT;
import static org.jboss.as.test.xts.util.EventLogEvent.PREPARE;
import static org.jboss.as.test.xts.util.EventLogEvent.ROLLBACK;
import static org.jboss.as.test.xts.util.EventLogEvent.VOLATILE_COMMIT;
import static org.jboss.as.test.xts.util.EventLogEvent.VOLATILE_ROLLBACK;
import static org.jboss.as.test.xts.util.ServiceCommand.APPLICATION_EXCEPTION;
import static org.jboss.as.test.xts.util.ServiceCommand.ROLLBACK_ONLY;
import static org.jboss.as.test.xts.util.ServiceCommand.VOTE_READONLY_DURABLE;
import static org.jboss.as.test.xts.util.ServiceCommand.VOTE_READONLY_VOLATILE;
import static org.jboss.as.test.xts.util.ServiceCommand.VOTE_ROLLBACK;
import static org.jboss.as.test.xts.util.ServiceCommand.VOTE_ROLLBACK_PRE_PREPARE;
import jakarta.inject.Inject;
import jakarta.xml.ws.soap.SOAPFaultException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.xts.base.BaseFunctionalTest;
import org.jboss.as.test.xts.base.TestApplicationException;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.as.test.xts.util.EventLog;
import org.jboss.as.test.xts.util.EventLogEvent;
import org.jboss.as.test.xts.wsat.service.AT;
import org.jboss.as.test.xts.wsat.service.ATService1;
import org.jboss.as.test.xts.wsat.service.ATService2;
import org.jboss.as.test.xts.wsat.service.ATService3;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.arjuna.mw.wst11.UserTransaction;
import com.arjuna.mw.wst11.UserTransactionFactory;
import com.arjuna.wst.TransactionRolledBackException;
/**
* XTS atomic transaction test case
*/
@RunWith(Arquillian.class)
public class ATTestCase extends BaseFunctionalTest {
private UserTransaction ut;
private AT client1, client2, client3;
public static final String ARCHIVE_NAME = "wsat-test";
@Inject
EventLog eventLog;
@Deployment
public static WebArchive createTestArchive() {
return DeploymentHelper.getInstance().getWebArchiveWithPermissions(ARCHIVE_NAME)
.addPackage(AT.class.getPackage())
.addPackage(ATClient.class.getPackage())
.addPackage(EventLog.class.getPackage())
.addPackage(BaseFunctionalTest.class.getPackage())
// needed to setup the server-side handler chain
.addAsResource("context-handlers.xml")
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts,org.jboss.jts\n"), "MANIFEST.MF");
}
@Before
public void setupTest() throws Exception {
ut = UserTransactionFactory.userTransaction();
client1 = ATClient.newInstance("ATService1");
client2 = ATClient.newInstance("ATService2");
client3 = ATClient.newInstance("ATService3");
}
protected EventLog getEventLog() {
return eventLog;
}
@After
public void teardownTest() throws Exception {
getEventLog().clear();
rollbackIfActive(ut);
}
@Test
public void testWSATSingleSimple() throws Exception {
ut.begin();
client1.invoke();
ut.commit();
assertEventLogClient1(BEFORE_PREPARE, PREPARE, COMMIT, VOLATILE_COMMIT);
}
@Test
public void testWSATSimple() throws Exception {
ut.begin();
client1.invoke();
client2.invoke();
client3.invoke();
ut.commit();
assertEventLogClient1(BEFORE_PREPARE, PREPARE, COMMIT, VOLATILE_COMMIT);
assertEventLogClient2(BEFORE_PREPARE, PREPARE, COMMIT, VOLATILE_COMMIT);
assertEventLogClient3(BEFORE_PREPARE, PREPARE, COMMIT, VOLATILE_COMMIT);
}
@Test
public void testWSATClientRollback() throws Exception {
ut.begin();
client1.invoke();
client2.invoke();
client3.invoke();
ut.rollback();
assertEventLogClient1(ROLLBACK, VOLATILE_ROLLBACK);
assertEventLogClient2(ROLLBACK, VOLATILE_ROLLBACK);
assertEventLogClient3(ROLLBACK, VOLATILE_ROLLBACK);
}
@Test(expected = TransactionRolledBackException.class)
public void testWSATVoteRollback() throws Exception {
try {
ut.begin();
client1.invoke();
client2.invoke(VOTE_ROLLBACK); // rollback voted on durable participant
client3.invoke();
ut.commit();
} catch (TransactionRolledBackException e) {
assertEventLogClient1(BEFORE_PREPARE, PREPARE, ROLLBACK, VOLATILE_ROLLBACK);
assertEventLogClient2(BEFORE_PREPARE, PREPARE, VOLATILE_ROLLBACK);
assertEventLogClient3(BEFORE_PREPARE, ROLLBACK, VOLATILE_ROLLBACK);
throw e;
}
}
@Test(expected = TransactionRolledBackException.class)
public void testWSATVoteRollbackPrePrepare() throws Exception {
try {
ut.begin();
client1.invoke();
client2.invoke(VOTE_ROLLBACK_PRE_PREPARE); // rollback voted on volatile participant
client3.invoke();
ut.commit();
} catch (TransactionRolledBackException e) {
assertEventLogClient1(BEFORE_PREPARE, ROLLBACK, VOLATILE_ROLLBACK);
assertEventLogClient2(BEFORE_PREPARE, ROLLBACK);
assertEventLogClient3(ROLLBACK, VOLATILE_ROLLBACK);
throw e;
}
}
@Test
public void testWSATRollbackOnly() throws Exception {
try {
ut.begin();
client1.invoke();
client2.invoke(ROLLBACK_ONLY);
client3.invoke(); // failing on enlisting next participant
// ut.commit();
Assert.fail("The " + SOAPFaultException.class.getName() + " is expected for RollbackOnly test");
} catch (SOAPFaultException sfe) {
assertEventLogClient1(ROLLBACK, VOLATILE_ROLLBACK);
assertEventLogClient2(ROLLBACK, VOLATILE_ROLLBACK);
assertEventLogClient3();
}
}
@Test
public void testWSATVoteReadOnly() throws Exception {
ut.begin();
client1.invoke(VOTE_READONLY_VOLATILE); // volatile for VOLATILE_COMMIT
client2.invoke(VOTE_READONLY_DURABLE); // durable for COMMIT
client3.invoke(VOTE_READONLY_DURABLE, VOTE_READONLY_VOLATILE);
ut.commit();
assertEventLogClient1(BEFORE_PREPARE, PREPARE, COMMIT);
assertEventLogClient2(BEFORE_PREPARE, PREPARE, VOLATILE_COMMIT);
assertEventLogClient3(BEFORE_PREPARE, PREPARE);
}
@Test
public void testWSATApplicationException() throws Exception {
try {
ut.begin();
client1.invoke();
client2.invoke(APPLICATION_EXCEPTION);
Assert.fail("Exception should have been thrown by now");
} catch (TestApplicationException e) {
//Exception expected
} finally {
client3.invoke();
ut.rollback();
}
assertEventLogClient1(ROLLBACK, VOLATILE_ROLLBACK);
assertEventLogClient2(ROLLBACK, VOLATILE_ROLLBACK);
assertEventLogClient3(ROLLBACK, VOLATILE_ROLLBACK);
}
@Test
public void testWSATApplicationExceptionCommit() throws Exception {
try {
ut.begin();
client1.invoke();
client2.invoke(APPLICATION_EXCEPTION);
Assert.fail("Exception should have been thrown by now");
} catch (TestApplicationException e) {
//Exception expected
} finally {
client3.invoke();
ut.commit();
}
assertEventLogClient1(BEFORE_PREPARE, PREPARE, COMMIT, VOLATILE_COMMIT);
assertEventLogClient2(BEFORE_PREPARE, PREPARE, COMMIT, VOLATILE_COMMIT);
assertEventLogClient3(BEFORE_PREPARE, PREPARE, COMMIT, VOLATILE_COMMIT);
}
// --- assert methods
// --- they take event log names from the service called by particular client
private void assertEventLogClient1(EventLogEvent... expectedOrder) {
assertEventLog(ATService1.LOG_NAME, expectedOrder);
}
private void assertEventLogClient2(EventLogEvent... expectedOrder) {
assertEventLog(ATService2.LOG_NAME, expectedOrder);
}
private void assertEventLogClient3(EventLogEvent... expectedOrder) {
assertEventLog(ATService3.LOG_NAME, expectedOrder);
}
}
| 9,703 | 36.758755 | 118 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/wsat/client/ATClient.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.wsat.client;
import io.undertow.util.NetworkUtils;
import java.net.URL;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import org.jboss.as.test.xts.wsat.service.AT;
import org.jboss.logging.Logger;
/**
* Atomic transaction client
*/
public class ATClient {
private static final Logger log = Logger.getLogger(ATClient.class);
private static final String NODE0_ADDR = NetworkUtils.formatPossibleIpv6Address(System.getProperty("node0", "localhost"));
// parametrize this one day in the future?
private static final int NODE0_PORT = 8080;
private static final String TARGET_NAMESPACE = "http://www.jboss.com/jbossas/test/xts/wsat/at/";
private static final String DEFAULT_PORT_NAME = "AT";
public static AT newInstance(String serviceNamespaceName) throws Exception {
return ATClient.newInstance(serviceNamespaceName, serviceNamespaceName);
}
public static AT newInstance(String serviceUrl, String serviceNamespaceName) throws Exception {
URL wsdlLocation = new URL("http://" + NODE0_ADDR + ":" + NODE0_PORT + "/" + ATTestCase.ARCHIVE_NAME + "/" + serviceUrl + "?wsdl");
log.trace("wsdlLocation for service: " + wsdlLocation);
QName serviceName = new QName(TARGET_NAMESPACE, serviceNamespaceName);
QName portName = new QName(TARGET_NAMESPACE, DEFAULT_PORT_NAME);
Service service = Service.create(wsdlLocation, serviceName);
AT atService = service.getPort(portName, AT.class);
return atService;
}
}
| 2,585 | 37.597015 | 139 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/service/TransactionalServiceImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.service;
import com.arjuna.ats.jta.TransactionManager;
import org.jboss.logging.Logger;
import jakarta.ejb.Stateless;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import jakarta.transaction.Status;
import jakarta.transaction.SystemException;
import jakarta.transaction.Transaction;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@Stateless
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
public class TransactionalServiceImpl implements TransactionalService {
private static Logger LOG = Logger.getLogger(TransactionalServiceImpl.class);
@Override
public boolean isTransactionActive() {
LOG.debug("TransactionalServiceImpl.isTransactionActive()");
Transaction transaction = null;
try {
transaction = TransactionManager.transactionManager().getTransaction();
} catch (SystemException e) {
}
if (transaction == null) {
return false;
}
try {
return transaction.getStatus() == Status.STATUS_ACTIVE;
} catch (SystemException e) {
return false;
}
}
}
| 2,363 | 32.771429 | 83 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/service/CompensatableService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.service;
import jakarta.jws.WebMethod;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public interface CompensatableService {
@WebMethod
boolean isTransactionActive();
}
| 1,272 | 35.371429 | 70 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/service/CompensatableServiceImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.service;
import com.arjuna.mw.wst.TxContext;
import com.arjuna.mw.wst11.BusinessActivityManager;
import org.jboss.logging.Logger;
import org.jboss.narayana.compensations.api.Compensatable;
import org.jboss.narayana.compensations.api.CompensationTransactionType;
import jakarta.ejb.Stateless;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@Stateless
@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
@Compensatable(CompensationTransactionType.SUPPORTS)
public class CompensatableServiceImpl implements CompensatableService {
private static Logger LOG = Logger.getLogger(CompensatableServiceImpl.class);
@Override
public boolean isTransactionActive() {
LOG.debug("CompensatableServiceImpl.isTransactionActive()");
TxContext txContext = null;
try {
txContext = BusinessActivityManager.getBusinessActivityManager().currentTransaction();
} catch (com.arjuna.wst.SystemException e) {
}
return txContext != null;
}
}
| 2,159 | 35.610169 | 98 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/service/TransactionalService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.service;
import jakarta.jws.WebMethod;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public interface TransactionalService {
@WebMethod
boolean isTransactionActive();
}
| 1,272 | 35.371429 | 70 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/client/TransactionalClient.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.client;
import org.jboss.as.test.xts.annotation.service.TransactionalService;
import org.jboss.logging.Logger;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public class TransactionalClient {
private static Logger LOG = Logger.getLogger(TransactionalClient.class);
private static final String NAME = "TransactionalServiceImpl";
private static final String TARGET_NAMESPACE = "http://service.annotation.xts.test.as.jboss.org/";
private static final String PORT_NAME = "TransactionalServiceImplPort";
private static final String SERVICE_NAME = "TransactionalServiceImplService";
public static TransactionalService newInstance(final String deploymentUrl) throws MalformedURLException {
LOG.debug("TransactionalClient.newInstance(deploymentUrl = " + deploymentUrl + ")");
final URL wsdlLocation = new URL(deploymentUrl + "/" + NAME + "?wsdl");
LOG.debug("wsdlLocation for service: " + wsdlLocation);
final QName serviceName = new QName(TARGET_NAMESPACE, SERVICE_NAME);
final QName portName = new QName(TARGET_NAMESPACE, PORT_NAME);
final Service service = Service.create(wsdlLocation, serviceName);
final TransactionalService transactionalService = service.getPort(portName, TransactionalService.class);
return transactionalService;
}
}
| 2,556 | 38.953125 | 112 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/client/CompensatableClient.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.client;
import org.jboss.as.test.xts.annotation.service.CompensatableService;
import org.jboss.logging.Logger;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public class CompensatableClient {
private static Logger LOG = Logger.getLogger(CompensatableClient.class);
private static final String NAME = "CompensatableServiceImpl";
private static final String TARGET_NAMESPACE = "http://service.annotation.xts.test.as.jboss.org/";
private static final String PORT_NAME = "CompensatableServiceImplPort";
private static final String SERVICE_NAME = "CompensatableServiceImplService";
public static CompensatableService newInstance(final String deploymentUrl) throws MalformedURLException {
LOG.debug("CompensatableClient.newInstance(deploymentUrl = " + deploymentUrl + ")");
final URL wsdlLocation = new URL(deploymentUrl + "/" + NAME + "?wsdl");
LOG.debug("wsdlLocation for service: " + wsdlLocation);
final QName serviceName = new QName(TARGET_NAMESPACE, SERVICE_NAME);
final QName portName = new QName(TARGET_NAMESPACE, PORT_NAME);
final Service service = Service.create(wsdlLocation, serviceName);
final CompensatableService compensatableService = service.getPort(portName, CompensatableService.class);
return compensatableService;
}
}
| 2,556 | 38.953125 | 112 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/client/CompensatableTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.client;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.jboss.as.test.xts.annotation.service.CompensatableService;
import org.jboss.as.test.xts.annotation.service.CompensatableServiceImpl;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.arjuna.mw.wst11.UserBusinessActivity;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@RunWith(Arquillian.class)
public class CompensatableTestCase {
private static final String DEPLOYMENT_NAME = "compensatable-test";
private static final String SERVER_HOST_PORT = TestSuiteEnvironment.getServerAddress() + ":"
+ TestSuiteEnvironment.getHttpPort();
private static final String DEPLOYMENT_URL = "http://" + SERVER_HOST_PORT + "/" + DEPLOYMENT_NAME;
@Deployment
public static WebArchive getDeployment() {
return DeploymentHelper.getInstance().getWebArchiveWithPermissions(DEPLOYMENT_NAME)
.addClass(CompensatableClient.class)
.addClass(CompensatableService.class)
.addClass(CompensatableServiceImpl.class)
.addClass(TestSuiteEnvironment.class);
}
@Test
public void testNoTransaction() throws Exception {
final String deploymentUrl = DEPLOYMENT_URL;
final CompensatableService compensatableService = CompensatableClient.newInstance(deploymentUrl);
final boolean isTransactionActive = compensatableService.isTransactionActive();
Assert.assertEquals(false, isTransactionActive);
}
@Test
public void testActiveTransaction() throws Exception {
final String deploymentUrl = DEPLOYMENT_URL;
final CompensatableService compensatableService = CompensatableClient.newInstance(deploymentUrl);
final UserBusinessActivity userBusinessActivity = UserBusinessActivity.getUserBusinessActivity();
userBusinessActivity.begin();
final boolean isTransactionActive = compensatableService.isTransactionActive();
userBusinessActivity.close();
Assert.assertEquals(true, isTransactionActive);
}
}
| 3,398 | 39.464286 | 105 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/client/TransactionalTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.client;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.jboss.as.test.xts.annotation.service.TransactionalService;
import org.jboss.as.test.xts.annotation.service.TransactionalServiceImpl;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.arjuna.mw.wst11.UserTransaction;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@RunWith(Arquillian.class)
public class TransactionalTestCase {
private static final String DEPLOYMENT_NAME = "transactional-test";
private static final String SERVER_HOST_PORT = TestSuiteEnvironment.getServerAddress() + ":"
+ TestSuiteEnvironment.getHttpPort();
private static final String DEPLOYMENT_URL = "http://" + SERVER_HOST_PORT + "/" + DEPLOYMENT_NAME;
@Deployment
public static WebArchive getDeployment() {
return DeploymentHelper.getInstance().getWebArchiveWithPermissions(DEPLOYMENT_NAME)
.addClass(TransactionalClient.class)
.addClass(TransactionalService.class)
.addClass(TransactionalServiceImpl.class)
.addClass(TestSuiteEnvironment.class)
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts,org.jboss.jts\n"), "MANIFEST.MF");
}
@Test
public void testNoTransaction() throws Exception {
final String deploymentUrl = DEPLOYMENT_URL;
final TransactionalService transactionalService = TransactionalClient.newInstance(deploymentUrl);
final boolean isTransactionActive = transactionalService.isTransactionActive();
Assert.assertEquals(false, isTransactionActive);
}
@Test
public void testActiveTransaction() throws Exception {
final String deploymentUrl = DEPLOYMENT_URL;
final TransactionalService transactionalService = TransactionalClient.newInstance(deploymentUrl);
final UserTransaction userTransaction = UserTransaction.getUserTransaction();
userTransaction.begin();
final boolean isTransactionActive = transactionalService.isTransactionActive();
userTransaction.commit();
Assert.assertEquals(true, isTransactionActive);
}
}
| 3,532 | 40.564706 | 118 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/compensationscoped/CompensationScopedData.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.compensationscoped;
import org.jboss.narayana.compensations.api.CompensationScoped;
import java.io.Serializable;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@CompensationScoped
public class CompensationScopedData implements Serializable {
private String value;
public String get() {
return value;
}
public void set(final String value) {
this.value = value;
}
}
| 1,495 | 33.790698 | 70 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/annotation/compensationscoped/CompensationScopedTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.annotation.compensationscoped;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.shared.IntermittentFailure;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.narayana.compensations.internal.BAController;
import org.jboss.narayana.compensations.internal.BAControllerFactory;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.inject.Inject;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@RunWith(Arquillian.class)
public class CompensationScopedTestCase {
@Inject
private CompensationScopedData data;
private BAController baController;
@Deployment
public static Archive<?> getDeployment() {
final WebArchive archive = DeploymentHelper.getInstance().getWebArchiveWithPermissions("test")
.addPackage(CompensationScopedTestCase.class.getPackage());
return archive;
}
@BeforeClass
public static void failing() {
IntermittentFailure.thisTestIsFailingIntermittently("WFLY-9871");
}
@Before
public void before() {
Assert.assertNotNull("Data should be injected", data);
baController = BAControllerFactory.getLocalInstance();
}
@After
public void after() {
try {
baController.cancelBusinessActivity();
} catch (Exception e) {
}
}
@Test
public void shouldSeeDifferentValuesInDifferentTransactions() throws Exception {
final String firstTransactionData = "FIRST_TRANSACTION_DATA";
final String secondTransactionData = "SECOND_TRANSACTION_DATA";
baController.beginBusinessActivity();
updateValue(firstTransactionData);
final Object firstTransactionContext = baController.suspend();
baController.beginBusinessActivity();
updateValue(secondTransactionData);
baController.closeBusinessActivity();
baController.resume(firstTransactionContext);
assertValue(firstTransactionData);
baController.closeBusinessActivity();
}
private void updateValue(final String value) {
data.set(value);
assertValue(value);
}
private void assertValue(final String value) {
Assert.assertEquals("Value should be set to " + value, value, data.get());
}
}
| 3,616 | 33.122642 | 102 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/RemoteService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend;
import jakarta.jws.WebService;
import java.util.List;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@WebService
public interface RemoteService {
void execute() throws Exception;
List<String> getParticipantInvocations();
void reset();
}
| 1,344 | 31.804878 | 70 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/Helpers.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import java.net.MalformedURLException;
import java.net.URL;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public class Helpers {
public static ExecutorService getExecutorService(URL url) throws MalformedURLException {
QName serviceName = new QName(ExecutorService.class.getPackage().getName(), ExecutorService.class.getSimpleName());
URL wsdlUrl = new URL(url, ExecutorService.class.getSimpleName() + "?wsdl");
Service service = Service.create(wsdlUrl, serviceName);
return service.getPort(ExecutorService.class);
}
public static RemoteService getRemoteService(URL url) throws MalformedURLException {
QName serviceName = new QName(RemoteService.class.getPackage().getName(), RemoteService.class.getSimpleName());
URL wsdlUrl = new URL(url, RemoteService.class.getSimpleName() + "?wsdl");
Service service = Service.create(wsdlUrl, serviceName);
return service.getPort(RemoteService.class);
}
}
| 2,133 | 41.68 | 123 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/ExecutorService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend;
import jakarta.jws.WebService;
import java.util.List;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@WebService
public interface ExecutorService {
void init(String activationServiceUrl, String remoteServiceUrl);
void begin() throws Exception;
void commit() throws Exception;
void rollback() throws Exception;
void enlistParticipant() throws Exception;
void execute() throws Exception;
void reset();
List<String> getParticipantInvocations();
}
| 1,576 | 29.921569 | 70 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/AbstractTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.FilePermission;
import java.io.IOException;
import java.net.SocketPermission;
import java.net.URL;
import java.util.List;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import static org.jboss.as.test.xts.suspend.Helpers.getExecutorService;
import static org.jboss.as.test.xts.suspend.Helpers.getRemoteService;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public abstract class AbstractTestCase {
protected static final String EXECUTOR_SERVICE_CONTAINER = "default-server";
protected static final String REMOTE_SERVICE_CONTAINER = "alternative-server";
protected static final String EXECUTOR_SERVICE_ARCHIVE_NAME = "executorService";
protected static final String REMOTE_SERVICE_ARCHIVE_NAME = "remoteService";
@ArquillianResource
@OperateOnDeployment(EXECUTOR_SERVICE_ARCHIVE_NAME)
private URL executorServiceUrl;
@ArquillianResource
@OperateOnDeployment(REMOTE_SERVICE_ARCHIVE_NAME)
private URL remoteServiceUrl;
@ArquillianResource
@OperateOnDeployment(REMOTE_SERVICE_ARCHIVE_NAME)
private ManagementClient remoteServiceContainerManager;
private ExecutorService executorService;
private RemoteService remoteService;
protected static WebArchive getExecutorServiceArchiveBase() {
return ShrinkWrap.create(WebArchive.class, EXECUTOR_SERVICE_ARCHIVE_NAME + ".war")
.addClasses(ExecutorService.class, RemoteService.class, Helpers.class)
.addAsResource("context-handlers.xml", "context-handlers.xml")
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts, org.jboss.jts"), "MANIFEST.MF")
.addAsManifestResource(createPermissionsXmlAsset(
new SocketPermission("127.0.0.1:8180", "connect,resolve"),
new RuntimePermission("org.apache.cxf.permission", "resolveUri"),
// WSDLFactory#L243 from wsdl4j library needs the following
new FilePermission(System.getProperty("java.home") + File.separator + "lib" + File.separator + "wsdl.properties", "read")
), "permissions.xml");
}
protected static WebArchive getRemoteServiceArchiveBase() {
return ShrinkWrap.create(WebArchive.class, REMOTE_SERVICE_ARCHIVE_NAME + ".war")
.addClasses(RemoteService.class)
.addAsResource("context-handlers.xml", "context-handlers.xml")
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.xts, org.jboss.jts"), "MANIFEST.MF");
}
protected abstract void assertParticipantInvocations(List<String> invocations);
@Before
public void before() throws Exception {
resumeServer();
executorService = getExecutorService(executorServiceUrl);
executorService.init(remoteServiceContainerManager.getWebUri().toString() + "/ws-c11/ActivationService",
remoteServiceUrl.toString());
executorService.reset();
remoteService = getRemoteService(remoteServiceUrl);
remoteService.reset();
}
@After
public void after() throws IOException {
resumeServer();
try {
executorService.rollback();
} catch (Throwable ignored) {
}
}
@Test(expected = Exception.class)
public void testBeginTransactionAfterSuspend() throws Exception {
suspendServer();
executorService.begin();
}
@Test
public void testCommitAfterSuspend() throws Exception {
executorService.begin();
suspendServer();
executorService.commit();
}
@Test
public void testRollbackAfterSuspend() throws Exception {
executorService.begin();
suspendServer();
executorService.reset();
}
@Test
public void testRemoteServiceAfterSuspend() throws Exception {
executorService.begin();
suspendServer();
executorService.enlistParticipant();
executorService.execute();
executorService.commit();
resumeServer();
assertParticipantInvocations(executorService.getParticipantInvocations());
assertParticipantInvocations(remoteService.getParticipantInvocations());
}
private void suspendServer() throws IOException {
ModelNode suspendOperation = new ModelNode();
suspendOperation.get(ModelDescriptionConstants.OP).set("suspend");
remoteServiceContainerManager.getControllerClient().execute(suspendOperation);
}
private void resumeServer() throws IOException {
ModelNode suspendOperation = new ModelNode();
suspendOperation.get(ModelDescriptionConstants.OP).set("resume");
remoteServiceContainerManager.getControllerClient().execute(suspendOperation);
}
}
| 6,472 | 38.469512 | 145 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/wsba/BusinessActivityRemoteService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend.wsba;
import java.util.List;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import com.arjuna.mw.wst11.BusinessActivityManager;
import com.arjuna.wst11.BAParticipantManager;
import org.jboss.as.test.xts.suspend.RemoteService;
import org.jboss.logging.Logger;
import com.arjuna.ats.arjuna.common.Uid;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@WebService(targetNamespace = "org.jboss.as.test.xts.suspend", serviceName = "RemoteService", portName = "RemoteService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
public class BusinessActivityRemoteService implements RemoteService {
private static final Logger LOGGER = Logger.getLogger(BusinessActivityRemoteService.class);
@Override
public void execute() throws Exception {
LOGGER.debugf("trying to enlist participant to the business activity %s",
BusinessActivityManager.getBusinessActivityManager().currentTransaction());
String participantId = new Uid().stringForm();
BusinessActivityParticipant businessActivityParticipant = new BusinessActivityParticipant(participantId);
BAParticipantManager participantManager = BusinessActivityManager.getBusinessActivityManager()
.enlistForBusinessAgreementWithParticipantCompletion(businessActivityParticipant,
businessActivityParticipant.getId());
participantManager.completed();
LOGGER.debugf("enlisted participant %s", businessActivityParticipant);
}
@Override
public List<String> getParticipantInvocations() {
return BusinessActivityParticipant.getInvocations();
}
@Override
public void reset() {
BusinessActivityParticipant.resetInvocations();
}
}
| 2,908 | 38.310811 | 121 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/wsba/BusinessActivityParticipant.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend.wsba;
import com.arjuna.wst.BusinessAgreementWithParticipantCompletionParticipant;
import com.arjuna.wst.FaultedException;
import com.arjuna.wst.Status;
import com.arjuna.wst.SystemException;
import com.arjuna.wst.WrongStateException;
import org.jboss.logging.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public class BusinessActivityParticipant implements BusinessAgreementWithParticipantCompletionParticipant {
private static final Logger LOGGER = Logger.getLogger(BusinessActivityParticipant.class);
private static final List<String> INVOCATIONS = new ArrayList<>();
private final String id;
public BusinessActivityParticipant(String id) {
this.id = id;
}
public static void resetInvocations() {
LOGGER.debugf("resetting invocations %s", INVOCATIONS);
INVOCATIONS.clear();
}
public static List<String> getInvocations() {
LOGGER.debugf("returning invocations %s", INVOCATIONS);
return Collections.unmodifiableList(INVOCATIONS);
}
public String getId() {
return id;
}
@Override
public void close() throws WrongStateException, SystemException {
INVOCATIONS.add("close");
LOGGER.debugf("close call on %s", this);
}
@Override
public void cancel() throws FaultedException, WrongStateException, SystemException {
INVOCATIONS.add("cancel");
LOGGER.debugf("cancel call on %s", this);
}
@Override
public void compensate() throws FaultedException, WrongStateException, SystemException {
INVOCATIONS.add("compensate");
LOGGER.debugf("compensate call on %s", this);
}
@Override
public String status() throws SystemException {
INVOCATIONS.add("status");
LOGGER.debugf("status call on %s", this);
return Status.STATUS_ACTIVE;
}
@Override
public void unknown() throws SystemException {
INVOCATIONS.add("unknown");
LOGGER.debugf("unknown call on %s", this);
}
@Override
public void error() throws SystemException {
INVOCATIONS.add("error");
LOGGER.debugf("error call on %s", this);
}
@Override
public String toString() {
return String.format("%s{id='%s', INVOCATIONS=%s}", this.getClass().getSimpleName(), id, INVOCATIONS);
}
}
| 3,499 | 31.407407 | 110 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/wsba/BusinessActivitySuspendTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend.wsba;
import static org.junit.Assert.assertEquals;
import java.util.Collections;
import java.util.List;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.xts.suspend.AbstractTestCase;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@RunWith(Arquillian.class)
public class BusinessActivitySuspendTestCase extends AbstractTestCase {
@TargetsContainer(EXECUTOR_SERVICE_CONTAINER)
@Deployment(name = EXECUTOR_SERVICE_ARCHIVE_NAME, testable = false)
public static WebArchive getExecutorServiceArchive() {
return getExecutorServiceArchiveBase().addClasses(BusinessActivityExecutionService.class,
BusinessActivityRemoteService.class, BusinessActivityParticipant.class)
.addAsManifestResource(DeploymentHelper.createPermissions(), "permissions.xml");
}
@TargetsContainer(REMOTE_SERVICE_CONTAINER)
@Deployment(name = REMOTE_SERVICE_ARCHIVE_NAME, testable = false)
public static WebArchive getRemoteServiceArchive() {
return getRemoteServiceArchiveBase().addClasses(BusinessActivityRemoteService.class,
BusinessActivityParticipant.class)
.addAsManifestResource(DeploymentHelper.createPermissions(), "permissions.xml");
}
protected void assertParticipantInvocations(List<String> invocations) {
assertEquals(Collections.singletonList("close"), invocations);
}
}
| 2,753 | 40.727273 | 97 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/wsba/BusinessActivityExecutionService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend.wsba;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import com.arjuna.mw.wst11.BusinessActivityManager;
import com.arjuna.mw.wst11.UserBusinessActivity;
import com.arjuna.mwlabs.wst11.ba.remote.UserBusinessActivityImple;
import com.arjuna.wst11.BAParticipantManager;
import org.jboss.as.test.xts.suspend.ExecutorService;
import org.jboss.as.test.xts.suspend.RemoteService;
import org.jboss.jbossts.xts.environment.XTSPropertyManager;
import org.jboss.logging.Logger;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.mw.wst.TxContext;
import static org.jboss.as.test.xts.suspend.Helpers.getRemoteService;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@WebService(targetNamespace = "org.jboss.as.test.xts.suspend", serviceName = "ExecutorService", portName = "ExecutorService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
public class BusinessActivityExecutionService implements ExecutorService {
private static final Logger LOGGER = Logger.getLogger(BusinessActivityExecutionService.class);
private RemoteService remoteService;
private TxContext currentActivity;
private boolean wasInitialised;
@Override
public void init(String activationServiceUrl, String remoteServiceUrl) {
LOGGER.debugf("initialising with activationServiceUrl=%s and remoteServiceUrl=%s", activationServiceUrl,
remoteServiceUrl);
if (!wasInitialised) {
// This is done only for testing purposes. In real application application server configuration should be used.
XTSPropertyManager.getWSCEnvironmentBean().setCoordinatorURL11(activationServiceUrl);
UserBusinessActivity.setUserBusinessActivity(new UserBusinessActivityImple());
wasInitialised = true;
}
try {
remoteService = getRemoteService(new URL(remoteServiceUrl));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
@Override
public void begin() throws Exception {
assert currentActivity == null : "Business activity already started";
LOGGER.debugf("trying to begin transaction on %s", XTSPropertyManager.getWSCEnvironmentBean().getCoordinatorURL11());
UserBusinessActivity.getUserBusinessActivity().begin();
currentActivity = BusinessActivityManager.getBusinessActivityManager().suspend();
LOGGER.debugf("started business activity %s", currentActivity);
}
@Override
public void commit() throws Exception {
assert currentActivity != null : "No active business activity";
LOGGER.debugf("trying to close business activity %s", currentActivity);
BusinessActivityManager.getBusinessActivityManager().resume(currentActivity);
UserBusinessActivity.getUserBusinessActivity().close();
currentActivity = null;
LOGGER.debugf("closed business activity");
}
@Override
public void rollback() throws Exception {
assert currentActivity != null : "No active business activity";
LOGGER.debugf("trying to cancel business activity %s", currentActivity);
BusinessActivityManager.getBusinessActivityManager().resume(currentActivity);
UserBusinessActivity.getUserBusinessActivity().cancel();
currentActivity = null;
LOGGER.debugf("canceled business activity");
}
@Override
public void enlistParticipant() throws Exception {
assert currentActivity != null : "No active business activity";
LOGGER.debugf("trying to enlist participant to the business activity %s", currentActivity);
BusinessActivityManager.getBusinessActivityManager().resume(currentActivity);
BusinessActivityParticipant businessActivityParticipant = new BusinessActivityParticipant(new Uid().stringForm());
BAParticipantManager participantManager = BusinessActivityManager.getBusinessActivityManager()
.enlistForBusinessAgreementWithParticipantCompletion(businessActivityParticipant,
businessActivityParticipant.getId());
participantManager.completed();
currentActivity = BusinessActivityManager.getBusinessActivityManager().suspend();
LOGGER.debugf("enlisted participant %s", businessActivityParticipant);
}
@Override
public void execute() throws Exception {
assert remoteService != null : "Remote service was not initialised";
assert currentActivity != null : "No active business activity";
LOGGER.debugf("trying to execute remote service in business activity %s", currentActivity);
BusinessActivityManager.getBusinessActivityManager().resume(currentActivity);
remoteService.execute();
currentActivity = BusinessActivityManager.getBusinessActivityManager().suspend();
LOGGER.debugf("executed remote service");
}
@Override
public void reset() {
BusinessActivityParticipant.resetInvocations();
}
@Override
public List<String> getParticipantInvocations() {
return BusinessActivityParticipant.getInvocations();
}
}
| 6,378 | 39.891026 | 125 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/wsat/AtomicTransactionRemoteService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend.wsat;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.mw.wst11.TransactionManager;
import org.jboss.as.test.xts.suspend.RemoteService;
import org.jboss.logging.Logger;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import java.util.List;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@WebService(targetNamespace = "org.jboss.as.test.xts.suspend", serviceName = "RemoteService", portName = "RemoteService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
public class AtomicTransactionRemoteService implements RemoteService {
private static final Logger LOGGER = Logger.getLogger(AtomicTransactionRemoteService.class);
@Override
public void execute() throws Exception {
LOGGER.debugf("trying to enlist participant to the transaction %s",
TransactionManager.getTransactionManager().currentTransaction());
String participantId = new Uid().stringForm();
TransactionParticipant transactionParticipant = new TransactionParticipant(participantId);
TransactionManager.getTransactionManager().enlistForVolatileTwoPhase(transactionParticipant,
transactionParticipant.getId());
LOGGER.debugf("enlisted participant %s", transactionParticipant);
}
@Override
public List<String> getParticipantInvocations() {
return TransactionParticipant.getInvocations();
}
@Override
public void reset() {
TransactionParticipant.resetInvocations();
}
}
| 2,658 | 37.536232 | 121 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/wsat/AtomicTransactionExecutionService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend.wsat;
import com.arjuna.ats.arjuna.common.Uid;
import com.arjuna.mw.wst.TxContext;
import com.arjuna.mw.wst11.TransactionManager;
import com.arjuna.mw.wst11.UserTransaction;
import com.arjuna.mwlabs.wst11.at.remote.UserTransactionImple;
import org.jboss.as.test.xts.suspend.ExecutorService;
import org.jboss.as.test.xts.suspend.RemoteService;
import org.jboss.jbossts.xts.environment.XTSPropertyManager;
import org.jboss.logging.Logger;
import jakarta.jws.HandlerChain;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import static org.jboss.as.test.xts.suspend.Helpers.getRemoteService;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@WebService(targetNamespace = "org.jboss.as.test.xts.suspend", serviceName = "ExecutorService", portName = "ExecutorService")
@SOAPBinding(style = SOAPBinding.Style.RPC)
@HandlerChain(file = "/context-handlers.xml")
public class AtomicTransactionExecutionService implements ExecutorService {
private static final Logger LOGGER = Logger.getLogger(AtomicTransactionExecutionService.class);
private volatile RemoteService remoteService;
private volatile TxContext currentTransaction;
private volatile boolean wasInitialised;
@Override
public void init(String activationServiceUrl, String remoteServiceUrl) {
LOGGER.debugf("initialising with activationServiceUrl=%s and remoteServiceUrl=%s", activationServiceUrl,
remoteServiceUrl);
if (!wasInitialised) {
// This is done only for testing purposes. In real application application server configuration should be used.
XTSPropertyManager.getWSCEnvironmentBean().setCoordinatorURL11(activationServiceUrl);
UserTransaction.setUserTransaction(new UserTransactionImple());
wasInitialised = true;
}
try {
remoteService = getRemoteService(new URL(remoteServiceUrl));
} catch (MalformedURLException e) {
throw new RuntimeException(e);
}
}
@Override
public void begin() throws Exception {
assert currentTransaction == null : "Transaction already started";
LOGGER.debugf("trying to start a new transaction");
UserTransaction.getUserTransaction().begin();
currentTransaction = TransactionManager.getTransactionManager().suspend();
LOGGER.debugf("started transaction %s", currentTransaction);
}
@Override
public void commit() throws Exception {
assert currentTransaction != null : "No active transaction";
LOGGER.debugf("trying to commit transaction %s", currentTransaction);
TransactionManager.getTransactionManager().resume(currentTransaction);
UserTransaction.getUserTransaction().commit();
currentTransaction = null;
LOGGER.debugf("committed transaction");
}
@Override
public void rollback() throws Exception {
assert currentTransaction != null : "No active transaction";
LOGGER.debugf("trying to rollback transaction %s", currentTransaction);
TransactionManager.getTransactionManager().resume(currentTransaction);
UserTransaction.getUserTransaction().rollback();
currentTransaction = null;
LOGGER.debugf("rolled back transaction");
}
@Override
public void enlistParticipant() throws Exception {
assert currentTransaction != null : "No active transaction";
LOGGER.debugf("trying to enlist participant to the transaction %s", currentTransaction);
TransactionManager.getTransactionManager().resume(currentTransaction);
String participantId = new Uid().stringForm();
TransactionParticipant transactionParticipant = new TransactionParticipant(participantId);
TransactionManager.getTransactionManager().enlistForVolatileTwoPhase(transactionParticipant, participantId);
currentTransaction = TransactionManager.getTransactionManager().suspend();
LOGGER.debugf("enlisted participant %s", transactionParticipant);
}
@Override
public void execute() throws Exception {
assert remoteService != null : "Remote service was not initialised";
assert currentTransaction != null : "No active transaction";
LOGGER.debugf("trying to execute remote service in transaction %s", currentTransaction);
TransactionManager.getTransactionManager().resume(currentTransaction);
remoteService.execute();
currentTransaction = TransactionManager.getTransactionManager().suspend();
LOGGER.debugf("executed remote service");
}
@Override
public void reset() {
TransactionParticipant.resetInvocations();
}
@Override
public List<String> getParticipantInvocations() {
return TransactionParticipant.getInvocations();
}
}
| 5,993 | 38.695364 | 125 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/wsat/TransactionParticipant.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend.wsat;
import com.arjuna.wst.Prepared;
import com.arjuna.wst.SystemException;
import com.arjuna.wst.Volatile2PCParticipant;
import com.arjuna.wst.Vote;
import com.arjuna.wst.WrongStateException;
import org.jboss.logging.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
public class TransactionParticipant implements Volatile2PCParticipant {
private static final Logger LOGGER = Logger.getLogger(TransactionParticipant.class);
private static final List<String> INVOCATIONS = new ArrayList<>();
private final String id;
public TransactionParticipant(String id) {
this.id = id;
}
public static void resetInvocations() {
LOGGER.debugf("resetting invocations %s", INVOCATIONS);
INVOCATIONS.clear();
}
public static List<String> getInvocations() {
LOGGER.debugf("returning invocations %s", INVOCATIONS);
return Collections.unmodifiableList(INVOCATIONS);
}
public String getId() {
return id;
}
@Override
public Vote prepare() throws WrongStateException, SystemException {
INVOCATIONS.add("prepare");
LOGGER.debugf("preparing call on %s", this);
return new Prepared();
}
@Override
public void commit() throws WrongStateException, SystemException {
INVOCATIONS.add("commit");
LOGGER.debugf("commit call on %s", this);
}
@Override
public void rollback() throws WrongStateException, SystemException {
INVOCATIONS.add("rollback");
LOGGER.debugf("rollback call on %s", this);
}
@Override
public void unknown() throws SystemException {
INVOCATIONS.add("unknown");
LOGGER.debugf("unknown call on %s", this);
}
@Override
public void error() throws SystemException {
INVOCATIONS.add("error");
LOGGER.debugf("error call on %s", this);
}
@Override
public String toString() {
return String.format("%s{id='%s', INVOCATIONS=%s}", this.getClass().getSimpleName(), id, INVOCATIONS);
}
}
| 3,213 | 30.821782 | 110 |
java
|
null |
wildfly-main/testsuite/integration/xts/src/test/java/org/jboss/as/test/xts/suspend/wsat/AtomicTransactionSuspendTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2016, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.xts.suspend.wsat;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.List;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.xts.suspend.AbstractTestCase;
import org.jboss.as.test.xts.util.DeploymentHelper;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Gytis Trikleris</a>
*/
@RunWith(Arquillian.class)
public class AtomicTransactionSuspendTestCase extends AbstractTestCase {
@TargetsContainer(EXECUTOR_SERVICE_CONTAINER)
@Deployment(name = EXECUTOR_SERVICE_ARCHIVE_NAME, testable = false)
public static WebArchive getExecutorServiceArchive() {
return getExecutorServiceArchiveBase().addClasses(AtomicTransactionExecutionService.class,
AtomicTransactionRemoteService.class, TransactionParticipant.class)
.addAsManifestResource(DeploymentHelper.createPermissions(), "permissions.xml");
}
@TargetsContainer(REMOTE_SERVICE_CONTAINER)
@Deployment(name = REMOTE_SERVICE_ARCHIVE_NAME, testable = false)
public static WebArchive getRemoteServiceArchive() {
return getRemoteServiceArchiveBase().addClasses(AtomicTransactionRemoteService.class,
TransactionParticipant.class)
.addAsManifestResource(DeploymentHelper.createPermissions(), "permissions.xml");
}
protected void assertParticipantInvocations(List<String> invocations) {
assertEquals(Arrays.asList("prepare", "commit"), invocations);
}
}
| 2,740 | 41.828125 | 98 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/test/CallbackBeansTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.test;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.pojo.support.TOwner;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
@RunWith(Arquillian.class)
public class CallbackBeansTestCase {
@Deployment(name = "callback-beans")
public static JavaArchive getCallbackBeansJar() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "callback-beans.jar");
archive.addPackage(TOwner.class.getPackage());
archive.addAsManifestResource(CallbackBeansTestCase.class.getPackage(), "callback-jboss-beans.xml", "callback-jboss-beans.xml");
return archive;
}
@Test
@OperateOnDeployment("callback-beans")
public void testCallbackBeans() throws Exception {
// TODO -- try to get beans?
}
}
| 2,155 | 39.679245 | 136 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/test/SimpleBeansTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.test;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.pojo.support.TFactory;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
@RunWith(Arquillian.class)
public class SimpleBeansTestCase {
@Deployment(name = "simple-beans")
public static JavaArchive getSimpleBeansJar() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "simple-beans.jar");
archive.addPackage(TFactory.class.getPackage());
archive.addAsManifestResource(SimpleBeansTestCase.class.getPackage(), "simple-jboss-beans.xml", "simple-jboss-beans.xml");
archive.addAsManifestResource(SimpleBeansTestCase.class.getPackage(), "legacy-jboss-beans.xml", "legacy-jboss-beans.xml");
return archive;
}
@Test
@OperateOnDeployment("simple-beans")
public void testSimpleBeans() throws Exception {
// TODO -- try to get beans?
}
}
| 2,272 | 41.092593 | 130 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/test/TypeBeansTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.test;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.pojo.support.TFactory;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
@RunWith(Arquillian.class)
public class TypeBeansTestCase {
@Deployment(name = "type-beans")
public static JavaArchive getTypeBeansJar() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "type-beans.jar");
archive.addPackage(TFactory.class.getPackage());
archive.addAsManifestResource(TypeBeansTestCase.class.getPackage(), "type-jboss-beans.xml", "type-jboss-beans.xml");
return archive;
}
@Test
@OperateOnDeployment("type-beans")
public void testTypeBeans() throws Exception {
// TODO -- try to get beans?
}
}
| 2,123 | 39.075472 | 124 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/test/CycleBeansTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.test;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.pojo.support.TFactory;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
@RunWith(Arquillian.class)
public class CycleBeansTestCase {
@Deployment(name = "cycle-beans")
public static JavaArchive getCycleBeansJar() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "cycle-beans.jar");
archive.addPackage(TFactory.class.getPackage());
archive.addAsManifestResource(CycleBeansTestCase.class.getPackage(), "a-jboss-beans.xml", "a-jboss-beans.xml");
archive.addAsManifestResource(CycleBeansTestCase.class.getPackage(), "b-jboss-beans.xml", "b-jboss-beans.xml");
return archive;
}
@Test
@OperateOnDeployment("cycle-beans")
public void testCycleBeans() throws Exception {
// TODO -- try to get beans?
}
}
| 2,244 | 40.574074 | 119 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/test/BeanFactoryTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.test;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.pojo.support.TFactory;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
@RunWith(Arquillian.class)
public class BeanFactoryTestCase {
@Deployment(name = "bean-factory")
public static JavaArchive getBeanFactoryJar() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "bean-factory.jar");
archive.addPackage(TFactory.class.getPackage());
archive.addAsManifestResource(BeanFactoryTestCase.class.getPackage(), "bf-jboss-beans.xml", "bf-jboss-beans.xml");
return archive;
}
@Test
@OperateOnDeployment("bean-factory")
public void testTypeBeans() throws Exception {
// TODO -- try to get beans?
}
}
| 2,131 | 39.226415 | 122 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/test/CollectionsBeansTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.test;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.pojo.support.TFactory;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
@RunWith(Arquillian.class)
public class CollectionsBeansTestCase {
@Deployment(name = "collections-beans")
public static JavaArchive getCycleBeansJar() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "collections-beans.jar");
archive.addPackage(TFactory.class.getPackage());
archive.addAsManifestResource(CollectionsBeansTestCase.class.getPackage(), "collections-jboss-beans.xml", "collections-jboss-beans.xml");
return archive;
}
@Test
@OperateOnDeployment("collections-beans")
public void testCycleBeans() throws Exception {
// TODO -- try to get beans?
}
}
| 2,174 | 40.037736 | 145 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/test/LifecycleBeansTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.test;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.pojo.support.Sub;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
@RunWith(Arquillian.class)
public class LifecycleBeansTestCase {
@Deployment(name = "lifecycle-beans")
public static JavaArchive getCycleBeansJar() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "lifecycle-beans.jar");
archive.addPackage(Sub.class.getPackage());
archive.addAsManifestResource(LifecycleBeansTestCase.class.getPackage(), "sub-jboss-beans.xml", "sub-jboss-beans.xml");
return archive;
}
@Test
@OperateOnDeployment("lifecycle-beans")
public void testTypeBeans() throws Exception {
// TODO -- try to get beans?
}
}
| 2,137 | 39.339623 | 127 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/test/TcclBeansTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.test;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.pojo.support.TFactory;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
@RunWith(Arquillian.class)
public class TcclBeansTestCase {
@Deployment(name = "tccl-beans")
public static JavaArchive getTcclBeansJar() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "tccl-beans.jar");
archive.addPackage(TFactory.class.getPackage());
archive.addAsManifestResource(TcclBeansTestCase.class.getPackage(), "tccl-jboss-beans.xml", "tccl-jboss-beans.xml");
archive.addAsResource(new StringAsset("tccl"), "tccl.txt");
return archive;
}
@Test
@OperateOnDeployment("tccl-beans")
public void testTcclBeans() throws Exception {
// TODO -- try to get beans?
}
}
| 2,242 | 39.781818 | 124 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/Super.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class Super {
protected void start() {
}
}
| 1,210 | 35.69697 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/TBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class TBean {
private String msg;
private TInjectee injectee;
public TBean() {
this("Hello, ");
}
public TBean(String msg) {
this.msg = msg;
}
public TInjectee getInjectee() {
return injectee;
}
public void setInjectee(TInjectee injectee) {
this.injectee = injectee;
}
public void create() {
if (injectee != null)
injectee.sayHello("world!");
}
public void start(String anotherMsg) {
if (injectee != null)
injectee.sayHello(anotherMsg);
}
public void stop(String anotherMsg) {
if (injectee != null)
injectee.sayHello(anotherMsg);
}
public void destroy() {
if (injectee != null)
injectee.sayHello("actually bye!");
}
public void install(String msg) {
if (injectee != null)
injectee.sayHello(this.msg + msg);
}
}
| 2,090 | 27.643836 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/B.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class B {
private A a;
private C c;
public A getA() {
return a;
}
public void setA(A a) {
this.a = a;
}
public C getC() {
return c;
}
public void setC(C c) {
this.c = c;
}
}
| 1,408 | 28.354167 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/D.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
import org.jboss.as.pojo.api.BeanFactory;
import java.lang.reflect.Method;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class D {
public void create(Object bf) throws Throwable {
Method create = bf.getClass().getMethod("create");
B b = (B) create.invoke(bf);
}
public void start(Object bf) throws Throwable {
BeanFactory tbf = (BeanFactory) bf;
B b = (B) tbf.create();
}
}
| 1,539 | 33.222222 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/TFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class TFactory {
private final String msg;
public TFactory(String msg) {
this.msg = msg;
}
public static TBean createBean(String msg) {
return new TBean(msg);
}
public TInjectee defaultInjectee() {
return new TInjectee(msg);
}
public TInjectee defaultInjectee(int x) {
return new TInjectee(String.valueOf(x));
}
}
| 1,544 | 31.87234 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/A.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class A {
private B b;
public A(B b) {
this.b = b;
}
public B getB() {
return b;
}
}
| 1,281 | 31.871795 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/TInjectee.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class TInjectee {
private final String prefix;
public TInjectee() {
this("Hello, ");
}
public TInjectee(String prefix) {
this.prefix = prefix;
}
public void sayHello(String msg) {
System.out.println(prefix + msg);
}
}
| 1,431 | 32.302326 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/TOwner.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
import java.util.HashSet;
import java.util.Set;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class TOwner {
private Set<TInjectee> injectees = new HashSet<TInjectee>();
public void addInjectee(TInjectee i) {
//System.out.println("add #i-b = " + injectees.size());
injectees.add(i);
//System.out.println("add #i-a = " + injectees.size());
}
public void removeInjectee(TInjectee i) {
//System.out.println("remove #i-b = " + injectees.size());
injectees.remove(i);
//System.out.println("remove #i-a = " + injectees.size());
}
}
| 1,709 | 36.173913 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/Sub.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class Sub extends Super {
}
| 1,186 | 38.566667 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/C.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class C {
}
| 1,170 | 38.033333 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/TCollections.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class TCollections {
private List<Integer> numbers;
private Set<TBean> beans;
private Map<String, TInjectee> map;
public List<Integer> getNumbers() {
return numbers;
}
public void setNumbers(List<Integer> numbers) {
this.numbers = numbers;
}
public Set<TBean> getBeans() {
return beans;
}
public void setBeans(Set<TBean> beans) {
this.beans = beans;
}
public Map<String, TInjectee> getMap() {
return map;
}
public void setMap(Map<String, TInjectee> map) {
this.map = map;
}
public void start() {
for (Integer n : numbers)
System.out.println("n = " + n);
for (TBean b : beans)
System.out.println("b = " + b);
for (Map.Entry entry : map.entrySet())
System.out.println("k = " + entry.getKey() + ", v = " + entry.getValue());
}
}
| 2,135 | 29.514286 | 86 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/pojo/support/TcclChecker.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.pojo.support;
import static org.wildfly.common.Assert.checkNotNullParam;
import java.net.URL;
/**
* @author <a href="mailto:[email protected]">Ales Justin</a>
*/
public class TcclChecker {
public void start() {
URL url = checkNotNullParam("tccl.txt", Thread.currentThread().getContextClassLoader().getResource("tccl.txt"));
}
}
| 1,415 | 37.27027 | 120 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/HelloBeanDD.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc;
/**
* A HelloBean.
*
* @author Josef Cacek
*/
public class HelloBeanDD {
public static final String HELLO_WORLD = "Hello world!";
// Public methods --------------------------------------------------------
/**
* Returns {@value #HELLO_WORLD}.
*
* @see org.jboss.as.test.integration.security.common.ejb3.Hello#sayHelloWorld()
*/
public String sayHello() {
return HELLO_WORLD;
}
/**
* Returns echo of the given string (2x repeated).
*
* @see org.jboss.as.test.integration.security.common.ejb3.Hello#sayHello()
*/
public String echo(String name) {
return name + name;
}
}
| 1,743 | 30.709091 | 84 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/JACCForEarModulesTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.OperateOnDeployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.test.categories.CommonCriteria;
import org.jboss.as.test.integration.security.common.AbstractSecurityDomainsServerSetupTask;
import org.jboss.as.test.integration.security.common.Utils;
import org.jboss.as.test.integration.security.common.config.SecurityDomain;
import org.jboss.as.test.integration.security.common.config.SecurityModule;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
/**
* Tests, which checks JACC permissions generated for enterprise applications.
*
* @author Josef Cacek
*/
@RunWith(Arquillian.class)
@ServerSetup({JACCForEarModulesTestCase.SecurityDomainsSetup.class})
@RunAsClient
@Category(CommonCriteria.class)
@Ignore("See WFLY-4990")
public class JACCForEarModulesTestCase {
private static final String SECURITY_DOMAIN_NAME = "jacc-test";
private static Logger LOGGER = Logger.getLogger(JACCForEarModulesTestCase.class);
// Public methods --------------------------------------------------------
/**
* Creates {@link WebArchive} deployment.
*/
@Deployment(name = "war")
public static WebArchive warDeployment() {
LOGGER.trace("Create WAR deployment");
return createWar(SECURITY_DOMAIN_NAME);
}
/**
* Creates {@link EnterpriseArchive} deployment.
*/
@Deployment(name = "ear")
public static EnterpriseArchive earDeployment() {
LOGGER.trace("Create EAR deployment");
final String earName = "ear-" + SECURITY_DOMAIN_NAME;
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, earName + ".ear");
final JavaArchive jar = createJar(earName);
final WebArchive war = createWar(earName);
ear.addAsModule(war);
ear.addAsModule(jar);
return ear;
}
/**
* Creates {@link JavaArchive} deployment.
*/
@Deployment(name = "jar", testable = false)
public static JavaArchive jarDeployment() {
LOGGER.trace("Start JAR deployment");
return createJar("jar-" + SECURITY_DOMAIN_NAME);
}
/**
* Tests web permissions (war directly and war in ear).
*
* @param webAppURL
* @throws Exception
*/
@Test
@OperateOnDeployment("war")
public void testWebPermissions(@ArquillianResource URL webAppURL) throws Exception {
final Document doc = getPermissionDocument(webAppURL);
testJACCWebPermissions(doc.selectSingleNode("/" + ListJACCPoliciesServlet.ROOT_ELEMENT
+ "/ActiveContextPolicies/ContextPolicy[@contextID='jacc-test.war']"));
testJACCWebPermissions(doc.selectSingleNode("/" + ListJACCPoliciesServlet.ROOT_ELEMENT
+ "/ActiveContextPolicies/ContextPolicy[@contextID='ear-jacc-test.ear!ear-jacc-test.war']"));
}
/**
* Tests EJB permissions (jar directly and jar in ear).
*
* @param webAppURL
* @throws Exception
*/
@Test
@OperateOnDeployment("war")
public void testEJBPermissions(@ArquillianResource URL webAppURL) throws Exception {
final Document doc = getPermissionDocument(webAppURL);
testJACCEjbPermissions(doc.selectSingleNode("/" + ListJACCPoliciesServlet.ROOT_ELEMENT
+ "/ActiveContextPolicies/ContextPolicy[@contextID='jar-jacc-test.jar']"));
testJACCEjbPermissions(doc.selectSingleNode("/" + ListJACCPoliciesServlet.ROOT_ELEMENT
+ "/ActiveContextPolicies/ContextPolicy[@contextID='ear-jacc-test.ear!ear-jacc-test.jar']"));
}
// Private methods -------------------------------------------------------
/**
* Creates EJB JAR module with the given name.
*
* @param jarName
* @return
*/
private static JavaArchive createJar(final String jarName) {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, jarName + ".jar");
jar.addClasses(HelloBeanDD.class);
jar.addAsManifestResource(EmptyAsset.INSTANCE, ArchivePaths.create("beans.xml"));
jar.addAsManifestResource(Utils.getJBossEjb3XmlAsset(SECURITY_DOMAIN_NAME), "jboss-ejb3.xml");
jar.addAsManifestResource(JACCForEarModulesTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
return jar;
}
/**
* Creates WAR module with the given name.
*
* @param warName
* @return
*/
private static WebArchive createWar(final String warName) {
final WebArchive war = ShrinkWrap.create(WebArchive.class, warName + ".war");
war.addClass(ListJACCPoliciesServlet.class);
war.addAsWebInfResource(JACCForEarModulesTestCase.class.getPackage(), "web.xml", "web.xml");
war.addAsWebInfResource(Utils.getJBossWebXmlAsset(SECURITY_DOMAIN_NAME), "jboss-web.xml");
return war;
}
/**
* Tests web-app permissions in given ContextPolicy Node.
*
* @param contextPolicyNode
* @throws Exception
*/
private void testJACCWebPermissions(final Node contextPolicyNode) throws Exception {
assertNotNull("Context policy for the web application should exist.", contextPolicyNode);
List<?> permNodes = contextPolicyNode.selectNodes("ExcludedPermissions/Permission");
assertEquals("ExcludedPermissions should exist.", 2, permNodes.size());
permNodes = contextPolicyNode.selectNodes("UncheckedPermissions/Permission");
assertFalse("UncheckedPermissions should exist.", permNodes.isEmpty());
}
/**
* Tests EJB permissions in the given ContextPolicy Node.
*
* @param contextPolicyNode
* @throws Exception
*/
private void testJACCEjbPermissions(final Node contextPolicyNode) throws Exception {
assertNotNull("Context policy for the EJB module should exist.", contextPolicyNode);
List<?> permNodes = contextPolicyNode.selectNodes("ExcludedPermissions/Permission");
assertFalse("ExcludedPermissions should exist.", permNodes.isEmpty());
}
/**
* Returns Dom4j XML Document representation of the JACC policies retrieved from the {@link ListJACCPoliciesServlet}.
*
* @param webAppURL
* @return
* @throws MalformedURLException
* @throws IOException
* @throws DocumentException
*/
private Document getPermissionDocument(final URL webAppURL) throws IOException, DocumentException {
final URL servletURL = new URL(webAppURL.toExternalForm() + ListJACCPoliciesServlet.SERVLET_PATH.substring(1));
LOGGER.trace("Testing JACC permissions: " + servletURL);
final InputStream is = servletURL.openStream();
try {
final Document document = new SAXReader().read(is);
return document;
} finally {
is.close();
}
}
// Embedded classes ------------------------------------------------------
/**
* A {@link ServerSetupTask} instance which creates security domains for this test case.
*
* @author Josef Cacek
*/
static class SecurityDomainsSetup extends AbstractSecurityDomainsServerSetupTask {
/**
* @see org.jboss.as.test.integration.security.common.AbstractSecurityDomainsServerSetupTask#getSecurityDomains()
*/
@Override
protected SecurityDomain[] getSecurityDomains() {
return new SecurityDomain[]{new SecurityDomain.Builder().name(SECURITY_DOMAIN_NAME)
.authorizationModules(new SecurityModule.Builder().name("JACC").flag("required").build()).build()};
}
}
}
| 9,739 | 38.918033 | 121 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/ListJACCPoliciesServlet.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright (c) 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc;
import java.io.IOException;
import java.io.PrintWriter;
import java.security.Policy;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
/**
* A simple servlet that lists JACC policies.
*
* @author Josef Cacek
*/
@WebServlet(urlPatterns = {ListJACCPoliciesServlet.SERVLET_PATH})
public class ListJACCPoliciesServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public static final String ROOT_ELEMENT = "jacc-policies";
public static final String SERVLET_PATH = "/listJACCPolicies";
/**
* Writes simple text response.
*
* @param req
* @param resp
* @throws ServletException
* @throws IOException
* @see jakarta.servlet.http.HttpServlet#doGet(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/plain");
final PrintWriter writer = resp.getWriter();
writer.append("<" + ROOT_ELEMENT + ">\n");
Policy policy = Policy.getPolicy();
// Tests that use this class are disabled (see WFLY-4990 and WFLY-4991)
// If they are ever re-enabled, this will fail until a test approach not reliant
// on the old picketbox impl is available
if (true) throw new IllegalStateException("Legacy security not supported");
// if (policy instanceof DelegatingPolicy) {
// writer.append(((DelegatingPolicy) policy).listContextPolicies() //
// //workarounds for https://issues.jboss.org/browse/SECURITY-663
// .replaceAll("Permission name=", "Permission' name=") //
// .replaceAll("RolePermssions", "RolePermissions")) //
// ;
// }
writer.append("</" + ROOT_ELEMENT + ">\n");
writer.close();
}
}
| 3,177 | 40.815789 | 133 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/JACCAuthzPropagationTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import org.apache.http.client.ClientProtocolException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.test.integration.security.common.AbstractSecurityDomainsServerSetupTask;
import org.jboss.as.test.integration.security.common.Utils;
import org.jboss.as.test.integration.security.common.config.SecurityDomain;
import org.jboss.as.test.integration.security.common.config.SecurityModule;
import org.jboss.as.test.integration.security.jacc.propagation.BridgeBean;
import org.jboss.as.test.integration.security.jacc.propagation.Manage;
import org.jboss.as.test.integration.security.jacc.propagation.PropagationTestServlet;
import org.jboss.as.test.integration.security.jacc.propagation.TargetBean;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests, which checks run-as identity handling in EJB JACC authorization module.
*
* @author Josef Cacek
*/
@RunWith(Arquillian.class)
@RunAsClient
@Ignore("See WFLY-4989")
public class JACCAuthzPropagationTestCase {
private static final Logger LOGGER = Logger.getLogger(JACCAuthzPropagationTestCase.class);
private static final String TEST_NAME = Manage.TEST_NAME;
// Public methods --------------------------------------------------------
/**
* Creates {@link WebArchive} deployment.
*/
@Deployment(name = "war")
public static WebArchive warDeployment() {
LOGGER.trace("Start WAR deployment");
final WebArchive war = ShrinkWrap.create(WebArchive.class, TEST_NAME + ".war");
war.addClasses(PropagationTestServlet.class, Manage.class, BridgeBean.class, TargetBean.class);
final StringAsset usersRolesAsset = new StringAsset(Utils.createUsersFromRoles(Manage.ROLES_ALL));
war.addAsResource(usersRolesAsset, "users.properties");
war.addAsResource(usersRolesAsset, "roles.properties");
//war.addAsWebInfResource(UsersRolesLoginModuleTestCase.class.getPackage(), "web-basic-authn.xml", "web.xml");
war.addAsWebInfResource(Utils.getJBossWebXmlAsset(TEST_NAME), "jboss-web.xml");
war.addAsWebInfResource(Utils.getJBossEjb3XmlAsset(TEST_NAME), "jboss-ejb3.xml");
return war;
}
/**
* Tests direct permissions (RolesAllowed).
*
* @param webAppURL
* @throws Exception
*/
@Test
public void testTarget(@ArquillianResource URL webAppURL) throws Exception {
assertAccessAllowed(webAppURL, Manage.BEAN_NAME_TARGET, PropagationTestServlet.METHOD_NAME_ADMIN, Manage.ROLE_ADMIN);
assertAccessAllowed(webAppURL, Manage.BEAN_NAME_TARGET, PropagationTestServlet.METHOD_NAME_MANAGE, Manage.ROLE_MANAGER);
assertAccessAllowed(webAppURL, Manage.BEAN_NAME_TARGET, PropagationTestServlet.METHOD_NAME_WORK, Manage.ROLE_ADMIN);
assertAccessDenied(webAppURL, Manage.BEAN_NAME_TARGET, PropagationTestServlet.METHOD_NAME_ADMIN, Manage.ROLE_MANAGER);
}
/**
* Tests run-as permissions.
*
* @param webAppURL
* @throws Exception
*/
@Test
public void testBridge(@ArquillianResource URL webAppURL) throws Exception {
assertAccessAllowed(webAppURL, Manage.BEAN_NAME_BRIDGE, PropagationTestServlet.METHOD_NAME_MANAGE, Manage.ROLE_ADMIN);
assertAccessAllowed(webAppURL, Manage.BEAN_NAME_BRIDGE, PropagationTestServlet.METHOD_NAME_MANAGE, Manage.ROLE_MANAGER);
assertAccessAllowed(webAppURL, Manage.BEAN_NAME_BRIDGE, PropagationTestServlet.METHOD_NAME_MANAGE, Manage.ROLE_USER);
assertAccessAllowed(webAppURL, Manage.BEAN_NAME_BRIDGE, PropagationTestServlet.METHOD_NAME_WORK, Manage.ROLE_USER);
assertAccessDenied(webAppURL, Manage.BEAN_NAME_BRIDGE, PropagationTestServlet.METHOD_NAME_ADMIN, Manage.ROLE_ADMIN);
assertAccessDenied(webAppURL, Manage.BEAN_NAME_BRIDGE, PropagationTestServlet.METHOD_NAME_ADMIN, Manage.ROLE_MANAGER);
}
// Private methods -------------------------------------------------------
/**
* Asserts the access to the given method in the given bean is allowed for given role.
*
* @param webAppURL
* @param beanName
* @param methodName
* @param roleName
* @throws ClientProtocolException
* @throws IOException
* @throws URISyntaxException
*/
private void assertAccessAllowed(URL webAppURL, String beanName, String methodName, String roleName)
throws IOException, URISyntaxException {
final URL testUrl = getTestURL(webAppURL, beanName, methodName);
assertEquals("Access of role " + roleName + " to " + methodName + " method in " + beanName + " should be allowed.",
Manage.RESULT, Utils.makeCallWithBasicAuthn(testUrl, roleName, roleName, 200));
}
/**
* Asserts the access to the given method in the given bean is denied for given role.
*
* @param webAppURL
* @param beanName
* @param methodName
* @param roleName
* @throws ClientProtocolException
* @throws IOException
* @throws URISyntaxException
*/
private void assertAccessDenied(URL webAppURL, String beanName, String methodName, String roleName)
throws IOException, URISyntaxException {
final URL testUrl = getTestURL(webAppURL, beanName, methodName);
assertEquals("Access of role " + roleName + " to " + methodName + " method in " + beanName + " should be denied.",
PropagationTestServlet.RESULT_EJB_ACCESS_EXCEPTION,
Utils.makeCallWithBasicAuthn(testUrl, roleName, roleName, 200));
}
/**
* Creates URL of the test application with the given values of request parameters.
*
* @param webAppURL
* @param beanName
* @param method
* @return
* @throws MalformedURLException
* @throws UnsupportedEncodingException
*/
private URL getTestURL(URL webAppURL, String beanName, String method) throws MalformedURLException,
UnsupportedEncodingException {
return new URL(webAppURL.toExternalForm() + PropagationTestServlet.SERVLET_PATH.substring(1) + "?" //
+ PropagationTestServlet.PARAM_BEAN_NAME + "=" + beanName + "&" //
+ PropagationTestServlet.PARAM_METHOD_NAME + "=" + method);
}
// Embedded classes ------------------------------------------------------
/**
* A {@link ServerSetupTask} instance which creates security domains for this test case.
*
* @author Josef Cacek
*/
static class SecurityDomainsSetup extends AbstractSecurityDomainsServerSetupTask {
/**
* @see org.jboss.as.test.integration.security.common.AbstractSecurityDomainsServerSetupTask#getSecurityDomains()
*/
@Override
protected SecurityDomain[] getSecurityDomains() {
return new SecurityDomain[]{new SecurityDomain.Builder().name(TEST_NAME)
.loginModules(new SecurityModule.Builder().name("UsersRoles").flag("required").build()) //
.authorizationModules(new SecurityModule.Builder().name("JACC").flag("required").build()) //
.cacheType("default") //
.build()};
}
}
}
| 8,882 | 43.863636 | 128 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/JACCTranslateServletDDTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.io.InputStream;
import java.net.URL;
import org.dom4j.Document;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.test.categories.CommonCriteria;
import org.jboss.as.test.integration.security.common.AbstractSecurityDomainsServerSetupTask;
import org.jboss.as.test.integration.security.common.config.SecurityDomain;
import org.jboss.as.test.integration.security.common.config.SecurityModule;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
/**
* Test based on a section 3.1.3 "Translating Servlet Deployment Descriptors" of the JACC 1.1 specification. This tests works
* with deployment descriptor (web.xml) content which is a part of the JACC specification as an Example section 3.1.3.4.
*
* @author Josef Cacek
*/
@RunWith(Arquillian.class)
@ServerSetup({JACCTranslateServletDDTestCase.SecurityDomainsSetup.class})
@RunAsClient
@Category(CommonCriteria.class)
@Ignore("WFLY-4991")
public class JACCTranslateServletDDTestCase {
private static final String SECURITY_DOMAIN_NAME = "jacc-test";
private static final String WEBAPP_NAME = "jacc-test.war";
private static Logger LOGGER = Logger.getLogger(JACCTranslateServletDDTestCase.class);
// Public methods --------------------------------------------------------
/**
* Creates {@link WebArchive}.
*
* @return
*/
@Deployment
public static WebArchive warDeployment() {
final WebArchive war = ShrinkWrap.create(WebArchive.class, WEBAPP_NAME);
war.addClass(ListJACCPoliciesServlet.class);
war.addAsWebInfResource(JACCTranslateServletDDTestCase.class.getPackage(), "web-JACC11-example.xml", "web.xml");
war.addAsWebInfResource(new StringAsset("<jboss-web>" + //
"<security-domain>" + SECURITY_DOMAIN_NAME + "</security-domain>" + //
"</jboss-web>"), "jboss-web.xml");
return war;
}
/**
* Test canonical form of HTTP Method list.
*
* @see #testHTTPMethodExceptionList(URL) for some other tests
*/
@Test
public void testHTTPMethodCanonical(@ArquillianResource URL webAppURL) throws Exception {
final Node node = getContextPolicyNode(webAppURL, WEBAPP_NAME);
assertTrue("HTTP Method names should be sorted alphabetically", node.selectNodes("*/Permission[@actions='PUT,DELETE']")
.isEmpty());
assertFalse("HTTP Method names should be sorted alphabetically", node
.selectNodes("*/Permission[@actions='DELETE,PUT']").isEmpty());
assertFalse("HTTP Method names should be sorted alphabetically",
node.selectNodes("RolePermissions/Role/Permission[@actions='GET,POST']").isEmpty());
assertTrue("HTTP Method names should be sorted alphabetically",
node.selectNodes("RolePermissions/Role/Permission[@actions='POST,GET']").isEmpty());
assertFalse("HTTP Method names should be sorted alphabetically, followed by colon-separated transport guarantee", node
.selectNodes("UncheckedPermissions/Permission[@actions='GET,POST:CONFIDENTIAL']").isEmpty());
}
/**
* Test usage of transport guarantee constraints.
*/
@Test
public void testConnectionType(@ArquillianResource URL webAppURL) throws Exception {
final Node node = getContextPolicyNode(webAppURL, WEBAPP_NAME);
assertFalse(
"WebUserDataPermission with the connection type :CONFIDENTIAL should be present in unchecked permissions ",
node.selectNodes(
"UncheckedPermissions/Permission[ends-with(@type,'WebUserDataPermission') and @actions='GET:CONFIDENTIAL']")
.isEmpty());
assertFalse(
"WebUserDataPermission with the connection type :CONFIDENTIAL should be present in unchecked permissions ",
node.selectNodes(
"UncheckedPermissions/Permission[ends-with(@type,'WebUserDataPermission') and @actions='GET,POST:CONFIDENTIAL']")
.isEmpty());
}
/**
* Test canonical form of HTTP Method list.
*/
@Test
@Ignore("JBPAPP-9405 JACC 1.1 implementation must use exception list instead of missing method list for HTTP methods in the unchecked permissions")
public void testHTTPMethodSubtraction(@ArquillianResource URL webAppURL) throws Exception {
final Node node = getContextPolicyNode(webAppURL, WEBAPP_NAME);
assertTrue("HTTP Method exception list must be used instead of method subtraction from 'big 7'.",
node.selectNodes("UncheckedPermissions/Permission[@actions='GET,HEAD,OPTIONS,POST,TRACE']").isEmpty());
}
/**
* Test handling of HTTP Method Exception list.
*/
@Test
@Ignore("JBPAPP-9400 - JACC permissions with HTTP method exception list are not correctly implemented")
public void testHTTPMethodExceptionList(@ArquillianResource URL webAppURL) throws Exception {
final Node node = getContextPolicyNode(webAppURL, WEBAPP_NAME);
assertFalse("Can't find permissions with a HTTP Method exception list",
node.selectNodes("UncheckedPermissions/Permission[@actions='!DELETE,GET,PUT']").isEmpty());
assertFalse("Can't find permissions with a HTTP Method exception list",
node.selectNodes("UncheckedPermissions/Permission[@actions='!DELETE,GET,POST,PUT']").isEmpty());
assertFalse("Can't find permissions with a HTTP Method exception list",
node.selectNodes("UncheckedPermissions/Permission[@actions='!DELETE,PUT']").isEmpty());
assertTrue("HTTP Method exception list should be constructed by using exclamation mark",
node.selectNodes("UncheckedPermissions/Permission[@actions='GET,HEAD,OPTIONS,POST,TRACE']").isEmpty());
}
/**
* Test usage of qualified patterns.
*/
@Test
public void testQualifiedPatterns(@ArquillianResource URL webAppURL) throws Exception {
final Node node = getContextPolicyNode(webAppURL, WEBAPP_NAME);
assertTrue("Default pattern '/' must be qualified.", node.selectNodes("*/Permission[@name='/']").isEmpty());
assertTrue("Qualified default pattern should not be present in ExcludedPermissions.",
node.selectNodes("ExcludedPermissions/Permission[starts-with(@name,'/:')]").isEmpty());
assertFalse("Qualified default pattern should be present in UncheckedPermissions.",
node.selectNodes("UncheckedPermissions/Permission[starts-with(@name,'/:')]").isEmpty());
assertTrue("Path prefix pattern must be qualified.", node.selectNodes("*/Permission[@name='/b/*']").isEmpty());
assertTrue("Path prefix pattern must be qualified.", node.selectNodes("*/Permission[@name='/a/*']").isEmpty());
assertTrue("Extension pattern must be qualified.", node.selectNodes("*/Permission[@name='*.asp']").isEmpty());
}
// Private methods -------------------------------------------------------
/**
* Retruns Node representing ContextPolicy with given contextId.
*
* @param webAppURL
*/
private Node getContextPolicyNode(final URL webAppURL, String contextId) throws Exception {
final URL servletURL = new URL(webAppURL.toExternalForm() + ListJACCPoliciesServlet.SERVLET_PATH.substring(1));
LOGGER.trace("Testing JACC permissions: " + servletURL);
final InputStream is = servletURL.openStream();
try {
final Document document = new SAXReader().read(is);
final String xpathBase = "/" + ListJACCPoliciesServlet.ROOT_ELEMENT
+ "/ActiveContextPolicies/ContextPolicy[@contextID='" + contextId + "']";
final Node contextPolicyNode = document.selectSingleNode(xpathBase);
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(contextPolicyNode.asXML());
}
return contextPolicyNode;
} finally {
is.close();
}
}
// Embedded classes ------------------------------------------------------
/**
* A {@link ServerSetupTask} instance which creates security domains for this test case.
*
* @author Josef Cacek
*/
static class SecurityDomainsSetup extends AbstractSecurityDomainsServerSetupTask {
/**
* @see org.jboss.as.test.integration.security.common.AbstractSecurityDomainsServerSetupTask#getSecurityDomains()
*/
@Override
protected SecurityDomain[] getSecurityDomains() {
return new SecurityDomain[]{new SecurityDomain.Builder().name(SECURITY_DOMAIN_NAME)
.authorizationModules(new SecurityModule.Builder().name("JACC").flag("required").build()).build()};
}
}
}
| 10,546 | 48.055814 | 151 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/propagation/PropagationTestServlet.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright (c) 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc.propagation;
import java.io.IOException;
import java.io.PrintWriter;
import jakarta.annotation.security.DeclareRoles;
import jakarta.ejb.EJBAccessException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.HttpConstraint;
import jakarta.servlet.annotation.ServletSecurity;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jboss.logging.Logger;
/**
* Servlet for testing JACC authorization propagation. It gets 2 request parameters:
* <ul>
* <li>{@value #PARAM_BEAN_NAME} - bean name used to JNDI lookup of {@link Manage} interface implementation
* <li>{@value #PARAM_METHOD_NAME} - the value should be one of {@value #METHOD_NAME_ADMIN}, {@value #METHOD_NAME_MANAGE},
* {@value #METHOD_NAME_USER}
* </ul>
*
* @author Josef Cacek
*/
@DeclareRoles({Manage.ROLE_ADMIN, Manage.ROLE_MANAGER, Manage.ROLE_USER})
@ServletSecurity(@HttpConstraint(rolesAllowed = {Manage.ROLE_ADMIN, Manage.ROLE_MANAGER, Manage.ROLE_USER}))
@WebServlet(PropagationTestServlet.SERVLET_PATH)
public class PropagationTestServlet extends HttpServlet {
private static Logger LOGGER = Logger.getLogger(PropagationTestServlet.class);
private static final long serialVersionUID = 1L;
public static final String SERVLET_PATH = "/propagation";
public static final String PARAM_BEAN_NAME = "beanName";
public static final String PARAM_METHOD_NAME = "methodName";
public static final String METHOD_NAME_ADMIN = "admin";
public static final String METHOD_NAME_MANAGE = "manage";
public static final String METHOD_NAME_WORK = "work";
public static final String RESULT_EJB_ACCESS_EXCEPTION = "EjbAccessException";
/**
* Tests access to EJBs implementing {@link Manage} interface.
*
* @param req
* @param resp
* @throws ServletException
* @throws IOException
* @see jakarta.servlet.http.HttpServlet#doGet(jakarta.servlet.http.HttpServletRequest, jakarta.servlet.http.HttpServletResponse)
*/
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("text/plain");
final PrintWriter writer = resp.getWriter();
final String beanName = req.getParameter(PARAM_BEAN_NAME);
final String methodName = req.getParameter(PARAM_METHOD_NAME);
Context ctx = null;
try {
ctx = new InitialContext();
final Manage manageBean = (Manage) ctx.lookup("java:app/" + Manage.TEST_NAME + "/" + beanName);
String msg = null;
if (METHOD_NAME_ADMIN.equals(methodName)) {
msg = manageBean.admin();
} else if (METHOD_NAME_MANAGE.equals(methodName)) {
msg = manageBean.manage();
} else if (METHOD_NAME_WORK.equals(methodName)) {
msg = manageBean.work();
} else {
msg = "Unknown method: " + methodName;
}
writer.append(msg);
} catch (EJBAccessException e) {
//expected state in this servlet
writer.append(RESULT_EJB_ACCESS_EXCEPTION);
} catch (Exception e) {
LOGGER.error("EJB Call failed", e);
e.printStackTrace(writer);
} finally {
if (ctx != null) {
try {
ctx.close();
} catch (NamingException e) {
LOGGER.error("Error", e);
}
}
}
writer.close();
}
}
| 4,848 | 39.408333 | 133 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/propagation/Manage.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc.propagation;
/**
* Interface used for testing authorization propagation in the JACC policy module.
*
* @author Josef Cacek
*/
public interface Manage {
String TEST_NAME = "jacc-propagation-test";
String ROLE_ADMIN = "Admin";
String ROLE_MANAGER = "Manager";
String ROLE_USER = "User";
/**
* All test roles
*/
String[] ROLES_ALL = {ROLE_ADMIN, ROLE_MANAGER, ROLE_USER};
String BEAN_NAME_TARGET = "TargetBean";
String BEAN_NAME_BRIDGE = "BridgeBean";
/**
* Default result of methods defined in this interface.
*/
String RESULT = "OK";
String admin();
String manage();
String work();
}
| 1,744 | 29.614035 | 82 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/propagation/BridgeBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc.propagation;
import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.RolesAllowed;
import jakarta.annotation.security.RunAs;
import jakarta.ejb.EJB;
import jakarta.ejb.Stateless;
/**
* Implementation of {@link Manage} interface which has injected {@link TargetBean} EJB and calls it's methods as
* {@link Manage#ROLE_MANAGER} role (using {@link jakarta.annotation.security.RunAs} annotation). This class is protected, it
* allows access to all test roles. Methods of this class are not protected.
*
* @author Josef Cacek
*/
@Stateless(name = Manage.BEAN_NAME_BRIDGE)
@DeclareRoles({Manage.ROLE_ADMIN, Manage.ROLE_MANAGER, Manage.ROLE_USER})
@RunAs(Manage.ROLE_MANAGER)
@RolesAllowed({Manage.ROLE_ADMIN, Manage.ROLE_MANAGER, Manage.ROLE_USER})
public class BridgeBean implements Manage {
@EJB(beanName = Manage.BEAN_NAME_TARGET)
private Manage targetBean = null;
// Public methods --------------------------------------------------------
public String admin() {
return targetBean.admin();
}
public String manage() {
return targetBean.manage();
}
public String work() {
return targetBean.work();
}
}
| 2,275 | 36.311475 | 125 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/propagation/TargetBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2012, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc.propagation;
import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.PermitAll;
import jakarta.annotation.security.RolesAllowed;
import jakarta.ejb.Stateless;
/**
* An implementation of {@link Manage} interface which has protected {@link #admin()} and {@link #manage()} methods.
*
* @author Josef Cacek
*/
@Stateless(name = Manage.BEAN_NAME_TARGET)
@DeclareRoles({Manage.ROLE_ADMIN, Manage.ROLE_MANAGER, Manage.ROLE_USER})
public class TargetBean implements Manage {
// Public methods --------------------------------------------------------
/**
* Method with only {@link Manage#ROLE_ADMIN} access.
*
* @return
*/
@RolesAllowed({ROLE_ADMIN})
public String admin() {
return RESULT;
}
/**
* Method with only {@link Manage#ROLE_MANAGER} access.
*
* @return
*/
@RolesAllowed({ROLE_MANAGER})
public String manage() {
return RESULT;
}
/**
* Unprotected method.
*
* @return
*/
@PermitAll
public String work() {
return RESULT;
}
}
| 2,173 | 29.619718 | 116 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/context/PolicyContextTestServlet.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc.context;
import java.io.IOException;
import org.jboss.logging.Logger;
import org.wildfly.common.function.ExceptionSupplier;
import jakarta.ejb.EJB;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
@WebServlet(urlPatterns = { PolicyContextTestServlet.SERVLET_PATH })
public class PolicyContextTestServlet extends HttpServlet {
private static final Logger LOGGER = Logger.getLogger(PolicyContextTestServlet.class);
private static final long serialVersionUID = 1L;
public static final String SERVLET_PATH = "/policy-context-test";
@EJB
private PolicyContextTestBean policyContextTestBean;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// This test is just using a static method on the bean implementation so it running in the servlet container.
boolean availableForServlet = isAvailable(PolicyContextTestBean::getHttpServletRequest);
// This test makes a call to the EJB so is running in the EJB container.
boolean availableForEjb = isAvailable(() -> policyContextTestBean.getHttpServletRequestFromPolicyContext());
if (!availableForServlet || !availableForEjb) {
throw new ServletException(String.format(
"HttpServletRequest not available in all containers availableForServlet=%b, availableForEjb=%b.",
availableForServlet, availableForEjb));
}
String responseString = "HttpServletRequest successfully obtained from both containers.";
LOGGER.debug(responseString);
response.getWriter().write(responseString);
}
private boolean isAvailable(ExceptionSupplier<HttpServletRequest, Exception> testSupplier) {
try {
HttpServletRequest request = testSupplier.get();
if (request == null) {
LOGGER.debug("Instance from test Supplier<T> was null.");
return false;
}
return true;
} catch (Exception e) {
LOGGER.warn("Unable to get instance from test Supplier<T>", e);
return false;
}
}
}
| 3,415 | 40.156627 | 121 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/context/PolicyContextTestBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc.context;
import jakarta.ejb.Stateless;
import jakarta.security.jacc.PolicyContext;
import jakarta.security.jacc.PolicyContextException;
import jakarta.servlet.http.HttpServletRequest;
@Stateless
public class PolicyContextTestBean {
public HttpServletRequest getHttpServletRequestFromPolicyContext() throws PolicyContextException {
return getHttpServletRequest();
}
// public as accessed from a different module.
public static HttpServletRequest getHttpServletRequest() throws PolicyContextException {
HttpServletRequest httpServletRequest = (HttpServletRequest) PolicyContext
.getContext("jakarta.servlet.http.HttpServletRequest");
return httpServletRequest;
}
}
| 1,803 | 40 | 102 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/jacc/context/PolicyContextTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.security.jacc.context;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import static org.junit.Assert.assertTrue;
import java.net.URL;
import java.security.SecurityPermission;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.test.integration.common.HttpRequest;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
@RunAsClient
public class PolicyContextTestCase {
private static Logger LOGGER = Logger.getLogger(PolicyContextTestCase.class);
@Deployment(name = "ear")
public static EnterpriseArchive createDeployment() {
final String earName = "ear-jacc-context";
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, earName + ".ear");
final JavaArchive jar = createJar(earName);
final WebArchive war = createWar(earName);
ear.addAsModule(war);
ear.addAsModule(jar);
ear.addAsManifestResource(createPermissionsXmlAsset(new SecurityPermission("setPolicy")), "permissions.xml");
return ear;
}
@Test
public void testHttpServletRequestFromPolicyContext(@ArquillianResource URL webAppURL) throws Exception {
String externalFormURL = webAppURL.toExternalForm();
String servletURL = externalFormURL.substring(0, externalFormURL.length() - 1) + PolicyContextTestServlet.SERVLET_PATH;
LOGGER.trace("Testing Jakarta Authorization Context: " + servletURL);
String response = HttpRequest.get(servletURL, 1000, SECONDS);
assertTrue(response.contains("HttpServletRequest successfully obtained from both containers."));
}
private static JavaArchive createJar(final String jarName) {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, jarName + ".jar");
jar.addClasses(PolicyContextTestBean.class);
jar.addAsManifestResource(PolicyContextTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
return jar;
}
private static WebArchive createWar(final String warName) {
final WebArchive war = ShrinkWrap.create(WebArchive.class, warName + ".war");
war.addClass(PolicyContextTestServlet.class);
return war;
}
}
| 3,774 | 40.944444 | 127 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/credentialreference/CredentialReferenceDatasourceTestCase.java
|
/*
Copyright 2017 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.jboss.as.test.integration.security.credentialreference;
import static org.jboss.as.controller.security.CredentialReference.CREDENTIAL_REFERENCE;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Objects;
import org.h2.tools.Server;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.test.integration.management.util.MgmtOperationException;
import org.jboss.as.test.integration.security.common.Utils;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* tests for credential-reference in datasource subsystem
*/
@RunWith(Arquillian.class)
@ServerSetup({CredentialStoreServerSetupTask.class, CredentialReferenceDatasourceTestCase.DatasourceServerSetupTask.class})
@RunAsClient
public class CredentialReferenceDatasourceTestCase {
private static final String DATABASE_PASSWORD = "chucknorris";
private static final PathAddress DATASOURCES_SUBSYSTEM_ADDRESS = PathAddress.pathAddress(ModelDescriptionConstants.SUBSYSTEM, "datasources");
private static final String CLEAR_TEXT_CREDENTIAL_REF_DS_NAME = "ClearTextCredentialReferenceDatasource";
private static final String STORE_ALIAS_CREDENTIAL_REF_DS_NAME = "StoreAliasCredentialReferenceDatasource";
private static final String PASSWORD_AND_CREDENTIAL_REF_DS_NAME = "PasswordAndClearTextCredentialReferenceDatasource";
enum Scenario {
// <credential-reference clear-text="chucknorris"/>
CREDENTIAL_REFERENCE_CLEAR_TEXT(CLEAR_TEXT_CREDENTIAL_REF_DS_NAME),
// <credential-reference store="store001" alias="alias001"/>
CREDENTIAL_REFERENCE_STORE_ALIAS(STORE_ALIAS_CREDENTIAL_REF_DS_NAME),
// password and credential-reference should be mutually exclusive
// test that it is not possible to create datasource with both defined
PASSWORD_AND_CREDENTIAL_REFERENCE_PREFERENCE(PASSWORD_AND_CREDENTIAL_REF_DS_NAME);
private final String datasourceName;
Scenario(String datasourceName) {
Objects.requireNonNull(datasourceName);
this.datasourceName = datasourceName;
}
private PathAddress getDatasourceAddress() {
return DATASOURCES_SUBSYSTEM_ADDRESS
.append("data-source", datasourceName);
}
private PathAddress getXADatasourceAddress() {
return DATASOURCES_SUBSYSTEM_ADDRESS
.append("xa-data-source", datasourceName);
}
public String getDatasourceJndiName() {
return "java:jboss/datasources/" + datasourceName;
}
}
@ArquillianResource
private ManagementClient client;
@Deployment
public static WebArchive deployment() {
final WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war");
war.addAsManifestResource(new StringAsset("Dependencies: org.jboss.dmr, org.jboss.as.controller-client, org.jboss.as.controller\n"), "MANIFEST.MF");
war.addClass(CredentialStoreServerSetupTask.class);
war.addClass(CredentialReferenceDatasourceTestCase.class);
return war;
}
@Test
public void testDatasourceClearTextCredentialReference() throws IOException, MgmtOperationException {
final Scenario scenario = Scenario.CREDENTIAL_REFERENCE_CLEAR_TEXT;
addDatasource(scenario);
try {
testConnectionInPool(scenario.getDatasourceAddress());
} finally {
removeDatasourceSilently(scenario);
}
}
@Test
public void testDatasourceStoreAliasCredentialReference() throws IOException, MgmtOperationException {
final Scenario scenario = Scenario.CREDENTIAL_REFERENCE_STORE_ALIAS;
addDatasource(scenario);
try {
testConnectionInPool(scenario.getDatasourceAddress());
} finally {
removeDatasourceSilently(scenario);
}
}
@Test
public void testDatasourceCredentialReferenceOverPasswordPreference() throws IOException {
final Scenario scenario = Scenario.PASSWORD_AND_CREDENTIAL_REFERENCE_PREFERENCE;
try {
addDatasource(scenario);
fail("It shouldn't be possible to add datasource with both, credential-reference and password, defined");
} catch (MgmtOperationException moe) {
// expected
} finally {
removeDatasourceSilently(scenario);
}
}
@Test
public void testXADatasourceClearTextCredentialReference() throws IOException, MgmtOperationException {
final Scenario scenario = Scenario.CREDENTIAL_REFERENCE_CLEAR_TEXT;
addXADatasource(scenario);
try {
testConnectionInPool(scenario.getXADatasourceAddress());
} finally {
removeXADatasourceSilently(scenario);
}
}
@Test
public void testXADatasourceStoreAliasCredentialReference() throws IOException, MgmtOperationException {
final Scenario scenario = Scenario.CREDENTIAL_REFERENCE_STORE_ALIAS;
addXADatasource(scenario);
try {
testConnectionInPool(scenario.getXADatasourceAddress());
} finally {
removeXADatasourceSilently(scenario);
}
}
@Test
public void testXADatasourceCredentialReferenceOverPasswordPreference() throws IOException {
final Scenario scenario = Scenario.PASSWORD_AND_CREDENTIAL_REFERENCE_PREFERENCE;
try {
addXADatasource(scenario);
fail("It shouldn't be possible to add datasource with both, credential-reference and password, defined");
} catch (MgmtOperationException moe) {
// expected
} finally {
removeXADatasourceSilently(scenario);
}
}
private void testConnectionInPool(PathAddress datasourceAddress) throws IOException, MgmtOperationException {
final ModelNode operation = new ModelNode();
operation.get(ModelDescriptionConstants.OP).set("test-connection-in-pool");
operation.get(ModelDescriptionConstants.OP_ADDR).set(datasourceAddress.toModelNode());
execute(operation);
}
private void addDatasource(final Scenario scenario) throws IOException, MgmtOperationException {
final ModelNode addOperation = Operations.createAddOperation(scenario.getDatasourceAddress().toModelNode());
addOperation.get("jndi-name").set(scenario.getDatasourceJndiName());
addOperation.get("driver-name").set("h2");
addOperation.get("user-name").set("sa");
addOperation.get("connection-url").set("jdbc:h2:tcp://" + Utils.getSecondaryTestAddress(client) + "/mem:" + CredentialReferenceDatasourceTestCase.class.getName());
addOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
ModelNode credentialReference = null;
switch (scenario) {
case PASSWORD_AND_CREDENTIAL_REFERENCE_PREFERENCE:
addOperation.get("password").set("wrong-password");
credentialReference = addOperation.get(CREDENTIAL_REFERENCE).setEmptyObject();
credentialReference.get("clear-text").set(DATABASE_PASSWORD);
break;
case CREDENTIAL_REFERENCE_CLEAR_TEXT:
credentialReference = addOperation.get(CREDENTIAL_REFERENCE).setEmptyObject();
credentialReference.get("clear-text").set(DATABASE_PASSWORD);
break;
case CREDENTIAL_REFERENCE_STORE_ALIAS:
credentialReference = addOperation.get(CREDENTIAL_REFERENCE).setEmptyObject();
credentialReference.get("store").set("store001");
credentialReference.get("alias").set("alias001");
break;
}
execute(addOperation);
}
private void removeDatasourceSilently(final Scenario scenario) throws IOException {
final ModelNode removeOperation = Operations.createRemoveOperation(scenario.getDatasourceAddress().toModelNode());
removeOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
try {
execute(removeOperation);
} catch (MgmtOperationException moe) {
// ignore
}
}
private void addXADatasource(final Scenario scenario) throws IOException, MgmtOperationException {
final ModelNode addOperation = Operations.createAddOperation(scenario.getXADatasourceAddress().toModelNode());
addOperation.get("jndi-name").set(scenario.getDatasourceJndiName());
addOperation.get("driver-name").set("h2");
addOperation.get("user-name").set("sa");
addOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
ModelNode credentialReference = null;
switch (scenario) {
case PASSWORD_AND_CREDENTIAL_REFERENCE_PREFERENCE:
addOperation.get("password").set("wrong-password");
credentialReference = addOperation.get(CREDENTIAL_REFERENCE).setEmptyObject();
credentialReference.get("clear-text").set(DATABASE_PASSWORD);
break;
case CREDENTIAL_REFERENCE_CLEAR_TEXT:
credentialReference = addOperation.get(CREDENTIAL_REFERENCE).setEmptyObject();
credentialReference.get("clear-text").set(DATABASE_PASSWORD);
break;
case CREDENTIAL_REFERENCE_STORE_ALIAS:
credentialReference = addOperation.get(CREDENTIAL_REFERENCE).setEmptyObject();
credentialReference.get("store").set("store001");
credentialReference.get("alias").set("alias001");
break;
}
final PathAddress urlXADatasourcePropertyAddress = scenario.getXADatasourceAddress().append("xa-datasource-properties", "URL");
final ModelNode addURLDatasourcePropertyOperation = Operations.createAddOperation(urlXADatasourcePropertyAddress.toModelNode());
addURLDatasourcePropertyOperation.get("value").set("jdbc:h2:tcp://" + Utils.getSecondaryTestAddress(client) + "/mem:" + CredentialReferenceDatasourceTestCase.class.getName());
ModelNode compositeOperation = Operations.createCompositeOperation();
compositeOperation.get(ModelDescriptionConstants.STEPS).add(addOperation);
compositeOperation.get(ModelDescriptionConstants.STEPS).add(addURLDatasourcePropertyOperation);
execute(compositeOperation);
}
private void removeXADatasourceSilently(final Scenario scenario) throws IOException {
final ModelNode removeOperation = Operations.createRemoveOperation(scenario.getXADatasourceAddress().toModelNode());
removeOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
try {
execute(removeOperation);
} catch (MgmtOperationException moe) {
// ignore
}
}
private ModelNode execute(final ModelNode op) throws IOException, MgmtOperationException {
final ModelNode result = client.getControllerClient().execute(op);
if (!Operations.isSuccessfulOutcome(result)) {
throw new MgmtOperationException(Operations.getFailureDescription(result).asString());
}
return result;
}
public static class DatasourceServerSetupTask implements ServerSetupTask {
private Server h2Server;
private Connection connection;
@Override
public void setup(ManagementClient managementClient, String s) throws Exception {
h2Server = Server.createTcpServer("-tcpAllowOthers").start();
// open connection to database, because that's only (easy) way to set password for user sa
connection = DriverManager.getConnection("jdbc:h2:mem:" + CredentialReferenceDatasourceTestCase.class.getName() + ";DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE", "sa", DATABASE_PASSWORD);
}
@Override
public void tearDown(ManagementClient managementClient, String s) throws Exception {
connection.close();
h2Server.shutdown();
}
}
}
| 13,496 | 44.908163 | 196 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/credentialreference/CredentialStoreServerSetupTask.java
|
/*
Copyright 2017 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.jboss.as.test.integration.security.credentialreference;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RELATIVE_TO;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import static org.jboss.as.controller.security.CredentialReference.CREDENTIAL_REFERENCE;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
/**
* @author Martin Simka
*/
public class CredentialStoreServerSetupTask implements ServerSetupTask {
private static final PathAddress CREDENTIAL_STORE_ADDRESS = PathAddress.pathAddress(SUBSYSTEM, "elytron").append("credential-store", "store001");
@Override
public void setup(ManagementClient managementClient, String s) throws Exception {
final ModelControllerClient client = managementClient.getControllerClient();
createCredentialStore(client);
createAlias(client);
}
@Override
public void tearDown(ManagementClient managementClient, String s) throws Exception {
final ModelNode removeOperation = Operations.createRemoveOperation(CREDENTIAL_STORE_ADDRESS.toModelNode());
removeOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
execute(managementClient.getControllerClient(), removeOperation);
Files.deleteIfExists(Paths.get(resolveJbossServerDataDir(managementClient.getControllerClient()), "store001.jceks"));
}
private void createCredentialStore(final ModelControllerClient client) throws IOException {
final ModelNode addOperation = Operations.createAddOperation(CREDENTIAL_STORE_ADDRESS.toModelNode());
addOperation.get("create").set("true");
addOperation.get("modifiable").set("true");
addOperation.get("location").set("store001.jceks");
addOperation.get(RELATIVE_TO).set("jboss.server.data.dir");
final ModelNode credentialReference = addOperation.get(CREDENTIAL_REFERENCE).setEmptyObject();
credentialReference.get("clear-text").set("joshua");
execute(client, addOperation);
}
private void createAlias(final ModelControllerClient client) throws IOException {
final ModelNode addOperation = Operations.createOperation("add-alias", CREDENTIAL_STORE_ADDRESS.toModelNode());
addOperation.get("alias").set("alias001");
addOperation.get("secret-value").set("chucknorris");
execute(client, addOperation);
}
private ModelNode execute(final ModelControllerClient client, final ModelNode op) throws IOException {
final ModelNode result = client.execute(op);
if (!Operations.isSuccessfulOutcome(result)) {
throw new RuntimeException(Operations.getFailureDescription(result).asString());
}
return result;
}
private String resolveJbossServerDataDir(final ModelControllerClient client) throws IOException {
ModelNode operation = Operations.createOperation("resolve-expression");
operation.get("expression").set("${jboss.server.data.dir}");
ModelNode result = execute(client, operation);
return Operations.readResult(result).asString();
}
}
| 4,152 | 45.144444 | 149 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/security/securitycontext/MyServletExtension.java
|
/*
Copyright 2018 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.jboss.as.test.integration.security.securitycontext;
import jakarta.servlet.ServletContext;
import io.undertow.server.HttpHandler;
import io.undertow.servlet.ServletExtension;
import io.undertow.servlet.api.DeploymentInfo;
public class MyServletExtension
implements ServletExtension {
private static final HttpHandler myTokenHandler = new MyDummyTokenHandler();
@Override
public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {
deploymentInfo.addSecurityWrapper(nextHandler -> exchange -> {
myTokenHandler.handleRequest(exchange);
nextHandler.handleRequest(exchange);
});
}
}
| 1,253 | 32 | 96 |
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.