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/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/cdi/RequestScopedCDIBean.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.mdb.cdi;
import jakarta.enterprise.context.RequestScoped;
/**
* @author Stuart Douglas
*/
@RequestScoped
public class RequestScopedCDIBean {
public String sayHello() {
return CdiIntegrationMDB.REPLY;
}
}
| 1,284 | 33.72973 | 73 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/cdi/MDBProxy.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.ejb.mdb.cdi;
import jakarta.ejb.Remote;
/**
* @author baranowb
*
*/
@Remote
public interface MDBProxy {
String REPLY_QUEUE_JNDI_NAME = "java:/mdb-cdi-test/replyQueue";
String QUEUE_JNDI_NAME = "java:/mdb-cdi-test/mdb-cdi-test";
void trigger() throws Exception;
}
| 1,344 | 33.487179 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/cdi/CdiIntegrationMDB.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.ejb.mdb.cdi;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.EJB;
import jakarta.ejb.MessageDriven;
import jakarta.inject.Inject;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import org.jboss.as.test.integration.ejb.mdb.JMSMessagingUtil;
import org.jboss.logging.Logger;
/**
* User: jpai
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destination", propertyValue = MDBCdiIntegrationTestCase.QUEUE_JNDI_NAME)
})
public class CdiIntegrationMDB implements MessageListener {
private static final Logger logger = Logger.getLogger(CdiIntegrationMDB.class);
public static final String REPLY = "Successful message delivery!";
@EJB
private JMSMessagingUtil jmsMessagingUtil;
@Inject
private RequestScopedCDIBean requestScopedCDIBean;
@Override
public void onMessage(Message message) {
logger.trace("Received message " + message);
try {
if (message.getJMSReplyTo() != null) {
logger.trace("Replying to " + message.getJMSReplyTo());
// send a reply
this.jmsMessagingUtil.sendTextMessage(requestScopedCDIBean.sayHello(), message.getJMSReplyTo(), null);
}
} catch (JMSException jmse) {
throw new RuntimeException(jmse);
}
}
}
| 2,449 | 34 | 122 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/cdi/MDBProxyBean.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.ejb.mdb.cdi;
import jakarta.annotation.Resource;
import jakarta.ejb.EJB;
import jakarta.ejb.Stateless;
import jakarta.jms.Message;
import jakarta.jms.Queue;
import jakarta.jms.TextMessage;
import org.jboss.as.test.integration.ejb.mdb.JMSMessagingUtil;
import org.junit.Assert;
/**
* @author baranowb
*
*/
@Stateless()
public class MDBProxyBean implements MDBProxy{
@EJB(mappedName = "java:module/JMSMessagingUtil")
private JMSMessagingUtil jmsUtil;
@Resource(mappedName = REPLY_QUEUE_JNDI_NAME)
private Queue replyQueue;
@Resource(mappedName = QUEUE_JNDI_NAME)
private Queue queue;
@Override
public void trigger() throws Exception {
final String goodMorning = "Good morning";
// send as ObjectMessage
// this.jmsUtil = (JMSMessagingUtil) getInitialContext().lookup(getEJBJNDIBinding());
this.jmsUtil.sendTextMessage(goodMorning, this.queue, this.replyQueue);
// wait for an reply
final Message reply = this.jmsUtil.receiveMessage(replyQueue, 5000);
// test the reply
final TextMessage textMessage = (TextMessage) reply;
Assert.assertEquals("Unexpected reply message on reply queue: " + this.replyQueue, CdiIntegrationMDB.REPLY,
textMessage.getText());
}
}
| 2,351 | 35.75 | 115 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/cmt/notsupported/BaseMDB.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.integration.ejb.mdb.cmt.notsupported;
import static org.jboss.as.test.integration.ejb.mdb.cmt.notsupported.ContainerManagedTransactionNotSupportedTestCase.EXCEPTION_PROP_NAME;
import jakarta.annotation.Resource;
import jakarta.ejb.MessageDrivenContext;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.JMSContext;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import org.jboss.logging.Logger;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
public abstract class BaseMDB implements MessageListener {
private static final Logger logger = Logger.getLogger(BaseMDB.class);
@Resource(lookup="java:comp/DefaultJMSConnectionFactory")
private ConnectionFactory cf;
@Resource
protected MessageDrivenContext messageDrivenContext;
@Override
public void onMessage(Message message) {
logger.trace("Received message: " + message);
boolean setRollbackOnlyThrowsIllegalStateException;
try {
// this method in a Container-managed MDB with transaction NOT_SUPPORTED must throw an exception
messageDrivenContext.setRollbackOnly();
setRollbackOnlyThrowsIllegalStateException = false;
} catch (IllegalStateException e) {
setRollbackOnlyThrowsIllegalStateException = true;
}
try {
final Destination replyTo = message.getJMSReplyTo();
if (replyTo != null) {
logger.trace("Replying to " + replyTo);
try (
JMSContext context = cf.createContext()
) {
context.createProducer()
.setJMSCorrelationID(message.getJMSMessageID())
.setProperty(EXCEPTION_PROP_NAME, setRollbackOnlyThrowsIllegalStateException)
.send(replyTo, "");
}
}
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
}
| 3,140 | 36.843373 | 137 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/cmt/notsupported/ContainerManagedTransactionNotSupportedMDBWithAnnotation.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.ejb.mdb.cmt.notsupported;
import static jakarta.ejb.TransactionAttributeType.NOT_SUPPORTED;
import static jakarta.ejb.TransactionManagementType.CONTAINER;
import static org.jboss.as.test.integration.ejb.mdb.cmt.notsupported.ContainerManagedTransactionNotSupportedTestCase.QUEUE_JNDI_NAME_FOR_ANNOTATION;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionManagement;
import jakarta.jms.Message;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
@TransactionManagement(CONTAINER)
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = QUEUE_JNDI_NAME_FOR_ANNOTATION)
})
public class ContainerManagedTransactionNotSupportedMDBWithAnnotation extends BaseMDB {
@TransactionAttribute(NOT_SUPPORTED)
@Override
public void onMessage(Message message) {
super.onMessage(message);
}
}
| 2,068 | 40.38 | 148 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/cmt/notsupported/ContainerManagedTransactionNotSupportedMDBWithDD.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.ejb.mdb.cmt.notsupported;
import jakarta.jms.Message;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
public class ContainerManagedTransactionNotSupportedMDBWithDD extends BaseMDB {
@Override
public void onMessage(Message message) {
super.onMessage(message);
}
}
| 1,387 | 36.513514 | 79 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/cmt/notsupported/ContainerManagedTransactionNotSupportedTestCase.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.ejb.mdb.cmt.notsupported;
import static org.jboss.as.test.shared.TimeoutUtil.adjust;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.PropertyPermission;
import java.util.UUID;
import jakarta.annotation.Resource;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.JMSContext;
import jakarta.jms.Message;
import jakarta.jms.Queue;
import jakarta.jms.TemporaryQueue;
import jakarta.jms.TextMessage;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.shrinkwrap.api.Archive;
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="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
@RunWith(Arquillian.class)
@ServerSetup({ContainerManagedTransactionNotSupportedTestCase.JmsQueueSetup.class})
public class ContainerManagedTransactionNotSupportedTestCase {
public static final String QUEUE_JNDI_NAME_FOR_ANNOTATION = "java:jboss/queue/cmt-not-supported-annotation";
public static final String QUEUE_JNDI_NAME_FOR_DD = "java:jboss/queue/cmt-not-supported-dd";
public static final String EXCEPTION_PROP_NAME = "setRollbackOnlyThrowsIllegalStateException";
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient);
jmsAdminOperations.createJmsQueue("ContainerManagedTransactionNotSupportedTestCaseQueueWithAnnotation", QUEUE_JNDI_NAME_FOR_ANNOTATION);
jmsAdminOperations.createJmsQueue("ContainerManagedTransactionNotSupportedTestCaseQueueWithDD", QUEUE_JNDI_NAME_FOR_DD);
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsQueue("ContainerManagedTransactionNotSupportedTestCaseQueueWithAnnotation");
jmsAdminOperations.removeJmsQueue("ContainerManagedTransactionNotSupportedTestCaseQueueWithDD");
jmsAdminOperations.close();
}
}
}
@Resource(mappedName = QUEUE_JNDI_NAME_FOR_ANNOTATION)
private Queue queueForAnnotation;
@Resource(mappedName = QUEUE_JNDI_NAME_FOR_DD)
private Queue queueForDD;
@Resource(mappedName = "java:/ConnectionFactory")
private ConnectionFactory cf;
@Deployment
public static Archive createDeployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ContainerManagedTransactionNotSupportedTestCase.jar");
jar.addPackage(JMSOperations.class.getPackage());
jar.addClasses(TimeoutUtil.class);
jar.addPackage(BaseMDB.class.getPackage());
jar.addAsManifestResource(ContainerManagedTransactionNotSupportedMDBWithDD.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
// grant necessary permissions
jar.addAsResource(createPermissionsXmlAsset(new PropertyPermission("ts.timeout.factor", "read")), "META-INF/jboss-permissions.xml");
return jar;
}
/**
* Test that the {@link jakarta.ejb.MessageDrivenContext#setRollbackOnly()} throws an IllegalStateException
* when a CMT MDB with NOT_SUPPORTED transaction attribute is invoked.
*
* @throws Exception
*/
@Test
public void testSetRollbackOnlyInContainerManagedTransactionNotSupportedMDBThrowsIllegalStateExceptionWithAnnotation() throws Exception {
doSetRollbackOnlyInContainerManagedTransactionNotSupportedMDBThrowsIllegalStateException(queueForAnnotation);
}
@Test
public void testSetRollbackOnlyInContainerManagedTransactionNotSupportedMDBThrowsIllegalStateExceptionWithDD() throws Exception {
doSetRollbackOnlyInContainerManagedTransactionNotSupportedMDBThrowsIllegalStateException(queueForDD);
}
private void doSetRollbackOnlyInContainerManagedTransactionNotSupportedMDBThrowsIllegalStateException(Destination destination) throws Exception {
try (
JMSContext context = cf.createContext()
) {
TemporaryQueue replyTo = context.createTemporaryQueue();
String text = UUID.randomUUID().toString();
TextMessage message = context.createTextMessage(text);
message.setJMSReplyTo(replyTo);
context.createProducer()
.send(destination, message);
Message reply = context.createConsumer(replyTo)
.receive(adjust(5000));
assertNotNull(reply);
assertEquals(message.getJMSMessageID(), reply.getJMSCorrelationID());
assertTrue("messageDrivenContext.setRollbackOnly() did not throw the expected IllegalStateException",
reply.getBooleanProperty(EXCEPTION_PROP_NAME));
}
}
}
| 6,707 | 43.131579 | 149 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/deliveryactive/MDBWithDeliveryActiveAnnotation.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright (c) 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.integration.ejb.mdb.deliveryactive;
import static org.jboss.as.test.integration.ejb.mdb.deliveryactive.ReplyUtil.reply;
import jakarta.annotation.Resource;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import org.jboss.ejb3.annotation.DeliveryActive;
/**
* A MDB deployed with deliveryActive set to false using annotations.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/deliveryactive/MDBWithAnnotationQueue"),
})
// Do not deliver messages to this MDB until start-delivery management operation is explicitly called on it.
@DeliveryActive(false)
public class MDBWithDeliveryActiveAnnotation implements MessageListener {
@Resource(lookup = "java:/JmsXA")
private ConnectionFactory factory;
@Override
public void onMessage(Message message) {
reply(factory, message);
}
}
| 2,160 | 38.290909 | 132 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/deliveryactive/MDBTestCase.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.integration.ejb.mdb.deliveryactive;
import static org.jboss.as.controller.client.helpers.ClientConstants.NAME;
import static org.jboss.as.controller.client.helpers.ClientConstants.OP;
import static org.jboss.as.controller.client.helpers.ClientConstants.OP_ADDR;
import static org.jboss.as.controller.client.helpers.ClientConstants.OUTCOME;
import static org.jboss.as.controller.client.helpers.ClientConstants.READ_ATTRIBUTE_OPERATION;
import static org.jboss.as.controller.client.helpers.ClientConstants.RESULT;
import static org.jboss.as.controller.client.helpers.ClientConstants.SUCCESS;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import java.io.FilePermission;
import java.io.IOException;
import java.util.PropertyPermission;
import jakarta.annotation.Resource;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.Message;
import jakarta.jms.MessageConsumer;
import jakarta.jms.MessageProducer;
import jakarta.jms.Queue;
import jakarta.jms.Session;
import jakarta.jms.TemporaryQueue;
import org.jboss.arquillian.container.test.api.Deployment;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import org.jboss.remoting3.security.RemotingPermission;
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.Test;
import org.junit.runner.RunWith;
/**
* Tests MDB DeliveryActive property + management methods to start/stop delivering messages.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
@RunWith(Arquillian.class)
@ServerSetup({MDBTestCase.JmsQueueSetup.class})
public class MDBTestCase {
private static final Logger logger = Logger.getLogger(MDBTestCase.class);
@Resource(mappedName = "java:/ConnectionFactory")
private ConnectionFactory cf;
@Resource(mappedName = "java:jboss/deliveryactive/MDBWithAnnotationQueue")
private Queue annotationQueue;
@Resource(mappedName = "java:jboss/deliveryactive/MDBWithDeploymentDescriptorQueue")
private Queue deploymentDescriptorQueue;
@ArquillianResource
private ManagementClient managementClient;
private static final int TIMEOUT = TimeoutUtil.adjust(5000);
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient);
jmsAdminOperations.createJmsQueue("deliveryactive/MDBWithAnnotationQueue", "java:jboss/deliveryactive/MDBWithAnnotationQueue");
jmsAdminOperations.createJmsQueue("deliveryactive/MDBWithDeploymentDescriptorQueue", "java:jboss/deliveryactive/MDBWithDeploymentDescriptorQueue");
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsQueue("deliveryactive/MDBWithAnnotationQueue");
jmsAdminOperations.removeJmsQueue("deliveryactive/MDBWithDeploymentDescriptorQueue");
jmsAdminOperations.close();
}
}
}
@Deployment
public static Archive getDeployment() {
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "mdb.jar")
.addPackage(MDBWithDeliveryActiveAnnotation.class.getPackage())
.addPackage(JMSOperations.class.getPackage())
.addClass(TimeoutUtil.class)
.addAsManifestResource(MDBWithDeliveryActiveAnnotation.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml")
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client, org.jboss.dmr, org.jboss.remoting\n"), "MANIFEST.MF");
// grant necessary permissions
ejbJar.addAsManifestResource(createPermissionsXmlAsset(
new PropertyPermission("ts.timeout.factor", "read"),
new RemotingPermission("createEndpoint"),
new RemotingPermission("connect"),
new FilePermission(System.getProperty("jboss.inst") + "/standalone/tmp/auth/*", "read")
), "permissions.xml");
return ejbJar;
}
@Test
public void testDeliveryActiveWithAnnotation() throws Exception {
doDeliveryActive(annotationQueue, "MDBWithDeliveryActiveAnnotation");
}
@Test
public void testDeliveryActiveWithDeploymentDescriptor() throws Exception {
doDeliveryActive(deploymentDescriptorQueue, "MDBWithDeliveryActiveDeploymentDescriptor");
}
private void doDeliveryActive(Destination destination, String mdbName) throws Exception {
// ReplyingMDB has been deployed with deliveryActive set to false
assertMDBDeliveryIsActive(mdbName, false);
Connection connection = null;
try {
connection = cf.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
TemporaryQueue replyQueue = session.createTemporaryQueue();
// send a message to the MDB
MessageProducer producer = session.createProducer(destination);
Message message = session.createMessage();
message.setJMSReplyTo(replyQueue);
producer.send(message);
// the MDB did not reply to the message because its delivery is not active
MessageConsumer consumer = session.createConsumer(replyQueue);
Message reply = consumer.receive(TIMEOUT);
assertNull(reply);
executeMDBOperation(mdbName, "start-delivery");
assertMDBDeliveryIsActive(mdbName, true);
// WFLY-4470 check duplicate message when start delivery twice. Last assertNull(reply) should still be valid
executeMDBOperation(mdbName, "start-delivery");
// the message was delivered to the MDB which replied
reply = consumer.receive(TIMEOUT);
assertNotNull(reply);
assertEquals(message.getJMSMessageID(), reply.getJMSCorrelationID());
executeMDBOperation(mdbName, "stop-delivery");
assertMDBDeliveryIsActive(mdbName, false);
// send again a message to the MDB
message = session.createMessage();
message.setJMSReplyTo(replyQueue);
producer.send(message);
// the MDB did not reply to the message because its delivery is not active
reply = consumer.receive(TIMEOUT);
assertNull(reply);
} finally {
if (connection != null) {
connection.close();
}
}
}
private void executeMDBOperation(String mdbName, String opName) throws IOException {
ModelNode operation = createMDBOperation(mdbName);
operation.get(OP).set(opName);
ModelNode result = managementClient.getControllerClient().execute(operation);
assertTrue(result.toJSONString(true), result.hasDefined(OUTCOME));
assertEquals(result.toJSONString(true), SUCCESS, result.get(OUTCOME).asString());
}
private void assertMDBDeliveryIsActive(String mdbName, boolean expected) throws IOException {
ModelNode operation = createMDBOperation(mdbName);
operation.get(OP).set(READ_ATTRIBUTE_OPERATION);
operation.get(NAME).set("delivery-active");
ModelNode result = managementClient.getControllerClient().execute(operation);
assertTrue(result.toJSONString(true), result.hasDefined(OUTCOME));
assertEquals(result.toJSONString(true), expected, result.get(RESULT).asBoolean());
}
private ModelNode createMDBOperation(String mdbName) {
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).add("deployment", "mdb.jar");
operation.get(OP_ADDR).add("subsystem", "ejb3");
operation.get(OP_ADDR).add("message-driven-bean", mdbName);
return operation;
}
}
| 9,967 | 43.302222 | 159 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/deliveryactive/MDBWithDeliveryActiveDeploymentDescriptor.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright (c) 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.integration.ejb.mdb.deliveryactive;
import static org.jboss.as.test.integration.ejb.mdb.deliveryactive.ReplyUtil.reply;
import jakarta.annotation.Resource;
import jakarta.ejb.MessageDriven;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
/**
* A MDB deployed with deliveryActive set to false in the deployment description.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
@MessageDriven
public class MDBWithDeliveryActiveDeploymentDescriptor implements MessageListener {
@Resource(lookup = "java:/JmsXA")
private ConnectionFactory factory;
@Override
public void onMessage(Message message) {
reply(factory, message);
}
}
| 1,797 | 37.255319 | 83 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/deliveryactive/ReplyUtil.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.integration.ejb.mdb.deliveryactive;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageProducer;
import jakarta.jms.Session;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
public class ReplyUtil {
public static void reply(ConnectionFactory factory, Message message) {
Connection connection = null;
try {
connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
final Destination destination = message.getJMSReplyTo();
// ignore messages that need no reply
if (destination == null)
return;
final MessageProducer replyProducer = session.createProducer(destination);
final Message replyMsg = session.createMessage();
replyMsg.setJMSCorrelationID(message.getJMSMessageID());
replyProducer.send(replyMsg);
replyProducer.close();
} catch (JMSException e) {
throw new RuntimeException(e);
} finally {
if (connection != null) {
try {
connection.close();
} catch (JMSException e) {
}
}
}
}
}
| 2,461 | 38.079365 | 88 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/objectmessage/MDBAcceptingObjectMessage.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.ejb.mdb.objectmessage;
import org.jboss.as.test.integration.ejb.mdb.JMSMessagingUtil;
import org.jboss.logging.Logger;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.EJB;
import jakarta.ejb.MessageDriven;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import jakarta.jms.ObjectMessage;
/**
* User: jpai
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destination", propertyValue = MDBAcceptingObjectMessage.QUEUE_JNDI_NAME)
})
public class MDBAcceptingObjectMessage implements MessageListener {
private static final Logger logger = Logger.getLogger(MDBAcceptingObjectMessage.class);
public static final String QUEUE_JNDI_NAME = "java:jboss/jms/mdbtest/objectmessage-queue";
@EJB
private JMSMessagingUtil jmsMessagingUtil;
@Override
public void onMessage(Message message) {
logger.trace("Received message: " + message);
if (message instanceof ObjectMessage == false) {
throw new RuntimeException(this.getClass().getName() + " only accepts ObjectMessage. " + message + " isn't an ObjectMessage");
}
try {
// get the underlying message
SimpleMessageInEarLibJar underlyingMessage = (SimpleMessageInEarLibJar) ((ObjectMessage) message).getObject();
if (message.getJMSReplyTo() != null) {
logger.trace("Replying to " + message.getJMSReplyTo());
// create an ObjectMessage as a reply and send it to the reply queue
this.jmsMessagingUtil.sendObjectMessage(underlyingMessage, message.getJMSReplyTo(), null);
}
} catch (JMSException jmse) {
throw new RuntimeException(jmse);
}
}
}
| 2,847 | 39.112676 | 138 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/objectmessage/MDBAcceptingObjectMessageOfArrayType.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.ejb.mdb.objectmessage;
import org.jboss.as.test.integration.ejb.mdb.JMSMessagingUtil;
import org.jboss.logging.Logger;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.EJB;
import jakarta.ejb.MessageDriven;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import jakarta.jms.ObjectMessage;
/**
* User: jpai
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destination", propertyValue = MDBAcceptingObjectMessageOfArrayType.QUEUE_JNDI_NAME)
})
public class MDBAcceptingObjectMessageOfArrayType implements MessageListener {
private static final Logger logger = Logger.getLogger(MDBAcceptingObjectMessageOfArrayType.class);
public static final String QUEUE_JNDI_NAME = "java:jboss/jms/mdbtest/objectmessage-array-queue";
@EJB
private JMSMessagingUtil jmsMessagingUtil;
@Override
public void onMessage(Message message) {
logger.trace("Received message: " + message);
if (message instanceof ObjectMessage == false) {
throw new RuntimeException(this.getClass().getName() + " only accepts ObjectMessage. " + message + " isn't an ObjectMessage");
}
try {
// get the underlying message
SimpleMessageInEarLibJar[] underlyingMessage = (SimpleMessageInEarLibJar[]) ((ObjectMessage) message).getObject();
if (message.getJMSReplyTo() != null) {
logger.trace("Replying to " + message.getJMSReplyTo());
// create an ObjectMessage as a reply and send it to the reply queue
this.jmsMessagingUtil.sendObjectMessage(underlyingMessage, message.getJMSReplyTo(), null);
}
} catch (JMSException jmse) {
throw new RuntimeException(jmse);
}
}
}
| 2,890 | 39.71831 | 138 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/objectmessage/SimpleMessageInEarLibJar.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.ejb.mdb.objectmessage;
import static org.wildfly.common.Assert.checkNotNullParam;
import java.io.Serializable;
/**
* User: jpai
*/
public class SimpleMessageInEarLibJar implements Serializable {
private final String msg;
public SimpleMessageInEarLibJar(String msg) {
this.msg = checkNotNullParam("msg", msg);
}
public String getMessage() {
return this.msg;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SimpleMessageInEarLibJar that = (SimpleMessageInEarLibJar) o;
return msg.equals(that.msg);
}
@Override
public int hashCode() {
return msg.hashCode();
}
}
| 1,819 | 29.333333 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/objectmessage/unit/ObjectMessageTestCase.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.ejb.mdb.objectmessage.unit;
import java.util.Arrays;
import java.util.PropertyPermission;
import jakarta.annotation.Resource;
import jakarta.ejb.EJB;
import jakarta.jms.Message;
import jakarta.jms.ObjectMessage;
import jakarta.jms.Queue;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.integration.ejb.mdb.JMSMessagingUtil;
import org.jboss.as.test.integration.ejb.mdb.objectmessage.MDBAcceptingObjectMessage;
import org.jboss.as.test.integration.ejb.mdb.objectmessage.MDBAcceptingObjectMessageOfArrayType;
import org.jboss.as.test.integration.ejb.mdb.objectmessage.SimpleMessageInEarLibJar;
import org.jboss.as.test.shared.TimeoutUtil;
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.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
/**
* Tests that a MDB can get hold of the underlying Object from a {@link ObjectMessage} without any classloading issues.
* <p/>
* User: Jaikiran Pai
*/
@RunWith(Arquillian.class)
@ServerSetup({ObjectMessageTestCase.JmsQueueSetup.class})
public class ObjectMessageTestCase {
private static final String OBJECT_MESSAGE_ARRAY_TYPE_REPLY_QUEUE_JNDI_NAME = "java:jboss/jms/mdbtest/objectmessage-array-reply-queue";
private static final String OBJECT_MESSAGE_REPLY_QUEUE_JNDI_NAME = "java:jboss/jms/mdbtest/objectmessage-reply-queue";
@EJB(mappedName = "java:module/JMSMessagingUtil")
private JMSMessagingUtil jmsUtil;
@Resource(mappedName = MDBAcceptingObjectMessageOfArrayType.QUEUE_JNDI_NAME)
private Queue objectMessageOfArrayTypeQueue;
@Resource(mappedName = ObjectMessageTestCase.OBJECT_MESSAGE_ARRAY_TYPE_REPLY_QUEUE_JNDI_NAME)
private Queue objectMessageOfArrayTypeReplyQueue;
@Resource(mappedName = MDBAcceptingObjectMessage.QUEUE_JNDI_NAME)
private Queue objectMessageQueue;
@Resource(mappedName = ObjectMessageTestCase.OBJECT_MESSAGE_REPLY_QUEUE_JNDI_NAME)
private Queue objectMessageReplyQueue;
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsAdminOperations.createJmsQueue("mdbtest/objectmessage-queue", MDBAcceptingObjectMessage.QUEUE_JNDI_NAME);
jmsAdminOperations.createJmsQueue("mdbtest/objectmessage-replyQueue", OBJECT_MESSAGE_REPLY_QUEUE_JNDI_NAME);
jmsAdminOperations.createJmsQueue("mdbtest/objectmessage-array-queue", MDBAcceptingObjectMessageOfArrayType.QUEUE_JNDI_NAME);
jmsAdminOperations.createJmsQueue("mdbtest/objectmessage-array-replyQueue", OBJECT_MESSAGE_ARRAY_TYPE_REPLY_QUEUE_JNDI_NAME);
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsQueue("mdbtest/objectmessage-queue");
jmsAdminOperations.removeJmsQueue("mdbtest/objectmessage-replyQueue");
jmsAdminOperations.removeJmsQueue("mdbtest/objectmessage-array-queue");
jmsAdminOperations.removeJmsQueue("mdbtest/objectmessage-array-replyQueue");
jmsAdminOperations.close();
}
}
}
/**
* .ear
* |
* |--- ejb.jar
* | |--- <classes including the MDB>
* |
* |--- lib
* | |
* | |--- util.jar
* | | |
* | | |--- <classes including the Class whose object is wrapped in an ObjectMessage>
*
* @return
*/
@Deployment
public static Archive getDeployment() {
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejb.jar");
ejbJar.addClasses(MDBAcceptingObjectMessageOfArrayType.class, JMSMessagingUtil.class, ObjectMessageTestCase.class,
MDBAcceptingObjectMessage.class, TimeoutUtil.class);
final JavaArchive libJar = ShrinkWrap.create(JavaArchive.class, "util.jar");
libJar.addClasses(SimpleMessageInEarLibJar.class);
libJar.addPackage(JMSOperations.class.getPackage());
libJar.addClass(JmsQueueSetup.class);
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "mdb-objectmessage-test.ear");
ear.addAsModule(ejbJar);
ear.addAsLibraries(libJar);
ear.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client, org.jboss.dmr \n"), "MANIFEST.MF");
ear.addAsManifestResource(createPermissionsXmlAsset(
new PropertyPermission(TimeoutUtil.FACTOR_SYS_PROP, "read")), "permissions.xml");
return ear;
}
/**
* Test that the MDB can process a {@link ObjectMessage} which consists of an array of objects,
* without any classloading issues
*
* @throws Exception
*/
@Test
public void testObjectMessageWithObjectArray() throws Exception {
final String goodMorning = "Good morning";
final String goodEvening = "Good evening";
// create the message
final SimpleMessageInEarLibJar[] multipleGreetings = new SimpleMessageInEarLibJar[2];
final SimpleMessageInEarLibJar messageOne = new SimpleMessageInEarLibJar(goodMorning);
final SimpleMessageInEarLibJar messageTwo = new SimpleMessageInEarLibJar(goodEvening);
multipleGreetings[0] = messageOne;
multipleGreetings[1] = messageTwo;
// send as ObjectMessage
this.jmsUtil.sendObjectMessage(multipleGreetings, this.objectMessageOfArrayTypeQueue, this.objectMessageOfArrayTypeReplyQueue);
// wait for an reply
final Message reply = this.jmsUtil.receiveMessage(objectMessageOfArrayTypeReplyQueue, 5000);
// test the reply
Assert.assertNotNull("Reply message was null on reply queue: " + this.objectMessageOfArrayTypeReplyQueue, reply);
final SimpleMessageInEarLibJar[] replyMessage = (SimpleMessageInEarLibJar[]) ((ObjectMessage) reply).getObject();
Assert.assertTrue("Unexpected reply message on reply queue: " + this.objectMessageOfArrayTypeReplyQueue, Arrays.equals(replyMessage, multipleGreetings));
}
/**
* Test that the MDB can process a {@link ObjectMessage} without any classloading issues
*
* @throws Exception
*/
@Test
public void testObjectMessage() throws Exception {
final String goodAfternoon = "Good afternoon!";
// create the message
final SimpleMessageInEarLibJar message = new SimpleMessageInEarLibJar(goodAfternoon);
// send as ObjectMessage
this.jmsUtil.sendObjectMessage(message, this.objectMessageQueue, this.objectMessageReplyQueue);
// wait for an reply
final Message reply = this.jmsUtil.receiveMessage(objectMessageReplyQueue, 5000);
// test the reply
Assert.assertNotNull("Reply message was null on reply queue: " + this.objectMessageReplyQueue, reply);
final SimpleMessageInEarLibJar replyMessage = (SimpleMessageInEarLibJar) ((ObjectMessage) reply).getObject();
Assert.assertEquals("Unexpected reply message on reply queue: " + this.objectMessageReplyQueue, message, replyMessage);
}
}
| 9,090 | 45.147208 | 161 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationconfig/MDBWithLookupActivationConfigProperties.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.ejb.mdb.activationconfig;
import static org.jboss.as.test.integration.ejb.mdb.activationconfig.JMSHelper.reply;
import jakarta.annotation.Resource;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
/**
* This message-driven bean does not implement MessageListener interface; instead
* it is specified with {@code messageListenerInterface} annotation.
*/
@MessageDriven (messageListenerInterface=MessageListener.class,
activationConfig = {
@ActivationConfigProperty(propertyName = "connectionFactoryLookup", propertyValue = "java:/ConnectionFactory"),
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = MDBWithLookupActivationConfigProperties.QUEUE_JNDI_NAME),
})
public class MDBWithLookupActivationConfigProperties {
public static final String QUEUE_JNDI_NAME = "java:jboss/jms/mdbtest/MDBWithLookupActivationConfigProperties";
@Resource(mappedName = "java:/ConnectionFactory")
private ConnectionFactory connectionFactory;
public void onMessage(Message message) {
reply(connectionFactory, message);
}
}
| 2,284 | 42.113208 | 143 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationconfig/MDBWithUnknownActivationConfigProperties.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.ejb.mdb.activationconfig;
import static org.jboss.as.test.integration.ejb.mdb.activationconfig.JMSHelper.reply;
import jakarta.annotation.Resource;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
/**
* User: jpai
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destination", propertyValue = MDBWithUnknownActivationConfigProperties.QUEUE_JNDI_NAME),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "jakarta.jms.Queue"),
@ActivationConfigProperty(propertyName = "foo", propertyValue = "bar") // activation config properties which aren't supported by the resource adapter
})
public class MDBWithUnknownActivationConfigProperties implements MessageListener {
public static final String QUEUE_JNDI_NAME = "java:jboss/jms/mdbtest/unknown-activationconfig-props";
@Resource(mappedName = "java:/ConnectionFactory")
private ConnectionFactory connectionFactory;
@Override
public void onMessage(Message message) {
reply(connectionFactory, message);
}
}
| 2,263 | 40.925926 | 157 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationconfig/JMSHelper.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.integration.ejb.mdb.activationconfig;
import static jakarta.jms.Session.AUTO_ACKNOWLEDGE;
import static org.junit.Assert.assertEquals;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.JMSContext;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.TemporaryQueue;
import jakarta.jms.TextMessage;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.logging.Logger;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2013 Red Hat inc.
*/
public class JMSHelper {
private static final Logger logger = Logger.getLogger(MDBWithLookupActivationConfigProperties.class);
public static void assertSendAndReceiveTextMessage(ConnectionFactory cf, Destination destination, String text) throws JMSException {
try(
JMSContext context = cf.createContext(AUTO_ACKNOWLEDGE)
) {
TemporaryQueue replyTo = context.createTemporaryQueue();
context.createProducer()
.setJMSReplyTo(replyTo)
.send(destination, text);
String replyText = context.createConsumer(replyTo)
.receiveBody(String.class, TimeoutUtil.adjust(5000));
assertEquals(text, replyText);
}
}
public static void reply(ConnectionFactory cf, Message message) {
logger.trace("Received message: " + message);
try (
JMSContext context = cf.createContext(AUTO_ACKNOWLEDGE)
) {
if (message.getJMSReplyTo() != null) {
logger.trace("Replying to " + message.getJMSReplyTo());
String text = (message instanceof TextMessage) ? ((TextMessage)message).getText() : message.toString();
context.createProducer()
.setJMSCorrelationID(message.getJMSMessageID())
.send(message.getJMSReplyTo(), text);
}
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
}
| 3,096 | 37.7125 | 136 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationconfig/unit/MDBActivationConfigTestCase.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.ejb.mdb.activationconfig.unit;
import static org.jboss.as.test.integration.ejb.mdb.activationconfig.JMSHelper.assertSendAndReceiveTextMessage;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import java.util.PropertyPermission;
import java.util.UUID;
import jakarta.annotation.Resource;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Queue;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.integration.ejb.mdb.JMSMessagingUtil;
import org.jboss.as.test.integration.ejb.mdb.activationconfig.MDBWithLookupActivationConfigProperties;
import org.jboss.as.test.integration.ejb.mdb.activationconfig.MDBWithUnknownActivationConfigProperties;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.logging.Logger;
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.Test;
import org.junit.runner.RunWith;
/**
* Tests activation config properties on a MDB
* <p/>
* User: Jaikiran Pai
*/
@RunWith(Arquillian.class)
@ServerSetup({MDBActivationConfigTestCase.JmsQueueSetup.class})
public class MDBActivationConfigTestCase {
private static final Logger logger = Logger.getLogger(MDBActivationConfigTestCase.class);
@Resource(mappedName = MDBWithUnknownActivationConfigProperties.QUEUE_JNDI_NAME)
private Queue queue;
@Resource(mappedName = MDBWithLookupActivationConfigProperties.QUEUE_JNDI_NAME)
private Queue queue2;
@Resource(mappedName = "/ConnectionFactory")
private ConnectionFactory cf;
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient);
jmsAdminOperations.createJmsQueue("mdbtest/activation-config-queue", MDBWithUnknownActivationConfigProperties.QUEUE_JNDI_NAME);
jmsAdminOperations.createJmsQueue("mdbtest/activation-config-queue2", MDBWithLookupActivationConfigProperties.QUEUE_JNDI_NAME);
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsQueue("mdbtest/activation-config-queue");
jmsAdminOperations.removeJmsQueue("mdbtest/activation-config-queue2");
jmsAdminOperations.close();
}
}
}
@Deployment
public static Archive getDeployment() {
return ShrinkWrap.create(JavaArchive.class, "MDBActivationConfigTestCase.jar")
.addPackage(MDBWithUnknownActivationConfigProperties.class.getPackage())
.addClasses(JMSOperations.class, JMSMessagingUtil.class, JmsQueueSetup.class)
.addClasses(TimeoutUtil.class)
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client, org.jboss.dmr \n"), "MANIFEST.MF")
.addAsResource(createPermissionsXmlAsset(new PropertyPermission("ts.timeout.factor", "read")), "META-INF/jboss-permissions.xml");
}
/**
* Tests that deployment of a MDB containing an unknown/unsupported activation config property doesn't throw
* a deployment error.
*
* @throws Exception
*/
@Test
public void testUnrecognizedActivationConfigProps() throws Exception {
String text = UUID.randomUUID().toString();
assertSendAndReceiveTextMessage(cf, queue, text);
}
/**
* Test that deployment of a MDB can use the connectionFactoryLookup and destinationLookup activation config properties.
*
* @throws Exception
*/
@Test
public void testConnectionFactoryLookupActivationConfigProperty() throws Exception {
String text = UUID.randomUUID().toString();
assertSendAndReceiveTextMessage(cf, queue2, text);
}
}
| 5,558 | 41.761538 | 145 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationname/ActivationNameTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat Middleware LLC, 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.ejb.mdb.activationname;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.connector.util.ConnectorServices;
import org.jboss.as.test.integration.ejb.mdb.activationname.adapter.SimpleListener;
import org.jboss.as.test.integration.ejb.mdb.activationname.adapter.SimpleResourceAdapter;
import org.jboss.as.test.integration.ejb.mdb.activationname.mdb.SimpleMdb;
import org.jboss.jca.core.spi.rar.Endpoint;
import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
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.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.endpoint.MessageEndpointFactory;
import java.util.Set;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
/**
* This tests if IronJacamar follows Jakarta Connectors 1.7 and properly defines {@code activation name} on {@code MessageEndpointFactory}.
* For details see {@link SimpleResourceAdapter#endpointActivation(MessageEndpointFactory, ActivationSpec)} and WFLY-8074.
*
* @author Ivo Studensky
*/
@RunWith(Arquillian.class)
public class ActivationNameTestCase {
@Deployment
public static Archive createDeplyoment() {
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ear-with-simple-adapter.ear")
.addAsModule(ShrinkWrap.create(JavaArchive.class, "simple-adapter.rar")
.addAsManifestResource(SimpleResourceAdapter.class.getPackage(), "ra.xml", "ra.xml")
.addPackage(SimpleResourceAdapter.class.getPackage()))
.addAsModule(ShrinkWrap.create(JavaArchive.class, "mdb.jar")
.addClasses(SimpleMdb.class, ActivationNameTestCase.class)
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.connector, org.jboss.ironjacamar.api\n"), "MANIFEST.MF"));
return ear;
}
@ArquillianResource
ServiceContainer serviceContainer;
@Test
public void testSimpleResourceAdapterAvailability() throws Exception {
ServiceController<?> controller = serviceContainer.getService(ConnectorServices.RA_REPOSITORY_SERVICE);
assertNotNull(controller);
ResourceAdapterRepository repository = (ResourceAdapterRepository) controller.getValue();
assertNotNull(repository);
Set<String> ids = repository.getResourceAdapters(SimpleListener.class);
assertNotNull(ids);
assertEquals(1, ids.size());
String piId = ids.iterator().next();
assertTrue(piId.indexOf("SimpleResourceAdapter") != -1);
Endpoint endpoint = repository.getEndpoint(piId);
assertNotNull(endpoint);
}
}
| 4,254 | 44.752688 | 141 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationname/adapter/SimpleActivationSpec.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat Middleware LLC, 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.ejb.mdb.activationname.adapter;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.InvalidPropertyException;
import jakarta.resource.spi.ResourceAdapter;
/**
* @author Ivo Studensky
*/
public class SimpleActivationSpec implements ActivationSpec {
private ResourceAdapter resourceAdapter;
public SimpleActivationSpec() {
}
@Override
public void validate() throws InvalidPropertyException {
// nothing to validate here
}
@Override
public ResourceAdapter getResourceAdapter() {
return resourceAdapter;
}
@Override
public void setResourceAdapter(ResourceAdapter ra) throws ResourceException {
this.resourceAdapter = ra;
}
}
| 1,835 | 33 | 81 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationname/adapter/SimpleListener.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat Middleware LLC, 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.ejb.mdb.activationname.adapter;
/**
* @author Ivo Studensky
*/
public interface SimpleListener {
void onMessage();
}
| 1,194 | 38.833333 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationname/adapter/SimpleResourceAdapter.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat Middleware LLC, 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.ejb.mdb.activationname.adapter;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.BootstrapContext;
import jakarta.resource.spi.ResourceAdapter;
import jakarta.resource.spi.ResourceAdapterInternalException;
import jakarta.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
/**
* @author Ivo Studensky
*/
public class SimpleResourceAdapter implements ResourceAdapter {
private Map<SimpleActivationSpec, SimpleActivation> activations;
public SimpleResourceAdapter() {
this.activations = Collections.synchronizedMap(new HashMap<SimpleActivationSpec, SimpleActivation>());
}
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
}
@Override
public void stop() {
}
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
final String activationName = messageEndpointFactory.getActivationName();
if (activationName == null) {
throw new ResourceException("MessageEndpointFactory#getActivationName() cannot be null [WFLY-8074].");
}
SimpleActivation activation = new SimpleActivation(this, messageEndpointFactory, (SimpleActivationSpec) activationSpec);
activations.put((SimpleActivationSpec) activationSpec, activation);
activation.start();
}
@Override
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) {
SimpleActivation activation = activations.remove(activationSpec);
if (activation != null) { activation.stop(); }
}
@Override
public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException {
return new XAResource[0];
}
@Override
public int hashCode() {
int result = 17;
return result;
}
@Override
public boolean equals(final Object other) {
if (other == null) { return false; }
if (other == this) { return true; }
if (!(other instanceof SimpleResourceAdapter)) { return false; }
SimpleResourceAdapter obj = (SimpleResourceAdapter) other;
boolean result = true;
return result;
}
class SimpleActivation {
private SimpleResourceAdapter ra;
private SimpleActivationSpec spec;
private MessageEndpointFactory endpointFactory;
public SimpleActivation(SimpleResourceAdapter ra,
MessageEndpointFactory endpointFactory,
SimpleActivationSpec spec)
throws ResourceException {
this.ra = ra;
this.endpointFactory = endpointFactory;
this.spec = spec;
}
public SimpleActivationSpec getActivationSpec() {
return spec;
}
public MessageEndpointFactory getMessageEndpointFactory() {
return endpointFactory;
}
public void start() throws ResourceException {
}
public void stop() {
}
}
}
| 4,369 | 34.241935 | 139 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationname/mdb/SimpleMdb.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2017, Red Hat Middleware LLC, 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.ejb.mdb.activationname.mdb;
import org.jboss.as.test.integration.ejb.mdb.activationname.adapter.SimpleListener;
import org.jboss.ejb3.annotation.ResourceAdapter;
import jakarta.ejb.MessageDriven;
/**
* @author Ivo Studensky
*/
@MessageDriven
@ResourceAdapter("ear-with-simple-adapter.ear#simple-adapter.rar")
public class SimpleMdb implements SimpleListener {
@Override
public void onMessage() {
// nothing to do here
}
}
| 1,519 | 35.190476 | 83 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/ejb2x/MDB20MessageSelectorTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, 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.ejb.mdb.ejb2x;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.shared.TimeoutUtil;
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.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.jms.Message;
import jakarta.jms.Queue;
import javax.naming.InitialContext;
import java.util.PropertyPermission;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import jakarta.jms.QueueRequestor;
import jakarta.jms.QueueSession;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.junit.After;
/**
* Tests EJB2.0 MDBs with message selector.
*
* @author <a href="mailto:[email protected]">Ivo Studensky</a>
*/
@RunWith(Arquillian.class)
@ServerSetup({MDB20MessageSelectorTestCase.JmsQueueSetup.class})
public class MDB20MessageSelectorTestCase extends AbstractMDB2xTestCase {
private Queue queue;
private Queue replyQueueA;
private Queue replyQueueB;
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsAdminOperations.createJmsQueue("ejb2x/queue", "java:jboss/ejb2x/queue");
jmsAdminOperations.createJmsQueue("ejb2x/replyQueueA", "java:jboss/ejb2x/replyQueueA");
jmsAdminOperations.createJmsQueue("ejb2x/replyQueueB", "java:jboss/ejb2x/replyQueueB");
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsQueue("ejb2x/queue");
jmsAdminOperations.removeJmsQueue("ejb2x/replyQueueA");
jmsAdminOperations.removeJmsQueue("ejb2x/replyQueueB");
jmsAdminOperations.close();
}
}
}
@Deployment
public static Archive getDeployment() {
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "mdb.jar");
ejbJar.addClasses(EJB2xMDB.class, AbstractMDB2xTestCase.class);
ejbJar.addPackage(JMSOperations.class.getPackage());
ejbJar.addClasses(JmsQueueSetup.class, TimeoutUtil.class);
ejbJar.addAsManifestResource(MDB20MessageSelectorTestCase.class.getPackage(), "ejb-jar-20-message-selector.xml", "ejb-jar.xml");
ejbJar.addAsManifestResource(MDB20MessageSelectorTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml");
ejbJar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client, org.jboss.dmr, org.apache.activemq.artemis\n"), "MANIFEST.MF");
ejbJar.addAsManifestResource(createPermissionsXmlAsset(new PropertyPermission("ts.timeout.factor", "read")), "jboss-permissions.xml");
return ejbJar;
}
@Before
public void initQueues() {
try {
final InitialContext ic = new InitialContext();
queue = (Queue) ic.lookup("java:jboss/ejb2x/queue");
replyQueueA = (Queue) ic.lookup("java:jboss/ejb2x/replyQueueA");
replyQueueB = (Queue) ic.lookup("java:jboss/ejb2x/replyQueueB");
purgeQueue("ejb2x/queue");
purgeQueue("ejb2x/replyQueueA");
purgeQueue("ejb2x/replyQueueB");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@After
public void purgeQueues() throws Exception {
purgeQueue("ejb2x/queue");
purgeQueue("ejb2x/replyQueueA");
purgeQueue("ejb2x/replyQueueB");
}
/**
* Tests 2 messages, only one of them with the selected format.
*/
@Test
public void testMessageSelectors() {
sendTextMessage("Say 1st hello to " + EJB2xMDB.class.getName() + " in 1.0 format", queue, replyQueueA, "Version 1.0");
final Message replyA = receiveMessage(replyQueueA, TimeoutUtil.adjust(5000));
Assert.assertNull("Unexpected reply from " + replyQueueA, replyA);
sendTextMessage("Say 2nd hello to " + EJB2xMDB.class.getName() + " in 1.1 format", queue, replyQueueB, "Version 1.1");
final Message replyB = receiveMessage(replyQueueB, TimeoutUtil.adjust(5000));
Assert.assertNotNull("Missing reply from " + replyQueueB, replyB);
}
/**
* Re-tests 2 messages, both of them with the selected format.
*/
@Test
public void retestMessageSelectors() {
sendTextMessage("Say 1st hello to " + EJB2xMDB.class.getName() + " in 1.1 format", queue, replyQueueA, "Version 1.1");
final Message replyA = receiveMessage(replyQueueA, TimeoutUtil.adjust(5000));
Assert.assertNotNull("Missing reply from " + replyQueueA, replyA);
sendTextMessage("Say 2nd hello to " + EJB2xMDB.class.getName() + " in 1.1 format", queue, replyQueueB, "Version 1.1");
final Message replyB = receiveMessage(replyQueueB, TimeoutUtil.adjust(5000));
Assert.assertNotNull("Missing reply from " + replyQueueB, replyB);
}
/**
* Removes all message son a queue
*
* @param queueName name of the queue
* @throws Exception
*/
private void purgeQueue(String queueName) throws Exception {
QueueRequestor requestor = new QueueRequestor((QueueSession) session, ActiveMQJMSClient.createQueue("activemq.management"));
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.QUEUE + "jms.queue." + queueName, "removeAllMessages");
Message reply = requestor.request(m);
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
logger.warn(reply.getBody(String.class));
}
}
}
| 7,590 | 43.91716 | 170 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/ejb2x/AbstractMDB2xTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, 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.ejb.mdb.ejb2x;
import org.jboss.logging.Logger;
import org.junit.After;
import org.junit.Before;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageConsumer;
import jakarta.jms.MessageProducer;
import jakarta.jms.Session;
import jakarta.jms.TextMessage;
import javax.naming.InitialContext;
import static org.junit.Assert.fail;
/**
* Common class for EJB 2.x MDB deployment tests.
*
* @author <a href="mailto:[email protected]">Ivo Studensky</a>
*/
public abstract class AbstractMDB2xTestCase {
protected static final Logger logger = Logger.getLogger(AbstractMDB2xTestCase.class);
protected Connection connection;
protected Session session;
@Before
public void initCommon() {
try {
final InitialContext ic = new InitialContext();
final ConnectionFactory cf = (ConnectionFactory) ic.lookup("java:/ConnectionFactory");
connection = cf.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@After
public void cleanUp() {
try {
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
} catch (JMSException e) {
e.printStackTrace();
}
}
protected Message receiveMessage(final Destination destination, final long waitInMillis) {
try {
final MessageConsumer consumer = session.createConsumer(destination);
return consumer.receive(waitInMillis);
} catch (JMSException e) {
e.printStackTrace();
fail("Couldn't receive message from " + destination);
}
return null;
}
protected void sendTextMessage(final String msg, final Destination destination) {
sendTextMessage(msg, destination, null);
}
protected void sendTextMessage(final String msg, final Destination destination, final Destination replyDestination) {
sendTextMessage(msg, destination, replyDestination, null);
}
protected void sendTextMessage(final String msg, final Destination destination, final Destination replyDestination, final String messageFormat) {
logger.debug("sending text message (" + msg + ") to " + destination);
MessageProducer messageProducer = null;
try {
final TextMessage message = session.createTextMessage(msg);
if (replyDestination != null) {
message.setJMSReplyTo(replyDestination);
}
if (messageFormat != null) {
message.setStringProperty("MessageFormat", messageFormat);
}
messageProducer = session.createProducer(destination);
messageProducer.send(message);
logger.debug("message sent");
} catch (JMSException e) {
e.printStackTrace();
fail("Failed to send message to " + destination);
} finally {
try {
if (messageProducer != null) {
messageProducer.close();
}
} catch (JMSException e) {
e.printStackTrace();
}
}
}
}
| 4,538 | 34.460938 | 149 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/ejb2x/MDB20QueueTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, 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.ejb.mdb.ejb2x;
import static org.jboss.as.test.integration.ejb.mdb.ejb2x.AbstractMDB2xTestCase.logger;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.shared.TimeoutUtil;
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.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.jms.Message;
import jakarta.jms.Queue;
import javax.naming.InitialContext;
import java.util.PropertyPermission;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import jakarta.jms.QueueRequestor;
import jakarta.jms.QueueSession;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
/**
* Tests EJB2.0 MDBs listening on a queue.
*
* @author <a href="mailto:[email protected]">Ivo Studensky</a>
*/
@RunWith(Arquillian.class)
@ServerSetup({MDB20QueueTestCase.JmsQueueSetup.class})
public class MDB20QueueTestCase extends AbstractMDB2xTestCase {
private Queue queue;
private Queue replyQueue;
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient);
jmsAdminOperations.createJmsQueue("ejb2x/queue", "java:jboss/ejb2x/queue");
jmsAdminOperations.createJmsQueue("ejb2x/replyQueue", "java:jboss/ejb2x/replyQueue");
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsQueue("ejb2x/queue");
jmsAdminOperations.removeJmsQueue("ejb2x/replyQueue");
jmsAdminOperations.close();
}
}
}
@Deployment
public static Archive getDeployment() {
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "mdb.jar");
ejbJar.addClasses(EJB2xMDB.class, AbstractMDB2xTestCase.class);
ejbJar.addPackage(JMSOperations.class.getPackage());
ejbJar.addClasses(JmsQueueSetup.class, TimeoutUtil.class);
ejbJar.addAsManifestResource(MDB20QueueTestCase.class.getPackage(), "ejb-jar-20.xml", "ejb-jar.xml");
ejbJar.addAsManifestResource(MDB20QueueTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml");
ejbJar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client, org.jboss.dmr, org.apache.activemq.artemis \n"), "MANIFEST.MF");
ejbJar.addAsManifestResource(createPermissionsXmlAsset(new PropertyPermission("ts.timeout.factor", "read")), "jboss-permissions.xml");
return ejbJar;
}
@Before
public void initQueues() {
try {
final InitialContext ic = new InitialContext();
queue = (Queue) ic.lookup("java:jboss/ejb2x/queue");
replyQueue = (Queue) ic.lookup("java:jboss/ejb2x/replyQueue");
purgeQueue("ejb2x/queue");
purgeQueue("ejb2x/replyQueue");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Tests a simple EJB2.0 MDB.
*/
@Test
public void testEjb20MDB() {
sendTextMessage("Say hello to " + EJB2xMDB.class.getName(), queue, replyQueue);
final Message reply = receiveMessage(replyQueue, TimeoutUtil.adjust(5000));
Assert.assertNotNull("Reply message was null on reply queue: " + replyQueue, reply);
}
/**
* Removes all message son a queue
*
* @param queueName name of the queue
* @throws Exception
*/
private void purgeQueue(String queueName) throws Exception {
QueueRequestor requestor = new QueueRequestor((QueueSession) session, ActiveMQJMSClient.createQueue("activemq.management"));
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putOperationInvocation(m, ResourceNames.QUEUE + "jms.queue." + queueName, "removeAllMessages");
Message reply = requestor.request(m);
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
logger.warn(reply.getBody(String.class));
}
}
}
| 5,979 | 41.112676 | 170 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/ejb2x/EJB2xMDB.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, 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.ejb.mdb.ejb2x;
import jakarta.ejb.EJBException;
import jakarta.ejb.MessageDrivenBean;
import jakarta.ejb.MessageDrivenContext;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.JMSContext;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import jakarta.jms.TextMessage;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.logging.Logger;
/**
* A replying EJB 2.x MDB.
*
* @author <a href="mailto:[email protected]">Ivo Studensky</a>
*/
public class EJB2xMDB implements MessageDrivenBean, MessageListener {
private static final Logger logger = Logger.getLogger(EJB2xMDB.class);
private MessageDrivenContext mdbContext;
private ConnectionFactory cf;
public EJB2xMDB() {
}
public void ejbCreate() {
InitialContext iniCtx = null;
try {
iniCtx = new InitialContext();
cf = (ConnectionFactory) iniCtx.lookup("java:/ConnectionFactory");
} catch (NamingException e) {
throw new EJBException(e);
}
}
@Override
public void setMessageDrivenContext(MessageDrivenContext ctx) throws EJBException {
this.mdbContext = ctx;
}
@Override
public void ejbRemove() throws EJBException {
}
@Override
public void onMessage(Message message) {
logger.trace("Received message " + message + " in MDB " + this.getClass().getName());
try {
if (message.getStringProperty("MessageFormat") != null)
logger.trace("MessageFormat property = " + message.getStringProperty("MessageFormat"));
Destination replyTo = message.getJMSReplyTo();
if (replyTo == null) {
try {
logger.trace("mdbContext = " + mdbContext);
replyTo = (Destination) mdbContext.lookup("jms/replyQueue");
} catch (Throwable e) {
logger.warn(e);
}
} else {
logger.trace("Using replyTo from message JMSReplyTo: " + replyTo);
}
if (replyTo == null) {
throw new EJBException("no replyTo Destination");
}
final TextMessage tm = (TextMessage) message;
final String reply = tm.getText() + "processed by: " + hashCode();
try (JMSContext context = cf.createContext()) {
context.createProducer()
.setJMSCorrelationID(message.getJMSMessageID())
.send(replyTo, reply);
}
} catch (Exception e) {
logger.error(e);
throw new EJBException(e);
}
}
}
| 3,785 | 33.733945 | 103 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/ejb2x/MDB20TopicTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, 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.ejb.mdb.ejb2x;
import org.jboss.arquillian.container.test.api.Deployment;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.remoting3.security.RemotingPermission;
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.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.jms.Message;
import jakarta.jms.Queue;
import jakarta.jms.Topic;
import javax.naming.InitialContext;
import java.io.FilePermission;
import java.util.PropertyPermission;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import java.io.IOException;
import jakarta.jms.QueueRequestor;
import jakarta.jms.QueueSession;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.api.jms.management.JMSManagementHelper;
import org.jboss.as.controller.client.helpers.ClientConstants;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.dmr.ModelNode;
/**
* Tests EJB2.0 MDBs listening on a topic.
*
* @author <a href="mailto:[email protected]">Ivo Studensky</a>
*/
@RunWith(Arquillian.class)
@ServerSetup({MDB20TopicTestCase.JmsQueueSetup.class})
public class MDB20TopicTestCase extends AbstractMDB2xTestCase {
@ArquillianResource
private ManagementClient managementClient;
private Topic topic;
private Queue replyQueueA;
private Queue replyQueueB;
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsAdminOperations.createJmsTopic("ejb2x/topic", "java:jboss/ejb2x/topic");
jmsAdminOperations.createJmsQueue("ejb2x/replyQueueA", "java:jboss/ejb2x/replyQueueA");
jmsAdminOperations.createJmsQueue("ejb2x/replyQueueB", "java:jboss/ejb2x/replyQueueB");
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsTopic("ejb2x/topic");
jmsAdminOperations.removeJmsQueue("ejb2x/replyQueueA");
jmsAdminOperations.removeJmsQueue("ejb2x/replyQueueB");
jmsAdminOperations.close();
}
}
}
@Deployment
public static Archive getDeployment() {
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "MDB20TopicTestCase.jar");
final String tempDir = TestSuiteEnvironment.getTmpDir();
ejbJar.addClasses(EJB2xMDB.class, AbstractMDB2xTestCase.class);
ejbJar.addPackage(JMSOperations.class.getPackage());
ejbJar.addClasses(JmsQueueSetup.class, TimeoutUtil.class);
ejbJar.addAsManifestResource(MDB20TopicTestCase.class.getPackage(), "ejb-jar-20-topic.xml", "ejb-jar.xml");
ejbJar.addAsManifestResource(MDB20TopicTestCase.class.getPackage(), "jboss-ejb3-topic.xml", "jboss-ejb3.xml");
ejbJar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client, org.jboss.dmr, org.jboss.remoting, org.apache.activemq.artemis\n"), "MANIFEST.MF");
ejbJar.addAsManifestResource(createPermissionsXmlAsset(
new PropertyPermission("ts.timeout.factor", "read"),
new RemotingPermission("createEndpoint"),
new RemotingPermission("connect"),
new FilePermission(tempDir + "/-", "read")
), "jboss-permissions.xml");
return ejbJar;
}
@Before
public void initTopics() {
try {
final InitialContext ic = new InitialContext();
topic = (Topic) ic.lookup("java:jboss/ejb2x/topic");
replyQueueA = (Queue) ic.lookup("java:jboss/ejb2x/replyQueueA");
replyQueueB = (Queue) ic.lookup("java:jboss/ejb2x/replyQueueB");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Tests 2 MDBs both listening on a topic.
*/
@Test
public void testEjb20TopicMDBs() throws Exception {
// make sure that 2 MDBs created 2 subscriptions on topic - wait 5 seconds
Assert.assertTrue("MDBs did not created 2 subscriptions on topic in 5s timeout.",
waitUntilAtLeastGivenNumberOfSubscriptionIsCreatedOnTopic("ejb2x/topic", 2, 5000));
sendTextMessage("Say hello to the topic", topic);
final Message replyA = receiveMessage(replyQueueA, TimeoutUtil.adjust(5000));
Assert.assertNotNull("Reply message was null on reply queue: " + replyQueueA, replyA);
final Message replyB = receiveMessage(replyQueueB, TimeoutUtil.adjust(5000));
Assert.assertNotNull("Reply message was null on reply queue: " + replyQueueB, replyB);
}
/**
* Waits given time out in ms for subscription to be created on topic
*
* @param topicCoreName core name of the topic
* @param numberOfSubscriptions number of subscriptions
* @param timeout timeout in ms
* @return true if subscription was created in given timeout, false if not
* @throws Exception
*/
private boolean waitUntilAtLeastGivenNumberOfSubscriptionIsCreatedOnTopic(String topicCoreName,
int numberOfSubscriptions,
long timeout) throws Exception {
long startTime = System.currentTimeMillis();
while (System.currentTimeMillis() - startTime < timeout) {
if (getNumberOfAllSubscriptions(topicCoreName) >= numberOfSubscriptions) {
return true;
}
Thread.sleep(100);
}
return false;
}
/**
* Returns number of all subscriptions on topic
*
* @param topicName name of topic
* @return number of subscriptions on topic
* @throws Exception
*/
public int getNumberOfAllSubscriptions(String topicName) throws Exception {
if(isRemoteBroker(managementClient)) {
return getRemoteNumberOfAllSubscriptions(topicName);
}
return getEmbeddedNumberOfAllSubscriptions(topicName);
}
private int getEmbeddedNumberOfAllSubscriptions(String topicCoreName) throws Exception {
ModelNode model = new ModelNode();
model.get(ClientConstants.OP).set("list-all-subscriptions");
model.get(ClientConstants.OP_ADDR).add("subsystem", "messaging-activemq");
model.get(ClientConstants.OP_ADDR).add("server", "default");
model.get(ClientConstants.OP_ADDR).add("jms-topic", topicCoreName);
ModelNode result = managementClient.getControllerClient().execute(model);
return result.get("result").asList().size();
}
private int getRemoteNumberOfAllSubscriptions(String topicName) throws Exception {
QueueRequestor requestor = new QueueRequestor((QueueSession) session, ActiveMQJMSClient.createQueue("activemq.management"));
Message m = session.createMessage();
org.apache.activemq.artemis.api.jms.management.JMSManagementHelper.putAttribute(m, ResourceNames.ADDRESS + "jms.topic." + topicName, "QueueNames");
Message reply = requestor.request(m);
if (!reply.getBooleanProperty("_AMQ_OperationSucceeded")) {
throw new RuntimeException(reply.getBody(String.class));
}
Object[] result = (Object[]) JMSManagementHelper.getResult(reply);
return result.length;
}
boolean isRemoteBroker(final org.jboss.as.arquillian.container.ManagementClient managementClient) throws IOException {
ModelNode addr = new ModelNode();
addr.add("socket-binding-group", "standard-sockets");
addr.add("remote-destination-outbound-socket-binding", "messaging-activemq");
ModelNode op = Operations.createReadResourceOperation(addr, false);
ModelNode response = managementClient.getControllerClient().execute(op);
final String outcome = response.require("outcome").asString();
return "success".equalsIgnoreCase(outcome);
}
}
| 9,931 | 43.941176 | 183 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/ejb2x/MDB21TestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, 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.ejb.mdb.ejb2x;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.shared.TimeoutUtil;
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.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.jms.Message;
import jakarta.jms.Queue;
import javax.naming.InitialContext;
import java.util.PropertyPermission;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
/**
* Tests EJB2.1 MDB deployments.
*
* @author <a href="mailto:[email protected]">Ivo Studensky</a>
*/
@RunWith(Arquillian.class)
@ServerSetup({MDB21TestCase.JmsQueueSetup.class})
public class MDB21TestCase extends AbstractMDB2xTestCase {
private Queue queue;
private Queue replyQueue;
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsAdminOperations.createJmsQueue("ejb2x/queue", "java:jboss/ejb2x/queue");
jmsAdminOperations.createJmsQueue("ejb2x/replyQueue", "java:jboss/ejb2x/replyQueue");
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsQueue("ejb2x/queue");
jmsAdminOperations.removeJmsQueue("ejb2x/replyQueue");
jmsAdminOperations.close();
}
}
}
@Deployment
public static Archive getDeployment() {
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "mdb.jar");
ejbJar.addClasses(EJB2xMDB.class, AbstractMDB2xTestCase.class);
ejbJar.addPackage(JMSOperations.class.getPackage());
ejbJar.addClasses(JmsQueueSetup.class, TimeoutUtil.class);
ejbJar.addAsManifestResource(MDB21TestCase.class.getPackage(), "ejb-jar-21.xml", "ejb-jar.xml");
ejbJar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client, org.jboss.dmr \n"), "MANIFEST.MF");
ejbJar.addAsManifestResource(createPermissionsXmlAsset(new PropertyPermission("ts.timeout.factor", "read")), "jboss-permissions.xml");
return ejbJar;
}
@Before
public void initQueues() {
try {
final InitialContext ic = new InitialContext();
queue = (Queue) ic.lookup("java:jboss/ejb2x/queue");
replyQueue = (Queue) ic.lookup("java:jboss/ejb2x/replyQueue");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
/**
* Test a simple 2.1 MDB.
*/
@Test
public void testSimple21MDB() {
sendTextMessage("Say hello to " + EJB2xMDB.class.getName(), queue, replyQueue);
final Message reply = receiveMessage(replyQueue, TimeoutUtil.adjust(5000));
Assert.assertNotNull("Reply message was null on reply queue: " + replyQueue, reply);
}
}
| 4,740 | 39.87069 | 142 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/vaultedproperties/MDB.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright (c) 2014, 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.ejb.mdb.vaultedproperties;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.inject.Inject;
import jakarta.jms.Destination;
import jakarta.jms.JMSContext;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import jakarta.jms.TextMessage;
/**
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2014 Red Hat inc.
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = MDBWithVaultedPropertiesTestCase.DEPLOYMENT_PROP_EXPRESSION)
})
public class MDB implements MessageListener {
@Inject
JMSContext context;
@Override
public void onMessage(Message message) {
try {
final Destination replyTo = message.getJMSReplyTo();
// ignore messages that need no reply
if (replyTo == null) {
return;
}
context.createProducer()
.setJMSCorrelationID(message.getJMSMessageID())
.send(replyTo, ((TextMessage) message).getText());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
| 2,276 | 36.327869 | 146 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/vaultedproperties/MDBWithVaultedPropertiesTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2014, 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.ejb.mdb.vaultedproperties;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import static org.junit.Assert.assertEquals;
import static org.wildfly.test.security.common.SecureExpressionUtil.getDeploymentPropertiesAsset;
import static org.wildfly.test.security.common.SecureExpressionUtil.setupCredentialStore;
import static org.wildfly.test.security.common.SecureExpressionUtil.setupCredentialStoreExpressions;
import static org.wildfly.test.security.common.SecureExpressionUtil.teardownCredentialStore;
import java.io.IOException;
import java.util.PropertyPermission;
import java.util.UUID;
import jakarta.annotation.Resource;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSConsumer;
import jakarta.jms.JMSContext;
import jakarta.jms.Queue;
import jakarta.jms.TemporaryQueue;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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.client.OperationBuilder;
import org.jboss.as.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.test.security.common.SecureExpressionUtil;
/**
* Verify that MDB activation config properties can be vaulted.
*
* The test case will send a message to the destination and expects a reply.
* The reply will be received only if the MDB was able to lookup the destination from its vaulted property in destinationLookup.
*
* @author <a href="http://jmesnil.net/">Jeff Mesnil</a> (c) 2014 Red Hat inc.
*/
@RunWith(Arquillian.class)
@ServerSetup({MDBWithVaultedPropertiesTestCase.StoreVaultedPropertyTask.class})
public class MDBWithVaultedPropertiesTestCase {
private static final String DEPLOYMENT = "MDBWithVaultedPropertiesTestCase.jar";
private static final String QUEUE_NAME = "vaultedproperties_queue";
static final String CLEAR_TEXT_DESTINATION_LOOKUP = "java:jboss/messaging/vaultedproperties/queue";
static final String UNIQUE_NAME = "MDBWithVaultedPropertiesTestCase";
static final String CREDENTIAL_EXPRESSION_PROP = "MDBWithVaultedPropertiesTestCase.destination";
// Expression we use as the annotation value. We add it to META-INF/jboss.properties so it resolves
// to a credential expression, which in turn resolves to clear text
static final String DEPLOYMENT_PROP_EXPRESSION = "${MDBWithVaultedPropertiesTestCase.destination}";
static final SecureExpressionUtil.SecureExpressionData EXPRESSION_DATA = new SecureExpressionUtil.SecureExpressionData(CLEAR_TEXT_DESTINATION_LOOKUP, CREDENTIAL_EXPRESSION_PROP);
static final String STORE_LOCATION = MDBWithVaultedPropertiesTestCase.class.getResource("/").getPath() + "security/" + UNIQUE_NAME + ".cs";
static class StoreVaultedPropertyTask implements ServerSetupTask {
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
setupCredentialStore(managementClient, UNIQUE_NAME, STORE_LOCATION);
createJMSQueue(managementClient, QUEUE_NAME, CLEAR_TEXT_DESTINATION_LOOKUP);
updateAnnotationPropertyReplacement(managementClient, true);
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
removeJMSQueue(managementClient, QUEUE_NAME);
teardownCredentialStore(managementClient, UNIQUE_NAME, STORE_LOCATION);
updateAnnotationPropertyReplacement(managementClient, false);
}
void createJMSQueue(ManagementClient managementClient, String name, String lookup) {
JMSOperations jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient);
jmsAdminOperations.createJmsQueue(name, lookup);
jmsAdminOperations.close();
}
void removeJMSQueue(ManagementClient managementClient, String name) {
JMSOperations jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient);
jmsAdminOperations.removeJmsQueue(name);
jmsAdminOperations.close();
}
private void updateAnnotationPropertyReplacement(ManagementClient managementClient, boolean value) throws IOException {
ModelNode op;
op = new ModelNode();
op.get(OP_ADDR).add("subsystem", "ee");
op.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
op.get(NAME).set("annotation-property-replacement");
op.get(VALUE).set(value);
managementClient.getControllerClient().execute(new OperationBuilder(op).build());
}
}
@Deployment(name = DEPLOYMENT)
public static JavaArchive getDeployment() throws Exception {
// Create the credential expressions so we can store them in the deployment
setupCredentialStoreExpressions(UNIQUE_NAME, EXPRESSION_DATA);
return ShrinkWrap.create(JavaArchive.class, DEPLOYMENT)
.addClass(StoreVaultedPropertyTask.class)
.addClass(MDB.class)
.addClass(TimeoutUtil.class)
.addClasses(SecureExpressionUtil.getDeploymentClasses())
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsManifestResource(createPermissionsXmlAsset(
new PropertyPermission(TimeoutUtil.FACTOR_SYS_PROP, "read")), "permissions.xml")
.addAsManifestResource(getDeploymentPropertiesAsset(EXPRESSION_DATA), "jboss.properties");
}
@Resource(mappedName = CLEAR_TEXT_DESTINATION_LOOKUP)
private Queue queue;
@Resource(mappedName = "/JmsXA")
private ConnectionFactory factory;
@Test
public void sendAndReceiveMessage() {
try (JMSContext context = factory.createContext()) {
TemporaryQueue replyTo = context.createTemporaryQueue();
String text = UUID.randomUUID().toString();
context.createProducer()
.setJMSReplyTo(replyTo)
.send(queue, text);
JMSConsumer consumer = context.createConsumer(replyTo);
String reply = consumer.receiveBody(String.class, TimeoutUtil.adjust(5000));
assertEquals(text, reply);
}
}
}
| 8,234 | 45.789773 | 182 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/MessageListenerInClassHierarchyTestCase.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.ejb.mdb.messagelistener;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.integration.ejb.mdb.JMSMessagingUtil;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.annotation.Resource;
import jakarta.ejb.EJB;
import jakarta.jms.Message;
import jakarta.jms.Queue;
import jakarta.jms.TextMessage;
import java.util.PropertyPermission;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
/**
* Tests that if a message listener interface is implemented by the base class of a message driven bean, then
* it's taken into consideration while checking for message listener interface for the MDB.
*
* <p>See https://issues.jboss.org/browse/AS7-2638</p>
*
* @author Jaikiran Pai
*/
@RunWith(Arquillian.class)
@ServerSetup({MessageListenerInClassHierarchyTestCase.JmsQueueSetup.class})
public class MessageListenerInClassHierarchyTestCase {
static class JmsQueueSetup implements ServerSetupTask {
private JMSOperations jmsAdminOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
jmsAdminOperations = JMSOperationsProvider.getInstance(managementClient);
jmsAdminOperations.createJmsQueue("messagelistener/queue", QUEUE_JNDI_NAME);
jmsAdminOperations.createJmsQueue("messagelistener/replyQueue", REPLY_QUEUE_JNDI_NAME);
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
if (jmsAdminOperations != null) {
jmsAdminOperations.removeJmsQueue("messagelistener/queue");
jmsAdminOperations.removeJmsQueue("messagelistener/replyQueue");
jmsAdminOperations.close();
}
}
}
private static final String QUEUE_JNDI_NAME = "java:jboss/queue/message-listener";
private static final String REPLY_QUEUE_JNDI_NAME = "java:jboss/queue/message-listener-reply-queue";
@EJB(mappedName = "java:module/JMSMessagingUtil")
private JMSMessagingUtil jmsUtil;
@Resource(mappedName = QUEUE_JNDI_NAME)
private Queue queue;
@Resource(mappedName = REPLY_QUEUE_JNDI_NAME)
private Queue replyQueue;
@Deployment
public static Archive createDeployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "message-listener-in-class-hierarchy-test.jar");
jar.addClasses(ConcreteMDB.class, CommonBase.class, JMSMessagingUtil.class, JmsQueueSetup.class, TimeoutUtil.class);
jar.addPackage(JMSOperations.class.getPackage());
jar.addAsManifestResource(createPermissionsXmlAsset(
new PropertyPermission(TimeoutUtil.FACTOR_SYS_PROP, "read")), "permissions.xml");
return jar;
}
/**
* Test that if a {@link jakarta.jms.MessageListener} interface is implemented by the base class of a
* message driven bean, then it's taken into consideration while looking for potential message listener
* interface
* <p>See https://issues.jboss.org/browse/AS7-2638</p>
*
* @throws Exception
*/
@Test
public void testSetMessageDrivenContext() throws Exception {
this.jmsUtil.sendTextMessage("hello world", this.queue, this.replyQueue);
final Message reply = this.jmsUtil.receiveMessage(replyQueue, 5000);
Assert.assertNotNull("Reply message was null on reply queue: " + this.replyQueue, reply);
final TextMessage textMessage = (TextMessage) reply;
Assert.assertEquals("setMessageDrivenContext method was *not* invoked on MDB", ConcreteMDB.SUCCESS_REPLY, textMessage.getText());
}
}
| 5,338 | 42.056452 | 137 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/CommonBase.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.ejb.mdb.messagelistener;
import jakarta.jms.MessageListener;
/**
* @author Jaikiran Pai
*/
public abstract class CommonBase implements MessageListener {
}
| 1,221 | 37.1875 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/ConcreteMDB.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.ejb.mdb.messagelistener;
import jakarta.annotation.Resource;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.JMSContext;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import org.jboss.logging.Logger;
/**
* @author Jaikiran Pai
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/queue/message-listener")
})
public class ConcreteMDB extends CommonBase {
private static final Logger logger = Logger.getLogger(ConcreteMDB.class);
public static final String SUCCESS_REPLY = "onMessage() method was invoked";
public static final String FAILURE_REPLY = "onMessage() method was *not* invoked";
@Resource(mappedName = "java:/JmsXA")
private ConnectionFactory factory;
@Override
public void onMessage(Message message) {
logger.trace("Received message: " + message);
try {
final Destination replyTo = message.getJMSReplyTo();
if (replyTo != null) {
logger.trace("Replying to " + replyTo);
try (
JMSContext context = factory.createContext()
) {
context.createProducer()
.setJMSCorrelationID(message.getJMSMessageID())
.send(replyTo, SUCCESS_REPLY);
}
}
} catch (JMSException jmse) {
throw new RuntimeException(jmse);
}
}
}
| 2,674 | 35.643836 | 116 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/nomethodinterface/SimpleActivationSpec.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.integration.ejb.mdb.messagelistener.nomethodinterface;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.InvalidPropertyException;
import jakarta.resource.spi.ResourceAdapter;
/**
* @author Jan Martiska
*/
public class SimpleActivationSpec implements ActivationSpec {
private ResourceAdapter ra;
// The message listener method. The RA will access this method via reflection.
private String methodName;
@Override
public void validate() throws InvalidPropertyException {
if (methodName == null) {
throw new InvalidPropertyException("methodName property needs to be specified ");
}
}
@Override
public ResourceAdapter getResourceAdapter() {
return this.ra;
}
@Override
public void setResourceAdapter(ResourceAdapter resourceAdapter) throws ResourceException {
this.ra = resourceAdapter;
}
public String getMethodName() {
return methodName;
}
public void setMethodName(String methodName) {
this.methodName = methodName;
}
}
| 2,169 | 32.384615 | 94 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/nomethodinterface/NoMethodMessageListenerTestCase.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.integration.ejb.mdb.messagelistener.nomethodinterface;
import java.util.concurrent.TimeUnit;
import jakarta.ejb.EJB;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* EJB 3.2 5.4.3:
* A message-driven bean is permitted to implement a listener interface with no methods. A bean that
* implements a no-methods interface, exposes all non-static public methods of the bean class and
* of any superclasses except java.lang.Object as message listener methods.
* In this case, when requested by a resource adapter, the container provides a proxy which implements the
* message listener interface and all message listener methods of the bean. A resource adapter may use the
* Reflection API to invoke a message listener method on such a proxy.
*
* @author Jan Martiska
*/
@RunWith(Arquillian.class)
public class NoMethodMessageListenerTestCase {
public static final String EAR_NAME = "no-method-message-listener-test";
private static final String RAR_NAME = "resource-adapter";
private static final String EJB_JAR_NAME = "message-driven-bean";
private static final String LIB_JAR_NAME = "common";
@EJB
private ReceivedMessageTracker tracker;
@Deployment
public static Archive createDeployment() {
final Package currentPackage = NoMethodMessageListenerTestCase.class.getPackage();
final JavaArchive rar = ShrinkWrap.create(JavaArchive.class, RAR_NAME + ".rar")
.addAsManifestResource(currentPackage, "ra.xml", "ra.xml");
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, EJB_JAR_NAME + ".jar")
.addClasses(SimpleMessageDrivenBean.class, NoMethodMessageListenerTestCase.class, ReceivedMessageTracker.class);
final JavaArchive libJar = ShrinkWrap.create(JavaArchive.class, LIB_JAR_NAME + ".jar")
.addClasses(SimpleActivationSpec.class, SimpleResourceAdapter.class)
.addClasses(NoMethodMessageListener.class, TimeoutUtil.class);
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME + ".ear")
.addAsModule(rar)
.addAsModule(ejbJar)
.addAsLibrary(libJar)
.addAsManifestResource(currentPackage, "permissions.xml", "permissions.xml");
return ear;
}
/**
* The resource adapter is programmed to send a message to the MDB right after the MDB endpoint is activated.
* Therefore, no actions except deploying the EAR are needed.
*
* @throws InterruptedException
*/
@Test
public void doTest() throws InterruptedException {
boolean receivedSuccessfully = tracker.getReceivedLatch()
.await(TimeoutUtil.adjust(30), TimeUnit.SECONDS);
Assert.assertTrue("Message was not received within reasonable timeout", receivedSuccessfully);
}
}
| 4,288 | 41.89 | 128 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/nomethodinterface/SimpleMessageDrivenBean.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.integration.ejb.mdb.messagelistener.nomethodinterface;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.EJB;
import jakarta.ejb.MessageDriven;
import org.jboss.ejb3.annotation.ResourceAdapter;
import org.jboss.logging.Logger;
/**
* @author Jan Martiska
*/
@MessageDriven(
messageListenerInterface = NoMethodMessageListener.class,
activationConfig = @ActivationConfigProperty(propertyName = "methodName", propertyValue = "handleMessage")
)
@ResourceAdapter("no-method-message-listener-test.ear#resource-adapter.rar")
public class SimpleMessageDrivenBean implements NoMethodMessageListener {
@EJB
private ReceivedMessageTracker tracker;
private Logger logger = Logger.getLogger(SimpleMessageDrivenBean.class);
public void handleMessage(String message) {
logger.trace("SimpleMessageDriven bean received message: " + message);
tracker.getReceivedLatch().countDown();
}
}
| 1,993 | 36.622642 | 114 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/nomethodinterface/SimpleResourceAdapter.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.integration.ejb.mdb.messagelistener.nomethodinterface;
import java.lang.reflect.Method;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.BootstrapContext;
import jakarta.resource.spi.ResourceAdapter;
import jakarta.resource.spi.ResourceAdapterInternalException;
import jakarta.resource.spi.endpoint.MessageEndpoint;
import jakarta.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
import org.jboss.logging.Logger;
/**
* @author Jan Martiska
*/
public class SimpleResourceAdapter implements ResourceAdapter {
private MessageEndpoint endpoint;
private Logger log = Logger.getLogger(SimpleResourceAdapter.class);
@Override
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException {
log.trace("SimpleResourceAdapter started");
}
@Override
public void stop() {
log.trace("SimpleResourceAdapter stopped");
}
/**
* Send a message to the MDB right after the MDB endpoint is activated.
* Using reflection to pick a method to invoke - see EJB 3.2 spec section 5.4.3
*/
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory,
ActivationSpec activationSpec) throws ResourceException {
log.trace("SimpleResourceAdapter activating MDB endpoint and sending a message to it");
Class<?> endpointClass = messageEndpointFactory.getEndpointClass();
try {
Method methodToInvoke = endpointClass.getMethod(((SimpleActivationSpec)activationSpec).getMethodName(), String.class);
MessageEndpoint endpoint = messageEndpointFactory.createEndpoint(null);
this.endpoint = endpoint;
methodToInvoke.invoke(endpoint, "Hello world");
} catch (Exception e) {
throw new ResourceException(e);
}
}
@Override
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory,
ActivationSpec activationSpec) {
log.trace("SimpleResourceAdapter deactivating MDB endpoint");
if (endpoint != null) {
endpoint.release();
endpoint = null;
}
}
@Override
public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException {
return null;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof SimpleResourceAdapter)) {
return false;
}
SimpleResourceAdapter that = (SimpleResourceAdapter)o;
return !(endpoint != null ? !endpoint.equals(that.endpoint) : that.endpoint != null);
}
@Override
public int hashCode() {
return endpoint != null ? endpoint.hashCode() : 0;
}
}
| 3,972 | 35.118182 | 130 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/nomethodinterface/ReceivedMessageTracker.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.integration.ejb.mdb.messagelistener.nomethodinterface;
import java.util.concurrent.CountDownLatch;
import jakarta.annotation.PostConstruct;
import jakarta.ejb.Singleton;
/**
* @author Jan Martiska
*/
@Singleton
public class ReceivedMessageTracker {
private CountDownLatch received;
@PostConstruct
public void init() {
received = new CountDownLatch(1);
}
public CountDownLatch getReceivedLatch() {
return received;
}
}
| 1,516 | 31.276596 | 80 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/messagelistener/nomethodinterface/NoMethodMessageListener.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.integration.ejb.mdb.messagelistener.nomethodinterface;
/**
* @author Jan Martiska
*/
public interface NoMethodMessageListener {
}
| 1,183 | 38.466667 | 80 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/containerstart/ReplyingMDB.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright (c) 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @authors tag. See the copyright.txt 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.ejb.mdb.containerstart;
import static java.util.concurrent.TimeUnit.SECONDS;
import static jakarta.jms.DeliveryMode.NON_PERSISTENT;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.annotation.Resource;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import jakarta.jms.MessageProducer;
import jakarta.jms.Session;
import jakarta.jms.TextMessage;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.logging.Logger;
/**
* @author <a href="[email protected]">Carlo de Wolf</a>
*/
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "jakarta.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "java:jboss/exported/queue/sendMessage"),
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1"),
@ActivationConfigProperty(propertyName = "transactionTimeout", propertyValue = "10"),
@ActivationConfigProperty(propertyName = "useDLQ", propertyValue = "false") })
public class ReplyingMDB implements MessageListener {
private static final Logger log = Logger.getLogger(ReplyingMDB.class);
@Resource(lookup = "java:/ConnectionFactory")
private ConnectionFactory factory;
private Connection connection;
private Session session;
private MessageProducer sender;
private static final int WAIT_S = TimeoutUtil.adjust(15);
public void onMessage(Message m) {
try {
TextMessage message = (TextMessage) m;
String text = message.getText();
TextMessage replyMessage;
if (message instanceof TextMessage) {
if (text.equals("await") && !message.getJMSRedelivered()) {
// we have received the first message
log.debugf("Message [%s, %s] contains text 'await'", message, text);
// synchronize with test to start with undeploy
HelperSingletonImpl.barrier.await(WAIT_S, SECONDS);
HelperSingletonImpl.barrier.reset();
// since HornetQ 2.4.3.Final, the MDB is *not* interrupted when it is undeployed
// (undeployment waits till the MDB ends with onMessage processing)
// waiting to get transaction timeout
try {
Thread.sleep(SECONDS.toMillis(WAIT_S));
} catch (InterruptedException ie) {
log.trace("Sleeping for transaction timeout was interrupted."
+ "This is expected at least for JTS transaction.");
}
// synchronize with test to undeploy would be in processing
HelperSingletonImpl.barrier.await(WAIT_S, SECONDS);
}
replyMessage = session.createTextMessage("Reply: " + text);
} else {
replyMessage = session.createTextMessage("Unknown message");
}
Destination destination = message.getJMSReplyTo();
message.setJMSDeliveryMode(NON_PERSISTENT);
sender.send(destination, replyMessage);
log.debugf("onMessage method [OK], msg: [%s] with id [%s]. Replying to destination [%s].",
text, message, destination);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@PostConstruct
public void postConstruct() {
log.trace(ReplyingMDB.class.getSimpleName() + " was created");
try {
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
sender = session.createProducer(null);
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
@PreDestroy
public void preDestroy() {
log.trace("Destroying MDB " + ReplyingMDB.class.getSimpleName());
try {
if (connection != null)
connection.close();
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
}
| 5,489 | 41.55814 | 121 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/containerstart/HelperSingletonImpl.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright (c) 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @authors tag. See the copyright.txt 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.ejb.mdb.containerstart;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import jakarta.ejb.Remote;
import jakarta.ejb.Singleton;
import jakarta.ejb.Startup;
/**
* @author <a href="[email protected]">Carlo de Wolf</a>
*/
@Singleton
@Startup
@Remote(HelperSingleton.class)
public class HelperSingletonImpl implements HelperSingleton {
public static CyclicBarrier barrier = new CyclicBarrier(2);
public int await(String where, long timeout, TimeUnit unit) throws BrokenBarrierException, TimeoutException, InterruptedException {
return barrier.await(timeout, unit);
}
public void reset() {
barrier.reset();
}
}
| 1,850 | 36.02 | 135 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/containerstart/SendMessagesTestCase.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright (c) 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @authors tag. See the copyright.txt 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.ejb.mdb.containerstart;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.jboss.as.test.integration.common.jms.JMSOperationsProvider.getInstance;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import java.util.PropertyPermission;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.DeliveryMode;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageConsumer;
import jakarta.jms.MessageProducer;
import jakarta.jms.Queue;
import jakarta.jms.Session;
import jakarta.jms.TextMessage;
import javax.naming.InitialContext;
import org.jboss.arquillian.container.test.api.Deployer;
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.ContainerResource;
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.client.ModelControllerClient;
import org.jboss.as.controller.client.OperationBuilder;
import org.jboss.as.controller.client.helpers.ClientConstants;
import org.jboss.as.controller.client.helpers.standalone.DeploymentPlan;
import org.jboss.as.controller.client.helpers.standalone.ServerDeploymentManager;
import org.jboss.as.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
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.AfterClass;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Part of migration EJB testsuite (JBAS-7922) to AS7 [JIRA JBQA-5483]. This test covers jira AS7-687 which aims to migrate this
* test to new testsuite.
* Testing undeploying an app in middle of MDB onMessage function and checking whether all messages will processed correctly.
*
* Code sequence is:
* 1. deploy the application
* 2. send 1 "await" message
* => test waits to MDB would start with receiving the message
* 3. undeploy the app (undeploy waits until onMessage finishes work)
* 4. MDB transaction is timeouted which means that is marked as rollback only (no exception thrown)
* transaction timeout influences only incoming message (is putting back to queue)
* the outgoing message is not "send" by XA aware connection factory
* when TM runs on JTS then sleep is interrupted with interrupted exception
* 5. meanwhile sending 50 "50loop" messages
* 6. MDB onMessage finishes ist work ("await" message is delivered to out-queue)
* and the undeployment of app could finish its work
* 7. ensure that the undeployment is completed
* 8. redeploy the application
* 9. send 10 "10loop" messages
* 10. check the test receives 62 messages:
* * 1 await
* * 50 do not lose
* * 10 some more
* * 1 await (redelivered message)
*
* @author Carlo de Wolf, Ondrej Chaloupka
*/
@RunWith(Arquillian.class)
@RunAsClient
@ServerSetup(SendMessagesTestCase.SendMessagesTestCaseSetup.class)
public class SendMessagesTestCase {
private static final Logger log = Logger.getLogger(SendMessagesTestCase.class);
private static final String MESSAGE_DRIVEN_BEAN = "message-driven-bean-containerstart";
private static final String SINGLETON = "single-containerstart";
private static ExecutorService executor = Executors.newSingleThreadExecutor();
private static String QUEUE_SEND = "queue/sendMessage";
private static final int UNDEPLOYED_WAIT_S = TimeoutUtil.adjust(30);
private static final int RECEIVE_WAIT_S = TimeoutUtil.adjust(30);
@ContainerResource
private ManagementClient managementClient;
static class SendMessagesTestCaseSetup implements ServerSetupTask {
@Override
public void setup(final ManagementClient managementClient, final String containerId) throws Exception {
final JMSOperations operations = getInstance(managementClient);
operations.createJmsQueue(QUEUE_SEND, "java:jboss/exported/" + QUEUE_SEND);
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
final JMSOperations operations = getInstance(managementClient);
operations.removeJmsQueue(QUEUE_SEND);
}
}
@ArquillianResource
private Deployer deployer;
@ContainerResource
private InitialContext ctx;
@AfterClass
public static void afterClass() {
executor.shutdown();
}
@Deployment(name = "singleton", order = 1, testable = false, managed = true)
public static Archive<?> deploymentMbean() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, SINGLETON + ".jar")
.addClasses(HelperSingleton.class, HelperSingletonImpl.class);
// grant necessary permissions
jar.addAsResource(createPermissionsXmlAsset(new PropertyPermission("ts.timeout.factor", "read")), "META-INF/jboss-permissions.xml");
return jar;
}
@Deployment(name = "mdb", order = 2, testable = false, managed = false)
public static Archive<?> deploymentMdb() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, MESSAGE_DRIVEN_BEAN + ".jar")
.addClasses(ReplyingMDB.class, TimeoutUtil.class);
jar.addAsManifestResource(new StringAsset("Dependencies: deployment." + SINGLETON + ".jar\n"), "MANIFEST.MF");
// grant necessary permissions
jar.addAsResource(createPermissionsXmlAsset(new PropertyPermission("ts.timeout.factor", "read")), "META-INF/jboss-permissions.xml");
return jar;
}
public static void applyUpdate(ModelNode update, final ModelControllerClient client) throws Exception {
ModelNode result = client.execute(new OperationBuilder(update).build());
if (result.hasDefined("outcome") && "success".equals(result.get("outcome").asString())) {
if (result.hasDefined("result")) {
log.trace(result.get("result"));
}
} else if (result.hasDefined("failure-description")) {
throw new RuntimeException(result.get("failure-description").toString());
} else {
throw new RuntimeException("Operation not successful; outcome = " + result.get("outcome"));
}
}
private int awaitSingleton(String where) throws Exception {
HelperSingleton helper = (HelperSingleton) ctx.lookup(SINGLETON + "/HelperSingletonImpl!org.jboss.as.test.integration.ejb.mdb.containerstart.HelperSingleton");
return helper.await(where, UNDEPLOYED_WAIT_S, SECONDS);
}
private static void sendMessage(Session session, MessageProducer sender, Queue replyQueue, String txt) throws JMSException {
TextMessage msg = session.createTextMessage(txt);
msg.setJMSReplyTo(replyQueue);
msg.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
sender.send(msg);
}
@Test
public void testShutdown(@ArquillianResource @OperateOnDeployment("singleton") ManagementClient client) throws Exception {
Connection connection = null;
try {
deployer.deploy("mdb");
ConnectionFactory cf = (ConnectionFactory) ctx.lookup("jms/RemoteConnectionFactory");
Queue queue = (Queue) ctx.lookup(QUEUE_SEND);
connection = cf.createConnection("guest", "guest");
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue replyQueue = session.createTemporaryQueue();
MessageProducer sender = session.createProducer(queue);
MessageConsumer receiver = session.createConsumer(replyQueue);
connection.start();
// we do not assume message order since the 1st message will be redelivered
// after redeployment (as the MDB is interrupted on 1st delivery)
Set<String> expected = new TreeSet<String>();
sendMessage(session, sender, replyQueue, "await");
expected.add("Reply: await");
// synchronize receiving message
int awaitInt = awaitSingleton("await before undeploy");
log.debug("testsuite: first awaitSingleton() returned: " + awaitInt);
Future<?> undeployed = executor.submit(undeployTask());
for (int i = 1; i <= 50; i++) {
String msg = this.getClass().getSimpleName() + " 50loop: " + i;
sendMessage(session, sender, replyQueue, msg); // should be bounced by BlockContainerShutdownInterceptor
expected.add("Reply: " + msg);
}
log.debug("Sent 50 messages during MDB is undeploying");
// synchronize with transaction timeout
awaitInt = awaitSingleton("await after undeploy");
log.debug("testsuite: second awaitSingleton() returned: " + awaitInt);
undeployed.get(UNDEPLOYED_WAIT_S, SECONDS);
// deploying via management client, arquillian deployer does not work for some reason
final ModelNode deployAddr = new ModelNode();
deployAddr.get(ClientConstants.OP_ADDR).add("deployment", MESSAGE_DRIVEN_BEAN + ".jar");
deployAddr.get(ClientConstants.OP).set("deploy");
applyUpdate(deployAddr, managementClient.getControllerClient());
for (int i = 1; i <= 10; i++) {
String msg = this.getClass().getSimpleName() + "10loop: " + i;
sendMessage(session, sender, replyQueue, msg);
expected.add("Reply: " + msg);
}
log.debug("Sent 10 more messages");
Set<String> received = new TreeSet<String>();
for (int i = 1; i <= (1 + 50 + 10 + 1); i++) {
Message msg = receiver.receive(SECONDS.toMillis(RECEIVE_WAIT_S));
assertNotNull("did not receive message with ordered number " + i +
" in " + SECONDS.toMillis(RECEIVE_WAIT_S) + " seconds", msg);
String text = ((TextMessage) msg).getText();
received.add(text);
log.trace(i + ": " + text);
}
assertNull(receiver.receiveNoWait());
assertEquals(expected, received);
} finally {
if(connection != null) {
connection.close();
}
deployer.undeploy("mdb");
}
}
// using DRM call for undeployment
private Callable<Void> undeployTask() {
return new Callable<Void>() {
public Void call() throws Exception {
ServerDeploymentManager deploymentManager = ServerDeploymentManager.Factory.create(managementClient.getControllerClient());
final DeploymentPlan plan = deploymentManager.newDeploymentPlan().undeploy(MESSAGE_DRIVEN_BEAN + ".jar").build();
deploymentManager.execute(plan).get(UNDEPLOYED_WAIT_S, SECONDS);
return null;
}
};
}
}
| 12,847 | 43.923077 | 167 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/containerstart/HelperSingleton.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright (c) 2011, Red Hat Middleware LLC, and individual contributors
* as indicated by the @authors tag. See the copyright.txt 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.ejb.mdb.containerstart;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* @author <a href="[email protected]">Carlo de Wolf</a>
*/
public interface HelperSingleton {
int await(String where, long timeout, TimeUnit unit) throws BrokenBarrierException, TimeoutException, InterruptedException;
void reset();
}
| 1,479 | 41.285714 | 127 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/jbossall/JBossAllEjbJarTestCase.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.jbossall;
import javax.naming.InitialContext;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests that jboss-ejb3.xml is picked up from jboss-all.xml
*/
@RunWith(Arquillian.class)
public class JBossAllEjbJarTestCase {
@ArquillianResource
private InitialContext ctx;
@Deployment(name = "test")
public static Archive<?> deploy() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "jbossAllEjb.jar");
jar.addPackage(JBossAllEjbJarTestCase.class.getPackage());
jar.addAsManifestResource(JBossAllEjbJarTestCase.class.getPackage(), "jboss-all.xml", "jboss-all.xml");
return jar;
}
@Test
public void test() throws Exception {
//if the lookup passes then we know the bean was added
ctx.lookup("java:module/" + JBossAllBean.class.getSimpleName());
}
}
| 2,226 | 36.116667 | 111 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/jbossall/JBossAllBean.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.ejb.packaging.jbossall;
/**
* @author Stuart Douglas
*/
public class JBossAllBean {
}
| 1,152 | 36.193548 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/injection/BaseBean.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.injection;
import jakarta.annotation.PostConstruct;
import jakarta.ejb.Stateless;
/**
* @author Stuart Douglas
*/
@Stateless
public class BaseBean {
private String message;
@PostConstruct
public void postConstruct() {
message = "Hello World";
}
public String sayHello() {
return message;
}
}
| 1,408 | 30.311111 | 73 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/injection/SimpleServlet.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.injection;
import jakarta.ejb.EJB;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author Stuart Douglas
*/
public class SimpleServlet extends HttpServlet {
@EJB
private BaseBean bean;
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
resp.getWriter().append(bean.sayHello());
}
}
| 1,631 | 36.090909 | 125 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/injection/CrossModuleInjectionTestCase.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.ejb.packaging.injection;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.test.integration.common.HttpRequest;
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.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests that lifecycle methods defined on classes in a different module to the component class
* are called.
*/
@RunWith(Arquillian.class)
public class CrossModuleInjectionTestCase {
private static final String ARCHIVE_NAME = "CrossModuleInjectionTestCase";
@ArquillianResource
private URL url;
private static final String WEB_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
" \n" +
"<web-app xmlns=\"http://java.sun.com/xml/ns/javaee\"\n" +
"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
"xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\"\n" +
"version=\"2.5\">\n" +
" \n" +
" <servlet>\n" +
" <servlet-name>SimpleServlet</servlet-name>\n" +
" <servlet-class>"+SimpleServlet.class.getName()+"</servlet-class>\n" +
" <load-on-startup>1</load-on-startup>\n" +
" </servlet>\n" +
" \n" +
" <servlet-mapping>\n" +
" <servlet-name>SimpleServlet</servlet-name>\n" +
" <url-pattern>/SimpleServlet</url-pattern>\n" +
" </servlet-mapping>\n" +
"</web-app>";
@Deployment(testable = false)
public static Archive<?> deploy() {
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, ARCHIVE_NAME + ".ear");
JavaArchive lib = ShrinkWrap.create(JavaArchive.class, "lib.jar");
lib.addClass(SimpleServlet.class);
ear.addAsLibrary(lib);
JavaArchive module = ShrinkWrap.create(JavaArchive.class, "ejb.jar");
module.addClasses(CrossModuleInjectionTestCase.class, BaseBean.class);
ear.addAsModule(module);
WebArchive war = ShrinkWrap.create(WebArchive.class,"simple.war");
war.addAsWebInfResource(new StringAsset(WEB_XML),"web.xml");
ear.addAsModule(war);
return ear;
}
@Test
public void testPostConstructCalled() throws Exception {
Assert.assertEquals("Hello World", HttpRequest.get( url.toExternalForm() + "SimpleServlet", 2, TimeUnit.SECONDS));
}
}
| 3,965 | 39.886598 | 124 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/RemoteBeanInterfaceInEarLib.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.ejb.packaging.multimodule;
import jakarta.ejb.Remote;
/**
* User: jpai
*/
@Remote
public interface RemoteBeanInterfaceInEarLib {
}
| 1,197 | 35.30303 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/BaseBean.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.multimodule;
import jakarta.annotation.PostConstruct;
/**
* @author Stuart Douglas
*/
public class BaseBean {
public static boolean postConstructCalled = false;
@PostConstruct
public void postConstruct() {
postConstructCalled = true;
}
}
| 1,337 | 33.307692 | 73 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/LocalBeanInterfaceInEjbJar.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.ejb.packaging.multimodule;
import jakarta.ejb.Local;
/**
* User: jpai
*/
@Local
public interface LocalBeanInterfaceInEjbJar {
}
| 1,194 | 35.212121 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/MrBean.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.ejb.packaging.multimodule;
import jakarta.ejb.LocalBean;
import jakarta.ejb.Stateless;
/**
* User: jpai
*/
@Stateless
@LocalBean
public class MrBean implements LocalBeanInterfaceInEarLib, LocalBeanInterfaceInEjbJar, RemoteBeanInterfaceInEarLib, RemoteBeanInterfaceInEjbJar {
}
| 1,343 | 37.4 | 145 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/ChildBean.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.multimodule;
import jakarta.ejb.Stateful;
/**
* @author Stuart Douglas
*/
@Stateful
public class ChildBean extends BaseBean {
public void doStuff() {
}
}
| 1,237 | 32.459459 | 73 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/RemoteBeanInterfaceInEjbJar.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.ejb.packaging.multimodule;
import jakarta.ejb.Remote;
/**
* User: jpai
*/
@Remote
public interface RemoteBeanInterfaceInEjbJar {
}
| 1,197 | 35.30303 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/ViewClassPackagingTestCase.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.ejb.packaging.multimodule;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.naming.Context;
import javax.naming.InitialContext;
/**
* Tests that a deployment containing EJB interfaces in a separate jar, than the bean implementation, is deployed correctly
* with the correct business interface views setup for the EJB.
*
* @see https://issues.jboss.org/browse/AS7-1112
* <p/>
* User: Jaikiran Pai
*/
@RunWith(Arquillian.class)
public class ViewClassPackagingTestCase {
private static final String APP_NAME = "ejb-packaging-test";
private static final String MODULE_NAME = "ejb-jar";
/**
* java:global/ namespace
*/
private static final String JAVA_GLOBAL_NAMESPACE_PREFIX = "java:global/";
/**
* java:app/ namespace
*/
private static final String JAVA_APP_NAMESPACE_PREFIX = "java:app/";
/**
* java:module/ namespace
*/
private static final String JAVA_MODULE_NAMESPACE_PREFIX = "java:module/";
@Deployment
public static EnterpriseArchive createDeployment() {
final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar");
ejbJar.addClasses(MrBean.class, LocalBeanInterfaceInEjbJar.class, RemoteBeanInterfaceInEjbJar.class, ViewClassPackagingTestCase.class);
final JavaArchive beanInterfacesLibraryJar = ShrinkWrap.create(JavaArchive.class, "bean-interfaces-library.jar");
beanInterfacesLibraryJar.addClasses(LocalBeanInterfaceInEarLib.class, RemoteBeanInterfaceInEarLib.class);
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, APP_NAME + ".ear");
ear.addAsModule(ejbJar);
ear.addAsLibrary(beanInterfacesLibraryJar);
return ear;
}
/**
* Tests that all possible local view bindings of a Stateless bean are available, when deployed through a .ear
*
* @throws Exception
*/
@Test
public void testBeanLocalViewBindings() throws Exception {
Context ctx = new InitialContext();
String ejbName = MrBean.class.getSimpleName();
// global bindings
// 1. local business interface
LocalBeanInterfaceInEarLib localBusinessInterfaceInEarLib = (LocalBeanInterfaceInEarLib) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + LocalBeanInterfaceInEarLib.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:global namespace", localBusinessInterfaceInEarLib);
LocalBeanInterfaceInEjbJar localBusinessInterfaceInEjbJar = (LocalBeanInterfaceInEjbJar) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + LocalBeanInterfaceInEjbJar.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:global namespace", localBusinessInterfaceInEjbJar);
// 2. no-interface view
MrBean noInterfaceView = (MrBean) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + MrBean.class.getName());
Assert.assertNotNull("Null object returned for no-interface view lookup in java:global namespace", noInterfaceView);
// app bindings
// 1. local business interface
LocalBeanInterfaceInEarLib localEarLibBusinessInterfaceInAppNamespace = (LocalBeanInterfaceInEarLib) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + LocalBeanInterfaceInEarLib.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:app namespace", localEarLibBusinessInterfaceInAppNamespace);
LocalBeanInterfaceInEjbJar localEjbJarBusinessInterfaceInAppNamespace = (LocalBeanInterfaceInEjbJar) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + LocalBeanInterfaceInEjbJar.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:app namespace", localEjbJarBusinessInterfaceInAppNamespace);
// 2. no-interface view
MrBean noInterfaceViewInAppNamespace = (MrBean) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + MrBean.class.getName());
Assert.assertNotNull("Null object returned for no-interface view lookup in java:app namespace", noInterfaceViewInAppNamespace);
// module bindings
// 1. local business interface
LocalBeanInterfaceInEarLib localEarLibBusinessInterfaceInModuleNamespace = (LocalBeanInterfaceInEarLib) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + LocalBeanInterfaceInEarLib.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:module namespace", localEarLibBusinessInterfaceInModuleNamespace);
LocalBeanInterfaceInEjbJar localEjbJarBusinessInterfaceInModuleNamespace = (LocalBeanInterfaceInEjbJar) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + LocalBeanInterfaceInEjbJar.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:module namespace", localEjbJarBusinessInterfaceInModuleNamespace);
// 2. no-interface view
MrBean noInterfaceViewInModuleNamespace = (MrBean) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + MrBean.class.getName());
Assert.assertNotNull("Null object returned for no-interface view lookup in java:module namespace", noInterfaceViewInModuleNamespace);
}
/**
* Tests that all possible remote view bindings of a Stateless bean are available, when deployed through a .ear
*
* @throws Exception
*/
@Test
public void testRemoteBindingsOnSLSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = MrBean.class.getSimpleName();
// global bindings
// 1. remote business interface
RemoteBeanInterfaceInEarLib remoteBusinessInterfaceInEarLib = (RemoteBeanInterfaceInEarLib) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + RemoteBeanInterfaceInEarLib.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:global namespace", remoteBusinessInterfaceInEarLib);
RemoteBeanInterfaceInEjbJar remoteBusinessInterfaceInEjbJar = (RemoteBeanInterfaceInEjbJar) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + RemoteBeanInterfaceInEjbJar.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:global namespace", remoteBusinessInterfaceInEjbJar);
// app bindings
// 1. remote business interface
RemoteBeanInterfaceInEarLib remoteEarLibBusinessInterfaceInAppNamespace = (RemoteBeanInterfaceInEarLib) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + RemoteBeanInterfaceInEarLib.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:app namespace", remoteEarLibBusinessInterfaceInAppNamespace);
RemoteBeanInterfaceInEjbJar remoteEjbJarBusinessInterfaceInAppNamespace = (RemoteBeanInterfaceInEjbJar) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + RemoteBeanInterfaceInEjbJar.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:app namespace", remoteEjbJarBusinessInterfaceInAppNamespace);
// module bindings
// 1. remote business interface
RemoteBeanInterfaceInEarLib remoteEarLibBusinessInterfaceInModuleNamespace = (RemoteBeanInterfaceInEarLib) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + RemoteBeanInterfaceInEarLib.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:module namespace", remoteEarLibBusinessInterfaceInModuleNamespace);
RemoteBeanInterfaceInEjbJar remoteEjbJarBusinessInterfaceInModuleNamespace = (RemoteBeanInterfaceInEjbJar) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + RemoteBeanInterfaceInEjbJar.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:module namespace", remoteEjbJarBusinessInterfaceInModuleNamespace);
}
}
| 9,786 | 56.570588 | 240 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/MultiModuleLifecycleMethodTestCase.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.ejb.packaging.multimodule;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests that lifecycle methods defined on classes in a different module to the component class
* are called.
*/
@RunWith(Arquillian.class)
public class MultiModuleLifecycleMethodTestCase {
private static final String ARCHIVE_NAME = "MultiModuleLifecycleMethodTestCase";
@Deployment
public static Archive<?> deploy() {
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, ARCHIVE_NAME + ".ear");
JavaArchive lib = ShrinkWrap.create(JavaArchive.class, "lib.jar");
lib.addClass(BaseBean.class);
ear.addAsLibrary(lib);
JavaArchive module = ShrinkWrap.create(JavaArchive.class, "module.jar");
module.addClasses(MultiModuleLifecycleMethodTestCase.class, ChildBean.class);
ear.addAsModule(module);
return ear;
}
@ArquillianResource
private InitialContext iniCtx;
protected <T> T lookup(String beanName, Class<T> interfaceType) throws NamingException {
return interfaceType.cast(iniCtx.lookup("java:global/" + ARCHIVE_NAME + "/module/" + beanName + "!" + interfaceType.getName()));
}
@Test
public void testPostConstructCalled() throws Exception {
ChildBean sfsb1 = lookup("ChildBean", ChildBean.class);
sfsb1.doStuff();
Assert.assertTrue(BaseBean.postConstructCalled);
}
}
| 2,931 | 38.093333 | 136 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/multimodule/LocalBeanInterfaceInEarLib.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.ejb.packaging.multimodule;
import jakarta.ejb.Local;
/**
* User: Jaikiran Pai
*/
@Local
public interface LocalBeanInterfaceInEarLib {
}
| 1,202 | 35.454545 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/Servlet.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war;
import java.io.IOException;
import jakarta.ejb.EJB;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
/**
* @author Ondrej Chaloupka
*/
public class Servlet extends HttpServlet {
private static final long serialVersionUID = 1L;
@EJB
JarBean jarBean;
@EJB
WarBean warBean;
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Object attr = req.getParameter("archive");
if ("jar".equals(attr)) {
try {
resp.getOutputStream().print(jarBean.checkMe());
} catch (Exception e) {
resp.getOutputStream().print("error");
}
}
if ("war".equals(attr)) {
try {
resp.getOutputStream().print(warBean.checkMe());
} catch (Exception e) {
resp.getOutputStream().print("error");
}
}
}
}
| 2,156 | 31.681818 | 113 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/WarBean.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war;
import jakarta.ejb.EJB;
/**
* Stateless bean placed into classes in war archive. Bean definition in xml dd.
*
* @author Ondrej Chaloupka
*/
public class WarBean implements BeanInterface {
@EJB
private JarBean jarBean;
public String checkMe() {
return "Hi " + jarBean.say() + " from war";
}
public String say() {
return "war";
}
}
| 1,452 | 32.022727 | 80 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/JarBean.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war;
import jakarta.ejb.EJB;
/**
* Stateless bean placed into jar archive in war archive.
* Bean definition in xml dd.
*
* @author Ondrej Chaloupka
*/
public class JarBean implements BeanInterface {
@EJB(beanName = "WarBean")
private BeanInterface warBean;
public String checkMe() {
return "Hi " + warBean.say() + " from jar";
}
public String say() {
return "jar";
}
}
| 1,487 | 32.066667 | 73 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/WarPackagingTestCase.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import javax.naming.InitialContext;
import org.junit.Assert;
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.test.integration.common.HttpRequest;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Testing packaging ejb in war.
*
* @author Ondrej Chaloupka
*/
@RunWith(Arquillian.class)
public class WarPackagingTestCase {
private static final Logger log = Logger.getLogger(WarPackagingTestCase.class);
private static final String ARCHIVE_NAME = "ejbinwar";
private static final String JAR_SUCCESS_STRING = "Hi war from jar";
private static final String WAR_SUCCESS_STRING = "Hi jar from war";
@ArquillianResource
private InitialContext ctx;
@Deployment(name = "test")
public static Archive<?> deploy() {
WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME + ".war");
// classes directly in war
war.addClasses(Servlet.class, WarBean.class, WarPackagingTestCase.class);
war.addAsWebInfResource(WarPackagingTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
war.addAsWebInfResource(WarPackagingTestCase.class.getPackage(), "web.xml", "web.xml");
// jar with bean interface
JavaArchive jarInterface = ShrinkWrap.create(JavaArchive.class, "interfacelib.jar");
jarInterface.addClass(BeanInterface.class);
// jar with bean implementation
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "jarlib.jar");
jar.addClass(JarBean.class);
war.addAsLibraries(jarInterface);
war.addAsLibraries(jar);
return war;
}
@Test
public void test() throws Exception {
JarBean jarBean = (JarBean) ctx.lookup("java:module/" + JarBean.class.getSimpleName() + "!" + JarBean.class.getName());
Assert.assertEquals(JAR_SUCCESS_STRING, jarBean.checkMe());
jarBean = (JarBean) ctx.lookup("java:global/" + ARCHIVE_NAME + "/" + JarBean.class.getSimpleName() + "!"
+ JarBean.class.getName());
Assert.assertEquals(JAR_SUCCESS_STRING, jarBean.checkMe());
WarBean warBean = (WarBean) ctx.lookup("java:module/" + WarBean.class.getSimpleName() + "!" + WarBean.class.getName());
Assert.assertEquals(WAR_SUCCESS_STRING, warBean.checkMe());
warBean = (WarBean) ctx.lookup("java:module/" + WarBean.class.getSimpleName() + "!" + WarBean.class.getName());
Assert.assertEquals(WAR_SUCCESS_STRING, warBean.checkMe());
}
@Test
@RunAsClient
public void testServletCall(@ArquillianResource @OperateOnDeployment("test") URL baseUrl) throws Exception {
String url = "http://" + baseUrl.getHost() + ":" + baseUrl.getPort() + "/ejbinwar/servlet?archive=jar";
log.trace(url);
String res = HttpRequest.get(url, 2, TimeUnit.SECONDS);
Assert.assertEquals(JAR_SUCCESS_STRING, res);
}
}
| 4,477 | 42.475728 | 127 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/BeanInterface.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2012, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war;
/**
* @author Ondrej Chaloupka
*/
public interface BeanInterface {
String checkMe();
String say();
}
| 1,187 | 35 | 73 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/namingcontext/EjbInterface.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war.namingcontext;
import javax.naming.NamingException;
import jakarta.transaction.UserTransaction;
/**
* @author Stuart Douglas
*/
public interface EjbInterface {
UserTransaction lookupUserTransaction() throws NamingException;
UserTransaction lookupOtherUserTransaction() throws NamingException;
}
| 1,380 | 38.457143 | 73 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/namingcontext/War2Ejb.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war.namingcontext;
import jakarta.annotation.Resource;
import jakarta.ejb.LocalBean;
import jakarta.ejb.Stateless;
import jakarta.ejb.TransactionManagement;
import jakarta.ejb.TransactionManagementType;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import jakarta.transaction.UserTransaction;
/**
* @author Stuart Douglas
*/
@Stateless
@LocalBean
@TransactionManagement(value = TransactionManagementType.BEAN)
public class War2Ejb implements EjbInterface {
@Resource
public UserTransaction ut2;
@Override
public UserTransaction lookupUserTransaction() throws NamingException {
return (UserTransaction) new InitialContext().lookup("java:comp/env/" + getClass().getName() + "/ut2");
}
@Override
public UserTransaction lookupOtherUserTransaction() throws NamingException {
return (UserTransaction) new InitialContext().lookup("java:comp/env/" + getClass().getPackage().getName() + "War1Ejb/ut1");
}
}
| 2,051 | 35 | 131 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/namingcontext/WarEjbNamingContextTestCase.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war.namingcontext;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.Archive;
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.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.naming.InitialContext;
import javax.naming.NamingException;
/**
* Tests that EJB's packaged in a war use the correct naming context
*
* @author Stuart Douglas
*/
@RunWith(Arquillian.class)
public class WarEjbNamingContextTestCase {
private static final String ARCHIVE_NAME = "WarEjbNamingContextTestCase";
@Deployment
public static Archive<?> deploy() {
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, ARCHIVE_NAME + ".ear");
JavaArchive lib = ShrinkWrap.create(JavaArchive.class, "lib.jar");
lib.addClass(EjbInterface.class);
ear.addAsLibrary(lib);
WebArchive war1 = ShrinkWrap.create(WebArchive.class, "war1.war");
war1.addClasses(WarEjbNamingContextTestCase.class, War1Ejb.class);
ear.addAsModule(war1);
WebArchive war2 = ShrinkWrap.create(WebArchive.class, "war2.war");
war2.addClasses(War2Ejb.class);
ear.addAsModule(war2);
return ear;
}
@Test
public void testCorrectNamingContextUsedForEjbInWar() throws Exception {
EjbInterface ejb = (EjbInterface) new InitialContext().lookup("java:app/war1/War1Ejb");
Assert.assertNotNull(ejb.lookupUserTransaction());
try {
ejb.lookupOtherUserTransaction();
Assert.fail();
} catch (NamingException expected) {
}
ejb = (EjbInterface) new InitialContext().lookup("java:app/war2/War2Ejb");
Assert.assertNotNull(ejb.lookupUserTransaction());
try {
ejb.lookupOtherUserTransaction();
Assert.fail();
} catch (NamingException expected) {
}
}
}
| 3,189 | 33.673913 | 98 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/packaging/war/namingcontext/War1Ejb.java
|
/*
* JBoss, Home of Professional Open Source
* Copyright 2010, Red Hat Inc., and individual contributors as indicated
* by the @authors tag. See the copyright.txt 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.ejb.packaging.war.namingcontext;
import jakarta.annotation.Resource;
import jakarta.ejb.LocalBean;
import jakarta.ejb.Stateless;
import jakarta.ejb.TransactionManagement;
import jakarta.ejb.TransactionManagementType;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import jakarta.transaction.UserTransaction;
/**
* @author Stuart Douglas
*/
@Stateless
@LocalBean
@TransactionManagement(value = TransactionManagementType.BEAN)
public class War1Ejb implements EjbInterface {
@Resource
public UserTransaction ut1;
public UserTransaction lookupUserTransaction() throws NamingException {
return (UserTransaction) new InitialContext().lookup("java:comp/env/" + getClass().getName() + "/ut1");
}
@Override
public UserTransaction lookupOtherUserTransaction() throws NamingException {
return (UserTransaction) new InitialContext().lookup("java:comp/env/" + getClass().getPackage().getName() + "War2Ejb/ut2");
}
}
| 2,035 | 36.703704 | 131 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/jndi/Echo.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.ejb.jndi;
/**
* User: jpai
*/
public interface Echo {
String echo(String msg);
}
| 1,151 | 35 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/jndi/OverriddenAppNameTestCase.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.ejb.jndi;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test that the deployment(s) with an overridden application-name and module-name have the correct EJB
* jndi bindings
* <p/>
* User: Jaikiran Pai
*/
@RunWith(Arquillian.class)
public class OverriddenAppNameTestCase {
/**
* The app name of the deployment
*/
private static final String APP_NAME = "application-name-in-application.xml";
/**
* Complete ear file name including the .ear file extension
*/
private static final String EAR_NAME = "overridden-application-name.ear";
/**
* The module name of the deployment
*/
private static final String MODULE_NAME = "module-name-in-ejb-jar.xml";
/**
* Complete jar file name including the .jar file extension
*/
private static final String JAR_NAME = "ejb.jar";
/**
* java:global/ namespace
*/
private static final String JAVA_GLOBAL_NAMESPACE_PREFIX = "java:global/";
/**
* java:app/ namespace
*/
private static final String JAVA_APP_NAMESPACE_PREFIX = "java:app/";
/**
* java:module/ namespace
*/
private static final String JAVA_MODULE_NAMESPACE_PREFIX = "java:module/";
/**
* Create the deployment
*
* @return
*/
@Deployment
public static EnterpriseArchive createEar() {
// create the top level ear
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, EAR_NAME);
// add application.xml
ear.addAsManifestResource(OverriddenAppNameTestCase.class.getPackage(), "application.xml", "application.xml");
// create the jar containing the EJBs
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, JAR_NAME);
// add ejb-jar.xml
jar.addAsManifestResource(OverriddenAppNameTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
// add the entire package
jar.addPackage(EchoBean.class.getPackage());
// add the jar to the .ear
ear.add(jar, "/", ZipExporter.class);
// return the .ear
return ear;
}
/**
* Tests that all possible local view bindings of a Stateless bean are available, when deployed through a .ear
*
* @throws Exception
*/
@Test
public void testLocalBindingsOnSLSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = EchoBean.class.getSimpleName();
// global bindings
// 1. local business interface
Echo localBusinessInterface = (Echo) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + Echo.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:global namespace", localBusinessInterface);
// 2. no-interface view
EchoBean noInterfaceView = (EchoBean) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + EchoBean.class.getName());
Assert.assertNotNull("Null object returned for no-interface view lookup in java:global namespace", noInterfaceView);
// app bindings
// 1. local business interface
Echo localBusinessInterfaceInAppNamespace = (Echo) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + Echo.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:app namespace", localBusinessInterfaceInAppNamespace);
// 2. no-interface view
EchoBean noInterfaceViewInAppNamespace = (EchoBean) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + EchoBean.class.getName());
Assert.assertNotNull("Null object returned for no-interface view lookup in java:app namespace", noInterfaceViewInAppNamespace);
// module bindings
// 1. local business interface
Echo localBusinessInterfaceInModuleNamespace = (Echo) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + Echo.class.getName());
Assert.assertNotNull("Null object returned for local business interface lookup in java:module namespace", localBusinessInterfaceInModuleNamespace);
// 2. no-interface view
EchoBean noInterfaceViewInModuleNamespace = (EchoBean) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + EchoBean.class.getName());
Assert.assertNotNull("Null object returned for no-interface view lookup in java:module namespace", noInterfaceViewInModuleNamespace);
}
/**
* Tests that all possible remote view bindings of a Stateless bean are available, when deployed through a .ear
*
* @throws Exception
*/
@Test
public void testRemoteBindingsOnSLSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = EchoBean.class.getSimpleName();
// global bindings
// 1. remote business interface
RemoteEcho remoteBusinessInterface = (RemoteEcho) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + RemoteEcho.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:global namespace", remoteBusinessInterface);
// app bindings
// 1. remote business interface
RemoteEcho remoteBusinessInterfaceInAppNamespace = (RemoteEcho) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + RemoteEcho.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:app namespace", remoteBusinessInterfaceInAppNamespace);
// module bindings
// 1. remote business interface
RemoteEcho remoteBusinessInterfaceInModuleNamespace = (RemoteEcho) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + RemoteEcho.class.getName());
Assert.assertNotNull("Null object returned for remote business interface lookup in java:module namespace", remoteBusinessInterfaceInModuleNamespace);
}
}
| 7,525 | 42.755814 | 181 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/jndi/RemoteEcho.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.ejb.jndi;
/**
* User: jpai
*/
public interface RemoteEcho extends Echo {
}
| 1,140 | 37.033333 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/jndi/EchoBean.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.ejb.jndi;
import jakarta.ejb.Local;
import jakarta.ejb.LocalBean;
import jakarta.ejb.Remote;
import jakarta.ejb.Stateless;
/**
* User: jpai
*/
@Stateless
@LocalBean
@Remote(RemoteEcho.class)
@Local(Echo.class)
public class EchoBean implements Echo {
public String echo(String msg) {
return msg;
}
}
| 1,382 | 31.162791 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/jndi/logging/HelloBean.java
|
package org.jboss.as.test.integration.ejb.jndi.logging;
import jakarta.ejb.Remote;
import jakarta.ejb.Stateless;
@Stateless(name="Hello")
@Remote(Hello.class)
public class HelloBean implements Hello {
}
| 205 | 19.6 | 55 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/jndi/logging/JNDIBindingsNoAppNameTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, 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.ejb.jndi.logging;
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.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.test.shared.TestLogHandlerSetupTask;
import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.jboss.as.test.shared.util.LoggingUtil;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import java.util.Collection;
import java.util.Collections;
import java.util.Properties;
/**
* Automated test for [ WFLY-11848 ] - Tests if JNDI bindings is correctly built in case there is no appName.
*
* @author Daniel Cihak
*/
@RunWith(Arquillian.class)
@RunAsClient
@ServerSetup(JNDIBindingsNoAppNameTestCase.TestLogHandlerSetup.class)
public class JNDIBindingsNoAppNameTestCase {
private static final String JAR_NAME = "ejb-jndi";
private static String HOST = TestSuiteEnvironment.getServerAddress();
private static int PORT = TestSuiteEnvironment.getHttpPort();
private static final String TEST_HANDLER_NAME = "test-" + JNDIBindingsNoAppNameTestCase.class.getSimpleName();
private static final String TEST_LOG_FILE_NAME = TEST_HANDLER_NAME + ".log";
public static class TestLogHandlerSetup extends TestLogHandlerSetupTask {
@Override
public Collection<String> getCategories() {
return Collections.singletonList("org.jboss");
}
@Override
public String getLevel() {
return "INFO";
}
@Override
public String getHandlerName() {
return TEST_HANDLER_NAME;
}
@Override
public String getLogFileName() {
return TEST_LOG_FILE_NAME;
}
}
@Deployment
public static JavaArchive createJar() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, JAR_NAME);
jar.addClasses(JNDIBindingsNoAppNameTestCase.class, Hello.class, HelloBean.class);
return jar;
}
@ContainerResource
private ManagementClient managementClient;
@Test
public void testJNDIBindingsNoAppName() throws Exception {
Context ctx = getInitialContext(HOST, PORT);
Hello ejb = (Hello) ctx.lookup("ejb:/ejb-jndi/Hello!org.jboss.as.test.integration.ejb.jndi.logging.Hello");
Assert.assertNotNull("Null object returned for local business interface lookup in the ejb namespace", ejb);
Assert.assertTrue("Expected JNDI binding message not found", LoggingUtil.hasLogMessage(managementClient, TEST_HANDLER_NAME,
"ejb:/ejb-jndi/Hello!org.jboss.as.test.integration.ejb.jndi.logging.Hello"));
}
private static Context getInitialContext(String host, Integer port) throws NamingException {
Properties props = new Properties();
props.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory");
props.put(Context.PROVIDER_URL, String.format("%s://%s:%d", "remote+http", host, port));
return new InitialContext(props);
}
}
| 4,473 | 39.672727 | 131 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/jndi/logging/Hello.java
|
package org.jboss.as.test.integration.ejb.jndi.logging;
public interface Hello {
}
| 84 | 16 | 55 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/global/Session21Home.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.ejb.ejb2.reference.global;
import jakarta.ejb.EJBHome;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Session21Home extends EJBHome {
Session21 create() throws java.rmi.RemoteException, jakarta.ejb.CreateException;
}
| 1,335 | 38.294118 | 84 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/global/Session21Bean.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.ejb.ejb2.reference.global;
import jakarta.ejb.SessionContext;
import javax.naming.InitialContext;
import org.jboss.logging.Logger;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public class Session21Bean implements jakarta.ejb.SessionBean {
private static final long serialVersionUID = 1L;
private static final Logger log = Logger.getLogger(Session21Bean.class);
public String access() {
return "Session21";
}
public String access30() {
try {
InitialContext jndiContext = new InitialContext();
Session30RemoteBusiness session = (Session30RemoteBusiness) jndiContext.lookup("java:comp/env/Session30");
return session.access();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public String globalAccess30() {
try {
InitialContext jndiContext = new InitialContext();
Session30RemoteBusiness session = (Session30RemoteBusiness) jndiContext.lookup("java:global/global-reference-ejb3/GlobalSession30");
return session.access();
} catch (Exception e) {
log.error("Session21Bean.globalAccess30()", e);
return null;
}
}
public void ejbCreate() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void ejbRemove() {
}
public void setSessionContext(SessionContext context) {
}
}
| 2,561 | 29.86747 | 144 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/global/Session21.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.ejb.ejb2.reference.global;
import java.rmi.RemoteException;
/**
* @author $Author: wolfc
*/
public interface Session21 extends jakarta.ejb.EJBObject {
String access() throws RemoteException;
String access30() throws RemoteException;
String globalAccess30() throws RemoteException;
}
| 1,367 | 35.972973 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/global/GlobalReferenceTestCase.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.ejb.ejb2.reference.global;
import java.util.Hashtable;
import jakarta.ejb.EJBHome;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.ejb.client.EJBClient;
import org.jboss.ejb.client.EJBHomeLocator;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Migration test from EJB Testsuite (reference21_30) to AS7 [JIRA JBQA-5483].
* Test for EJB3.0/EJB2.1 references
*
* @author William DeCoste, Ondrej Chaloupka
*/
@RunWith(Arquillian.class)
public class GlobalReferenceTestCase {
private static final String EJB2 = "global-reference-ejb2";
private static final String EJB3 = "global-reference-ejb3";
@Deployment(name = "ejb3")
public static Archive<?> deploymentEjb3() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, EJB3 + ".jar")
.addClasses(GlobalReferenceTestCase.class, GlobalSession30Bean.class, Session30.class, Session30RemoteBusiness.class,
Session21.class, Session21Home.class);
return jar;
}
@Deployment(name = "ejb2")
public static Archive<?> deploymentEjb2() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, EJB2 + ".jar")
.addClasses(Session21.class, Session21Bean.class, Session21Home.class,
Session30.class, Session30RemoteBusiness.class);
jar.addAsManifestResource(GlobalReferenceTestCase.class.getPackage(), "jboss-ejb3-global.xml", "jboss.xml");
jar.addAsManifestResource(GlobalReferenceTestCase.class.getPackage(), "ejb-jar-global.xml", "ejb-jar.xml");
return jar;
}
// app name: simple jar - empty app name
// module name: name of jar = eb
private <T extends EJBHome> T getHome(final Class<T> homeClass, final String beanName) {
final EJBHomeLocator<T> locator = new EJBHomeLocator<T>(homeClass, "", EJB2, beanName, "");
return EJBClient.createProxy(locator);
}
private InitialContext getInitialContext() throws NamingException {
final Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.as.naming.InitialContextFactory");
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
return new InitialContext(jndiProperties);
}
@Test
public void testSession21() throws Exception {
Session21Home home = this.getHome(Session21Home.class, "Session21");
Session21 session = home.create();
String access = session.access();
Assert.assertEquals("Session21", access);
access = session.globalAccess30();
Assert.assertEquals("Session30", access);
}
@Test
public void testSession30() throws Exception {
Session30RemoteBusiness session = (Session30RemoteBusiness) getInitialContext().lookup(
"ejb:/" + EJB3 + "/GlobalSession30!" + Session30RemoteBusiness.class.getName());
String access = session.access();
Assert.assertEquals("Session30", access);
access = session.globalAccess21();
Assert.assertEquals("Session21", access);
}
}
| 4,538 | 41.027778 | 128 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/global/Session30.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.ejb.ejb2.reference.global;
import java.rmi.RemoteException;
import jakarta.ejb.EJBObject;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Session30 extends EJBObject {
String access() throws RemoteException;
String access21() throws RemoteException;
String globalAccess21() throws RemoteException;
String accessLocalStateful() throws RemoteException;
String accessLocalStateful(String value) throws RemoteException;
String accessLocalStateful(String value, Integer suffix) throws RemoteException;
}
| 1,641 | 35.488889 | 84 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/global/Session30RemoteBusiness.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.ejb.ejb2.reference.global;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Session30RemoteBusiness {
String access();
String access21();
String globalAccess21();
String accessLocalStateful();
String accessLocalStateful(String value);
String accessLocalStateful(String value, Integer suffix);
}
| 1,434 | 34 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/global/GlobalSession30Bean.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.ejb.ejb2.reference.global;
import jakarta.ejb.Remote;
import jakarta.ejb.Stateless;
import javax.naming.InitialContext;
import org.jboss.logging.Logger;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
@Stateless(name = "GlobalSession30")
@Remote(Session30RemoteBusiness.class)
public class GlobalSession30Bean implements Session30RemoteBusiness {
private static final Logger log = Logger.getLogger(GlobalSession30Bean.class);
public String access() {
return "Session30";
}
public String access21() {
return null;
}
public String accessLocalStateful() {
return "not supported";
}
public String accessLocalStateful(String value) {
return "not supported";
}
public String accessLocalStateful(String value, Integer suffix) {
return "not supported";
}
public String globalAccess21() {
try {
InitialContext jndiContext = new InitialContext();
Session21Home home = (Session21Home) jndiContext.lookup("java:global/global-reference-ejb2/Session21!" + Session21Home.class.getName());
Session21 session = home.create();
return session.access();
} catch (Exception e) {
log.error("GlobalSession30Bean.globalAccess21()", e);
return null;
}
}
}
| 2,422 | 32.652778 | 148 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive/Test3.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.ejb.ejb2.reference.eararchive;
import jakarta.ejb.EJBObject;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Test3 extends EJBObject, Test3Business {
void testAccess() throws Exception;
}
| 1,304 | 38.545455 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive/Test3Bean.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.ejb.ejb2.reference.eararchive;
import jakarta.ejb.EJB;
import jakarta.ejb.EJBs;
import jakarta.ejb.Remote;
import jakarta.ejb.RemoteHome;
import jakarta.ejb.Stateless;
import javax.naming.InitialContext;
import org.jboss.logging.Logger;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
@Stateless(name = "Test3")
@Remote(Test3Business.class)
@RemoteHome(Test3Home.class)
@EJBs({@EJB(name = "injected/Test2", lookup = "java:app/multideploy-ejb2/ejb_Test2!org.jboss.as.test.integration.ejb.ejb2.reference.eararchive.Test2Home", beanInterface = Test2Home.class)})
public class Test3Bean implements Test3Business {
private static final Logger log = Logger.getLogger(Test3Bean.class);
@EJB(name = "ejb/Test2")
private Test2Home test2Home = null;
public void testAccess() throws Exception {
Test2 test2 = test2Home.create();
InitialContext jndiContext = new InitialContext();
Test2Home home = (Test2Home) jndiContext.lookup("java:comp/env/injected/Test2");
test2 = home.create();
}
}
| 2,128 | 37.709091 | 189 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive/ReferenceEarTestCase.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.ejb.ejb2.reference.eararchive;
import javax.naming.InitialContext;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Migration test from EJB Testsuite (reference21_30) to AS7 [JIRA JBQA-5483]. Test for EJB3.0/EJB2.1 references
*
* @author William DeCoste, Ondrej Chaloupka
*/
@RunWith(Arquillian.class)
public class ReferenceEarTestCase {
@ArquillianResource
InitialContext ctx;
@Deployment
public static Archive<?> deployment() {
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "multideploy-reference21_31-test.ear");
final JavaArchive jar1 = ShrinkWrap.create(JavaArchive.class, "multideploy-ejb2.jar")
.addClasses(
Test2.class,
Test2Bean.class,
Test2Home.class);
jar1.addClass(ReferenceEarTestCase.class);
jar1.addAsManifestResource(ReferenceEarTestCase.class.getPackage(), "jboss-ejb3-ejb2.xml", "jboss-ejb3.xml");
jar1.addAsManifestResource(ReferenceEarTestCase.class.getPackage(), "ejb-jar-ejb2.xml", "ejb-jar.xml");
final JavaArchive jar2 = ShrinkWrap.create(JavaArchive.class, "multideploy-ejb3.jar")
.addClasses(
Test3.class,
Test3Business.class,
Test3Home.class,
Test3Bean.class);
jar2.addAsManifestResource(ReferenceEarTestCase.class.getPackage(), "jboss-ejb3-ejb3.xml", "jboss-ejb3.xml");
jar2.addAsManifestResource(ReferenceEarTestCase.class.getPackage(), "ejb-jar-ejb3.xml", "ejb-jar.xml");
ear.addAsModule(jar1);
ear.addAsModule(jar2);
return ear;
}
@Test
public void testEjbInjection2() throws Exception {
Test3Home test3Home = (Test3Home) ctx.lookup("java:app/multideploy-ejb3/Test3!" + Test3Home.class.getName());
Test3 test3 = test3Home.create();
Assert.assertNotNull(test3);
test3.testAccess();
Test2Home home = (Test2Home) ctx.lookup("java:app/multideploy-ejb2/ejb_Test2!" + Test2Home.class.getName());
Assert.assertNotNull(home);
Test2 test2 = home.create();
Assert.assertNotNull(test2);
test2.testAccess();
}
@Test
public void testEjbInjection3() throws Exception {
Test3Business test3 = (Test3Business) ctx.lookup("java:app/multideploy-ejb3/Test3!" + Test3Business.class.getName());
Assert.assertNotNull(test3);
test3.testAccess();
Test2Home home = (Test2Home) ctx.lookup("java:app/multideploy-ejb2/ejb_Test2!" + Test2Home.class.getName());
Assert.assertNotNull(home);
Test2 test2 = home.create();
Assert.assertNotNull(test2);
test2.testAccess();
}
}
| 4,242 | 39.409524 | 125 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive/Test2Bean.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.ejb.ejb2.reference.eararchive;
import jakarta.ejb.SessionContext;
import javax.naming.InitialContext;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public class Test2Bean implements jakarta.ejb.SessionBean {
private static final long serialVersionUID = -8375644698783606562L;
public void testAccess() throws Exception {
InitialContext jndiContext = new InitialContext();
Test3Business session = (Test3Business) jndiContext.lookup("java:comp/env/ejb/Test3");
session.testAccess();
Test3Home home = (Test3Home) jndiContext.lookup("java:comp/env/ejb/Test3Home");
session = home.create();
session.testAccess();
}
public void ejbCreate() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}
public void ejbRemove() {
}
public void setSessionContext(SessionContext context) {
}
}
| 1,996 | 29.723077 | 94 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive/Test2.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.ejb.ejb2.reference.eararchive;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Test2 extends jakarta.ejb.EJBObject {
void testAccess() throws Exception;
}
| 1,270 | 40 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive/Test2Home.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.ejb.ejb2.reference.eararchive;
import jakarta.ejb.EJBHome;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Test2Home extends EJBHome {
Test2 create() throws java.rmi.RemoteException, jakarta.ejb.CreateException;
}
| 1,331 | 38.176471 | 80 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive/Test3Business.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.ejb.ejb2.reference.eararchive;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Test3Business {
void testAccess() throws Exception;
}
| 1,248 | 39.290323 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/eararchive/Test3Home.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.ejb.ejb2.reference.eararchive;
import jakarta.ejb.EJBHome;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Test3Home extends EJBHome {
Test3 create() throws java.rmi.RemoteException, jakarta.ejb.CreateException;
}
| 1,331 | 38.176471 | 80 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/Session30Home.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.ejb.ejb2.reference.annotation;
import jakarta.ejb.EJBHome;
import org.jboss.as.test.integration.ejb.ejb2.reference.global.Session30;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Session30Home extends EJBHome {
Session30 create() throws java.rmi.RemoteException, jakarta.ejb.CreateException;
}
| 1,415 | 37.27027 | 84 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/LocalSession30.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.ejb.ejb2.reference.annotation;
import jakarta.ejb.EJBLocalObject;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface LocalSession30 extends EJBLocalObject, LocalSession30Business {
}
| 1,292 | 39.40625 | 80 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/HomedStatefulSession30Bean.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.ejb.ejb2.reference.annotation;
import jakarta.annotation.PreDestroy;
import jakarta.ejb.Init;
import jakarta.ejb.Local;
import jakarta.ejb.LocalHome;
import jakarta.ejb.RemoteHome;
import jakarta.ejb.Stateful;
import javax.naming.InitialContext;
import org.jboss.logging.Logger;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
@Stateful(name = "HomedStatefulSession30")
@RemoteHome(StatefulSession30Home.class)
@LocalHome(StatefulSession30LocalHome.class)
@Local(LocalStatefulSession30Business.class)
public class HomedStatefulSession30Bean implements java.io.Serializable {
private static final long serialVersionUID = -1013103935052726415L;
private static final Logger log = Logger.getLogger(HomedStatefulSession30Bean.class);
private String value = null;
public void setValue(String value) {
this.value = value;
}
public String getValue() {
return value;
}
public void setLocalValue(String value) {
this.value = value;
}
public String getLocalValue() {
return value;
}
public String accessLocalStateless() {
try {
InitialContext jndiContext = new InitialContext();
Session30LocalHome localHome = (Session30LocalHome) jndiContext.lookup("java:module/StatefulSession30! " + StatefulSession30Home.class.getName());
LocalSession30 localSession = localHome.create();
return localSession.access();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public String accessLocalHome() {
return null;
}
@Init
public void ejbCreate() {
value = "default";
}
@Init
public void ejbCreate(String value) {
this.value = value;
}
@Init
public void ejbCreate(String value, Integer suffix) {
this.value = value + suffix;
}
@PreDestroy
public void preDestroy() {
log.trace("Invoking PreDestroy");
}
}
| 3,078 | 29.186275 | 158 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/LocalSession30Business.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.ejb.ejb2.reference.annotation;
import java.rmi.RemoteException;
/**
* LocalSession30Business
*
* @author <a href="mailto:[email protected]">ALR</a>
*/
public interface LocalSession30Business {
String access() throws RemoteException;
}
| 1,319 | 36.714286 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/Session30LocalHome.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.ejb.ejb2.reference.annotation;
import jakarta.ejb.EJBLocalHome;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface Session30LocalHome extends EJBLocalHome {
LocalSession30 create() throws jakarta.ejb.CreateException;
}
| 1,332 | 39.393939 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/LocalStatefulSession30Business.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.ejb.ejb2.reference.annotation;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface LocalStatefulSession30Business {
String getLocalValue();
void setLocalValue(String value);
}
| 1,292 | 38.181818 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/Session30Bean.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.ejb.ejb2.reference.annotation;
import jakarta.ejb.EJB;
import jakarta.ejb.EJBs;
import jakarta.ejb.Local;
import jakarta.ejb.LocalHome;
import jakarta.ejb.Remote;
import jakarta.ejb.RemoteHome;
import jakarta.ejb.Stateless;
import javax.naming.InitialContext;
import org.jboss.as.test.integration.ejb.ejb2.reference.global.Session21;
import org.jboss.as.test.integration.ejb.ejb2.reference.global.Session21Home;
import org.jboss.as.test.integration.ejb.ejb2.reference.global.Session30RemoteBusiness;
import org.jboss.logging.Logger;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
@Stateless(name = "Session30")
@Remote(Session30RemoteBusiness.class)
@Local(LocalSession30Business.class)
@RemoteHome(Session30Home.class)
@LocalHome(Session30LocalHome.class)
@EJBs({@EJB(name = "injected", beanInterface = Session21Home.class, beanName = "Session21")})
public class Session30Bean implements Session30RemoteBusiness, LocalSession30Business {
private static final Logger log = Logger.getLogger(Session30Bean.class);
public String access() {
return "Session30";
}
public String access21() {
try {
InitialContext jndiContext = new InitialContext();
Session21Home sessionHome = (Session21Home) jndiContext.lookup("java:comp/env/injected");
Session21 session = sessionHome.create();
return session.access();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public String globalAccess21() {
try {
InitialContext jndiContext = new InitialContext();
Session21Home home = (Session21Home) jndiContext.lookup("java:module/Session21!" + Session21Home.class.getName());
Session21 session = home.create();
return session.access();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public String accessLocalStateful() {
try {
InitialContext jndiContext = new InitialContext();
StatefulSession30LocalHome localHome = (StatefulSession30LocalHome) jndiContext.lookup("java:module/StatefulSession30!" + StatefulSession30LocalHome.class.getName());
LocalStatefulSession30 localSession = localHome.create();
return localSession.getLocalValue();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public String accessLocalStateful(String value) {
try {
InitialContext jndiContext = new InitialContext();
StatefulSession30LocalHome localHome = (StatefulSession30LocalHome) jndiContext.lookup("java:module/StatefulSession30!" + StatefulSession30LocalHome.class.getName());
LocalStatefulSession30 localSession = localHome.create(value);
return localSession.getLocalValue();
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public String accessLocalStateful(String value, Integer suffix) {
try {
InitialContext jndiContext = new InitialContext();
StatefulSession30LocalHome localHome = (StatefulSession30LocalHome) jndiContext.lookup("java:module/StatefulSession30!" + StatefulSession30LocalHome.class.getName());
LocalStatefulSession30 localSession = localHome.create(value, suffix);
return localSession.getLocalValue();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
| 4,590 | 39.991071 | 178 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/StatefulSession30LocalHome.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.ejb.ejb2.reference.annotation;
import jakarta.ejb.EJBLocalHome;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface StatefulSession30LocalHome extends EJBLocalHome {
LocalStatefulSession30 create() throws jakarta.ejb.CreateException;
LocalStatefulSession30 create(String value) throws jakarta.ejb.CreateException;
LocalStatefulSession30 create(String value, Integer suffix) throws jakarta.ejb.CreateException;
}
| 1,535 | 39.421053 | 99 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/ejb2/reference/annotation/StatefulSession30Home.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.ejb.ejb2.reference.annotation;
import jakarta.ejb.EJBHome;
/**
* @author <a href="mailto:[email protected]">William DeCoste</a>
*/
public interface StatefulSession30Home extends EJBHome {
StatefulSession30 create() throws java.rmi.RemoteException, jakarta.ejb.CreateException;
StatefulSession30 create(String value) throws java.rmi.RemoteException, jakarta.ejb.CreateException;
StatefulSession30 create(String value, Integer suffix) throws java.rmi.RemoteException, jakarta.ejb.CreateException;
}
| 1,583 | 40.684211 | 120 |
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.