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/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/inflow/PureInflowResourceAdapter.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.inflow;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
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 org.jboss.logging.Logger;
/**
* PureInflowResourceAdapter
*
* @version $Revision: $
*/
public class PureInflowResourceAdapter implements ResourceAdapter {
/**
* The logger
*/
private static Logger log = Logger.getLogger(PureInflowResourceAdapter.class);
/**
* The activations by activation spec
*/
private Map<PureInflowActivationSpec, PureInflowActivation> activations;
/**
* Default constructor
*/
public PureInflowResourceAdapter() {
this.activations = Collections.synchronizedMap(new HashMap<PureInflowActivationSpec, PureInflowActivation>());
}
/**
* This is called during the activation of a message endpoint.
*
* @param endpointFactory A message endpoint factory instance.
* @param spec An activation spec JavaBean instance.
* @throws ResourceException generic exception
*/
public void endpointActivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) throws ResourceException {
PureInflowActivation activation = new PureInflowActivation(this, endpointFactory, (PureInflowActivationSpec) spec);
activations.put((PureInflowActivationSpec) spec, activation);
activation.start();
log.trace("endpointActivation()");
}
/**
* This is called when a message endpoint is deactivated.
*
* @param endpointFactory A message endpoint factory instance.
* @param spec An activation spec JavaBean instance.
*/
public void endpointDeactivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) {
PureInflowActivation activation = (PureInflowActivation) activations.remove(spec);
if (activation != null) { activation.stop(); }
log.trace("endpointDeactivation()");
}
/**
* This is called when a resource adapter instance is bootstrapped.
*
* @param ctx A bootstrap context containing references
* @throws ResourceAdapterInternalException indicates bootstrap failure.
*/
public void start(BootstrapContext ctx)
throws ResourceAdapterInternalException {
log.trace("start()");
}
/**
* This is called when a resource adapter instance is undeployed or
* during application server shutdown.
*/
public void stop() {
log.trace("stop()");
}
/**
* This method is called by the application server during crash recovery.
*
* @param specs An array of ActivationSpec JavaBeans
* @return An array of XAResource objects
* @throws ResourceException generic exception
*/
public XAResource[] getXAResources(ActivationSpec[] specs)
throws ResourceException {
log.trace("getXAResources()");
return null;
}
/**
* Returns a hash code value for the object.
*
* @return A hash code value for this object.
*/
@Override
public int hashCode() {
int result = 17;
return result;
}
/**
* Indicates whether some other object is equal to this one.
*
* @param other The reference object with which to compare.
* @return true if this object is the same as the obj argument, false otherwise.
*/
@Override
public boolean equals(Object other) {
if (other == null) { return false; }
if (other == this) { return true; }
if (!(other instanceof PureInflowResourceAdapter)) { return false; }
PureInflowResourceAdapter obj = (PureInflowResourceAdapter) other;
boolean result = true;
return result;
}
}
| 5,204 | 33.019608 | 123 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyAdminObjectInterface.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
import java.io.Serializable;
import jakarta.resource.Referenceable;
/**
* ConfigPropertyAdminObjectInterface
*
* @version $Revision: $
*/
public interface ConfigPropertyAdminObjectInterface extends Referenceable, Serializable {
/**
* Set property
*
* @param property The value
*/
void setProperty(String property);
/**
* Get property
*
* @return The value
*/
String getProperty();
}
| 1,541 | 31.808511 | 89 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyAdminObjectImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
import java.io.Serializable;
import javax.naming.NamingException;
import javax.naming.Reference;
import jakarta.resource.Referenceable;
import jakarta.resource.spi.ResourceAdapter;
import jakarta.resource.spi.ResourceAdapterAssociation;
/**
* ConfigPropertyAdminObjectImpl
*
* @version $Revision: $
*/
public class ConfigPropertyAdminObjectImpl implements ConfigPropertyAdminObjectInterface,
ResourceAdapterAssociation, Referenceable, Serializable {
/**
* Serial version uid
*/
private static final long serialVersionUID = 1L;
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* Reference
*/
private Reference reference;
/**
* property
*/
private String property;
/**
* Default constructor
*/
public ConfigPropertyAdminObjectImpl() {
}
/**
* Set property
*
* @param property The value
*/
public void setProperty(String property) {
this.property = property;
}
/**
* Get property
*
* @return The value
*/
public String getProperty() {
return property;
}
/**
* Get the resource adapter
*
* @return The handle
*/
public ResourceAdapter getResourceAdapter() {
return ra;
}
/**
* Set the resource adapter
*
* @param ra The handle
*/
public void setResourceAdapter(ResourceAdapter ra) {
this.ra = ra;
}
/**
* Get the Reference instance.
*
* @return Reference instance
* @throws javax.naming.NamingException Thrown if a reference can't be obtained
*/
@Override
public Reference getReference() throws NamingException {
return reference;
}
/**
* Set the Reference instance.
*
* @param reference A Reference instance
*/
@Override
public void setReference(Reference reference) {
this.reference = reference;
}
/**
* Returns a hash code value for the object.
*
* @return A hash code value for this object.
*/
@Override
public int hashCode() {
int result = 17;
if (property != null) { result += 31 * result + 7 * property.hashCode(); } else { result += 31 * result + 7; }
return result;
}
/**
* Indicates whether some other object is equal to this one.
*
* @param other The reference object with which to compare.
* @return true if this object is the same as the obj argument, false otherwise.
*/
@Override
public boolean equals(Object other) {
if (other == null) { return false; }
if (other == this) { return true; }
if (!(other instanceof ConfigPropertyAdminObjectImpl)) { return false; }
ConfigPropertyAdminObjectImpl obj = (ConfigPropertyAdminObjectImpl) other;
boolean result = true;
if (result) {
if (property == null) { result = obj.getProperty() == null; } else { result = property.equals(obj.getProperty()); }
}
return result;
}
}
| 4,185 | 26.006452 | 127 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyConnectionFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
import java.io.Serializable;
import jakarta.resource.Referenceable;
import jakarta.resource.ResourceException;
/**
* ConfigPropertyConnectionFactory
*
* @version $Revision: $
*/
public interface ConfigPropertyConnectionFactory extends Serializable, Referenceable {
/**
* Get connection from factory
*
* @return ConfigPropertyConnection instance
* @throws jakarta.resource.ResourceException Thrown if a connection can't be obtained
*/
ConfigPropertyConnection getConnection() throws ResourceException;
}
| 1,637 | 38 | 90 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyResourceAdapter.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
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;
/**
* ConfigPropertyResourceAdapter
*
* @version $Revision: $
*/
public class ConfigPropertyResourceAdapter implements ResourceAdapter {
/**
* property
*/
private String property;
/**
* Default constructor
*/
public ConfigPropertyResourceAdapter() {
}
/**
* Set property
*
* @param property The value
*/
public void setProperty(String property) {
this.property = property;
}
/**
* Get property
*
* @return The value
*/
public String getProperty() {
return property;
}
/**
* This is called during the activation of a message endpoint.
*
* @param endpointFactory A message endpoint factory instance.
* @param spec An activation spec JavaBean instance.
* @throws jakarta.resource.ResourceException generic exception
*/
public void endpointActivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) throws ResourceException {
}
/**
* This is called when a message endpoint is deactivated.
*
* @param endpointFactory A message endpoint factory instance.
* @param spec An activation spec JavaBean instance.
*/
public void endpointDeactivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) {
}
/**
* This is called when a resource adapter instance is bootstrapped.
*
* @param ctx A bootstrap context containing references
* @throws jakarta.resource.spi.ResourceAdapterInternalException indicates bootstrap failure.
*/
public void start(BootstrapContext ctx)
throws ResourceAdapterInternalException {
}
/**
* This is called when a resource adapter instance is undeployed or
* during application server shutdown.
*/
public void stop() {
}
/**
* This method is called by the application server during crash recovery.
*
* @param specs An array of ActivationSpec JavaBeans
* @return An array of XAResource objects
* @throws jakarta.resource.ResourceException generic exception
*/
public XAResource[] getXAResources(ActivationSpec[] specs)
throws ResourceException {
return null;
}
/**
* Returns a hash code value for the object.
*
* @return A hash code value for this object.
*/
@Override
public int hashCode() {
int result = 17;
if (property != null) { result += 31 * result + 7 * property.hashCode(); } else { result += 31 * result + 7; }
return result;
}
/**
* Indicates whether some other object is equal to this one.
*
* @param other The reference object with which to compare.
* @return true if this object is the same as the obj argument, false otherwise.
*/
@Override
public boolean equals(Object other) {
if (other == null) { return false; }
if (other == this) { return true; }
if (!(other instanceof ConfigPropertyResourceAdapter)) { return false; }
ConfigPropertyResourceAdapter obj = (ConfigPropertyResourceAdapter) other;
boolean result = true;
if (result) {
if (property == null) { result = obj.getProperty() == null; } else { result = property.equals(obj.getProperty()); }
}
return result;
}
}
| 4,887 | 31.586667 | 127 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyConnectionImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
/**
* ConfigPropertyConnectionImpl
*
* @version $Revision: $
*/
public class ConfigPropertyConnectionImpl implements ConfigPropertyConnection {
/**
* ManagedConnection
*/
private ConfigPropertyManagedConnection mc;
/**
* ManagedConnectionFactory
*/
private ConfigPropertyManagedConnectionFactory mcf;
/**
* Default constructor
*
* @param mc ConfigPropertyManagedConnection
* @param mcf ConfigPropertyManagedConnectionFactory
*/
public ConfigPropertyConnectionImpl(ConfigPropertyManagedConnection mc, ConfigPropertyManagedConnectionFactory mcf) {
this.mc = mc;
this.mcf = mcf;
}
/**
* Call getResourceAdapterProperty
*
* @return String
*/
public String getResourceAdapterProperty() {
return ((ConfigPropertyResourceAdapter) mcf.getResourceAdapter()).getProperty();
}
/**
* Call getManagedConnectionFactoryProperty
*
* @return String
*/
public String getManagedConnectionFactoryProperty() {
return mcf.getProperty();
}
/**
* Close
*/
public void close() {
mc.closeHandle(this);
}
}
| 2,285 | 29.078947 | 121 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyManagedConnectionMetaData.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ManagedConnectionMetaData;
/**
* ConfigPropertyManagedConnectionMetaData
*
* @version $Revision: $
*/
public class ConfigPropertyManagedConnectionMetaData implements ManagedConnectionMetaData {
/**
* Default constructor
*/
public ConfigPropertyManagedConnectionMetaData() {
}
/**
* Returns Product name of the underlying EIS instance connected through the ManagedConnection.
*
* @return Product name of the EIS instance
* @throws jakarta.resource.ResourceException Thrown if an error occurs
*/
@Override
public String getEISProductName() throws ResourceException {
return null;
}
/**
* Returns Product version of the underlying EIS instance connected through the ManagedConnection.
*
* @return Product version of the EIS instance
* @throws jakarta.resource.ResourceException Thrown if an error occurs
*/
@Override
public String getEISProductVersion() throws ResourceException {
return null;
}
/**
* Returns maximum limit on number of active concurrent connections
*
* @return Maximum limit for number of active concurrent connections
* @throws jakarta.resource.ResourceException Thrown if an error occurs
*/
@Override
public int getMaxConnections() throws ResourceException {
return 0;
}
/**
* Returns name of the user associated with the ManagedConnection instance
*
* @return Name of the user
* @throws jakarta.resource.ResourceException Thrown if an error occurs
*/
@Override
public String getUserName() throws ResourceException {
return null;
}
}
| 2,845 | 33.289157 | 102 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyManagedConnectionFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Set;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionManager;
import jakarta.resource.spi.ConnectionRequestInfo;
import jakarta.resource.spi.ManagedConnection;
import jakarta.resource.spi.ManagedConnectionFactory;
import jakarta.resource.spi.ResourceAdapter;
import jakarta.resource.spi.ResourceAdapterAssociation;
import javax.security.auth.Subject;
/**
* ConfigPropertyManagedConnectionFactory
*
* @version $Revision: $
*/
public class ConfigPropertyManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation {
/**
* The serial version UID
*/
private static final long serialVersionUID = 1L;
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* The logwriter
*/
private PrintWriter logwriter;
/**
* property
*/
private String property;
/**
* Default constructor
*/
public ConfigPropertyManagedConnectionFactory() {
}
/**
* Set property
*
* @param property The value
*/
public void setProperty(String property) {
this.property = property;
}
/**
* Get property
*
* @return The value
*/
public String getProperty() {
return property;
}
/**
* Creates a Connection Factory instance.
*
* @param cxManager ConnectionManager to be associated with created EIS connection factory instance
* @return EIS-specific Connection Factory instance or jakarta.resource.cci.ConnectionFactory instance
* @throws jakarta.resource.ResourceException Generic exception
*/
public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException {
return new ConfigPropertyConnectionFactoryImpl(this, cxManager);
}
/**
* Creates a Connection Factory instance.
*
* @return EIS-specific Connection Factory instance or jakarta.resource.cci.ConnectionFactory instance
* @throws jakarta.resource.ResourceException Generic exception
*/
public Object createConnectionFactory() throws ResourceException {
throw new ResourceException("This resource adapter doesn't support non-managed environments");
}
/**
* Creates a new physical connection to the underlying EIS resource manager.
*
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @return ManagedConnection instance
* @throws jakarta.resource.ResourceException generic exception
*/
public ManagedConnection createManagedConnection(Subject subject,
ConnectionRequestInfo cxRequestInfo) throws ResourceException {
return new ConfigPropertyManagedConnection(this);
}
/**
* Returns a matched connection from the candidate set of connections.
*
* @param connectionSet Candidate connection set
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @return ManagedConnection if resource adapter finds an acceptable match otherwise null
* @throws jakarta.resource.ResourceException generic exception
*/
public ManagedConnection matchManagedConnections(Set connectionSet,
Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof ConfigPropertyManagedConnection) {
result = mc;
}
}
return result;
}
/**
* Get the log writer for this ManagedConnectionFactory instance.
*
* @return PrintWriter
* @throws jakarta.resource.ResourceException generic exception
*/
public PrintWriter getLogWriter() throws ResourceException {
return logwriter;
}
/**
* Set the log writer for this ManagedConnectionFactory instance.
*
* @param out PrintWriter - an out stream for error logging and tracing
* @throws jakarta.resource.ResourceException generic exception
*/
public void setLogWriter(PrintWriter out) throws ResourceException {
logwriter = out;
}
/**
* Get the resource adapter
*
* @return The handle
*/
public ResourceAdapter getResourceAdapter() {
return ra;
}
/**
* Set the resource adapter
*
* @param ra The handle
*/
public void setResourceAdapter(ResourceAdapter ra) {
this.ra = ra;
}
/**
* Returns a hash code value for the object.
*
* @return A hash code value for this object.
*/
@Override
public int hashCode() {
int result = 17;
if (property != null) { result += 31 * result + 7 * property.hashCode(); } else { result += 31 * result + 7; }
return result;
}
/**
* Indicates whether some other object is equal to this one.
*
* @param other The reference object with which to compare.
* @return true if this object is the same as the obj argument, false otherwise.
*/
@Override
public boolean equals(Object other) {
if (other == null) { return false; }
if (other == this) { return true; }
if (!(other instanceof ConfigPropertyManagedConnectionFactory)) { return false; }
ConfigPropertyManagedConnectionFactory obj = (ConfigPropertyManagedConnectionFactory) other;
boolean result = true;
if (result) {
if (property == null) { result = obj.getProperty() == null; } else { result = property.equals(obj.getProperty()); }
}
return result;
}
}
| 7,150 | 32.260465 | 133 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyConnectionFactoryImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
import javax.naming.NamingException;
import javax.naming.Reference;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionManager;
/**
* ConfigPropertyConnectionFactoryImpl
*
* @version $Revision: $
*/
public class ConfigPropertyConnectionFactoryImpl implements ConfigPropertyConnectionFactory {
/**
* The serial version UID
*/
private static final long serialVersionUID = 1L;
/**
* Reference
*/
private Reference reference;
/**
* ManagedConnectionFactory
*/
private ConfigPropertyManagedConnectionFactory mcf;
/**
* ConnectionManager
*/
private ConnectionManager connectionManager;
/**
* Default constructor
*/
public ConfigPropertyConnectionFactoryImpl() {
}
/**
* Constructor
*
* @param mcf ManagedConnectionFactory
* @param cxManager ConnectionManager
*/
public ConfigPropertyConnectionFactoryImpl(ConfigPropertyManagedConnectionFactory mcf, ConnectionManager cxManager) {
this.mcf = mcf;
this.connectionManager = cxManager;
}
/**
* Get connection from factory
*
* @return ConfigPropertyConnection instance
* @throws jakarta.resource.ResourceException Thrown if a connection can't be obtained
*/
@Override
public ConfigPropertyConnection getConnection() throws ResourceException {
return (ConfigPropertyConnection) connectionManager.allocateConnection(mcf, null);
}
/**
* Get the Reference instance.
*
* @return Reference instance
* @throws javax.naming.NamingException Thrown if a reference can't be obtained
*/
@Override
public Reference getReference() throws NamingException {
return reference;
}
/**
* Set the Reference instance.
*
* @param reference A Reference instance
*/
@Override
public void setReference(Reference reference) {
this.reference = reference;
}
}
| 3,105 | 28.580952 | 121 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyManagedConnection.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import jakarta.resource.NotSupportedException;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionEvent;
import jakarta.resource.spi.ConnectionEventListener;
import jakarta.resource.spi.ConnectionRequestInfo;
import jakarta.resource.spi.LocalTransaction;
import jakarta.resource.spi.ManagedConnection;
import jakarta.resource.spi.ManagedConnectionMetaData;
import javax.security.auth.Subject;
import javax.transaction.xa.XAResource;
/**
* ConfigPropertyManagedConnection
*
* @version $Revision: $
*/
public class ConfigPropertyManagedConnection implements ManagedConnection {
/**
* The logwriter
*/
private PrintWriter logwriter;
/**
* ManagedConnectionFactory
*/
private ConfigPropertyManagedConnectionFactory mcf;
/**
* Listeners
*/
private List<ConnectionEventListener> listeners;
/**
* Connection
*/
private Object connection;
/**
* Default constructor
*
* @param mcf mcf
*/
public ConfigPropertyManagedConnection(ConfigPropertyManagedConnectionFactory mcf) {
this.mcf = mcf;
this.logwriter = null;
this.listeners = new ArrayList<ConnectionEventListener>(1);
this.connection = null;
}
/**
* Creates a new connection handle for the underlying physical connection
* represented by the ManagedConnection instance.
*
* @param subject Security context as JAAS subject
* @param cxRequestInfo ConnectionRequestInfo instance
* @return generic Object instance representing the connection handle.
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public Object getConnection(Subject subject,
ConnectionRequestInfo cxRequestInfo) throws ResourceException {
connection = new ConfigPropertyConnectionImpl(this, mcf);
return connection;
}
/**
* Used by the container to change the association of an
* application-level connection handle with a ManagedConneciton instance.
*
* @param connection Application-level connection handle
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public void associateConnection(Object connection) throws ResourceException {
}
/**
* Application server calls this method to force any cleanup on the ManagedConnection instance.
*
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public void cleanup() throws ResourceException {
}
/**
* Destroys the physical connection to the underlying resource manager.
*
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public void destroy() throws ResourceException {
}
/**
* Adds a connection event listener to the ManagedConnection instance.
*
* @param listener A new ConnectionEventListener to be registered
*/
public void addConnectionEventListener(ConnectionEventListener listener) {
if (listener == null) { throw new IllegalArgumentException("Listener is null"); }
listeners.add(listener);
}
/**
* Removes an already registered connection event listener from the ManagedConnection instance.
*
* @param listener already registered connection event listener to be removed
*/
public void removeConnectionEventListener(ConnectionEventListener listener) {
if (listener == null) { throw new IllegalArgumentException("Listener is null"); }
listeners.remove(listener);
}
/**
* Close handle
*
* @param handle The handle
*/
public void closeHandle(ConfigPropertyConnection handle) {
ConnectionEvent event = new ConnectionEvent(this, ConnectionEvent.CONNECTION_CLOSED);
event.setConnectionHandle(handle);
for (ConnectionEventListener cel : listeners) {
cel.connectionClosed(event);
}
}
/**
* Gets the log writer for this ManagedConnection instance.
*
* @return Character ourput stream associated with this Managed-Connection instance
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public PrintWriter getLogWriter() throws ResourceException {
return logwriter;
}
/**
* Sets the log writer for this ManagedConnection instance.
*
* @param out Character Output stream to be associated
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public void setLogWriter(PrintWriter out) throws ResourceException {
logwriter = out;
}
/**
* Returns an <code>jakarta.resource.spi.LocalTransaction</code> instance.
*
* @return LocalTransaction instance
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public LocalTransaction getLocalTransaction() throws ResourceException {
throw new NotSupportedException("LocalTransaction not supported");
}
/**
* Returns an <code>javax.transaction.xa.XAresource</code> instance.
*
* @return XAResource instance
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public XAResource getXAResource() throws ResourceException {
throw new NotSupportedException("GetXAResource not supported not supported");
}
/**
* Gets the metadata information for this connection's underlying EIS resource manager instance.
*
* @return ManagedConnectionMetaData instance
* @throws jakarta.resource.ResourceException generic exception if operation fails
*/
public ManagedConnectionMetaData getMetaData() throws ResourceException {
return new ConfigPropertyManagedConnectionMetaData();
}
}
| 7,095 | 34.48 | 100 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/deployment/rar/configproperty/ConfigPropertyConnection.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.deployment.rar.configproperty;
/**
* ConfigPropertyConnection
*
* @version $Revision: $
*/
public interface ConfigPropertyConnection {
/**
* getResourceAdapterProperty
*
* @return String
*/
String getResourceAdapterProperty();
/**
* getManagedConnectionFactoryProperty
*
* @return String
*/
String getManagedConnectionFactoryProperty();
/**
* Close
*/
void close();
}
| 1,513 | 29.897959 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/sar/ProcessMonitorService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.sar;
import java.util.concurrent.atomic.AtomicBoolean;
import org.jboss.logging.Logger;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public class ProcessMonitorService implements ProcessMonitorServiceMBean {
Logger log = Logger.getLogger(ProcessMonitorService.class);
private ConfigServiceMBean config;
AtomicBoolean stop = new AtomicBoolean();
public void setConfig(ConfigServiceMBean config) {
this.config = config;
}
public void start() {
log.trace("Starting " + config.getExampleName());
Thread t = new Thread(new Runnable() {
@Override
public void run() {
long starttime = System.currentTimeMillis();
while (!stop.get()) {
double totalmemory = bytesToMb(Runtime.getRuntime().totalMemory());
double usedmemory = totalmemory - bytesToMb(Runtime.getRuntime().freeMemory());
long seconds = (System.currentTimeMillis() - starttime)/1000;
log.trace(config.getExampleName() + "-Montitor: System using " + usedmemory + " Mb of " + totalmemory + " Mb after " + seconds + " seconds");
try {
Thread.sleep(config.getIntervalSeconds() * 1000);
} catch (InterruptedException e) {
stop.set(true);
}
}
}
});
t.start();
}
public void stop() {
stop.set(true);
log.trace("Stopping " + config.getExampleName());
}
static double bytesToMb(double d) {
d = d/(1024*1024);
d = Math.round(d*100);
return d/100;
}
}
| 2,814 | 32.511905 | 161 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/sar/ConfigService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.sar;
import org.jboss.logging.Logger;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public class ConfigService implements ConfigServiceMBean {
Logger log = Logger.getLogger(ConfigService.class);
private final String exampleName;
private int interval;
public ConfigService(String exampleName) {
this.exampleName = exampleName;
}
public int getIntervalSeconds() {
return interval;
}
public void setIntervalSeconds(int interval) {
log.trace("Setting IntervalSeconds to " + interval);
this.interval = interval;
}
public String getExampleName() {
return exampleName;
}
}
| 1,765 | 30.535714 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/sar/ConfigServiceMBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.sar;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public interface ConfigServiceMBean {
int getIntervalSeconds();
void setIntervalSeconds(int interval);
String getExampleName();
}
| 1,302 | 35.194444 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/sar/ProcessMonitorServiceMBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.sar;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public interface ProcessMonitorServiceMBean {
void start();
void stop();
}
| 1,241 | 36.636364 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/sar/SarTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.sar;
import javax.management.Attribute;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.xnio.IoUtils;
/**
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
@RunWith(Arquillian.class)
@RunAsClient
public class SarTestCase {
@ArquillianResource
private ManagementClient managementClient;
@Deployment(testable = false)
public static JavaArchive createDeployment() throws Exception {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "sar-example.sar");
jar.addPackage(SarTestCase.class.getPackage());
jar.addAsManifestResource(SarTestCase.class.getPackage(), "jboss-service.xml", "jboss-service.xml");
return jar;
}
@Test
public void testMBean() throws Exception {
final JMXConnector connector = JMXConnectorFactory.connect(managementClient.getRemoteJMXURL());
try {
MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();
ObjectName objectName = new ObjectName("jboss:name=test,type=config");
mbeanServer.getAttribute(objectName, "IntervalSeconds");
mbeanServer.setAttribute(objectName, new Attribute("IntervalSeconds", 2));
} finally {
IoUtils.safeClose(connector);
}
}
}
| 2,932 | 38.635135 | 108 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jaxrs/JaxrsTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jaxrs;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.test.integration.common.HttpRequest;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
*
* @author Stuart Douglas
*/
@RunWith(Arquillian.class)
@RunAsClient
public class JaxrsTestCase {
@ArquillianResource
private URL url;
@Deployment(testable = false)
public static Archive<?> getDeployment(){
final WebArchive war = create(WebArchive.class, "jaxrs-example.war");
war.addPackage(JaxrsTestCase.class.getPackage());
war.setWebXML(JaxrsTestCase.class.getPackage(), "web.xml");
return war;
}
@Test
public void testJaxrs() throws Exception {
String s = performCall();
Assert.assertEquals("Hello World!", s);
}
private String performCall() throws Exception {
URL url = new URL(this.url.toExternalForm() + "helloworld");
return HttpRequest.get(url.toExternalForm(), 10, TimeUnit.SECONDS);
}
}
| 2,448 | 33.985714 | 77 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jaxrs/HelloWorldResource.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.smoke.jaxrs;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
@Path("/helloworld")
@Produces({"text/plain"})
public class HelloWorldResource {
@GET
public String getMessage() {
return "Hello World!";
}
}
| 1,303 | 35.222222 | 73 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/InterceptorBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.managedbean;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.PreDestroy;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.InvocationContext;
import org.jboss.logging.Logger;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public class InterceptorBean {
private final Logger log = Logger.getLogger(InterceptorBean.class);
private String name;
@PostConstruct
public void initializeInterceptor(InvocationContext context) {
log.trace("Post constructing it");
name = "#InterceptorBean#";
}
@PreDestroy
public void destroyInterceptor(InvocationContext context) {
log.trace("Pre destroying it");
}
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
if (!context.getMethod().getName().equals("echo")) {
return context.proceed();
}
log.trace("-----> Intercepting call to " + context.getMethod().getDeclaringClass() + "." + context.getMethod().getName() + "()");
return name + context.proceed();
}
}
| 2,187 | 33.730159 | 138 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/CDIInterceptor.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.smoke.managedbean;
import jakarta.annotation.Priority;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptor;
import jakarta.interceptor.InvocationContext;
/**
* @author Jozef Hartinger
*/
@Interceptor
@CDIBinding
@Priority(Interceptor.Priority.APPLICATION + 50)
public class CDIInterceptor {
@AroundInvoke
Object intercept(InvocationContext ctx) throws Exception {
if (!ctx.getMethod().getName().equals("echo")) {
return ctx.proceed();
}
return "#CDIInterceptor#" + ctx.proceed();
}
}
| 1,614 | 34.888889 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/BeanWithSimpleInjected.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.managedbean;
import jakarta.annotation.ManagedBean;
import jakarta.annotation.PostConstruct;
import jakarta.annotation.Resource;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Inject;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptors;
import jakarta.interceptor.InvocationContext;
import org.jboss.logging.Logger;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @author [email protected]
*/
@ManagedBean("BeanWithSimpleInjected")
@Interceptors(InterceptorBean.class)
public class BeanWithSimpleInjected extends BeanParent {
private final Logger log = Logger.getLogger(BeanWithSimpleInjected.class);
@Resource
private SimpleManagedBean simple;
@Resource(lookup="java:module/SimpleManagedBean")
private SimpleManagedBean simple2;
@Inject
private CDIManagedBean bean;
private CDIManagedBean bean2;
@Inject
public void initMethod(CDIManagedBean bean) {
this.bean2 = bean;
}
@Inject int number;
@Inject String value;
@Inject Instance<String> valueInstance;
@PostConstruct
public void start() {
if(bean2 == null) {
throw new RuntimeException("PostConstruct called before @Inject method");
}
log.trace("-----> Constructed BeanWithSimpleInjected, simple=" + simple);
}
@Interceptors(OtherInterceptorBean.class)
@CDIBinding
public String echo(String msg) {
return msg + bean.getValue() + bean2.getValue();
}
public SimpleManagedBean getSimple() {
return simple;
}
public SimpleManagedBean getSimple2() {
return simple2;
}
public int getNumber() {
return number;
}
public String getValue() {
return value;
}
public String getValue2() {
return valueInstance.get();
}
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
if (!context.getMethod().getName().equals("echo")) {
return context.proceed();
}
log.trace("-----> Intercepting call to " + context.getMethod());
return "#BeanWithSimpleInjected#" + context.proceed();
}
}
| 3,269 | 28.196429 | 85 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/ManagedBeanTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.managedbean;
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.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;
/**
* @author <a href="[email protected]">Kabir Khan</a>
* @author [email protected]
*/
@RunWith(Arquillian.class)
public class ManagedBeanTestCase {
@ArquillianResource
private InitialContext context;
@Deployment
public static EnterpriseArchive createDeployment() throws Exception {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "managedbean-example.jar");
jar.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml");
jar.addPackage(SimpleManagedBean.class.getPackage());
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "managedbean-example.ear");
ear.addAsModule(jar);
return ear;
}
@Test
public void testManagedBean() throws Exception {
BeanWithSimpleInjected bean = (BeanWithSimpleInjected) context.lookup("java:module/" + BeanWithSimpleInjected.class.getSimpleName());
Assert.assertNotNull(bean.getSimple());
Assert.assertNotNull(bean.getSimple2());
String s = bean.echo("Hello");
Assert.assertEquals("#InterceptorFromParent##InterceptorBean##OtherInterceptorBean##CDIInterceptor##BeanParent##BeanWithSimpleInjected#Hello#CDIBean#CDIBean", s);
Assert.assertEquals(100, bean.getNumber());
Assert.assertEquals("value", bean.getValue());
Assert.assertEquals("value", bean.getValue2());
}
}
| 2,974 | 42.115942 | 170 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/InterceptorFromParent.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.managedbean;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.InvocationContext;
import org.jboss.logging.Logger;
/**
* @author John Bailey
*/
public class InterceptorFromParent {
private final Logger log = Logger.getLogger(InterceptorBean.class);
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
if (!context.getMethod().getName().equals("echo")) {
return context.proceed();
}
return "#InterceptorFromParent#" + context.proceed();
}
}
| 1,605 | 34.688889 | 73 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/BeanParent.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.managedbean;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.Interceptors;
import jakarta.interceptor.InvocationContext;
/**
* @author John Bailey
*/
@Interceptors(InterceptorFromParent.class)
public class BeanParent {
@AroundInvoke
public Object interceptParent(InvocationContext context) throws Exception {
if (!context.getMethod().getName().equals("echo")) {
return context.proceed();
}
return "#BeanParent#" + context.proceed();
}
}
| 1,565 | 36.285714 | 79 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/CDIManagedBean.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.smoke.managedbean;
/**
* @author Stuart Douglas
*/
public class CDIManagedBean {
public String getValue() {
return "#CDIBean";
}
}
| 1,194 | 34.147059 | 73 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/CDIBinding.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.smoke.managedbean;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import jakarta.interceptor.InterceptorBinding;
/**
* @author Jozef Hartinger
*/
@Target({ TYPE, METHOD })
@Retention(RUNTIME)
@Inherited
@InterceptorBinding
public @interface CDIBinding {
}
| 1,546 | 34.976744 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/SimpleManagedBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.managedbean;
import jakarta.annotation.ManagedBean;
/**
* @author <a href="[email protected]">Kabir Khan</a>
*/
@ManagedBean("SimpleManagedBean")
public class SimpleManagedBean {
}
| 1,244 | 36.727273 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/SimpleProducerBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.managedbean;
import jakarta.annotation.ManagedBean;
import jakarta.enterprise.inject.Produces;
/**
* @author [email protected]
*/
@ManagedBean("SimpleProducerBean")
public class SimpleProducerBean {
@Produces
public int number() {
return 100;
}
@Produces
public String value() {
return "value";
}
}
| 1,407 | 31.744186 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/managedbean/OtherInterceptorBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.managedbean;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.InvocationContext;
import org.jboss.logging.Logger;
/**
* @author John Bailey
*/
public class OtherInterceptorBean {
private final Logger log = Logger.getLogger(InterceptorBean.class);
@AroundInvoke
public Object intercept(InvocationContext context) throws Exception {
if (!context.getMethod().getName().equals("echo")) {
return context.proceed();
}
return "#OtherInterceptorBean#" + context.proceed();
}
}
| 1,603 | 34.644444 | 73 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/property/EjbDDWithPropertyTestCase.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.smoke.property;
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.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
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.Test;
import org.junit.runner.RunWith;
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.SUBSYSTEM;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
import static org.junit.Assert.assertEquals;
/**
* @author John Bailey
*/
@RunWith(Arquillian.class)
@ServerSetup(EjbDDWithPropertyTestCase.EjbDDWithPropertyTestCaseSeverSetup.class)
public class EjbDDWithPropertyTestCase {
private static final String MODULE_NAME = "dd-based";
private static final String JAR_NAME = MODULE_NAME + ".jar";
public static class EjbDDWithPropertyTestCaseSeverSetup implements ServerSetupTask {
@Override
public void setup(final ManagementClient managementClient, final String containerId) throws Exception {
final ModelNode op = new ModelNode();
op.get(OP_ADDR).set(SUBSYSTEM, "ee");
op.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
op.get(NAME).set("spec-descriptor-property-replacement");
op.get(VALUE).set(true);
managementClient.getControllerClient().execute(op);
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
final ModelNode op = new ModelNode();
op.get(OP_ADDR).set(SUBSYSTEM, "ee");
op.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
op.get(NAME).set("spec-descriptor-property-replacement");
op.get(VALUE).set(false);
managementClient.getControllerClient().execute(op);
}
}
@Deployment
public static Archive getDeployment() throws Exception {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, JAR_NAME);
jar.addPackage(TestSessionBean.class.getPackage());
jar.addAsManifestResource(TestSessionBean.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "test.ear");
ear.addAsModule(jar);
ear.addAsManifestResource(EjbDDWithPropertyTestCase.class.getPackage(), "application.xml", "application.xml");
ear.addAsManifestResource(TestSessionBean.class.getPackage(), "jboss.properties", "jboss.properties");
return ear;
}
@Test
public void testPropertyBasedEnvEntry() throws Exception {
Context ctx = new InitialContext();
String ejbName = TestSessionBean.class.getSimpleName();
TestBean bean = (TestBean) ctx.lookup("java:global/test/" + MODULE_NAME + "/" + ejbName + "!" + TestBean.class.getName());
assertEquals("foo" + System.getProperty("file.separator") + "bar", bean.getValue());
}
@Test
public void testPropertyBasedEnvEntryWithOverride() throws Exception {
Context ctx = new InitialContext();
String ejbName = TestSessionBean.class.getSimpleName();
TestBean bean = (TestBean) ctx.lookup("java:global/test/" + MODULE_NAME + "/" + ejbName + "!" + TestBean.class.getName());
assertEquals("foo-|-bar", bean.getValueOverride());
}
@Test
public void testApplicationXmlEnvEntry() throws Exception {
Context ctx = new InitialContext();
String value = (String) ctx.lookup("java:app/value");
assertEquals("foo" + System.getProperty("file.separator") + "bar", value);
}
}
| 5,352 | 43.983193 | 130 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/property/TestSessionBean.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.smoke.property;
import jakarta.annotation.Resource;
import jakarta.ejb.Stateless;
/**
* @author John Bailey
*/
@Stateless
public class TestSessionBean implements TestBean {
@Resource
private String value;
@Resource
private String valueOverride;
public String getValue() {
return value;
}
public String getValueOverride() {
return valueOverride;
}
}
| 1,454 | 29.957447 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/property/TestBean.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.smoke.property;
/**
* @author John Bailey
*/
public interface TestBean {
String getValue();
String getValueOverride();
}
| 1,182 | 35.96875 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/dd/Echo.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.dd;
/**
* User: jpai
*/
public interface Echo {
String echo(String msg);
}
| 1,144 | 34.78125 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/dd/PartialDDSFSB.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.smoke.ejb3.dd;
import jakarta.ejb.EJB;
import jakarta.ejb.LocalBean;
/**
* @author Jaikiran Pai
*/
@LocalBean
public class PartialDDSFSB implements Echo {
@EJB (beanName = "DDBasedSLSB")
private Echo otherEchoBean;
@Override
public String echo(String msg) {
return this.otherEchoBean.echo(msg);
}
}
| 1,383 | 31.952381 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/dd/DDBasedEJBTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.dd;
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.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author Jaikiran Pai
*/
@RunWith(Arquillian.class)
public class DDBasedEJBTestCase {
private static final String MODULE_NAME = "dd-based-slsb";
private static final String JAR_NAME = MODULE_NAME + ".jar";
@Deployment
public static JavaArchive getDeployment() throws Exception {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, JAR_NAME);
jar.addPackage(DDBasedEJBTestCase.class.getPackage());
jar.addPackage(DDBasedSLSB.class.getPackage());
jar.addAsManifestResource(DDBasedEJBTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml");
jar.addAsManifestResource(DDBasedEJBTestCase.class.getPackage(), "MANIFEST.MF", "MANIFEST.MF");
return jar;
}
/**
* Tests that all possible local view bindings of a Stateless bean are available.
*
* @throws Exception
*/
@Test
public void testLocalBindingsOnSLSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = DDBasedSLSB.class.getSimpleName();
Echo bean = (Echo) ctx.lookup("java:global/" + MODULE_NAME + "/" + ejbName + "!" + Echo.class.getName());
String msg = "Simple echo!";
String echo = bean.echo(msg);
Assert.assertEquals("Unexpected return message from bean", msg, echo);
}
/**
* Tests that the overrides in the ejb-jar.xml for a SLSB are honoured, and the bean is invokable through
* its exposed views
*
* @throws Exception
*/
@Test
public void testDDOverrideOfSLSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = DDOverrideSLSB.class.getSimpleName();
String jndiName = "java:global/" + MODULE_NAME + "/" + ejbName;
Echo bean = (Echo) ctx.lookup(jndiName);
String msg = "Another simple echo!";
String echo = bean.echo(msg);
Assert.assertEquals("Unexpected return message from bean", msg, echo);
}
/**
* Tests that the ejb-jar.xml and annotations are merged correctly for a SFSB, and the bean is invokable through
* its exposed views
*
* @throws Exception
*/
@Test
public void testPartialDDSFSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = PartialDDSFSB.class.getSimpleName();
String localBusinessInterfaceViewJndiName = "java:global/" + MODULE_NAME + "/" + ejbName + "!" + Echo.class.getName();
Echo localBusinessIntfView = (Echo) ctx.lookup(localBusinessInterfaceViewJndiName);
String msgOne = "This is message one!";
Assert.assertEquals("Unexpected return message from bean", msgOne, localBusinessIntfView.echo(msgOne));
String noInterfaceViewJndiName = "java:global/" + MODULE_NAME + "/" + ejbName + "!" + PartialDDSFSB.class.getName();
PartialDDSFSB noInterfaceView = (PartialDDSFSB) ctx.lookup(noInterfaceViewJndiName);
String msgTwo = "Yet another message!";
Assert.assertEquals("Unexpected return message from no-interface view of bean", msgTwo, noInterfaceView.echo(msgTwo));
}
@Test
public void testInterceptorsOnSingleton() throws Exception {
Context ctx = new InitialContext();
String ejbName = InterceptedDDBean.class.getSimpleName();
String jndiName = "java:global/" + MODULE_NAME + "/" + ejbName + "!" + InterceptedDDBean.class.getName();
InterceptedDDBean interceptedBean = (InterceptedDDBean) ctx.lookup(jndiName);
String msg = "You will be intercepted!!!";
String returnMsg = interceptedBean.echo(msg);
String expectedReturnMsg = SimpleInterceptor.class.getName() + "#" + DDBasedInterceptor.class.getName() + "#" + msg;
Assert.assertEquals("Unexpected return message from bean", expectedReturnMsg, returnMsg);
}
}
| 5,245 | 40.634921 | 126 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/dd/DDBasedSLSB.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.dd;
/**
* @author Jaikiran Pai
*/
public class DDBasedSLSB implements Echo {
@Override
public String echo(String msg) {
return msg;
}
}
| 1,221 | 33.914286 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/dd/InterceptedDDBean.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.smoke.ejb3.dd;
/**
* User: jpai
*/
public class InterceptedDDBean implements Echo {
@Override
public String echo(String msg) {
return msg;
}
}
| 1,218 | 32.861111 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/dd/DDBasedInterceptor.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.smoke.ejb3.dd;
import jakarta.interceptor.InvocationContext;
/**
* User: jpai
*/
public class DDBasedInterceptor {
private boolean postConstructInvoked;
private void onConstruct(InvocationContext ctx) throws Exception {
this.postConstructInvoked = true;
ctx.proceed();
}
public Object onInvoke(InvocationContext invocationContext) throws Exception {
if (!this.postConstructInvoked) {
throw new IllegalStateException("PostConstruct method on " + this.getClass().getName() + " interceptor was not invoked");
}
return this.getClass().getName() + "#" + invocationContext.proceed();
}
}
| 1,713 | 35.468085 | 133 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/dd/SimpleInterceptor.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.smoke.ejb3.dd;
import jakarta.annotation.PostConstruct;
import jakarta.interceptor.AroundInvoke;
import jakarta.interceptor.InvocationContext;
/**
* User: jpai
*/
public class SimpleInterceptor {
private boolean postConstructInvoked;
@PostConstruct
private void onConstruct(InvocationContext invocationContext) throws Exception {
this.postConstructInvoked = true;
invocationContext.proceed();
}
@AroundInvoke
public Object onInvoke(InvocationContext ctx) throws Exception {
if (!this.postConstructInvoked) {
throw new IllegalStateException("PostConstruct method on " + this.getClass().getName() + " interceptor was not invoked");
}
return getClass().getName() + "#" + ctx.proceed();
}
}
| 1,824 | 35.5 | 133 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/dd/DDOverrideSLSB.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.smoke.ejb3.dd;
import jakarta.ejb.Stateless;
/**
* @author Jaikiran Pai
*/
@Stateless
public class DDOverrideSLSB implements Echo {
@Override
public String echo(String msg) {
return msg;
}
}
| 1,266 | 32.342105 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/jndi/Echo.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.jndi;
/**
* @author Jaikiran Pai
*/
public interface Echo {
String echo(String msg);
}
| 1,156 | 35.15625 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/jndi/StandaloneModuleEjbJndiBindingTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.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.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.assertNotNull;
/**
* Tests that the session beans are bound to all the jndi binding names mandated by the EJB3.1 spec, when the EJBs are
* deployed in a standalone jar file
*
* @author Jaikiran Pai
*/
@RunWith(Arquillian.class)
public class StandaloneModuleEjbJndiBindingTestCase {
/**
* The module name of the deployment
*/
private static final String MODULE_NAME = "ejb3-jndi-binding-test";
/**
* Complete jar file name including the .jar file extension
*/
private static final String ARCHIVE_NAME = MODULE_NAME + ".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 JavaArchive createStandaloneJar() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, ARCHIVE_NAME);
// add the entire package
jar.addPackage(SampleSLSB.class.getPackage());
return jar;
}
/**
* Tests that all possible local view bindings of a Stateless bean are available.
*
* @throws Exception
*/
@Test
public void testLocalBindingsOnSLSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = SampleSLSB.class.getSimpleName();
// global bindings
// 1. local business interface
Echo localBusinessInterface = (Echo) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + 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
SampleSLSB noInterfaceView = (SampleSLSB) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + SampleSLSB.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
SampleSLSB noInterfaceViewInAppNamespace = (SampleSLSB) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + SampleSLSB.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
SampleSLSB noInterfaceViewInModuleNamespace = (SampleSLSB) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + SampleSLSB.class.getName());
Assert.assertNotNull("Null object returned for no-interface view lookup in java:module namespace", noInterfaceViewInModuleNamespace);
// additional binding
{
final Echo bean = (Echo) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + "Additional");
assertNotNull("Null object returned from java:global/Additional", bean);
}
}
/**
* Tests that all possible remote view bindings of a Stateless bean are available.
*
* @throws Exception
*/
@Test
public void testRemoteBindingsOnSLSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = SampleSLSB.class.getSimpleName();
// global bindings
// 1. remote business interface
RemoteEcho remoteBusinessInterface = (RemoteEcho) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + 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);
}
/**
* Tests that all possible local view bindings of a Stateful bean are available.
*
* @throws Exception
*/
@Test
public void testLocalBindingsOnSFSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = SampleSFSB.class.getSimpleName();
// global bindings
// 1. local business interface
Echo localBusinessInterface = (Echo) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + 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
SampleSFSB noInterfaceView = (SampleSFSB) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + SampleSFSB.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
SampleSFSB noInterfaceViewInAppNamespace = (SampleSFSB) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + SampleSFSB.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
SampleSFSB noInterfaceViewInModuleNamespace = (SampleSFSB) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + SampleSFSB.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 Stateful bean are available.
*
* @throws Exception
*/
@Test
public void testRemoteBindingsOnSFSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = SampleSFSB.class.getSimpleName();
// global bindings
// 1. remote business interface
RemoteEcho remoteBusinessInterface = (RemoteEcho) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + 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);
}
}
| 10,654 | 48.55814 | 175 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/jndi/SampleSLSB.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.jndi;
import jakarta.ejb.EJB;
import jakarta.ejb.Local;
import jakarta.ejb.LocalBean;
import jakarta.ejb.Remote;
import jakarta.ejb.Stateless;
/**
* @author Jaikiran Pai
*/
@Stateless
@LocalBean
@Local (Echo.class)
@Remote(RemoteEcho.class)
@EJB(name = "java:global/Additional", beanName = "SampleSLSB", beanInterface = Echo.class)
// TODO: Add all other views @LocalHome and @RemoteHome
public class SampleSLSB implements Echo {
@Override
public String echo(String msg) {
return msg;
}
}
| 1,575 | 32.531915 | 90 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/jndi/RemoteEcho.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.jndi;
/**
* @author Jaikiran Pai
*/
public interface RemoteEcho extends Echo {
}
| 1,145 | 37.2 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/jndi/SampleSFSB.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.jndi;
import jakarta.ejb.Local;
import jakarta.ejb.LocalBean;
import jakarta.ejb.Remote;
import jakarta.ejb.Stateful;
/**
* @author Jaikiran Pai
*/
@Stateful
@LocalBean
@Remote(RemoteEcho.class)
@Local (Echo.class)
// TODO: Add other views too like @LocalHome and @RemoteHome
public class SampleSFSB implements RemoteEcho {
@Override
public String echo(String msg) {
return msg;
}
}
| 1,471 | 31 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/ejb3/jndi/EarDeploymentEjbJndiBindingTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.ejb3.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;
/**
* Tests that the session beans are bound to all the jndi binding names mandated by the Enterprise Beans 3.1 spec, when the Jakarta Enterprise Beans are
* deployed within a top level .ear file
*
* @author Jaikiran Pai
*/
@RunWith(Arquillian.class)
public class EarDeploymentEjbJndiBindingTestCase {
/**
* The app name of the deployment
*/
private static final String APP_NAME = "ear-deployment-ejb3-binding";
/**
* Complete ear file name including the .ear file extension
*/
private static final String EAR_NAME = APP_NAME + ".ear";
/**
* The module name of the deployment
*/
private static final String MODULE_NAME = "ejb3-jndi-binding-test";
/**
* Complete jar file name including the .jar file extension
*/
private static final String JAR_NAME = MODULE_NAME + ".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);
// create the jar containing the Jakarta Enterprise Beans
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, JAR_NAME);
// add the entire package
jar.addPackage(SampleSLSB.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 = SampleSLSB.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
SampleSLSB noInterfaceView = (SampleSLSB) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + SampleSLSB.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
SampleSLSB noInterfaceViewInAppNamespace = (SampleSLSB) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + SampleSLSB.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
SampleSLSB noInterfaceViewInModuleNamespace = (SampleSLSB) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + SampleSLSB.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 = SampleSLSB.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);
}
/**
* Tests that all possible local view bindings of a Stateful bean are available, when deployed through a .ear
*
* @throws Exception
*/
@Test
public void testLocalBindingsOnSFSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = SampleSFSB.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
SampleSFSB noInterfaceView = (SampleSFSB) ctx.lookup(JAVA_GLOBAL_NAMESPACE_PREFIX + APP_NAME + "/" + MODULE_NAME + "/" + ejbName + "!" + SampleSFSB.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
SampleSFSB noInterfaceViewInAppNamespace = (SampleSFSB) ctx.lookup(JAVA_APP_NAMESPACE_PREFIX + MODULE_NAME + "/" + ejbName + "!" + SampleSFSB.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
SampleSFSB noInterfaceViewInModuleNamespace = (SampleSFSB) ctx.lookup(JAVA_MODULE_NAMESPACE_PREFIX + ejbName + "!" + SampleSFSB.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 Stateful bean are available, when deployed through a .ear
*
* @throws Exception
*/
@Test
public void testRemoteBindingsOnSFSB() throws Exception {
Context ctx = new InitialContext();
String ejbName = SampleSFSB.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);
}
}
| 11,298 | 48.77533 | 181 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldConnectionFactoryImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
import javax.naming.NamingException;
import javax.naming.Reference;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionManager;
/**
* HelloWorldConnectionFactoryImpl
*
* @version $Revision: $
*/
public class HelloWorldConnectionFactoryImpl implements HelloWorldConnectionFactory {
private static final long serialVersionUID = 1L;
private Reference reference;
private final HelloWorldManagedConnectionFactory mcf;
private final ConnectionManager connectionManager;
/**
* default constructor
* @param mcf ManagedConnectionFactory
* @param cxManager ConnectionManager
*/
public HelloWorldConnectionFactoryImpl(HelloWorldManagedConnectionFactory mcf,
ConnectionManager cxManager) {
this.mcf = mcf;
this.connectionManager = cxManager;
}
/**
* get connection from factory
*
* @return HelloWorldConnection instance
* @exception ResourceException Thrown if a connection can't be obtained
*/
@Override
public HelloWorldConnection getConnection() throws ResourceException {
return new HelloWorldConnectionImpl(mcf);
}
/**
* Get the Reference instance.
*
* @return Reference instance
* @exception NamingException Thrown if a reference can't be obtained
*/
@Override
public Reference getReference() throws NamingException {
return reference;
}
/**
* Set the Reference instance.
*
* @param reference A Reference instance
*/
@Override
public void setReference(Reference reference) {
this.reference = reference;
}
}
| 2,726 | 31.082353 | 85 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldConnectionImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
import org.jboss.logging.Logger;
/**
* HelloWorldConnectionImpl
*
* @version $Revision: $
*/
public class HelloWorldConnectionImpl implements HelloWorldConnection {
/** The logger */
private static Logger log = Logger.getLogger("HelloWorldConnectionImpl");
private final HelloWorldManagedConnectionFactory mcf;
/**
* default constructor
*/
public HelloWorldConnectionImpl(HelloWorldManagedConnectionFactory mcf) {
this.mcf = mcf;
}
/**
* call helloWorld
*/
public String helloWorld() {
return helloWorld(((HelloWorldResourceAdapter)mcf.getResourceAdapter()).getName());
}
/**
* call helloWorld
*/
public String helloWorld(String name) {
return "Hello World, " + name + " !";
}
}
| 1,836 | 30.672414 | 89 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldResourceAdapter.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
import org.jboss.logging.Logger;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.BootstrapContext;
import jakarta.resource.spi.ConfigProperty;
import jakarta.resource.spi.Connector;
import jakarta.resource.spi.ResourceAdapter;
import jakarta.resource.spi.ResourceAdapterInternalException;
import jakarta.resource.spi.TransactionSupport;
import jakarta.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
/**
* HelloWorldResourceAdapter
*
* @version $Revision: $
*/
@Connector(
reauthenticationSupport = false,
transactionSupport = TransactionSupport.TransactionSupportLevel.NoTransaction)
public class HelloWorldResourceAdapter implements ResourceAdapter {
/** The logger */
private static Logger log = Logger.getLogger("HelloWorldResourceAdapter");
/** Name property */
@ConfigProperty(defaultValue="AS 7", supportsDynamicUpdates=true)
private String name;
/**
* default constructor
*/
public HelloWorldResourceAdapter() {
}
/**
* set name
* @param name The value
*/
public void setName(String name) {
this.name = name;
}
/**
* get name
* @return The value
*/
public String getName() {
return name;
}
/**
* This is called during the activation of a message endpoint.
*
* @param endpointFactory a message endpoint factory instance.
* @param spec an activation spec JavaBean instance.
* @throws ResourceException generic exception
*/
public void endpointActivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) throws ResourceException {
}
/**
* This is called when a message endpoint is deactivated.
*
* @param endpointFactory a message endpoint factory instance.
* @param spec an activation spec JavaBean instance.
*/
public void endpointDeactivation(MessageEndpointFactory endpointFactory,
ActivationSpec spec) {
}
/**
* This is called when a resource adapter instance is bootstrapped.
*
* @param ctx a bootstrap context containing references
* @throws ResourceAdapterInternalException indicates bootstrap failure.
*/
public void start(BootstrapContext ctx)
throws ResourceAdapterInternalException {
}
/**
* This is called when a resource adapter instance is undeployed or
* during application server shutdown.
*/
public void stop() {
}
/**
* This method is called by the application server during crash recovery.
*
* @param specs an array of ActivationSpec JavaBeans
* @throws ResourceException generic exception
* @return an array of XAResource objects
*/
public XAResource[] getXAResources(ActivationSpec[] specs)
throws ResourceException {
return null;
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
int result = 17;
if (name != null)
result += 31 * result + 7 * name.hashCode();
else
result += 31 * result + 7;
return result;
}
/**
* Indicates whether some other object is equal to this one.
* @param other the reference object with which to compare.
* @return true if this object is the same as the obj argument; false otherwise.
*/
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other == this)
return true;
if (!(other instanceof HelloWorldResourceAdapter))
return false;
HelloWorldResourceAdapter obj = (HelloWorldResourceAdapter)other;
boolean result = true;
if (result) {
if (name == null)
result = obj.getName() == null;
else
result = name.equals(obj.getName());
}
return result;
}
}
| 5,063 | 30.067485 | 83 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldManagedConnectionMetaData.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ManagedConnectionMetaData;
/**
* HelloWorldManagedConnectionMetaData
*
* @version $Revision: $
*/
public class HelloWorldManagedConnectionMetaData implements ManagedConnectionMetaData {
/**
* default constructor
*/
public HelloWorldManagedConnectionMetaData() {
}
/**
* Returns Product name of the underlying EIS instance connected through the ManagedConnection.
*
* @return Product name of the EIS instance
* @throws ResourceException Thrown if an error occurs
*/
@Override
public String getEISProductName() throws ResourceException {
return "HelloWorld Resource Adapter";
}
/**
* Returns Product version of the underlying EIS instance connected through the ManagedConnection.
*
* @return Product version of the EIS instance
* @throws ResourceException Thrown if an error occurs
*/
@Override
public String getEISProductVersion() throws ResourceException {
return "1.0";
}
/**
* Returns maximum limit on number of active concurrent connections
*
* @return Maximum limit for number of active concurrent connections
* @throws ResourceException Thrown if an error occurs
*/
@Override
public int getMaxConnections() throws ResourceException {
return 0;
}
/**
* Returns name of the user associated with the ManagedConnection instance
*
* @return name of the user
* @throws ResourceException Thrown if an error occurs
*/
@Override
public String getUserName() throws ResourceException {
return null;
}
}
| 2,717 | 31.746988 | 101 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldConnection.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
/**
* HelloWorldConnection
*
* @version $Revision: $
*/
public interface HelloWorldConnection {
/**
* helloWorld
* @return String
*/
String helloWorld();
/**
* helloWorld
* @param name name
* @return String
*/
String helloWorld(String name);
}
| 1,359 | 30.627907 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldManagedConnectionFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.Set;
import org.jboss.logging.Logger;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionDefinition;
import jakarta.resource.spi.ConnectionManager;
import jakarta.resource.spi.ConnectionRequestInfo;
import jakarta.resource.spi.ManagedConnection;
import jakarta.resource.spi.ManagedConnectionFactory;
import jakarta.resource.spi.ResourceAdapter;
import jakarta.resource.spi.ResourceAdapterAssociation;
import javax.security.auth.Subject;
/**
* HelloWorldManagedConnectionFactory
*
* @version $Revision: $
*/
@ConnectionDefinition(connectionFactory = HelloWorldConnectionFactory.class,
connectionFactoryImpl = HelloWorldConnectionFactoryImpl.class,
connection = HelloWorldConnection.class,
connectionImpl = HelloWorldConnectionImpl.class)
public class HelloWorldManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation {
private static final long serialVersionUID = 1L;
/** The logger */
private static Logger log = Logger.getLogger("HelloWorldManagedConnectionFactory");
/** The resource adapter */
private ResourceAdapter ra;
/** The logwriter */
private PrintWriter logwriter;
/**
* default constructor
*/
public HelloWorldManagedConnectionFactory() {
}
/**
* Creates a Connection Factory instance.
*
* @return EIS-specific Connection Factory instance or jakarta.resource.cci.ConnectionFactory instance
* @throws ResourceException Generic exception
*/
public Object createConnectionFactory() throws ResourceException {
return createConnectionFactory(new HelloWorldConnectionManager());
}
/**
* Creates a Connection Factory instance.
*
* @param cxManager ConnectionManager to be associated with created EIS connection factory instance
* @return EIS-specific Connection Factory instance or jakarta.resource.cci.ConnectionFactory instance
* @throws ResourceException Generic exception
*/
public Object createConnectionFactory(ConnectionManager cxManager) throws ResourceException {
return new HelloWorldConnectionFactoryImpl(this, cxManager);
}
/**
* Creates a new physical connection to the underlying EIS resource manager.
*
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @throws ResourceException generic exception
* @return ManagedConnection instance
*/
public ManagedConnection createManagedConnection(Subject subject,
ConnectionRequestInfo cxRequestInfo) throws ResourceException {
return new HelloWorldManagedConnection(this);
}
/**
* Returns a matched connection from the candidate set of connections.
*
* @param connectionSet candidate connection set
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @throws ResourceException generic exception
* @return ManagedConnection if resource adapter finds an acceptable match otherwise null
*/
public ManagedConnection matchManagedConnections(Set connectionSet,
Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection)it.next();
if (mc instanceof HelloWorldManagedConnection) {
HelloWorldManagedConnection hwmc = (HelloWorldManagedConnection)mc;
result = hwmc;
}
}
return result;
}
/**
* Get the log writer for this ManagedConnectionFactory instance.
*
* @return PrintWriter
* @throws ResourceException generic exception
*/
public PrintWriter getLogWriter() throws ResourceException {
return logwriter;
}
/**
* Set the log writer for this ManagedConnectionFactory instance.
*
* @param out PrintWriter - an out stream for error logging and tracing
* @throws ResourceException generic exception
*/
public void setLogWriter(PrintWriter out) throws ResourceException {
logwriter = out;
}
/**
* Get the resource adapter
*
* @return The handle
*/
public ResourceAdapter getResourceAdapter() {
return ra;
}
/**
* Set the resource adapter
*
* @param ra The handle
*/
public void setResourceAdapter(ResourceAdapter ra) {
this.ra = ra;
}
/**
* Returns a hash code value for the object.
* @return a hash code value for this object.
*/
@Override
public int hashCode() {
int result = 17;
return result;
}
/**
* Indicates whether some other object is equal to this one.
* @param other the reference object with which to compare.
* @return true if this object is the same as the obj argument; false otherwise.
*/
@Override
public boolean equals(Object other) {
if (other == null)
return false;
if (other == this)
return true;
if (!(other instanceof HelloWorldManagedConnectionFactory))
return false;
HelloWorldManagedConnectionFactory obj = (HelloWorldManagedConnectionFactory)other;
boolean result = true;
return result;
}
}
| 6,671 | 33.391753 | 132 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldConnectionManager.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionManager;
import jakarta.resource.spi.ConnectionRequestInfo;
import jakarta.resource.spi.ManagedConnectionFactory;
/**
* HelloWorldConnectionManager
*
* @version $Revision: $
*/
public class HelloWorldConnectionManager implements ConnectionManager {
private static final long serialVersionUID = 1L;
/**
* default constructor
*/
public HelloWorldConnectionManager() {
}
/**
* Allocate a connection
*
* @param mcf The managed connection factory
* @param cri The connection request information
* @return Object The connection
* @exception ResourceException Thrown if an error occurs
*/
@Override
public Object allocateConnection(ManagedConnectionFactory mcf,ConnectionRequestInfo cri) throws ResourceException {
return null;
}
}
| 1,949 | 32.050847 | 118 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldConnectionFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
import java.io.Serializable;
import jakarta.resource.Referenceable;
import jakarta.resource.ResourceException;
/**
* HelloWorldConnectionFactory
*
* @version $Revision: $
*/
public interface HelloWorldConnectionFactory extends Serializable, Referenceable {
/**
* get connection from factory
*
* @return HelloWorldConnection instance
* @exception ResourceException Thrown if a connection can't be obtained
*/
HelloWorldConnection getConnection() throws ResourceException;
}
| 1,576 | 34.840909 | 82 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/HelloWorldManagedConnection.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import org.jboss.logging.Logger;
import jakarta.resource.NotSupportedException;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionEventListener;
import jakarta.resource.spi.ConnectionRequestInfo;
import jakarta.resource.spi.LocalTransaction;
import jakarta.resource.spi.ManagedConnection;
import jakarta.resource.spi.ManagedConnectionMetaData;
import javax.security.auth.Subject;
import javax.transaction.xa.XAResource;
/**
* HelloWorldManagedConnection
*
* @version $Revision: $
*/
public class HelloWorldManagedConnection implements ManagedConnection {
/** The logger */
private static Logger log = Logger.getLogger("HelloWorldManagedConnection");
/** MCF */
private final HelloWorldManagedConnectionFactory mcf;
/** Log writer */
private PrintWriter logWriter;
/** Listeners */
private final List<ConnectionEventListener> listeners;
/** Connection */
private Object connection;
/**
* default constructor
* @param mcf mcf
*/
public HelloWorldManagedConnection(HelloWorldManagedConnectionFactory mcf) {
this.mcf = mcf;
this.logWriter = null;
this.listeners = new ArrayList<ConnectionEventListener>(1);
this.connection = null;
}
/**
* Creates a new connection handle for the underlying physical connection
* represented by the ManagedConnection instance.
*
* @param subject security context as JAAS subject
* @param cxRequestInfo ConnectionRequestInfo instance
* @return generic Object instance representing the connection handle.
* @throws ResourceException generic exception if operation fails
*/
public Object getConnection(Subject subject,
ConnectionRequestInfo cxRequestInfo) throws ResourceException {
connection = new HelloWorldConnectionImpl(mcf);
return connection;
}
/**
* Used by the container to change the association of an
* application-level connection handle with a ManagedConnection instance.
*
* @param connection Application-level connection handle
* @throws ResourceException generic exception if operation fails
*/
public void associateConnection(Object connection) throws ResourceException {
this.connection = connection;
}
/**
* Application server calls this method to force any cleanup on the ManagedConnection instance.
*
* @throws ResourceException generic exception if operation fails
*/
public void cleanup() throws ResourceException {
}
/**
* Destroys the physical connection to the underlying resource manager.
*
* @throws ResourceException generic exception if operation fails
*/
public void destroy() throws ResourceException {
this.connection = null;
}
/**
* Adds a connection event listener to the ManagedConnection instance.
*
* @param listener a new ConnectionEventListener to be registered
*/
public void addConnectionEventListener(ConnectionEventListener listener) {
if (listener == null)
throw new IllegalArgumentException("Listener is null");
listeners.add(listener);
}
/**
* Removes an already registered connection event listener from the ManagedConnection instance.
*
* @param listener already registered connection event listener to be removed
*/
public void removeConnectionEventListener(ConnectionEventListener listener) {
if (listener == null)
throw new IllegalArgumentException("Listener is null");
listeners.remove(listener);
}
/**
* Gets the log writer for this ManagedConnection instance.
*
* @return Character output stream associated with this Managed-Connection instance
* @throws ResourceException generic exception if operation fails
*/
public PrintWriter getLogWriter() throws ResourceException {
return logWriter;
}
/**
* Sets the log writer for this ManagedConnection instance.
*
* @param out Character Output stream to be associated
* @throws ResourceException generic exception if operation fails
*/
public void setLogWriter(PrintWriter out) throws ResourceException {
this.logWriter = out;
}
/**
* Returns an <code>jakarta.resource.spi.LocalTransaction</code> instance.
*
* @return LocalTransaction instance
* @throws ResourceException generic exception if operation fails
*/
public LocalTransaction getLocalTransaction() throws ResourceException {
throw new NotSupportedException("LocalTransaction not supported");
}
/**
* Returns an <code>javax.transaction.xa.XAResource</code> instance.
*
* @return XAResource instance
* @throws ResourceException generic exception if operation fails
*/
public XAResource getXAResource() throws ResourceException {
throw new NotSupportedException("GetXAResource not supported");
}
/**
* Gets the metadata information for this connection's underlying EIS resource manager instance.
*
* @return ManagedConnectionMetaData instance
* @throws ResourceException generic exception if operation fails
*/
public ManagedConnectionMetaData getMetaData() throws ResourceException {
return new HelloWorldManagedConnectionMetaData();
}
}
| 6,551 | 33.666667 | 99 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/rar/RarTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.rar;
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.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
@RunWith(Arquillian.class)
public class RarTestCase {
private static final String JNDI_NAME = "java:/eis/HelloWorld";
@ArquillianResource
private InitialContext initialContext;
@Deployment
public static Archive<?> getDeployment(){
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "rar-example.rar");
archive.addPackage(RarTestCase.class.getPackage());
archive.addAsManifestResource(RarTestCase.class.getPackage(), "ironjacamar.xml", "ironjacamar.xml");
return archive;
}
@Test
public void helloWorld() throws Exception {
String s = getConnection().helloWorld();
Assert.assertEquals("Hello World, AS 7 !", s);
}
@Test
public void helloWorld2() throws Exception {
String s = getConnection().helloWorld("Test");
Assert.assertEquals("Hello World, Test !", s);
}
private HelloWorldConnection getConnection() throws Exception {
HelloWorldConnectionFactory factory = (HelloWorldConnectionFactory)initialContext.lookup(JNDI_NAME);
HelloWorldConnection conn = factory.getConnection();
if (conn == null) {
throw new RuntimeException("No connection");
}
return conn;
}
}
| 2,824 | 34.3125 | 108 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/DefaultJMSConnectionFactoryTest.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.UUID;
import jakarta.annotation.Resource;
import jakarta.ejb.EJB;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageConsumer;
import jakarta.jms.Queue;
import jakarta.jms.Session;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.jms.auxiliary.CreateQueueSetupTask;
import org.jboss.as.test.smoke.jms.auxiliary.SimplifiedMessageProducer;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Tests sending Jakarta Messaging messages using the server's default Jakarta Messaging Connection Factory.
*
* Jakarta EE 8 spec, §EE.5.20 Default Jakarta Messaging Connection Factory
*
* @author <a href="http://jmesnil.net">Jeff Mesnil</a> (c) 2013 Red Hat Inc.
*/
@RunWith(Arquillian.class)
@ServerSetup(CreateQueueSetupTask.class)
public class DefaultJMSConnectionFactoryTest {
private static final Logger logger = Logger.getLogger(DefaultJMSConnectionFactoryTest.class);
@EJB
private SimplifiedMessageProducer producerEJB;
@Resource(mappedName = "/queue/myAwesomeQueue")
private Queue queue;
@Resource
private ConnectionFactory factory;
@Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "DefaultJMSConnectionFactoryTest.jar")
.addClass(SimplifiedMessageProducer.class)
.addClass(CreateQueueSetupTask.class)
.addPackage(JMSOperations.class.getPackage())
.addAsManifestResource(EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml"));
}
@Test
public void sendWithDefaultJMSConnectionFactory() throws Exception {
String text = UUID.randomUUID().toString();
producerEJB.sendWithDefaultJMSConnectionFactory(queue, text);
assertMessageInQueue(text);
}
@Test
public void sendWithRegularConnectionFactory() throws Exception {
String text = UUID.randomUUID().toString();
producerEJB.sendWithRegularConnectionFactory(queue, text);
assertMessageInQueue(text);
}
private void assertMessageInQueue(String text) throws JMSException {
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queue);
connection.start();
Message message = consumer.receive(2000);
assertNotNull(message);
assertTrue(message instanceof TextMessage);
assertEquals(text, ((TextMessage) message).getText());
connection.close();
}
}
| 4,349 | 35.25 | 108 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/SendToTopicFromWithinTransactionTest.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms;
import jakarta.ejb.EJB;
import jakarta.enterprise.event.Observes;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.jms.auxiliary.CreateTopicSetupTask;
import org.jboss.as.test.smoke.jms.auxiliary.TopicMessageDrivenBean;
import org.jboss.as.test.smoke.jms.auxiliary.TransactedTopicMessageSender;
import org.jboss.logging.Logger;
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;
/**
* Tests sending Jakarta Messaging messages to a topic within a transaction
*
* @author <a href="[email protected]">Jan Martiska</a>
*/
@RunWith(Arquillian.class)
@ServerSetup(CreateTopicSetupTask.class)
public class SendToTopicFromWithinTransactionTest {
private static final Logger logger = Logger.getLogger(SendToTopicFromWithinTransactionTest.class);
@EJB
private TransactedTopicMessageSender sender;
@EJB
private TransactedTopicMessageSender sender2;
private static volatile boolean messageReceived;
@Before
public void setMessageReceived() {
messageReceived = false;
}
@Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClass(TransactedTopicMessageSender.class)
.addClass(TopicMessageDrivenBean.class)
.addClass(CreateTopicSetupTask.class)
.addPackage(JMSOperations.class.getPackage())
.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml");
}
@Test
public void sendSuccessfully() throws Exception {
try {
sender.sendToTopicSuccessfully();
Thread.sleep(2000);
} catch (Exception ex) {
ex.printStackTrace();
}
Assert.assertTrue(messageReceived);
}
@Test
public void sendAndRollback() {
try {
sender2.sendToTopicAndRollback();
Thread.sleep(2000);
} catch (Exception ex) {
ex.printStackTrace();
}
Assert.assertFalse(messageReceived);
}
public void receivedMessage(@Observes Message message) {
messageReceived = true;
try {
logger.trace("caught event... message=" + ((TextMessage) message).getText());
} catch (JMSException ex) {
ex.printStackTrace();
Assert.fail(ex.getMessage());
}
}
}
| 3,931 | 33.491228 | 116 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/SendToJMSQueueTest.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms;
import jakarta.annotation.Resource;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
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 org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.jms.auxiliary.CreateQueueSetupTask;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Basic Jakarta Messaging test using a customly created Jakarta Messaging queue
*
* @author <a href="[email protected]">Jan Martiska</a>
*/
@RunWith(Arquillian.class)
@ServerSetup(CreateQueueSetupTask.class)
public class SendToJMSQueueTest {
private static final Logger logger = Logger.getLogger(SendToJMSQueueTest.class);
private static final String MESSAGE_TEXT = "Hello world!";
@Resource(mappedName = "/queue/myAwesomeQueue")
private Queue queue;
@Resource(mappedName = "/queue/myAwesomeQueue2")
private Queue queue2;
@Resource(mappedName = "/queue/myAwesomeQueue3")
private Queue queue3;
@Resource(mappedName = "/ConnectionFactory")
private ConnectionFactory factory;
@Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addPackage(JMSOperations.class.getPackage())
.addClass(CreateQueueSetupTask.class)
.addAsManifestResource(
EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml"));
}
@Test
public void sendAndReceiveMessage() throws Exception {
Connection connection = null;
Session session = null;
Message receivedMessage = null;
try {
// SEND A MESSAGE
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
Message message = session.createTextMessage(MESSAGE_TEXT);
producer.send(message);
connection.start();
session.close();
connection.close();
try {
Thread.sleep(2000);
} catch (InterruptedException ex) {
}
// RECEIVE THE MESSAGE BACK
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(queue);
connection.start();
receivedMessage = consumer.receive(5000);
} catch (Exception e) {
e.printStackTrace();
} finally {
// CLEANUP
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}
// ASSERTIONS
Assert.assertTrue(receivedMessage instanceof TextMessage);
Assert.assertTrue(((TextMessage) receivedMessage).getText().equals(MESSAGE_TEXT));
}
@Test
public void sendMessageWithClientAcknowledge() throws Exception {
Connection senderConnection = null;
Connection consumerConnection = null;
Session senderSession = null;
Session consumerSession = null;
MessageConsumer consumer = null;
try {
// CREATE CONSUMER
logger.trace("******* Creating connection for consumer");
consumerConnection = factory.createConnection();
logger.trace("Creating session for consumer");
consumerSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
logger.trace("Creating consumer");
consumer = consumerSession.createConsumer(queue2);
logger.trace("Start session");
consumerConnection.start();
// SEND A MESSAGE
logger.trace("***** Start - sending message to topic");
senderConnection = factory.createConnection();
logger.trace("Creating session..");
senderSession = senderConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageProducer producer = senderSession.createProducer(queue2);
TextMessage message = senderSession.createTextMessage("Hahaha!");
logger.trace("Sending..");
producer.send(message);
logger.trace("Message sent");
senderConnection.start();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
logger.trace("Closing connections and sessions");
if (senderSession != null) {
senderSession.close();
}
if (senderConnection != null) {
senderConnection.close();
}
}
Message receivedMessage = null;
Message receivedMessage2 = null;
try {
logger.trace("Receiving");
receivedMessage = consumer.receive(5000);
logger.trace("Received a message");
receivedMessage.acknowledge();
consumerSession.recover();
receivedMessage2 = consumer.receive(5000);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (consumerSession != null) {
consumerSession.close();
}
if (consumerConnection != null) {
consumerConnection.close();
}
}
if (receivedMessage == null) {
Assert.fail("received null instead of a TextMessage");
}
Assert.assertTrue("received a " + receivedMessage.getClass().getName() + " instead of a TextMessage", receivedMessage instanceof TextMessage);
Assert.assertEquals("Hahaha!", ((TextMessage) receivedMessage).getText());
if (receivedMessage2 != null) {
Assert.fail("redelivered=" + String.valueOf(receivedMessage2.getJMSRedelivered()) + ", text=" + ((TextMessage) receivedMessage).getText());
}
Assert.assertNull("Message should not have been re-delivered", receivedMessage2);
}
@Test
public void sendMessageWithMissingClientAcknowledge() throws Exception {
Connection senderConnection = null;
Connection consumerConnection = null;
Session senderSession = null;
Session consumerSession = null;
MessageConsumer consumer = null;
try {
// CREATE SUBSCRIBER
logger.trace("******* Creating connection for consumer");
consumerConnection = factory.createConnection();
logger.trace("Creating session for consumer");
consumerSession = consumerConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
logger.trace("Creating consumer");
consumer = consumerSession.createConsumer(queue3);
logger.trace("Start session");
consumerConnection.start();
// SEND A MESSAGE
logger.trace("***** Start - sending message to topic");
senderConnection = factory.createConnection();
logger.trace("Creating session..");
senderSession = senderConnection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
MessageProducer producer = senderSession.createProducer(queue3);
TextMessage message = senderSession.createTextMessage("Hello world!");
logger.trace("Sending..");
producer.send(message);
logger.trace("Message sent");
senderConnection.start();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
logger.trace("Closing connections and sessions");
if (senderSession != null) {
senderSession.close();
}
if (senderConnection != null) {
senderConnection.close();
}
}
Message receivedMessage = null;
try {
logger.trace("Receiving");
receivedMessage = consumer.receive(5000);
try {
Thread.sleep(1000);
} catch (InterruptedException ex) {
}
consumerSession.recover();
receivedMessage = consumer.receive(5000);
receivedMessage.acknowledge();
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
} finally {
if (consumerSession != null) {
consumerSession.close();
}
if (consumerConnection != null) {
consumerConnection.close();
}
}
if (receivedMessage == null) {
Assert.fail("Message should have been re-delivered, but subsequent attempt to receive it returned null");
}
Assert.assertTrue("received a " + receivedMessage.getClass().getName() + " instead of a TextMessage", receivedMessage instanceof TextMessage);
Assert.assertEquals("Hello world!", ((TextMessage) receivedMessage).getText());
Assert.assertTrue("Redelivered header should have been set to true", receivedMessage.getJMSRedelivered());
}
}
| 10,785 | 37.798561 | 151 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/DefaultJMSBridgeTest.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.smoke.jms;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.UUID;
import jakarta.annotation.Resource;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.DeliveryMode;
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 org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.jms.auxiliary.CreateQueueSetupTask;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Jakarta Messaging bridge test.
*
* @author Jeff Mesnil (c) 2012 Red Hat Inc.
*/
@RunWith(Arquillian.class)
@ServerSetup(DefaultCreateJMSBridgeSetupTask.class)
public class DefaultJMSBridgeTest {
private static final Logger logger = Logger.getLogger(DefaultJMSBridgeTest.class);
private static final String MESSAGE_TEXT = "Hello world!";
@Resource(mappedName = "/queue/myAwesomeQueue")
private Queue sourceQueue;
@Resource(mappedName = "/queue/myAwesomeQueue2")
private Queue targetQueue;
@Resource(mappedName = "/myAwesomeCF")
private ConnectionFactory factory;
@Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addPackage(JMSOperations.class.getPackage())
.addClass(DefaultCreateJMSBridgeSetupTask.class)
.addClass(AbstractCreateJMSBridgeSetupTask.class)
.addClass(CreateQueueSetupTask.class)
.addAsManifestResource(
EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml"));
}
/**
* Send a message on the source queue
* Consumes it on the target queue
*
* The test will pass since a Jakarta Messaging Bridge has been created to bridge the source destination to the target destination.
*/
@Test
public void sendAndReceiveMessage() throws Exception {
Connection connection = null;
Session session = null;
Message receivedMessage = null;
try {
// SEND A MESSAGE on the source queue
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(sourceQueue);
String text = MESSAGE_TEXT + " " + UUID.randomUUID().toString();
Message message = session.createTextMessage(text);
message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.send(message);
connection.start();
connection.close();
// RECEIVE THE MESSAGE from the target queue
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(targetQueue);
connection.start();
receivedMessage = consumer.receive(5000);
// ASSERTIONS
assertNotNull("did not receive expected message", receivedMessage);
assertTrue(receivedMessage instanceof TextMessage);
assertEquals(text, ((TextMessage) receivedMessage).getText());
assertTrue("got header set by the Jakarta Messaging bridge", receivedMessage.getStringProperty(ActiveMQJMSConstants.AMQ_MESSAGING_BRIDGE_MESSAGE_ID_LIST) == null);
} catch (Exception e) {
e.printStackTrace();
} finally {
// CLEANUP
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}
}
}
| 5,384 | 37.464286 | 175 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/SendToJMSTopicTest.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms;
import jakarta.annotation.Resource;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.Message;
import jakarta.jms.MessageConsumer;
import jakarta.jms.MessageProducer;
import jakarta.jms.Session;
import jakarta.jms.TextMessage;
import jakarta.jms.Topic;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.jms.auxiliary.CreateTopicSetupTask;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Basic Jakarta Messaging test using a customly created Jakarta Messaging topic
*
* @author <a href="[email protected]">Jan Martiska</a>
*/
@RunWith(Arquillian.class)
@ServerSetup(CreateTopicSetupTask.class)
public class SendToJMSTopicTest {
private static final Logger logger = Logger.getLogger(SendToJMSTopicTest.class);
@Resource(mappedName = "/topic/myAwesomeTopic")
private Topic topic;
@Resource(mappedName = "/ConnectionFactory")
private ConnectionFactory factory;
@Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addPackage(JMSOperations.class.getPackage())
.addClass(CreateTopicSetupTask.class)
.addAsManifestResource(
EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml"));
}
@Test
public void sendMessage() throws Exception {
Connection senderConnection = null;
Connection consumerConnection = null;
Session senderSession = null;
Session consumerSession = null;
MessageConsumer consumer = null;
try {
// CREATE SUBSCRIBER
logger.trace("******* Creating connection for consumer");
consumerConnection = factory.createConnection();
logger.trace("Creating session for consumer");
consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
logger.trace("Creating consumer");
consumer = consumerSession.createConsumer(topic);
logger.trace("Start session");
consumerConnection.start();
// SEND A MESSAGE
logger.trace("***** Start - sending message to topic");
senderConnection = factory.createConnection();
logger.trace("Creating session..");
senderSession = senderConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = senderSession.createProducer(topic);
TextMessage message = senderSession.createTextMessage("Hello world!");
logger.trace("Sending..");
producer.send(message);
logger.trace("Message sent");
senderConnection.start();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
logger.trace("Closing connections and sessions");
if (senderSession != null) {
senderSession.close();
}
if (senderConnection != null) {
senderConnection.close();
}
}
Message receivedMessage = null;
try {
logger.trace("Receiving");
receivedMessage = consumer.receive(5000);
logger.trace("Received: " + ((TextMessage) receivedMessage).getText());
} catch (Exception e) {
e.printStackTrace();
Assert.fail(e.getMessage());
} finally {
if (receivedMessage == null) {
Assert.fail("received null instead of a TextMessage");
}
if (consumerSession != null) {
consumerSession.close();
}
if (consumerConnection != null) {
consumerConnection.close();
}
}
Assert.assertTrue("received a " + receivedMessage.getClass().getName() + " instead of a TextMessage", receivedMessage instanceof TextMessage);
Assert.assertEquals("Hello world!", ((TextMessage) receivedMessage).getText());
}
}
| 5,549 | 37.811189 | 150 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/JMSBridgeTest.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.smoke.jms;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OUTCOME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESULT;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.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.assertTrue;
import java.io.FilePermission;
import java.io.IOException;
import java.util.UUID;
import jakarta.annotation.Resource;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.DeliveryMode;
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 org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants;
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.container.ManagementClient;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.jms.auxiliary.CreateQueueSetupTask;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import org.jboss.remoting3.security.RemotingPermission;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Jakarta Messaging bridge test.
*
* @author Jeff Mesnil (c) 2012 Red Hat Inc.
*/
@RunWith(Arquillian.class)
@ServerSetup(CreateJMSBridgeSetupTask.class)
public class JMSBridgeTest {
private static final Logger logger = Logger.getLogger(JMSBridgeTest.class);
private static final String MESSAGE_TEXT = "Hello world!";
@Resource(mappedName = "/queue/myAwesomeQueue")
private Queue sourceQueue;
@Resource(mappedName = "/queue/myAwesomeQueue2")
private Queue targetQueue;
@Resource(mappedName = "/myAwesomeCF")
private ConnectionFactory factory;
@ArquillianResource
private ManagementClient managementClient;
@Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addPackage(JMSOperations.class.getPackage())
.addClass(CreateJMSBridgeSetupTask.class)
.addClass(AbstractCreateJMSBridgeSetupTask.class)
.addClass(CreateQueueSetupTask.class)
.addAsManifestResource(
EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml"))
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.controller-client,org.jboss.dmr,org.jboss.remoting\n"), "MANIFEST.MF")
.addAsManifestResource(createPermissionsXmlAsset(
new RemotingPermission("createEndpoint"),
new RemotingPermission("connect"),
new FilePermission(System.getProperty("jboss.inst") + "/standalone/tmp/auth/*", "read")
), "permissions.xml");
}
/**
* Send a message on the source queue
* Consumes it on the target queue
*
* The test will pass since a Jakarta Messaging Bridge has been created to bridge the source destination to the target
* destination.
*/
@Test
public void sendAndReceiveMessage() throws Exception {
Connection connection = null;
Session session = null;
Message receivedMessage = null;
try {
assertEquals("Message count bridge metric is not correct", 0L, readMetric("message-count"));
assertEquals("Aborted message count bridge metric is not correct", 0L, readMetric("aborted-message-count"));
// SEND A MESSAGE on the source queue
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(sourceQueue);
String text = MESSAGE_TEXT + " " + UUID.randomUUID().toString();
Message message = session.createTextMessage(text);
message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.send(message);
connection.start();
connection.close();
// RECEIVE THE MESSAGE from the target queue
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(targetQueue);
connection.start();
receivedMessage = consumer.receive(5000);
// ASSERTIONS
assertNotNull("did not receive expected message", receivedMessage);
assertTrue(receivedMessage instanceof TextMessage);
assertEquals(text, ((TextMessage) receivedMessage).getText());
assertNotNull("did not get header set by the Jakarta Messaging bridge", receivedMessage.getStringProperty(ActiveMQJMSConstants.AMQ_MESSAGING_BRIDGE_MESSAGE_ID_LIST));
assertEquals("Message count bridge metric is not correct", 1L, readMetric("message-count"));
assertEquals("Aborted message count bridge metric is not correct", 0L, readMetric("aborted-message-count"));
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
// CLEANUP
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}
}
private long readMetric(String metric) throws IOException {
ModelNode address = new ModelNode();
address.add("subsystem", "messaging-activemq");
address.add("jms-bridge", CreateJMSBridgeSetupTask.JMS_BRIDGE_NAME);
ModelNode operation = Operations.createReadAttributeOperation(address, metric);
ModelNode result = managementClient.getControllerClient().execute(operation);
assertEquals(SUCCESS, result.get(OUTCOME).asString());
return result.get(RESULT).asLong();
}
}
| 7,670 | 42.834286 | 178 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/SendToQueueIgnoreJTATest.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.jms.auxiliary.CreateQueueSetupTask;
import org.jboss.as.test.smoke.jms.auxiliary.JMSListener;
import org.jboss.as.test.smoke.jms.auxiliary.QueueMessageDrivenBean;
import org.jboss.as.test.smoke.jms.auxiliary.TransactedQueueMessageSenderIgnoreJTA;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.ejb.EJB;
import java.util.concurrent.CountDownLatch;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertEquals;
/**
* Test of fix for WFLY-9762.
* Jakarta Messaging message s send and verified if is delivered. Difference is in creation if ConectionFactory (based JMSConnectionFactoryDefinition annotation with the transactional attribute)
* and also tries rollback.
*
* Test is based on test from issue - https://github.com/javaee-samples/javaee7-samples/tree/master/jms/jms-xa
*
* @author <a href="[email protected]">Jiri Ondrusek</a>
*/
@RunWith(Arquillian.class)
@ServerSetup(CreateQueueSetupTask.class)
public class SendToQueueIgnoreJTATest {
private static int MAX_WAIT_IN_SECONDS = 15;
@EJB
private TransactedQueueMessageSenderIgnoreJTA sender;
@EJB
private JMSListener jmsListener;
private CountDownLatch latch;
@Before
public void setMessageReceived() {
latch = new CountDownLatch(1);
jmsListener.setLatch(latch);
}
@Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClass(TransactedQueueMessageSenderIgnoreJTA.class)
.addClass(JMSListener.class)
.addClass(QueueMessageDrivenBean.class)
.addClass(CreateQueueSetupTask.class)
.addPackage(JMSOperations.class.getPackage())
.addAsManifestResource(
EmptyAsset.INSTANCE,
ArchivePaths.create("beans.xml"));
}
/**
* Jakarta Messaging message is send using connection factory with transactional = false. Message should be delivered - main reason of fix.
*/
@Test
public void sendIgnoreJTA() throws Exception {
sender.send(true, false);
latch.await(MAX_WAIT_IN_SECONDS, SECONDS);
assertEquals(0, latch.getCount());
}
/**
* Jakarta Messaging message is send using connection factory with transactional = false and with rollback of Jakarta Transactions transaction.
* Message should be still delivered as Jakarta Transactions transaction is ignored.
*/
@Test
public void sendAndRollbackIgnoreJTA() throws Exception {
sender.send(true, true);
latch.await(MAX_WAIT_IN_SECONDS, SECONDS);
assertEquals(0, latch.getCount());
}
/**
* Jakarta Messaging message is send using connection factory with transactional = true.
* Messaging behaves as a part of Jakarta Transactions transaction, message should be delivered.
*/
@Test
public void sendInJTA() throws Exception {
sender.send(false,false);
latch.await(MAX_WAIT_IN_SECONDS, SECONDS);
assertEquals(0, latch.getCount());
}
/**
* Jakarta Messaging message is send using connection factory with transactional = true and Jakarta Transactions rollback
* Messaging behaves as a part of Jakarta Transactions transaction, message should NOT be delivered.
*/
@Test
public void sendAndRollbackInJTA() throws Exception {
sender.send(false, true);
latch.await(MAX_WAIT_IN_SECONDS, SECONDS);
assertEquals(1, latch.getCount());
}
}
| 5,119 | 35.312057 | 194 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/CreateJMSBridgeSetupTask.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.smoke.jms;
import org.jboss.dmr.ModelNode;
/**
* Setup task to create/remove a Jakarta Messaging bridge.
*
* @author Jeff Mesnil (c) 2012 Red Hat Inc.
*/
public class CreateJMSBridgeSetupTask extends AbstractCreateJMSBridgeSetupTask {
@Override
protected void configureBridge(ModelNode jmsBridgeAttributes) {
jmsBridgeAttributes.get("quality-of-service").set("ONCE_AND_ONLY_ONCE");
jmsBridgeAttributes.get("failure-retry-interval").set(500);
jmsBridgeAttributes.get("max-retries").set(2);
jmsBridgeAttributes.get("max-batch-size").set(1024);
jmsBridgeAttributes.get("max-batch-time").set(100);
jmsBridgeAttributes.get("add-messageID-in-header").set("true");
}
}
| 1,779 | 39.454545 | 80 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/SendToQueueFromWithinTransactionTest.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms;
import jakarta.ejb.EJB;
import jakarta.enterprise.event.Observes;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
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.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.jms.auxiliary.CreateQueueSetupTask;
import org.jboss.as.test.smoke.jms.auxiliary.QueueMessageDrivenBean;
import org.jboss.as.test.smoke.jms.auxiliary.TransactedQueueMessageSender;
import org.jboss.logging.Logger;
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;
/**
* Tests sending Jakarta Messaging messages to a queue within a transaction
*
* @author <a href="[email protected]">Jan Martiska</a>
*/
@RunWith(Arquillian.class)
@ServerSetup(CreateQueueSetupTask.class)
public class SendToQueueFromWithinTransactionTest {
private static final Logger logger = Logger.getLogger(SendToQueueFromWithinTransactionTest.class);
@EJB
private TransactedQueueMessageSender sender;
@EJB
private TransactedQueueMessageSender sender2;
private static volatile boolean messageReceived;
@Before
public void setMessageReceived() {
messageReceived = false;
}
@Deployment
public static JavaArchive createTestArchive() {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClass(TransactedQueueMessageSender.class)
.addClass(QueueMessageDrivenBean.class)
.addClass(CreateQueueSetupTask.class)
.addPackage(JMSOperations.class.getPackage())
.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml");
}
@Test
public void sendSuccessfully() throws Exception {
try {
sender.sendToQueueSuccessfully();
Thread.sleep(2000);
} catch (Exception ex) {
ex.printStackTrace();
}
Assert.assertTrue(messageReceived);
}
@Test
public void sendAndRollback() {
try {
sender2.sendToQueueAndRollback();
Thread.sleep(2000);
} catch (Exception ex) {
ex.printStackTrace();
}
Assert.assertFalse(messageReceived);
}
public void receivedMessage(@Observes Message message) {
messageReceived = true;
try {
logger.trace("caught event... message=" + ((TextMessage) message).getText());
} catch (JMSException ex) {
ex.printStackTrace();
Assert.fail(ex.getMessage());
}
}
}
| 3,931 | 33.491228 | 116 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/DefaultCreateJMSBridgeSetupTask.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.smoke.jms;
import org.jboss.dmr.ModelNode;
/**
* Setup task to create/remove a minimal Jakarta Messaging bridge.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public class DefaultCreateJMSBridgeSetupTask extends AbstractCreateJMSBridgeSetupTask {
@Override
protected void configureBridge(ModelNode jmsBridgeAttributes) {
}
}
| 1,401 | 36.891892 | 87 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/AbstractCreateJMSBridgeSetupTask.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.smoke.jms;
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.jms.auxiliary.CreateQueueSetupTask;
import org.jboss.dmr.ModelNode;
/**
* Abstract Setup task to create/remove a Jakarta Messaging bridge.
* @author Emmanuel Hugonnet (c) 2019 Red Hat, Inc.
*/
public abstract class AbstractCreateJMSBridgeSetupTask extends CreateQueueSetupTask {
public static final String CF_NAME = "myAwesomeCF";
public static final String CF_JNDI_NAME = "/myAwesomeCF";
public static final String JMS_BRIDGE_NAME = "myAwesomeJMSBridge";
private JMSOperations jmsOperations;
@Override
public void setup(ManagementClient managementClient, String containerId) throws Exception {
super.setup(managementClient, containerId);
jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
ModelNode connectionFactoryAttributes = new ModelNode();
connectionFactoryAttributes.get("connectors").add("in-vm");
connectionFactoryAttributes.get("factory-type").set("XA_GENERIC");
jmsOperations.addJmsConnectionFactory(CF_NAME, CF_JNDI_NAME, connectionFactoryAttributes);
ModelNode jmsBridgeAttributes = new ModelNode();
jmsBridgeAttributes.get("source-connection-factory").set(CF_JNDI_NAME);
jmsBridgeAttributes.get("source-destination").set(QUEUE1_JNDI_NAME);
jmsBridgeAttributes.get("target-connection-factory").set(CF_JNDI_NAME);
jmsBridgeAttributes.get("target-destination").set(QUEUE2_JNDI_NAME);
jmsBridgeAttributes.get("module").set("org.apache.activemq.artemis:main");
configureBridge(jmsBridgeAttributes);
jmsOperations.addJmsBridge(JMS_BRIDGE_NAME, jmsBridgeAttributes);
}
protected abstract void configureBridge(ModelNode jmsBridgeAttributes);
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
jmsOperations.removeJmsBridge(JMS_BRIDGE_NAME);
jmsOperations.removeJmsConnectionFactory(CF_NAME);
super.tearDown(managementClient, containerId);
}
}
| 3,316 | 44.438356 | 98 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/auxiliary/TransactedQueueMessageSenderIgnoreJTA.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms.auxiliary;
import org.jboss.logging.Logger;
import jakarta.annotation.Resource;
import jakarta.ejb.SessionContext;
import jakarta.ejb.Stateful;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.enterprise.context.RequestScoped;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSConnectionFactoryDefinition;
import jakarta.jms.JMSConnectionFactoryDefinitions;
import jakarta.jms.JMSContext;
import jakarta.jms.JMSDestinationDefinition;
import jakarta.jms.Queue;
@JMSDestinationDefinition(
name = "java:/app/jms/nonXAQueue",
interfaceName = "jakarta.jms.Queue"
)
@JMSConnectionFactoryDefinitions(
value = {
@JMSConnectionFactoryDefinition(
name = "java:/jms/nonXAcf",
transactional = false,
properties = {
"connectors=in-vm",}
),
@JMSConnectionFactoryDefinition(
name = "java:/jms/XAcf",
properties = {
"connectors=in-vm",}
)
}
)
/**
* Auxiliary class for Jakarta Messaging smoke tests - sends messages to a queue from within a transaction with different value in JMSConnectionFactoryDefinition annotation's transactional attribute
* Test of fix for WFLY-9762
*
* @author <a href="[email protected]">Jiri Ondrusek</a>
*/
@Stateful
@RequestScoped
public class TransactedQueueMessageSenderIgnoreJTA {
private static final Logger logger = Logger.getLogger(TransactedQueueMessageSenderIgnoreJTA.class);
@Resource(lookup = "java:/app/jms/nonXAQueue")
private Queue queue;
@Resource(lookup = "java:/ConnectionFactory")
private ConnectionFactory factory;
@Resource(lookup = "java:/jms/XAcf")
private ConnectionFactory factoryXA;
@Resource(lookup = "java:/jms/nonXAcf")
private ConnectionFactory factoryNonXA;
@Resource
private SessionContext ctx;
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
public void send(boolean ignoreJTA, boolean rollback) throws Exception {
try (JMSContext context = getFactory(ignoreJTA).createContext()) {
context.createProducer().send(queue, "test");
if (rollback) {
ctx.setRollbackOnly();
}
}
}
private ConnectionFactory getFactory(boolean ignoreJTA) {
return ignoreJTA ? factoryNonXA : factoryXA;
}
}
| 3,607 | 34.029126 | 198 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/auxiliary/QueueMessageDrivenBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms.auxiliary;
import org.jboss.logging.Logger;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.enterprise.event.Event;
import jakarta.inject.Inject;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import jakarta.jms.TextMessage;
/**
* Auxiliary class for Jakarta Messaging smoke tests - receives messages from a queue and fires events afterwards
*
* @author <a href="[email protected]">Jan Martiska</a>
*/
@MessageDriven(
name = "ShippingRequestProcessor",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "jakarta.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/myAwesomeQueue")
}
)
public class QueueMessageDrivenBean implements MessageListener {
private static final Logger logger = Logger.getLogger(QueueMessageDrivenBean.class);
@Inject
private Event<Message> event;
public void onMessage(Message message) {
try {
logger.trace("message " + ((TextMessage) message).getText() + " received! Sending event.");
} catch (JMSException e) {
e.printStackTrace();
}
event.fire(message);
}
}
| 2,375 | 35.553846 | 113 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/auxiliary/JMSListener.java
|
package org.jboss.as.test.smoke.jms.auxiliary;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import java.util.concurrent.CountDownLatch;
import org.jboss.logging.Logger;
@MessageDriven(
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:/app/jms/nonXAQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "jakarta.jms.Queue"), }
)
/**
* Auxiliary class for Jakarta Messaging smoke tests - receives messages from a queue.
* Test of fix for WFLY-9762
*
* @author <a href="[email protected]">Jiri Ondrusek</a>
*/
public class JMSListener implements MessageListener {
private static final Logger logger = Logger.getLogger(JMSListener.class.getName());
private CountDownLatch latch;
public void setLatch(CountDownLatch latch) {
this.latch = latch;
}
@Override
public void onMessage(Message message) {
try {
logger.debug("Message received (async): " + message.getBody(String.class));
latch.countDown();
} catch (JMSException ex) {
logger.error("Error onMessage", ex);
}
}
}
| 1,318 | 26.479167 | 114 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/auxiliary/TopicMessageDrivenBean.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms.auxiliary;
import org.jboss.logging.Logger;
import jakarta.ejb.ActivationConfigProperty;
import jakarta.ejb.MessageDriven;
import jakarta.enterprise.event.Event;
import jakarta.inject.Inject;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageListener;
import jakarta.jms.TextMessage;
/**
* Auxiliary class for Jakarta Messaging smoke tests - receives messages from a topic and fires events afterwards
*
* @author <a href="[email protected]">Jan Martiska</a>
*/
@MessageDriven(
name = "ShippingRequestProcessor",
activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "jakarta.jms.Topic"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "topic/myAwesomeTopic")
}
)
public class TopicMessageDrivenBean implements MessageListener {
private static final Logger logger = Logger.getLogger(TopicMessageDrivenBean.class);
@Inject
private Event<Message> event;
public void onMessage(Message message) {
try {
logger.trace("message " + ((TextMessage) message).getText() + " received! Sending event.");
} catch (JMSException e) {
e.printStackTrace();
}
event.fire(message);
}
}
| 2,375 | 35.553846 | 113 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/auxiliary/TransactedQueueMessageSender.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms.auxiliary;
import org.jboss.logging.Logger;
import jakarta.annotation.Resource;
import jakarta.ejb.SessionContext;
import jakarta.ejb.Stateful;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.enterprise.context.RequestScoped;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageProducer;
import jakarta.jms.Queue;
import jakarta.jms.Session;
/**
* Auxiliary class for Jakarta Messaging smoke tests - sends messages to a queue from within a transaction
*
* @author <a href="[email protected]">Jan Martiska</a>
*/
@Stateful
@RequestScoped
public class TransactedQueueMessageSender {
private static final Logger logger = Logger.getLogger(TransactedQueueMessageSender.class);
@Resource(lookup = "java:/queue/myAwesomeQueue")
private Queue queue;
@Resource(lookup = "java:/ConnectionFactory")
private ConnectionFactory factory;
@Resource
private SessionContext ctx;
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
public void sendToQueueSuccessfully() throws Exception {
Connection connection = null;
Session session = null;
try {
logger.trace("Creating a Connection");
connection = factory.createConnection();
logger.trace("Creating a Session");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
Message message = session.createTextMessage("Hello world!");
logger.trace("Sending message");
producer.send(message);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}
}
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
public void sendToQueueAndRollback() throws JMSException {
Connection connection = null;
Session session = null;
try {
logger.trace("Creating a Connection");
connection = factory.createConnection();
logger.trace("Creating a Session");
session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(queue);
Message message = session.createTextMessage("Hello world 2!");
logger.trace("Sending message");
producer.send(message);
// ROLLBACK
ctx.setRollbackOnly();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}
}
}
| 4,082 | 33.601695 | 106 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/auxiliary/TransactedTopicMessageSender.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms.auxiliary;
import org.jboss.logging.Logger;
import jakarta.annotation.Resource;
import jakarta.ejb.SessionContext;
import jakarta.ejb.Stateful;
import jakarta.ejb.TransactionAttribute;
import jakarta.ejb.TransactionAttributeType;
import jakarta.enterprise.context.RequestScoped;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageProducer;
import jakarta.jms.Session;
import jakarta.jms.Topic;
/**
* Auxiliary class for Jakarta Messaging smoke tests - sends messages to a topic from within a transaction
*
* @author <a href="[email protected]">Jan Martiska</a>
*/
@Stateful
@RequestScoped
public class TransactedTopicMessageSender {
private static final Logger logger = Logger.getLogger(TransactedTopicMessageSender.class);
@Resource(lookup = "java:/topic/myAwesomeTopic")
private Topic topic;
@Resource(lookup = "java:/ConnectionFactory")
private ConnectionFactory factory;
@Resource
private SessionContext ctx;
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
public void sendToTopicSuccessfully() throws Exception {
Connection connection = null;
Session session = null;
try {
logger.trace("Creating a Connection");
connection = factory.createConnection();
logger.trace("Creating a Session");
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(topic);
Message message = session.createTextMessage("Hello world!");
logger.trace("Sending message");
producer.send(message);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}
}
@TransactionAttribute(value = TransactionAttributeType.REQUIRES_NEW)
public void sendToTopicAndRollback() throws JMSException {
Connection connection = null;
Session session = null;
try {
logger.trace("Creating a Connection");
connection = factory.createConnection();
logger.trace("Creating a Session");
session = connection.createSession(true, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(topic);
Message message = session.createTextMessage("Hello world 2!");
logger.trace("Sending message");
producer.send(message);
// ROLLBACK
ctx.setRollbackOnly();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) {
session.close();
}
if (connection != null) {
connection.close();
}
}
}
}
| 4,082 | 33.601695 | 106 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/jms/auxiliary/SimplifiedMessageProducer.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.jms.auxiliary;
import org.jboss.logging.Logger;
import jakarta.annotation.Resource;
import jakarta.ejb.Stateful;
import jakarta.enterprise.context.RequestScoped;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.DeliveryMode;
import jakarta.jms.Destination;
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.
*/
@Stateful
@RequestScoped
public class SimplifiedMessageProducer {
private static final Logger logger = Logger.getLogger(SimplifiedMessageProducer.class);
@Resource
private ConnectionFactory defaultConnectionFactory;
@Resource(lookup = "java:/ConnectionFactory")
private ConnectionFactory regularConnectionFactory;
public void sendWithDefaultJMSConnectionFactory(Destination destination, String text) throws Exception {
send(defaultConnectionFactory, destination, text);
}
public void sendWithRegularConnectionFactory(Destination destination, String text) throws Exception {
send(regularConnectionFactory, destination, text);
}
private void send(ConnectionFactory cf, Destination destination, String text) throws Exception {
// TODO use Jakarta Messaging 2.0 context when HornetQ supports it
Connection connection = cf.createConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(destination);
Message message = session.createTextMessage(text);
message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
producer.send(message);
connection.close();
}
}
| 2,800 | 36.851351 | 108 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/datasource/DsTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.datasource;
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.sql.Connection;
import java.sql.ResultSet;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.connector.subsystems.datasources.WildFlyDataSource;
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;
/**
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
@RunWith(Arquillian.class)
public class DsTestCase {
private static final String JNDI_NAME = "java:jboss/datasources/ExampleDS";
@Deployment
public static Archive<?> getDeployment() {
JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "ds-example.jar");
archive.addClass(DsTestCase.class);
archive.addClass(WildFlyDataSource.class);
return archive;
}
@Test
public void testDatasource() throws Exception {
InitialContext context = new InitialContext();
DataSource ds = (DataSource) context.lookup(JNDI_NAME);
Connection conn = ds.getConnection();
ResultSet rs = conn.prepareStatement("select 1").executeQuery();
Assert.assertTrue(rs.next());
conn.close();
}
@Test
public void testDatasourceSerialization() throws Exception {
InitialContext context = new InitialContext();
DataSource originalDs = (DataSource) context.lookup(JNDI_NAME);
//serialize
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput out = null;
DataSource ds;
ObjectInput in = null;
try {
out = new ObjectOutputStream(bos);
out.writeObject(originalDs);
byte[] bytes = bos.toByteArray();
//deserialize
ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
try {
in = new ObjectInputStream(bis);
ds = (DataSource) in.readObject();
} finally {
try {
bis.close();
} catch (IOException ex) {
// ignore close exception
}
try {
if (in != null) {
in.close();
}
} catch (IOException ex) {
// ignore close exception
}
}
//use
Connection conn = ds.getConnection();
ResultSet rs = conn.prepareStatement("select 1").executeQuery();
Assert.assertTrue(rs.next());
conn.close();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException ex) {
// ignore close exception
}
try {
bos.close();
} catch (IOException ex) {
// ignore close exception
}
}
}
}
| 4,444 | 32.674242 | 85 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/serviceloader/TestServiceImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.serviceloader;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public class TestServiceImpl implements TestService {
public String decorate(String s) {
return "#TestService#" + s;
}
}
| 1,307 | 35.333333 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/serviceloader/ServiceLoaderTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.serviceloader;
import java.util.ServiceLoader;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.modules.Module;
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;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
@RunWith(Arquillian.class)
public class ServiceLoaderTestCase {
@Deployment
public static Archive<?> getDeployment() {
final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "serviceloader-example.jar");
jar.addAsServiceProvider(TestService.class, TestServiceImpl.class);
jar.addPackage(ServiceLoaderTestCase.class.getPackage());
return jar;
}
@Test
public void decorateWithServiceLoader() {
Module module = Module.forClass(TestService.class);
ServiceLoader<TestService> loader = module.loadService(TestService.class);
String s = "Hello";
for (TestService service : loader) {
s = service.decorate(s);
}
Assert.assertEquals("#TestService#Hello", s);
}
}
| 2,337 | 33.895522 | 98 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/serviceloader/TestService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.serviceloader;
/**
*
* @author <a href="[email protected]">Kabir Khan</a>
* @version $Revision: 1.1 $
*/
public interface TestService {
String decorate(String s);
}
| 1,233 | 36.393939 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/webservices/Endpoint.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2011, 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.smoke.webservices;
import jakarta.jws.WebMethod;
import jakarta.jws.WebService;
import jakarta.jws.soap.SOAPBinding;
@WebService (name="Endpoint")
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface Endpoint {
@WebMethod(operationName = "echoString", action = "urn:EchoString")
String echo(String input);
}
| 1,382 | 39.676471 | 70 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/webservices/WSTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.webservices;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertNotNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.test.integration.common.HttpRequest;
import org.jboss.as.test.integration.domain.management.util.DomainTestSupport;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="[email protected]">Alessio Soldano</a>
* @version $Revision: 1.1 $
*/
@RunWith(Arquillian.class)
@RunAsClient
public class WSTestCase {
private static final ModelNode webserviceAddress;
static {
webserviceAddress = new ModelNode();
webserviceAddress.add("subsystem", "webservices");
}
@ContainerResource
private ManagementClient managementClient;
@ArquillianResource
private URL url;
@Deployment(testable = false)
public static Archive<?> getDeployment() {
final WebArchive war = ShrinkWrap.create(WebArchive.class, "ws-example.war");
war.addPackage(WSTestCase.class.getPackage());
war.setWebXML(WSTestCase.class.getPackage(), "web.xml");
return war;
}
@Test
@InSequence(1)
public void testWSDL() throws Exception {
String wsdl = performCall("?wsdl");
assertNotNull(wsdl);
assertThat(wsdl, containsString("wsdl:definitions"));
}
@Test
@InSequence(2)
public void testManagementDescription() throws Exception {
final ModelNode address = new ModelNode();
address.add(ModelDescriptionConstants.DEPLOYMENT, "ws-example.war");
address.add(ModelDescriptionConstants.SUBSYSTEM, "webservices"); //EndpointService
address.add("endpoint", "*"); // get all endpoints
final ModelNode operation = new ModelNode();
operation.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.READ_RESOURCE_OPERATION);
operation.get(ModelDescriptionConstants.OP_ADDR).set(address);
operation.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(true);
operation.get(ModelDescriptionConstants.RECURSIVE).set(true);
final ModelNode result = managementClient.getControllerClient().execute(operation);
List<ModelNode> endpoints = DomainTestSupport.validateResponse(result).asList();
assertThat(endpoints.size() > 0, is(true));
for (final ModelNode endpointResult : result.get("result").asList()) {
final ModelNode endpoint = endpointResult.get("result");
assertThat(endpoint.hasDefined("class"), is(true));
assertThat(endpoint.hasDefined("name"), is(true));
assertThat(endpoint.hasDefined("wsdl-url"), is(true));
assertThat(endpoint.get("wsdl-url").asString().endsWith("?wsdl"), is(true));
assertThat(endpoint.hasDefined("request-count"), is(true));
assertThat(endpoint.get("request-count").asString(), is("0"));
}
}
@Test
@InSequence(3)
public void testManagementDescriptionMetrics() throws Exception {
setStatisticsEnabled(true);
final ModelNode address = new ModelNode();
address.add(ModelDescriptionConstants.DEPLOYMENT, "ws-example.war");
address.add(ModelDescriptionConstants.SUBSYSTEM, "webservices"); //EndpointService
address.add("endpoint", "*"); // get all endpoints
final ModelNode operation = new ModelNode();
operation.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.READ_RESOURCE_OPERATION);
operation.get(ModelDescriptionConstants.OP_ADDR).set(address);
operation.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(true);
operation.get(ModelDescriptionConstants.RECURSIVE).set(true);
ModelNode result = managementClient.getControllerClient().execute(operation);
List<ModelNode> endpoints = DomainTestSupport.validateResponse(result).asList();
assertThat(endpoints.size() > 0, is(true));
for (final ModelNode endpointResult : result.get("result").asList()) {
final ModelNode endpoint = endpointResult.get("result");
// Get the wsdl again to be sure the endpoint has been hit at least once
final URL wsdlUrl = new URL(endpoint.get("wsdl-url").asString());
String wsdl = HttpRequest.get(wsdlUrl.toExternalForm(), 30, TimeUnit.SECONDS);
assertThat(wsdl, is(notNullValue()));
// Read metrics
checkCountMetric(endpointResult, managementClient.getControllerClient(), "request-count");
checkCountMetric(endpointResult, managementClient.getControllerClient(), "response-count");
}
setStatisticsEnabled(false);
result = managementClient.getControllerClient().execute(operation);
endpoints = DomainTestSupport.validateResponse(result).asList();
for (final ModelNode endpointResult : endpoints) {
final ModelNode endpoint = endpointResult.get("result");
assertThat(endpoint.hasDefined("request-count"), is(true));
assertThat(endpoint.get("request-count").asString(), is("1"));
}
}
private int checkCountMetric(final ModelNode endpointResult, final ModelControllerClient client, final String metricName) throws IOException {
final ModelNode readAttribute = new ModelNode();
readAttribute.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.READ_ATTRIBUTE_OPERATION);
readAttribute.get(ModelDescriptionConstants.OP_ADDR).set(endpointResult.get(ModelDescriptionConstants.OP_ADDR));
readAttribute.get(ModelDescriptionConstants.NAME).set(metricName);
long timeout = 30_000L + System.currentTimeMillis();
String value = "-1";
while (System.currentTimeMillis() < timeout) {
ModelNode attribute = client.execute(readAttribute);
ModelNode result = DomainTestSupport.validateResponse(attribute);
value = result.asString();
assertThat("We have found " + result, value.length(), is(1));
if (result.asInt() > 0) {
//We have found a valid metric
return result.asInt();
}
}
fail("We have found " + value + " for metric " + metricName + " instead of some positive value");
return -1;
}
@Test
@InSequence(4)
public void testAccess() throws Exception {
URL wsdlURL = new URL(this.url.toExternalForm() + "ws-example?wsdl");
QName serviceName = new QName("http://webservices.smoke.test.as.jboss.org/", "EndpointService");
Service service = Service.create(wsdlURL, serviceName);
Endpoint port = (Endpoint) service.getPort(Endpoint.class);
String echo = port.echo("Foo");
assertThat("Echoing Foo should return Foo not " + echo, echo, is("Foo"));
}
private String performCall(String params) throws Exception {
URL callUrl = new URL(this.url.toExternalForm() + "ws-example/" + params);
return HttpRequest.get(callUrl.toExternalForm(), 30, TimeUnit.SECONDS);
}
private void setStatisticsEnabled(boolean enabled) throws Exception {
final ModelNode updateStatistics = new ModelNode();
updateStatistics.get(ModelDescriptionConstants.OP).set(ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION);
updateStatistics.get(ModelDescriptionConstants.OP_ADDR).set(webserviceAddress);
updateStatistics.get(ModelDescriptionConstants.NAME).set("statistics-enabled");
updateStatistics.get(ModelDescriptionConstants.VALUE).set(enabled);
final ModelNode result = managementClient.getControllerClient().execute(updateStatistics);
DomainTestSupport.validateResponse(result, false);
}
}
| 9,801 | 45.899522 | 146 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/webservices/EndpointService.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, 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.smoke.webservices;
import java.net.URL;
import javax.xml.namespace.QName;
import jakarta.xml.ws.Service;
import jakarta.xml.ws.WebEndpoint;
import jakarta.xml.ws.WebServiceClient;
import jakarta.xml.ws.WebServiceFeature;
/**
* This class was generated by Apache CXF 2.3.1
* Mon Mar 14 19:07:07 BRT 2011
* Generated source version: 2.3.1
*
* @author <a href="mailto:[email protected]">Flavia Rainone</a>
*/
@WebServiceClient(name = "EndpointService",
wsdlLocation = "META-INF/wsdl/EndpointService.wsdl",//"http://localhost:8080/ws-example?wsdl",
targetNamespace = "http://webservices.smoke.test.as.jboss.org/")
public class EndpointService extends Service {
public static final QName SERVICE = new QName("http://archive.ws.demos.as.jboss.org/", "EndpointService");
public static final QName EndpointPort = new QName("http://archive.ws.demos.as.jboss.org/", "EndpointPort");
public EndpointService(URL wsdlLocation) {
super(wsdlLocation, SERVICE);
}
public EndpointService(URL wsdlLocation, QName serviceName) {
super(wsdlLocation, serviceName);
}
public EndpointService() {
super(null, SERVICE);
}
@WebEndpoint(name = "EndpointPort")
public Endpoint getEndpointPort() {
return super.getPort(EndpointPort, Endpoint.class);
}
@WebEndpoint(name = "EndpointPort")
public Endpoint getEndpointPort(WebServiceFeature... features) {
return super.getPort(EndpointPort, Endpoint.class, features);
}
}
| 2,604 | 35.690141 | 112 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/webservices/EndpointImpl.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2006, 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.smoke.webservices;
import jakarta.jws.WebService;
import org.jboss.logging.Logger;
/**
* A simple endpoint
*
* @author [email protected]
* @since 25-Jan-2011
*/
@WebService(serviceName="EndpointService", portName="EndpointPort", endpointInterface = "org.jboss.as.test.smoke.webservices.Endpoint")
public class EndpointImpl {
// Provide logging
private static Logger log = Logger.getLogger(EndpointImpl.class);
public String echo(String input) {
log.trace("echo: " + input);
return input;
}
}
| 1,591 | 35.181818 | 135 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/messaging/ArtemisMessagingTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.messaging;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.apache.activemq.artemis.api.core.client.ClientConsumer;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.MessageHandler;
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory;
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.container.ManagementClient;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* [TODO]
*
* @author <a href="[email protected]">Kabir Khan</a>
*/
@RunWith(Arquillian.class)
public class ArtemisMessagingTestCase {
private static final String QUEUE_EXAMPLE_QUEUE = "queue.exampleQueue";
static final Logger log = Logger.getLogger(ArtemisMessagingTestCase.class);
private static final String BODY = "msg.body";
private ClientSessionFactory sf;
private ClientSession session;
@ArquillianResource
private ManagementClient managementClient;
@Deployment
public static JavaArchive createDeployment() throws Exception {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "messaging-example.jar");
jar.addAsManifestResource(new StringAsset("Manifest-Version: 1.0\n" +
"Dependencies: org.apache.activemq.artemis, org.jboss.dmr, org.jboss.as.controller-client\n"), "MANIFEST.MF");
jar.addClass(ArtemisMessagingTestCase.class);
return jar;
}
@Before
public void start() throws Exception {
//Not using JNDI so we use the core services directly
sf = ActiveMQClient.createServerLocatorWithoutHA(new TransportConfiguration(InVMConnectorFactory.class.getName())).createSessionFactory();
session = sf.createSession();
//Create a queue
ClientSession coreSession = sf.createSession();
coreSession.createQueue(QUEUE_EXAMPLE_QUEUE, QUEUE_EXAMPLE_QUEUE, false);
coreSession.close();
session = sf.createSession();
session.start();
}
@After
public void stop() throws Exception {
if (session != null) {
session.close();
}
if (sf != null) {
ClientSession coreSession = sf.createSession();
coreSession.deleteQueue(QUEUE_EXAMPLE_QUEUE);
coreSession.close();
sf.close();
}
}
@Test
public void testMessaging() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
final AtomicReference<ClientMessage> message = new AtomicReference<ClientMessage>();
ClientConsumer consumer = session.createConsumer(QUEUE_EXAMPLE_QUEUE);
consumer.setMessageHandler(new MessageHandler() {
@Override
public void onMessage(ClientMessage m) {
try {
m.acknowledge();
message.set(m);
latch.countDown();
} catch (ActiveMQException e) {
e.printStackTrace();
}
}
});
String text = UUID.randomUUID().toString();
sendMessage(text);
assertTrue(latch.await(1, SECONDS));
assertEquals(text, message.get().getStringProperty(BODY));
}
private void sendMessage(String text) throws Exception {
ClientProducer producer = session.createProducer(QUEUE_EXAMPLE_QUEUE);
ClientMessage message = session.createMessage(false);
message.putStringProperty(BODY, text);
log.trace("-----> Sending message");
producer.send(message);
}
}
| 5,618 | 36.46 | 146 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/messaging/NoBrokerMessagingTestCase.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.smoke.messaging;
import static org.jboss.shrinkwrap.api.ShrinkWrap.create;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.test.integration.common.HttpRequest;
import org.jboss.as.test.shared.ServerReload;
import org.jboss.as.test.shared.SnapshotRestoreSetupTask;
import org.jboss.as.test.shared.TimeoutUtil;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Simple test to cover the deployment of a simple web application whithout any internal broker.
* Checks that without the default Jakarta Messaging factory all is working properly.
*
* @author Emmanuel Hugonnet (c) 2018 Red Hat, inc.
*/
@RunWith(Arquillian.class)
@RunAsClient
@ServerSetup(NoBrokerMessagingTestCase.SetupTask.class)
public class NoBrokerMessagingTestCase {
@ArquillianResource
private URL url;
static class SetupTask extends SnapshotRestoreSetupTask {
private static final Logger logger = Logger.getLogger(NoBrokerMessagingTestCase.SetupTask.class);
@Override
public void doSetup(org.jboss.as.arquillian.container.ManagementClient managementClient, String s) throws Exception {
execute(managementClient, Operations.createUndefineAttributeOperation(PathAddress.parseCLIStyleAddress("/subsystem=ee/service=default-bindings").toModelNode(), "jms-connection-factory"), true);
execute(managementClient, Operations.createRemoveOperation(PathAddress.parseCLIStyleAddress("/subsystem=messaging-activemq/server=default").toModelNode()), true);
ServerReload.executeReloadAndWaitForCompletion(managementClient);
}
private ModelNode execute(final org.jboss.as.arquillian.container.ManagementClient managementClient, final ModelNode op, final boolean expectSuccess) throws IOException {
ModelNode response = managementClient.getControllerClient().execute(op);
final String outcome = response.get("outcome").asString();
if (expectSuccess) {
assertEquals(response.toString(), "success", outcome);
return response.get("result");
} else {
assertEquals("failed", outcome);
return response.get("failure-description");
}
}
}
@Deployment
public static WebArchive createArchive() {
return create(WebArchive.class, "nobroker.war")
.addAsWebResource(new StringAsset("<!DOCTYPE html>\n"
+ "<html lang= \"en\">\n"
+ " <head>\n"
+ " <meta charset=\"utf-8\">\n"
+ " <title>No Broker</title>\n"
+ " </head>\n"
+ " <body>\n"
+ " <h1>Simple Content test for nobroker.war</h1>\n"
+ " <p>This is not a 404 error.</p>\n"
+ " </body>\n"
+ "</html>"), "index.html");
}
@Test
public void testWarIsDeployed() throws Exception {
String reply = HttpRequest.get(this.url.toExternalForm(), TimeoutUtil.adjust(10), TimeUnit.SECONDS);
assertNotNull(reply);
}
}
| 4,899 | 43.545455 | 205 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/messaging/client/jms/JmsClientTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.messaging.client.jms;
import static java.util.concurrent.TimeUnit.SECONDS;
import static jakarta.jms.Session.AUTO_ACKNOWLEDGE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import jakarta.jms.Connection;
import jakarta.jms.ConnectionFactory;
import jakarta.jms.DeliveryMode;
import jakarta.jms.Destination;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.MessageConsumer;
import jakarta.jms.MessageListener;
import jakarta.jms.MessageProducer;
import jakarta.jms.Session;
import jakarta.jms.TextMessage;
import javax.naming.Context;
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.container.ManagementClient;
import org.jboss.as.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Demo using the AS management API to create and destroy a Jakarta Messaging queue.
*
* @author Emanuel Muckenhuber
*/
@RunWith(Arquillian.class)
@RunAsClient
public class JmsClientTestCase {
private static final String QUEUE_NAME = "createdTestQueue";
private static final String EXPORTED_QUEUE_NAME = "java:jboss/exported/createdTestQueue";
@ContainerResource
private Context remoteContext;
@ContainerResource
private ManagementClient managementClient;
@Before
public void setUp() throws IOException {
JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient);
jmsOperations.createJmsQueue(QUEUE_NAME, EXPORTED_QUEUE_NAME);
}
@After
public void tearDown() throws IOException {
JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient);
jmsOperations.removeJmsQueue(QUEUE_NAME);
}
@Test
public void testSendAndReceive() throws Exception {
doSendAndReceive("jms/RemoteConnectionFactory");
}
private void doSendAndReceive(String connectionFactoryLookup) throws Exception {
Connection conn = null;
try {
ConnectionFactory cf = (ConnectionFactory) remoteContext.lookup(connectionFactoryLookup);
assertNotNull(cf);
Destination destination = (Destination) remoteContext.lookup(QUEUE_NAME);
assertNotNull(destination);
conn = cf.createConnection("guest", "guest");
conn.start();
Session consumerSession = conn.createSession(false, AUTO_ACKNOWLEDGE);
final CountDownLatch latch = new CountDownLatch(10);
final List<String> result = new ArrayList<String>();
// Set the async listener
MessageConsumer consumer = consumerSession.createConsumer(destination);
consumer.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
TextMessage msg = (TextMessage) message;
try {
result.add(msg.getText());
latch.countDown();
} catch (JMSException e) {
e.printStackTrace();
}
}
});
final Session producerSession = conn.createSession(false, AUTO_ACKNOWLEDGE);
MessageProducer producer = producerSession.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
for (int i = 0 ; i < 10 ; i++) {
String s = "Test" + i;
TextMessage msg = producerSession.createTextMessage(s);
//System.out.println("sending " + s);
producer.send(msg);
}
producerSession.close();
assertTrue(latch.await(3, SECONDS));
assertEquals(10, result.size());
for (int i = 0 ; i < result.size() ; i++) {
assertEquals("Test" + i, result.get(i));
}
} finally {
try {
conn.close();
} catch (Exception ignore) {
}
}
}
}
| 5,540 | 35.94 | 101 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/messaging/client/messaging/CoreQueueMessagingTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.messaging.client.messaging;
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.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.ServerReload;
import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Demo using the AS management API to create and destroy a Artemis core queue.
*
* @author Emanuel Muckenhuber
* @author Kabir Khan
*/
@RunWith(Arquillian.class)
@RunAsClient
public class CoreQueueMessagingTestCase {
private final String queueName = "queue.standalone";
@ContainerResource
private ManagementClient managementClient;
@Test
public void testMessagingClientUsingMessagingPort() throws Exception {
JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsOperations.addCoreQueue(queueName, queueName, true, "ANYCAST");
ServerReload.executeReloadAndWaitForCompletion(managementClient);
jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsOperations.removeCoreQueue(queueName);
ServerReload.executeReloadAndWaitForCompletion(managementClient);
jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsOperations.addCoreQueue(queueName, queueName, true, "MULTICAST");
}
@After
public void tearDown() throws Exception {
JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsOperations.removeCoreQueue(queueName);
ServerReload.executeReloadAndWaitForCompletion(managementClient);
}
}
| 2,979 | 39.821918 | 112 |
java
|
null |
wildfly-main/testsuite/integration/smoke/src/test/java/org/jboss/as/test/smoke/messaging/client/messaging/MessagingClientTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2010, 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.smoke.messaging.client.messaging;
import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.apache.activemq.artemis.api.core.client.ClientConsumer;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
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.container.ManagementClient;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.controller.client.helpers.ClientConstants;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.test.integration.common.jms.JMSOperations;
import org.jboss.as.test.integration.common.jms.JMSOperationsProvider;
import org.jboss.as.test.shared.ServerReload;
import org.jboss.dmr.ModelNode;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import jakarta.resource.spi.IllegalStateException;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static org.jboss.as.controller.client.helpers.ClientConstants.ADD;
import static org.jboss.as.controller.client.helpers.ClientConstants.REMOVE_OPERATION;
import static org.junit.Assert.assertNotNull;
/**
* Demo using the AS management API to create and destroy a Artemis core queue.
*
* @author Emanuel Muckenhuber
* @author Kabir Khan
*/
@RunWith(Arquillian.class)
@RunAsClient
public class MessagingClientTestCase {
private final String queueName = "queue.standalone";
private final int messagingPort = 5445;
private String messagingSocketBindingName = "messaging";
private String remoteAcceptorName = "netty";
@ContainerResource
private ManagementClient managementClient;
@Test
public void testMessagingClientUsingMessagingPort() throws Exception {
final ClientSessionFactory sf = createClientSessionFactory(managementClient.getWebUri().getHost(), messagingPort,
false);
doMessagingClient(sf);
sf.close();
}
@Test
public void testMessagingClientUsingHTTPPort() throws Exception {
final ClientSessionFactory sf = createClientSessionFactory(managementClient.getWebUri().getHost(), managementClient.getWebUri().getPort(),
true);
doMessagingClient(sf);
sf.close();
}
public void loop() throws Exception {
for (int i = 0; i < 1000; i++) {
//System.out.println("i = " + i);
testMessagingClientUsingHTTPPort();
}
}
private void doMessagingClient(ClientSessionFactory sf) throws Exception {
// Check if the queue exists
if (!queueExists(queueName, sf)) {
throw new IllegalStateException();
}
ClientSession session = null;
try {
session = sf.createSession("guest", "guest", false, true, true, false, 1);
ClientProducer producer = session.createProducer(queueName);
ClientMessage message = session.createMessage(false);
final String propName = "myprop";
message.putStringProperty(propName, "Hello sent at " + new Date());
producer.send(message);
ClientConsumer messageConsumer = session.createConsumer(queueName);
session.start();
ClientMessage messageReceived = messageConsumer.receive(1000);
assertNotNull("a message MUST have been received", messageReceived);
} finally {
if (session != null) {
session.close();
}
}
}
private boolean queueExists(final String queueName, final ClientSessionFactory sf) throws ActiveMQException {
final ClientSession session = sf.createSession("guest", "guest", false, false, false, false, 1);
try {
final ClientSession.QueueQuery query = session.queueQuery(new SimpleString(queueName));
return query.isExists();
} finally {
session.close();
}
}
private ClientSessionFactory createClientSessionFactory(String host, int port, boolean httpUpgradeEnabled) throws Exception {
final Map<String, Object> properties = new HashMap<String, Object>();
properties.put(TransportConstants.HOST_PROP_NAME, host);
properties.put(TransportConstants.PORT_PROP_NAME, port);
properties.put(TransportConstants.HTTP_UPGRADE_ENABLED_PROP_NAME, httpUpgradeEnabled);
if (httpUpgradeEnabled) {
properties.put(TransportConstants.HTTP_UPGRADE_ENDPOINT_PROP_NAME, "http-acceptor");
}
final TransportConfiguration configuration = new TransportConfiguration(NettyConnectorFactory.class.getName(), properties);
return ActiveMQClient.createServerLocatorWithoutHA(configuration).createSessionFactory();
}
@Before
public void setup() throws Exception {
createSocketBinding(managementClient.getControllerClient(), messagingSocketBindingName, messagingPort);
JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsOperations.createRemoteAcceptor(remoteAcceptorName, messagingSocketBindingName, null);
jmsOperations.addCoreQueue(queueName, queueName, true, "ANYCAST");
ServerReload.reloadIfRequired(managementClient);
}
@After
public void tearDown() throws Exception {
JMSOperations jmsOperations = JMSOperationsProvider.getInstance(managementClient.getControllerClient());
jmsOperations.removeRemoteAcceptor(remoteAcceptorName);
jmsOperations.removeCoreQueue(queueName);
removeSocketBinding(managementClient.getControllerClient(), messagingSocketBindingName);
ServerReload.reloadIfRequired(managementClient);
}
public final void createSocketBinding(final ModelControllerClient modelControllerClient, final String name, int port) {
ModelNode model = new ModelNode();
model.get(ClientConstants.OP).set(ADD);
model.get(ClientConstants.OP_ADDR).add("socket-binding-group", "standard-sockets");
model.get(ClientConstants.OP_ADDR).add("socket-binding", name);
model.get("interface").set("public");
model.get("port").set(port);
model.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
try {
execute(modelControllerClient, model);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public final void removeSocketBinding(final ModelControllerClient modelControllerClient, final String name) {
ModelNode model = new ModelNode();
model.get(ClientConstants.OP).set(REMOVE_OPERATION);
model.get(ClientConstants.OP_ADDR).add("socket-binding-group", "standard-sockets");
model.get(ClientConstants.OP_ADDR).add("socket-binding", name);
model.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
try {
execute(modelControllerClient, model);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
/**
* Executes the operation and returns the result if successful. Else throws an exception
*
* @param modelControllerClient
* @param operation
* @return
* @throws IOException
*/
private ModelNode execute(final ModelControllerClient modelControllerClient, final ModelNode operation) throws IOException {
final ModelNode result = modelControllerClient.execute(operation);
if (result.hasDefined(ClientConstants.OUTCOME) && ClientConstants.SUCCESS.equals(result.get(ClientConstants.OUTCOME).asString())) {
//logger.trace("Operation " + operation.toString() + " successful");
return result;
} else if (result.hasDefined(ClientConstants.FAILURE_DESCRIPTION)) {
final String failureDesc = result.get(ClientConstants.FAILURE_DESCRIPTION).toString();
throw new RuntimeException(failureDesc);
} else {
throw new RuntimeException("Operation not successful; outcome = " + result.get(ClientConstants.OUTCOME));
}
}
}
| 9,933 | 42.191304 | 146 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/management/MPScriptTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2020, 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.wildfly.test.manual.management;
import java.io.File;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import org.jboss.dmr.ModelNode;
import org.junit.Assume;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.wildfly.core.testrunner.ManagementClient;
import org.wildfly.core.testrunner.ServerControl;
import org.wildfly.core.testrunner.ServerController;
import org.wildfly.core.testrunner.WildFlyRunner;
import jakarta.inject.Inject;
import org.jboss.as.cli.CommandContext;
import org.jboss.as.cli.CommandContextFactory;
import org.jboss.as.controller.PathAddress;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RECURSIVE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import org.jboss.as.controller.operations.common.Util;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.wildfly.core.testrunner.Server;
/**
* Apply CLI script to evolve standalone configurations with MP.
*
* @author jdenise
*/
@RunWith(WildFlyRunner.class)
@ServerControl(manual = true)
public class MPScriptTestCase {
private static final File ROOT = new File(System.getProperty("jboss.home"));
private static final Path CONFIG_DIR = ROOT.toPath().resolve("standalone").resolve("configuration");
private static final Path SCRIPT_FILE = ROOT.toPath().resolve("docs").resolve("examples").resolve("enable-microprofile.cli");
private static final String CONFIG_FILE_PROP = "config";
private static final String PREFIX = "copy-";
@Inject
private ServerController serverController;
private String currentConfig;
@Before
public void check() {
Assume.assumeTrue(String.format("Configuration file %s not found. Skipping these tests.", SCRIPT_FILE), Files.exists(SCRIPT_FILE));
}
@Test
public void test() throws Exception {
currentConfig = "standalone.xml";
setupConfig();
doTest();
}
@Test
public void testFull() throws Exception {
currentConfig = "standalone-full.xml";
setupConfig();
doTest();
}
@Test
public void testHa() throws Exception {
currentConfig = "standalone-ha.xml";
setupConfig();
doTest();
}
@Test
public void testFullHa() throws Exception {
currentConfig = "standalone-full-ha.xml";
setupConfig();
doTest();
}
@After
public void resetConfig() throws Exception {
Path copy = CONFIG_DIR.resolve(PREFIX + currentConfig);
if (Files.exists(copy)) {
Files.move(copy,
CONFIG_DIR.resolve(currentConfig), StandardCopyOption.REPLACE_EXISTING);
}
}
private void doTest() throws Exception {
serverController.start(currentConfig, Server.StartMode.NORMAL);
try {
ManagementClient client = serverController.getClient();
ModelNode rr = Util.createEmptyOperation(READ_RESOURCE_OPERATION, PathAddress.EMPTY_ADDRESS);
rr.get(RECURSIVE).set(true);
ModelNode result = client.executeForResult(rr);
//Check subsystems are present and security removed
Assert.assertTrue(result.has(SUBSYSTEM, "microprofile-fault-tolerance-smallrye"));
Assert.assertTrue(result.has(SUBSYSTEM, "microprofile-jwt-smallrye"));
Assert.assertTrue(result.has(SUBSYSTEM, "microprofile-openapi-smallrye"));
Assert.assertFalse(result.has(SUBSYSTEM, "security"));
} finally {
serverController.stop();
}
}
private void setupConfig() throws Exception {
System.setProperty(CONFIG_FILE_PROP, currentConfig);
try {
Files.copy(CONFIG_DIR.resolve(currentConfig), CONFIG_DIR.resolve(PREFIX + currentConfig));
CommandContext ctx = CommandContextFactory.getInstance().newCommandContext();
for (String line : Files.readAllLines(SCRIPT_FILE, Charset.forName("UTF-8"))) {
ctx.handle(line);
}
} finally {
System.clearProperty(CONFIG_FILE_PROP);
}
}
}
| 5,368 | 35.773973 | 139 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/lra/LRAExpressionSupportTestCase.java
|
package org.wildfly.test.manual.microprofile.lra;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.client.ModelControllerClient;
import org.jboss.as.test.integration.management.base.AbstractExpressionSupportTestCase;
import org.junit.Test;
import org.junit.runner.RunWith;
import java.io.IOException;
import static org.jboss.as.controller.operations.common.Util.createAddOperation;
@RunWith(Arquillian.class)
public class LRAExpressionSupportTestCase extends AbstractExpressionSupportTestCase {
private static final String JBOSSAS = "jbossas-custom";
private ManagementClient managementClient;
private void setup(String containerName) throws Exception {
if (!container.isStarted(containerName)) {
container.start(containerName);
}
managementClient = createManagementClient();
ModelControllerClient controllerClient = managementClient.getControllerClient();
controllerClient.execute(createAddOperation(PathAddress.pathAddress("extension", "org.wildfly.extension.microprofile.lra-coordinator")));
controllerClient.execute(createAddOperation(PathAddress.pathAddress("extension", "org.wildfly.extension.microprofile.lra-participant")));
controllerClient.execute(createAddOperation(PathAddress.pathAddress("subsystem", "microprofile-lra-coordinator")));
controllerClient.execute(createAddOperation(PathAddress.pathAddress("subsystem", "microprofile-lra-participant")));
}
private void teardown(String containerName) throws IOException {
container.stop(containerName);
managementClient.close();
}
private void testContainer(String containerName) throws Exception {
try {
setup(containerName);
test(managementClient);
} finally {
teardown(containerName);
}
}
@Test
public void testDefault() throws Exception {
testContainer(JBOSSAS);
}
}
| 2,076 | 38.188679 | 145 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/MicroProfileHealthDefaultEmptyStartupHTTPEndpointTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.jboss.as.arquillian.container.ManagementClient;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
import jakarta.json.JsonValue;
import java.io.IOException;
import java.io.StringReader;
import java.net.ConnectException;
import static org.eclipse.microprofile.health.HealthCheckResponse.Status.DOWN;
import static org.eclipse.microprofile.health.HealthCheckResponse.Status.UP;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author <a href="http://xstefank.io/">Martin Stefanko</a> (c) 2021 Red Hat inc.
*/
public class MicroProfileHealthDefaultEmptyStartupHTTPEndpointTestCase extends MicroProfileHealthDefaultEmptyStartupTestBase {
void checkGlobalOutcome(ManagementClient managementClient, String operation, boolean mustBeUP, String probeName) throws IOException, InvalidHealthResponseException {
assertEquals("check-started", operation);
final String httpEndpoint = "/health/started";
final String healthURL = "http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort() + httpEndpoint;
try (CloseableHttpClient client = HttpClients.createDefault();
CloseableHttpResponse resp = client.execute(new HttpGet(healthURL))) {
final int statusCode = resp.getStatusLine().getStatusCode();
// ignore 404 during the server boot
if (404 == statusCode) {
throw new ConnectException("System boot in process");
}
if (mustBeUP) {
if (200 != statusCode) {
throw new InvalidHealthResponseException(UP, "HTTP status code " + statusCode);
}
} else {
if (503 != statusCode) {
throw new InvalidHealthResponseException(DOWN, "HTTP status code " + statusCode);
}
}
String content = EntityUtils.toString(resp.getEntity());
System.out.println("Health response content: " + content);
try (
JsonReader jsonReader = Json.createReader(new StringReader(content))
) {
JsonObject payload = jsonReader.readObject();
String outcome = payload.getString("status");
assertEquals(mustBeUP ? "UP": "DOWN", outcome);
if (probeName != null) {
for (JsonValue check : payload.getJsonArray("checks")) {
if (probeName.equals(check.asJsonObject().getString("name"))) {
// probe name found
assertEquals(mustBeUP ? "UP" : "DOWN", check.asJsonObject().getString("status"));
return;
}
}
fail("Probe named " + probeName + " not found in " + content);
}
}
}
}
}
| 4,293 | 41.514851 | 169 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/MicroProfileHealthDefaultEmptyStartupOperationTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import java.io.IOException;
import java.net.ConnectException;
import static org.eclipse.microprofile.health.HealthCheckResponse.Status.DOWN;
import static org.eclipse.microprofile.health.HealthCheckResponse.Status.UP;
import static org.jboss.as.controller.operations.common.Util.getEmptyOperation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author <a href="http://xstefank.io/">Martin Stefanko</a> (c) 2021 Red Hat inc.
*/
public class MicroProfileHealthDefaultEmptyStartupOperationTestCase extends MicroProfileHealthDefaultEmptyStartupTestBase {
void checkGlobalOutcome(ManagementClient managementClient, String operation, boolean mustBeUP, String probeName) throws IOException, InvalidHealthResponseException {
final ModelNode address = new ModelNode();
address.add("subsystem", "microprofile-health-smallrye");
ModelNode checkOp = getEmptyOperation(operation, address);
ModelNode response = null;
try {
response = managementClient.getControllerClient().execute(checkOp);
} catch (IllegalStateException | IOException e) {
// management client is not initialized yet
throw new ConnectException(e.getMessage());
}
final String opOutcome = response.get("outcome").asString();
// if system boot in process - WFLYCTL0379
if (opOutcome.equals("failed") && response.get("failure-description").asString().contains("WFLYCTL0379")) {
throw new ConnectException("System boot in process");
}
assertEquals("success", opOutcome);
ModelNode result = response.get("result");
final String status = result.get("status").asString();
if (mustBeUP) {
if (!"UP".equals(status)) {
throw new InvalidHealthResponseException(UP, "CLI status " + status);
}
} else {
if (!"DOWN".equals(status)) {
throw new InvalidHealthResponseException(DOWN, "CLI status " + status);
}
}
if (probeName != null) {
for (ModelNode check : result.get("checks").asList()) {
if (probeName.equals(check.get("name").asString())) {
// probe name found
// global outcome is driven by this probe state
assertEquals(mustBeUP ? "UP" : "DOWN", check.get("status").asString());
return;
}
}
fail("Probe named " + probeName + " not found in " + result);
}
}
}
| 3,768 | 39.967391 | 169 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/MicroProfileHealthDefaultEmptyReadinessHTTPEndpointTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.jboss.as.arquillian.container.ManagementClient;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
import jakarta.json.JsonValue;
import java.io.IOException;
import java.io.StringReader;
import java.net.ConnectException;
import static org.eclipse.microprofile.health.HealthCheckResponse.Status.DOWN;
import static org.eclipse.microprofile.health.HealthCheckResponse.Status.UP;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author <a href="http://xstefank.io/">Martin Stefanko</a> (c) 2021 Red Hat inc.
*/
public class MicroProfileHealthDefaultEmptyReadinessHTTPEndpointTestCase extends MicroProfileHealthDefaultEmptyReadinessTestBase {
void checkGlobalOutcome(ManagementClient managementClient, String operation, boolean mustBeUP, String probeName) throws IOException, InvalidHealthResponseException {
assertEquals("check-ready", operation);
final String httpEndpoint = "/health/ready";
final String healthURL = "http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort() + httpEndpoint;
try (CloseableHttpClient client = HttpClients.createDefault();
CloseableHttpResponse resp = client.execute(new HttpGet(healthURL))) {
final int statusCode = resp.getStatusLine().getStatusCode();
// ignore 404 during the server boot
if (404 == statusCode) {
throw new ConnectException("System boot in process");
}
if (mustBeUP) {
if (200 != statusCode) {
throw new InvalidHealthResponseException(UP, "HTTP status code " + statusCode);
}
} else {
if (503 != statusCode) {
throw new InvalidHealthResponseException(DOWN, "HTTP status code " + statusCode);
}
}
String content = EntityUtils.toString(resp.getEntity());
System.out.println("Health response content: " + content);
try (
JsonReader jsonReader = Json.createReader(new StringReader(content))
) {
JsonObject payload = jsonReader.readObject();
String outcome = payload.getString("status");
assertEquals(mustBeUP ? "UP": "DOWN", outcome);
if (probeName != null) {
for (JsonValue check : payload.getJsonArray("checks")) {
if (probeName.equals(check.asJsonObject().getString("name"))) {
// probe name found
assertEquals(mustBeUP ? "UP" : "DOWN", check.asJsonObject().getString("status"));
return;
}
}
fail("Probe named " + probeName + " not found in " + content);
}
}
}
}
}
| 4,293 | 41.514851 | 169 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/MicroProfileHealthDefaultEmptyReadinessOperationTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import java.io.IOException;
import java.net.ConnectException;
import static org.eclipse.microprofile.health.HealthCheckResponse.Status.DOWN;
import static org.eclipse.microprofile.health.HealthCheckResponse.Status.UP;
import static org.jboss.as.controller.operations.common.Util.getEmptyOperation;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
/**
* @author <a href="http://xstefank.io/">Martin Stefanko</a> (c) 2021 Red Hat inc.
*/
public class MicroProfileHealthDefaultEmptyReadinessOperationTestCase extends MicroProfileHealthDefaultEmptyReadinessTestBase {
void checkGlobalOutcome(ManagementClient managementClient, String operation, boolean mustBeUP, String probeName) throws IOException, InvalidHealthResponseException {
final ModelNode address = new ModelNode();
address.add("subsystem", "microprofile-health-smallrye");
ModelNode checkOp = getEmptyOperation(operation, address);
ModelNode response = null;
try {
response = managementClient.getControllerClient().execute(checkOp);
} catch (IllegalStateException | IOException e) {
// management client is not initialized yet
throw new ConnectException(e.getMessage());
}
final String opOutcome = response.get("outcome").asString();
// if system boot in process - WFLYCTL0379
if (opOutcome.equals("failed") && response.get("failure-description").asString().contains("WFLYCTL0379")) {
throw new ConnectException("System boot in process");
}
assertEquals("success", opOutcome);
ModelNode result = response.get("result");
final String status = result.get("status").asString();
if (mustBeUP) {
if (!"UP".equals(status)) {
throw new InvalidHealthResponseException(UP, "CLI status " + status);
}
} else {
if (!"DOWN".equals(status)) {
throw new InvalidHealthResponseException(DOWN, "CLI status " + status);
}
}
if (probeName != null) {
for (ModelNode check : result.get("checks").asList()) {
if (probeName.equals(check.get("name").asString())) {
// probe name found
// global outcome is driven by this probe state
assertEquals(mustBeUP ? "UP" : "DOWN", check.get("status").asString());
return;
}
}
fail("Probe named " + probeName + " not found in " + result);
}
}
}
| 3,772 | 40.01087 | 169 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/InvalidHealthResponseException.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import org.eclipse.microprofile.health.HealthCheckResponse;
public class InvalidHealthResponseException extends Exception {
public InvalidHealthResponseException(HealthCheckResponse.Status expectedStatus, String receivedStatus) {
super(String.format("Expected %s but received %s", expectedStatus, receivedStatus));
}
}
| 1,414 | 43.21875 | 109 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/SuccessfulReadinessCheck.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Readiness;
@Readiness
public class SuccessfulReadinessCheck implements HealthCheck {
public static final String NAME = "SuccessfulReadinessCheck";
@Override
public HealthCheckResponse call() {
return HealthCheckResponse.up(NAME);
}
}
| 1,490 | 37.230769 | 70 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/SuccessfulStartupCheck.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;
import org.eclipse.microprofile.health.Startup;
@Startup
public class SuccessfulStartupCheck implements HealthCheck {
public static final String NAME = "SuccessfulStartupCheck";
@Override
public HealthCheckResponse call() {
return HealthCheckResponse.up(NAME);
}
}
| 1,482 | 37.025641 | 70 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/MicroProfileHealthDefaultEmptyStartupTestBase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import java.io.IOException;
import java.net.ConnectException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.jboss.arquillian.container.test.api.ContainerController;
import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.test.shared.util.AssumeTestGroupUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test that startup handling with mp.health.disable-default-procedures=true respects the
* value of mp.health.default.startup.empty.response
*/
@RunWith(Arquillian.class)
@RunAsClient
public abstract class MicroProfileHealthDefaultEmptyStartupTestBase {
abstract void checkGlobalOutcome(ManagementClient managementClient, String operation, boolean mustBeUP, String probeName) throws IOException, InvalidHealthResponseException;
public static final String MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_STARTUP_TEST_BASE = "MicroProfileHealthApplicationWithoutStartupTestBase";
public static final String MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_STARTUP_TEST_BASE = "MicroProfileHealthApplicationWithSuccessfulStartupTestBase";
private static final String CONTAINER_NAME = "microprofile";
private static final String DISABLE_DEFAULT_PROCEDURES_PROPERTY = "-Dmp.health.disable-default-procedures=true";
private static final String DEFAULT_STARTUP_EMPTY_RESPONSE_PROPERTY = "-Dmp.health.default.startup.empty.response";
private static final String MICROPROFILE_SERVER_JVM_ARGS = "microprofile.server.jvm.args";
private static final String JAVA_VM_ARGUMENTS = "javaVmArguments";
// deployment does not define any startup probe
@Deployment(name = MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_STARTUP_TEST_BASE, managed = false, testable = false)
@TargetsContainer(CONTAINER_NAME)
public static Archive<?> deployEmpty() {
WebArchive war = ShrinkWrap.create(WebArchive.class, MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_STARTUP_TEST_BASE + ".war")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
return war;
}
// deployment defines one successful startup probe
@Deployment(name = MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_STARTUP_TEST_BASE, managed = false, testable = false)
@TargetsContainer(CONTAINER_NAME)
public static Archive<?> deploySuccessful() {
WebArchive war = ShrinkWrap.create(WebArchive.class, MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_STARTUP_TEST_BASE + ".war")
.addClasses(SuccessfulStartupCheck.class)
.addAsWebInfResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml");
return war;
}
@ContainerResource(CONTAINER_NAME)
ManagementClient managementClient;
@ArquillianResource
private Deployer deployer;
@ArquillianResource
private ContainerController containerController;
@Before
public void check() {
//Assume we are using the full distribution which contains standalone-microprofile.xml
AssumeTestGroupUtil.assumeFullDistribution();
}
@Test
@InSequence(1)
public void testApplicationStartupWithoutDeploymentWithDefaultEmptyStartup() throws Exception {
final CompletableFuture<Void> testResultFuture = CompletableFuture.runAsync(() -> {
boolean connectionEstablished = false;
do {
try {
checkGlobalOutcome(managementClient, "check-started", false, null);
connectionEstablished = true;
} catch (ConnectException ce) {
// OK, server is not started yet
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
} while (!connectionEstablished);
try {
checkGlobalOutcome(managementClient, "check-started", false, null);
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
});
Map<String, String> map = getVMArgMap(DISABLE_DEFAULT_PROCEDURES_PROPERTY);
containerController.start(CONTAINER_NAME, map);
try {
testResultFuture.get(1, TimeUnit.MINUTES);
} finally {
containerController.stop(CONTAINER_NAME);
}
}
@Test
@InSequence(2)
public void testApplicationStartupWithEmptyDeploymentWithDefaultEmptyStartup() throws Exception {
// deploy the application and stop the container
containerController.start(CONTAINER_NAME);
deployer.deploy(MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_STARTUP_TEST_BASE);
containerController.stop(CONTAINER_NAME);
// check that the startup status is changed to UP once the user deployment checks (which there are none
// in this case) are processed
final CompletableFuture<Void> testResultFuture = CompletableFuture.runAsync(() -> {
boolean connectionEstablished = false;
do {
try {
checkGlobalOutcome(managementClient, "check-started", false, null);
connectionEstablished = true;
} catch (ConnectException ce) {
// OK, server is not started yet
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} catch (InvalidHealthResponseException ihre) {
// this might happen if the first call hits already processed user checks (responds UP)
// so continue to check if the rest of the responses is correct
connectionEstablished = true;
}
} while (!connectionEstablished);
boolean userChecksProcessed = false;
do {
try {
checkGlobalOutcome(managementClient, "check-started", false, null);
} catch (InvalidHealthResponseException ihre) {
// OK user checks are processed, check once more that we have an UP empty response
userChecksProcessed = true;
try {
checkGlobalOutcome(managementClient, "check-started", true, null);
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} while (!userChecksProcessed);
});
Map<String, String> map = getVMArgMap(DISABLE_DEFAULT_PROCEDURES_PROPERTY);
containerController.start(CONTAINER_NAME, map);
try {
testResultFuture.get(1, TimeUnit.MINUTES);
} finally {
deployer.undeploy(MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_STARTUP_TEST_BASE);
containerController.stop(CONTAINER_NAME);
}
}
@Test
@InSequence(3)
public void testApplicationStartupWithDeploymentContainingStartupCheckWithDefaultEmptyStartup() throws Exception {
// deploy the application and stop the container
containerController.start(CONTAINER_NAME);
deployer.deploy(MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_STARTUP_TEST_BASE);
containerController.stop(CONTAINER_NAME);
// check that the startup status is changed to UP once the user deployment checks are processed
final CompletableFuture<Void> testResultFuture = CompletableFuture.runAsync(() -> {
boolean connectionEstablished = false;
do {
try {
checkGlobalOutcome(managementClient, "check-started", false, null);
connectionEstablished = true;
} catch (ConnectException ce) {
// OK, server is not started yet
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} catch (InvalidHealthResponseException ihre) {
// this might happen if the first call hits already processed user checks (responds UP)
// so continue to check if the rest of the responses is correct
connectionEstablished = true;
}
} while (!connectionEstablished);
boolean userChecksProcessed = false;
do {
try {
checkGlobalOutcome(managementClient, "check-started", false, null);
} catch (InvalidHealthResponseException ihre) {
// OK user checks are processed, check once more that we have an UP response
userChecksProcessed = true;
try {
checkGlobalOutcome(managementClient, "check-started", true,
SuccessfulStartupCheck.NAME);
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} while (!userChecksProcessed);
});
Map<String, String> map = getVMArgMap(DISABLE_DEFAULT_PROCEDURES_PROPERTY);
containerController.start(CONTAINER_NAME, map);
try {
testResultFuture.get(1, TimeUnit.MINUTES);
} finally {
deployer.undeploy(MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_STARTUP_TEST_BASE);
containerController.stop(CONTAINER_NAME);
}
}
@Test
@InSequence(4)
public void testApplicationStartupWithoutDeploymentWithEmptyStartupSetToUP() throws Exception {
final CompletableFuture<Void> testResultFuture = CompletableFuture.runAsync(() -> {
boolean connectionEstablished = false;
do {
try {
checkGlobalOutcome(managementClient, "check-started", true, null);
connectionEstablished = true;
} catch (ConnectException ce) {
// OK, server is not started yet
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
} while (!connectionEstablished);
try {
checkGlobalOutcome(managementClient, "check-started", true, null);
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
});
Map<String, String> map = getVMArgMap(String.format("%s %s=UP",
DISABLE_DEFAULT_PROCEDURES_PROPERTY, DEFAULT_STARTUP_EMPTY_RESPONSE_PROPERTY));
containerController.start(CONTAINER_NAME, map);
try {
testResultFuture.get(1, TimeUnit.MINUTES);
} finally {
containerController.stop(CONTAINER_NAME);
}
}
private Map<String, String> getVMArgMap(String vmArgs) {
Map<String, String> map = new HashMap<>();
map.put(JAVA_VM_ARGUMENTS, System.getProperty(MICROPROFILE_SERVER_JVM_ARGS) + " " + vmArgs);
return map;
}
}
| 13,167 | 42.03268 | 177 |
java
|
null |
wildfly-main/testsuite/integration/manualmode-expansion/src/test/java/org/wildfly/test/manual/microprofile/health/MicroProfileHealthDefaultEmptyReadinessTestBase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2021, 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.wildfly.test.manual.microprofile.health;
import java.io.IOException;
import java.net.ConnectException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import org.jboss.arquillian.container.test.api.ContainerController;
import org.jboss.arquillian.container.test.api.Deployer;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.container.test.api.TargetsContainer;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.junit.InSequence;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.test.shared.util.AssumeTestGroupUtil;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test that readiness handling with mp.health.disable-default-procedures=true respects the
* value of mp.health.default.readiness.empty.response
*/
@RunWith(Arquillian.class)
@RunAsClient
public abstract class MicroProfileHealthDefaultEmptyReadinessTestBase {
abstract void checkGlobalOutcome(ManagementClient managementClient, String operation, boolean mustBeUP, String probeName) throws IOException, InvalidHealthResponseException;
public static final String MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_READINESS_TEST_BASE = "MicroProfileHealthApplicationWithoutReadinessTestBase";
public static final String MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_READINESS_TEST_BASE = "MicroProfileHealthApplicationWithSuccessfulReadinessTestBase";
private static final String CONTAINER_NAME = "microprofile";
private static final String DISABLE_DEFAULT_PROCEDURES_PROPERTY = "-Dmp.health.disable-default-procedures=true";
private static final String DEFAULT_READINESS_EMPTY_RESPONSE_PROPERTY = "-Dmp.health.default.readiness.empty.response";
private static final String MICROPROFILE_SERVER_JVM_ARGS = "microprofile.server.jvm.args";
private static final String JAVA_VM_ARGUMENTS = "javaVmArguments";
// deployment does not define any readiness probe
@Deployment(name = MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_READINESS_TEST_BASE, managed = false, testable = false)
@TargetsContainer(CONTAINER_NAME)
public static Archive<?> deployEmpty() {
WebArchive war = ShrinkWrap.create(WebArchive.class, MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_READINESS_TEST_BASE + ".war")
.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
return war;
}
// deployment defines one successful readiness probe
@Deployment(name = MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_READINESS_TEST_BASE, managed = false, testable = false)
@TargetsContainer(CONTAINER_NAME)
public static Archive<?> deploySuccessful() {
WebArchive war = ShrinkWrap.create(WebArchive.class, MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_READINESS_TEST_BASE + ".war")
.addClasses(SuccessfulReadinessCheck.class)
.addAsWebInfResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml");
return war;
}
@ContainerResource(CONTAINER_NAME)
ManagementClient managementClient;
@ArquillianResource
private Deployer deployer;
@ArquillianResource
private ContainerController containerController;
@Before
public void check() {
//Assume we are using the full distribution which contains standalone-microprofile.xml
AssumeTestGroupUtil.assumeFullDistribution();
}
@Test
@InSequence(1)
public void testApplicationReadinessWithoutDeploymentWithDefaultEmptyReadiness() throws Exception {
final CompletableFuture<Void> testResultFuture = CompletableFuture.runAsync(() -> {
boolean connectionEstablished = false;
do {
try {
checkGlobalOutcome(managementClient, "check-ready", false, null);
connectionEstablished = true;
} catch (ConnectException ce) {
// OK, server is not started yet
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
} while (!connectionEstablished);
try {
checkGlobalOutcome(managementClient, "check-ready", false, null);
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
});
Map<String, String> map = getVMArgMap(DISABLE_DEFAULT_PROCEDURES_PROPERTY);
containerController.start(CONTAINER_NAME, map);
try {
testResultFuture.get(1, TimeUnit.MINUTES);
} finally {
containerController.stop(CONTAINER_NAME);
}
}
@Test
@InSequence(2)
public void testApplicationReadinessWithEmptyDeploymentWithDefaultEmptyReadiness() throws Exception {
// deploy the application and stop the container
containerController.start(CONTAINER_NAME);
deployer.deploy(MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_READINESS_TEST_BASE);
containerController.stop(CONTAINER_NAME);
// check that the readiness status is changed to UP once the user deployment checks (which there are none
// in this case) are processed
final CompletableFuture<Void> testResultFuture = CompletableFuture.runAsync(() -> {
boolean connectionEstablished = false;
do {
try {
checkGlobalOutcome(managementClient, "check-ready", false, null);
connectionEstablished = true;
} catch (ConnectException ce) {
// OK, server is not started yet
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} catch (InvalidHealthResponseException ihre) {
// this might happen if the first call hits already processed user checks (responds UP)
// so continue to check if the rest of the responses is correct
connectionEstablished = true;
}
} while (!connectionEstablished);
boolean userChecksProcessed = false;
do {
try {
checkGlobalOutcome(managementClient, "check-ready", false, null);
} catch (InvalidHealthResponseException ihre) {
// OK user checks are processed, check once more that we have an UP empty response
userChecksProcessed = true;
try {
checkGlobalOutcome(managementClient, "check-ready", true, null);
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} while (!userChecksProcessed);
});
Map<String, String> map = getVMArgMap(DISABLE_DEFAULT_PROCEDURES_PROPERTY);
containerController.start(CONTAINER_NAME, map);
try {
testResultFuture.get(1, TimeUnit.MINUTES);
} finally {
deployer.undeploy(MICRO_PROFILE_HEALTH_APPLICATION_WITHOUT_READINESS_TEST_BASE);
containerController.stop(CONTAINER_NAME);
}
}
@Test
@InSequence(3)
public void testApplicationReadinessWithDeploymentContainingReadinessCheckWithDefaultEmptyReadiness() throws Exception {
// deploy the application and stop the container
containerController.start(CONTAINER_NAME);
deployer.deploy(MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_READINESS_TEST_BASE);
containerController.stop(CONTAINER_NAME);
// check that the readiness status is changed to UP once the user deployment checks are processed
final CompletableFuture<Void> testResultFuture = CompletableFuture.runAsync(() -> {
boolean connectionEstablished = false;
do {
try {
checkGlobalOutcome(managementClient, "check-ready", false, null);
connectionEstablished = true;
} catch (ConnectException ce) {
// OK, server is not started yet
} catch (IOException ioe) {
throw new RuntimeException(ioe);
} catch (InvalidHealthResponseException ihre) {
// this might happen if the first call hits already processed user checks (responds UP)
// so continue to check if the rest of the responses is correct
connectionEstablished = true;
}
} while (!connectionEstablished);
boolean userChecksProcessed = false;
do {
try {
checkGlobalOutcome(managementClient, "check-ready", false, null);
} catch (InvalidHealthResponseException ihre) {
// OK user checks are processed, check once more that we have an UP response
userChecksProcessed = true;
try {
checkGlobalOutcome(managementClient, "check-ready", true,
SuccessfulReadinessCheck.NAME);
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
} while (!userChecksProcessed);
});
Map<String, String> map = getVMArgMap(DISABLE_DEFAULT_PROCEDURES_PROPERTY);
containerController.start(CONTAINER_NAME, map);
try {
testResultFuture.get(1, TimeUnit.MINUTES);
} finally {
deployer.undeploy(MICRO_PROFILE_HEALTH_APPLICATION_WITH_SUCCESSFUL_READINESS_TEST_BASE);
containerController.stop(CONTAINER_NAME);
}
}
@Test
@InSequence(4)
public void testApplicationReadinessWithoutDeploymentWithEmptyReadinessSetToUP() throws Exception {
final CompletableFuture<Void> testResultFuture = CompletableFuture.runAsync(() -> {
boolean connectionEstablished = false;
do {
try {
checkGlobalOutcome(managementClient, "check-ready", true, null);
connectionEstablished = true;
} catch (ConnectException ce) {
// OK, server is not started yet
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
} while (!connectionEstablished);
try {
checkGlobalOutcome(managementClient, "check-ready", true, null);
} catch (IOException | InvalidHealthResponseException ex) {
throw new RuntimeException(ex);
}
});
Map<String, String> map = getVMArgMap(String.format("%s %s=UP",
DISABLE_DEFAULT_PROCEDURES_PROPERTY, DEFAULT_READINESS_EMPTY_RESPONSE_PROPERTY));
containerController.start(CONTAINER_NAME, map);
try {
testResultFuture.get(1, TimeUnit.MINUTES);
} finally {
containerController.stop(CONTAINER_NAME);
}
}
private Map<String, String> getVMArgMap(String vmArgs) {
Map<String, String> map = new HashMap<>();
map.put(JAVA_VM_ARGUMENTS, System.getProperty(MICROPROFILE_SERVER_JVM_ARGS) + " " + vmArgs);
return map;
}
}
| 13,216 | 42.334426 | 177 |
java
|
null |
wildfly-main/testsuite/integration/microprofile/src/test/java/org/apache/kafka/raft/FileBasedStateStore.java
|
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.kafka.raft;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.EOFException;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.nio.file.StandardOpenOption;
import java.util.List;
import java.util.OptionalInt;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.kafka.common.utils.Utils;
import org.apache.kafka.raft.generated.QuorumStateData;
import org.apache.kafka.raft.generated.QuorumStateData.Voter;
import org.apache.kafka.raft.generated.QuorumStateDataJsonConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.node.ShortNode;
/**
* Applies https://github.com/apache/kafka/commit/f7cc920771735576d9cfba2afe6f26fdcfb2ccd4 to
* https://github.com/apache/kafka/blob/trunk/raft/src/main/java/org/apache/kafka/raft/FileBasedStateStore.java
*
* The fix is needed to be able to boot the embedded Kafka on Windows. The mentioned patch will not be
* included in Kafka upstream, as Windows is not as a supported platform for Kafka.
*
* The aim for us is to make sure that we can connect to a running Kafka from both Linux and Windows.
*
* We might need to update this patch if FileBasedStateStore on Kafka changes in new versions.
* The change needed for Windows is in writeElectionStateToFile():
*
* <pre>
* - try (final FileOutputStream fileOutputStream = new FileOutputStream(temp);
* - final BufferedWriter writer = new BufferedWriter(
* - new OutputStreamWriter(fileOutputStream, StandardCharsets.UTF_8))) {
* + final OpenOption[] options = { StandardOpenOption.WRITE,
* + StandardOpenOption.CREATE_NEW, StandardOpenOption.SPARSE };
* +
* + try (BufferedWriter writer = Files.newBufferedWriter(temp.toPath(), StandardCharsets.UTF_8, options)) {
* short version = state.highestSupportedVersion();
*
* ObjectNode jsonState = (ObjectNode) QuorumStateDataJsonConverter.write(state, version);
* jsonState.set(DATA_VERSION, new ShortNode(version));
* writer.write(jsonState.toString());
* writer.flush();
* - fileOutputStream.getFD().sync();
* + writer.close();
* Utils.atomicMoveWithFallback(temp.toPath(), stateFile.toPath());
* </pre>
*/
public class FileBasedStateStore implements QuorumStateStore {
private static final Logger log = LoggerFactory.getLogger(FileBasedStateStore.class);
private final File stateFile;
static final String DATA_VERSION = "data_version";
public FileBasedStateStore(final File stateFile) {
this.stateFile = stateFile;
}
private QuorumStateData readStateFromFile(File file) {
try (final BufferedReader reader = Files.newBufferedReader(file.toPath())) {
final String line = reader.readLine();
if (line == null) {
throw new EOFException("File ended prematurely.");
}
final ObjectMapper objectMapper = new ObjectMapper();
JsonNode readNode = objectMapper.readTree(line);
if (!(readNode instanceof ObjectNode)) {
throw new IOException("Deserialized node " + readNode +
" is not an object node");
}
final ObjectNode dataObject = (ObjectNode) readNode;
JsonNode dataVersionNode = dataObject.get(DATA_VERSION);
if (dataVersionNode == null) {
throw new IOException("Deserialized node " + readNode +
" does not have " + DATA_VERSION + " field");
}
final short dataVersion = dataVersionNode.shortValue();
return QuorumStateDataJsonConverter.read(dataObject, dataVersion);
} catch (IOException e) {
throw new UncheckedIOException(
String.format("Error while reading the Quorum status from the file %s", file), e);
}
}
/**
* Reads the election state from local file.
*/
@Override
public ElectionState readElectionState() {
if (!stateFile.exists()) {
return null;
}
QuorumStateData data = readStateFromFile(stateFile);
return new ElectionState(data.leaderEpoch(),
data.leaderId() == UNKNOWN_LEADER_ID ? OptionalInt.empty() : OptionalInt.of(data.leaderId()),
data.votedId() == NOT_VOTED ? OptionalInt.empty() : OptionalInt.of(data.votedId()),
data.currentVoters()
.stream().map(Voter::voterId).collect(Collectors.toSet()));
}
@Override
public void writeElectionState(ElectionState latest) {
QuorumStateData data = new QuorumStateData()
.setLeaderEpoch(latest.epoch)
.setVotedId(latest.hasVoted() ? latest.votedId() : NOT_VOTED)
.setLeaderId(latest.hasLeader() ? latest.leaderId() : UNKNOWN_LEADER_ID)
.setCurrentVoters(voters(latest.voters()));
writeElectionStateToFile(stateFile, data);
}
private List<Voter> voters(Set<Integer> votersId) {
return votersId.stream().map(
voterId -> new Voter().setVoterId(voterId)).collect(Collectors.toList());
}
private void writeElectionStateToFile(final File stateFile, QuorumStateData state) {
final File temp = new File(stateFile.getAbsolutePath() + ".tmp");
deleteFileIfExists(temp);
log.trace("Writing tmp quorum state {}", temp.getAbsolutePath());
final OpenOption[] options = { StandardOpenOption.WRITE,
StandardOpenOption.CREATE_NEW, StandardOpenOption.SPARSE };
try (BufferedWriter writer = Files.newBufferedWriter(temp.toPath(), StandardCharsets.UTF_8, options)) {
short version = state.highestSupportedVersion();
ObjectNode jsonState = (ObjectNode) QuorumStateDataJsonConverter.write(state, version);
jsonState.set(DATA_VERSION, new ShortNode(version));
writer.write(jsonState.toString());
writer.flush();
writer.close();
Utils.atomicMoveWithFallback(temp.toPath(), stateFile.toPath());
} catch (IOException e) {
throw new UncheckedIOException(
String.format("Error while writing the Quorum status from the file %s",
stateFile.getAbsolutePath()),
e);
} finally {
// cleanup the temp file when the write finishes (either success or fail).
deleteFileIfExists(temp);
}
}
/**
* Clear state store by deleting the local quorum state file
*/
@Override
public void clear() {
deleteFileIfExists(stateFile);
deleteFileIfExists(new File(stateFile.getAbsolutePath() + ".tmp"));
}
@Override
public String toString() {
return "Quorum state filepath: " + stateFile.getAbsolutePath();
}
private void deleteFileIfExists(File file) {
try {
Files.deleteIfExists(file.toPath());
} catch (IOException e) {
throw new UncheckedIOException(
String.format("Error while deleting file %s", file.getAbsoluteFile()), e);
}
}
}
| 8,427 | 40.517241 | 115 |
java
|
null |
wildfly-main/testsuite/integration/microprofile/src/test/java/org/wildfly/test/integration/observability/micrometer/OpenTelemetryCollectorContainer.java
|
/*
* Copyright 2023 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.wildfly.test.integration.observability.micrometer;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.containers.wait.strategy.WaitAllStrategy;
import org.testcontainers.shaded.com.google.common.collect.Lists;
import org.testcontainers.utility.DockerImageName;
import java.time.Duration;
public class OpenTelemetryCollectorContainer extends GenericContainer<OpenTelemetryCollectorContainer> {
public static final int HTTP_OTLP_PORT = 4318;
public static final int PROMETHEUS_PORT = 49152;
public static final int HEALTH_CHECK_PORT = 13133;
public static final String OTEL_COLLECTOR_CONFIG_YAML = "/etc/otel-collector-config.yaml";
private static final String imageName = "otel/opentelemetry-collector";
private static final String imageVersion = "0.74.0";
private static final int STARTUP_ATTEMPTS = Integer.parseInt(
System.getProperty("testsuite.integration.otelcollector.container.startup.attempts", "5"));
private static final Duration ATTEMPT_DURATION = Duration.parse(
System.getProperty("testsuite.integration.otelcollector.container.attempt.duration", "PT30S"));
private String otlpEndpoint;
private String prometheusUrl;
public OpenTelemetryCollectorContainer() {
super(DockerImageName.parse(imageName + ":" + imageVersion));
setExposedPorts(Lists.newArrayList(HTTP_OTLP_PORT, HEALTH_CHECK_PORT, PROMETHEUS_PORT));
setWaitStrategy(
new WaitAllStrategy()
.withStrategy(Wait.forHttp("/").forPort(HEALTH_CHECK_PORT))
.withStrategy(Wait.forHttp("/metrics").forPort(PROMETHEUS_PORT))
.withStrategy(Wait.forHttp("/v1/metrics").forPort(HTTP_OTLP_PORT).forStatusCode(405))
.withStartupTimeout(ATTEMPT_DURATION)
);
setStartupAttempts(STARTUP_ATTEMPTS);
}
@Override
public OpenTelemetryCollectorContainer withExposedPorts(Integer... ports) {
getExposedPorts().addAll(Lists.newArrayList(ports));
return this;
}
@Override
public void start() {
super.start();
otlpEndpoint = "http://localhost:" + getMappedPort(HTTP_OTLP_PORT) + "/v1/metrics";
prometheusUrl = "http://localhost:" + getMappedPort(PROMETHEUS_PORT) + "/metrics";
}
public String getOtlpEndpoint() {
return otlpEndpoint;
}
public String getPrometheusUrl() {
return prometheusUrl;
}
}
| 3,166 | 41.226667 | 109 |
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.