repo
stringlengths 1
191
⌀ | file
stringlengths 23
351
| code
stringlengths 0
5.32M
| file_length
int64 0
5.32M
| avg_line_length
float64 0
2.9k
| max_line_length
int64 0
288k
| extension_type
stringclasses 1
value |
---|---|---|---|---|---|---|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidConnectionFactory1.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.integration.jca.beanvalidation.ra;
import java.io.Serializable;
import jakarta.resource.Referenceable;
import jakarta.resource.ResourceException;
/**
* Connection factory
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public interface ValidConnectionFactory1 extends Serializable, Referenceable {
/**
* Get connection from factory
*
* @return Connection instance
* @throws jakarta.resource.ResourceException Thrown if a connection can't be obtained
*/
ValidConnection getConnection() throws ResourceException;
}
| 1,638 | 38.02381 | 90 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidConnectionFactoryImpl1.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.integration.jca.beanvalidation.ra;
import javax.naming.NamingException;
import javax.naming.Reference;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionManager;
/**
* Connection factory implementation
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public class ValidConnectionFactoryImpl1 implements ValidConnectionFactory1 {
/**
* The serial version UID
*/
private static final long serialVersionUID = 1L;
/**
* Reference
*/
private Reference reference;
/**
* ManagedConnectionFactory
*/
private ValidManagedConnectionFactory1 mcf;
/**
* ConnectionManager
*/
private ConnectionManager connectionManager;
/**
* Default constructor
*/
public ValidConnectionFactoryImpl1() {
}
/**
* Constructor
*
* @param mcf ManagedConnectionFactory
* @param cxManager ConnectionManager
*/
public ValidConnectionFactoryImpl1(ValidManagedConnectionFactory1 mcf, ConnectionManager cxManager) {
this.mcf = mcf;
this.connectionManager = cxManager;
}
/**
* Get connection from factory
*
* @return Connection instance
* @throws jakarta.resource.ResourceException Thrown if a connection can't be obtained
*/
@Override
public ValidConnection getConnection() throws ResourceException {
return (ValidConnection) 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,068 | 28.228571 | 105 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidAdminObjectImpl1.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.integration.jca.beanvalidation.ra;
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;
import org.hibernate.validator.constraints.NotEmpty;
/**
* Admin object implementation
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public class ValidAdminObjectImpl1 implements ValidAdminObjectInterface1, ResourceAdapterAssociation, Referenceable, Serializable {
/**
* Serial version uid
*/
private static final long serialVersionUID = 1L;
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* Reference
*/
private Reference reference;
/**
* property
*/
@NotEmpty
private String aoProperty;
/**
* Default constructor
*/
public ValidAdminObjectImpl1() {
}
/**
* Set property
*
* @param property The value
*/
public void setAoProperty(String property) {
this.aoProperty = property;
}
/**
* Get property
*
* @return The value
*/
public String getAoProperty() {
return aoProperty;
}
/**
* 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 = 77;
if (aoProperty != null) { result += 13 * result + 11 * aoProperty.hashCode(); } else { result += 13 * result + 11; }
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 ValidAdminObjectImpl1)) { return false; }
ValidAdminObjectImpl1 obj = (ValidAdminObjectImpl1) other;
boolean result = true;
if (result) {
if (aoProperty == null) { result = obj.getAoProperty() == null; } else { result = aoProperty.equals(obj.getAoProperty()); }
}
return result;
}
}
| 4,263 | 26.333333 | 135 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidConnection.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.integration.jca.beanvalidation.ra;
/**
* Connection
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public interface ValidConnection {
/**
* getResourceAdapterProperty
*
* @return String
*/
int getResourceAdapterProperty();
/**
* getManagedConnectionFactoryProperty
*
* @return String
*/
String getManagedConnectionFactoryProperty();
/**
* Close
*/
void close();
}
| 1,532 | 30.285714 | 71 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidManagedConnectionMetaData.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.integration.jca.beanvalidation.ra;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ManagedConnectionMetaData;
/**
* Managed connection metadata
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public class ValidManagedConnectionMetaData implements ManagedConnectionMetaData {
/**
* Default constructor
*/
public ValidManagedConnectionMetaData() {
}
/**
* 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,860 | 33.46988 | 102 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidManagedConnectionFactory.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.integration.jca.beanvalidation.ra;
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;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
/**
* Managed connection factory
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public class ValidManagedConnectionFactory 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
*/
@NotNull
@Size(max = 5)
private String cfProperty;
/**
* Default constructor
*/
public ValidManagedConnectionFactory() {
}
/**
* Set property
*
* @param property The value
*/
public void setCfProperty(String property) {
this.cfProperty = property;
}
/**
* Get property
*
* @return The value
*/
public String getCfProperty() {
return cfProperty;
}
/**
* 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 ValidConnectionFactoryImpl(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 ValidManagedConnection(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 ValidManagedConnection) {
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 (cfProperty != null) { result += 31 * result + 7 * cfProperty.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 ValidManagedConnectionFactory)) { return false; }
ValidManagedConnectionFactory obj = (ValidManagedConnectionFactory) other;
boolean result = true;
if (result) {
if (cfProperty == null) { result = obj.getCfProperty() == null; } else { result = cfProperty.equals(obj.getCfProperty()); }
}
return result;
}
}
| 7,173 | 31.908257 | 135 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidGroup1.java
|
package org.jboss.as.test.integration.jca.beanvalidation.ra;
import jakarta.validation.groups.Default;
public interface ValidGroup1 extends Default {
}
| 155 | 18.5 | 60 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidConnectionImpl1.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.integration.jca.beanvalidation.ra;
/**
* Connection implementation
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public class ValidConnectionImpl1 implements ValidConnection1 {
/**
* ManagedConnection
*/
private ValidManagedConnection1 mc;
/**
* ManagedConnectionFactory
*/
private ValidManagedConnectionFactory1 mcf;
/**
* Default constructor
*
* @param mc ManagedConnection
* @param mcf ManagedConnectionFactory
*/
public ValidConnectionImpl1(ValidManagedConnection1 mc, ValidManagedConnectionFactory1 mcf) {
this.mc = mc;
this.mcf = mcf;
}
/**
* Call getResourceAdapterProperty
*
* @return String
*/
public int getResourceAdapterProperty() {
return ((ValidResourceAdapter) mcf.getResourceAdapter()).getRaProperty();
}
/**
* Call getManagedConnectionFactoryProperty
*
* @return String
*/
public String getManagedConnectionFactoryProperty() {
return mcf.getCfProperty();
}
/**
* Close
*/
public void close() {
mc.closeHandle(this);
}
}
| 2,235 | 28.421053 | 97 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidAdminObjectInterface.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.integration.jca.beanvalidation.ra;
import java.io.Serializable;
import jakarta.resource.Referenceable;
/**
* Admin object
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public interface ValidAdminObjectInterface extends Referenceable, Serializable {
/**
* Set property
*
* @param property The value
*/
void setAoProperty(String property);
/**
* Get property
*
* @return The value
*/
String getAoProperty();
}
| 1,559 | 32.191489 | 80 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidManagedConnection1.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.integration.jca.beanvalidation.ra;
import static org.wildfly.common.Assert.checkNotNullParam;
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;
/**
* Managed connection
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public class ValidManagedConnection1 implements ManagedConnection {
/**
* The logwriter
*/
private PrintWriter logwriter;
/**
* ManagedConnectionFactory
*/
private ValidManagedConnectionFactory1 mcf;
/**
* Listeners
*/
private List<ConnectionEventListener> listeners;
/**
* Connection
*/
private Object connection;
/**
* Default constructor
*
* @param mcf mcf
*/
public ValidManagedConnection1(ValidManagedConnectionFactory1 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 ValidConnectionImpl1(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) {
checkNotNullParam("listener", listener);
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) {
checkNotNullParam("listener", listener);
listeners.remove(listener);
}
/**
* Close handle
*
* @param handle The handle
*/
public void closeHandle(ValidConnection1 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 ValidManagedConnectionMetaData();
}
}
| 7,009 | 34.05 | 124 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidAdminObjectImpl.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.integration.jca.beanvalidation.ra;
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;
import jakarta.validation.constraints.NotEmpty;
/**
* Admin object implementation
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public class ValidAdminObjectImpl implements ValidAdminObjectInterface, ResourceAdapterAssociation, Referenceable, Serializable {
/**
* Serial version uid
*/
private static final long serialVersionUID = 1L;
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* Reference
*/
private Reference reference;
/**
* property
*/
@NotEmpty
private String aoProperty;
/**
* Default constructor
*/
public ValidAdminObjectImpl() {
}
/**
* Set property
*
* @param property The value
*/
public void setAoProperty(String property) {
this.aoProperty = property;
}
/**
* Get property
*
* @return The value
*/
public String getAoProperty() {
return aoProperty;
}
/**
* 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 = 77;
if (aoProperty != null) { result += 13 * result + 11 * aoProperty.hashCode(); } else { result += 13 * result + 11; }
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 ValidAdminObjectImpl)) { return false; }
ValidAdminObjectImpl obj = (ValidAdminObjectImpl) other;
boolean result = true;
if (result) {
if (aoProperty == null) { result = obj.getAoProperty() == null; } else { result = aoProperty.equals(obj.getAoProperty()); }
}
return result;
}
}
| 4,251 | 26.432258 | 135 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidMessageEndpointFactory.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.integration.jca.beanvalidation.ra;
import java.lang.reflect.Method;
import jakarta.resource.spi.endpoint.MessageEndpoint;
import jakarta.resource.spi.endpoint.MessageEndpointFactory;
import javax.transaction.xa.XAResource;
/**
* A simple message endpoint factory
*
* @author <a href="mailto:[email protected]>Vladimir Rastseluev</a>
*/
public class ValidMessageEndpointFactory implements MessageEndpointFactory {
private MessageEndpoint me;
/**
* Constructor
*
* @param me The message endpoint that should be used
*/
public ValidMessageEndpointFactory(MessageEndpoint me) {
this.me = me;
}
/**
* {@inheritDoc}
*/
public MessageEndpoint createEndpoint(XAResource xaResource) {
return me;
}
/**
* {@inheritDoc}
*/
public MessageEndpoint createEndpoint(XAResource xaResource, long timeout) {
return me;
}
/**
* {@inheritDoc}
*/
public boolean isDeliveryTransacted(Method method) {
return false;
}
@Override
public String getActivationName() {
return "activationName";
}
@Override
public Class<?> getEndpointClass() {
return me.getClass();
}
}
| 2,288 | 27.974684 | 80 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/beanvalidation/ra/ValidActivation.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.integration.jca.beanvalidation.ra;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.endpoint.MessageEndpointFactory;
/**
* Activation
*
* @author <a href="mailto:[email protected]">Vladimir Rastseluev</a>
*/
public class ValidActivation {
/**
* The resource adapter
*/
private ValidResourceAdapter ra;
/**
* Activation spec
*/
private ValidActivationSpec spec;
/**
* The message endpoint factory
*/
private MessageEndpointFactory endpointFactory;
/**
* Default constructor
*
* @throws ResourceException Thrown if an error occurs
*/
public ValidActivation() throws ResourceException {
this(null, null, null);
}
/**
* Constructor
*
* @param ra ResourceAdapter
* @param endpointFactory MessageEndpointFactory
* @param spec ActivationSpec
* @throws ResourceException Thrown if an error occurs
*/
public ValidActivation(ValidResourceAdapter ra, MessageEndpointFactory endpointFactory, ValidActivationSpec spec)
throws ResourceException {
this.ra = ra;
this.endpointFactory = endpointFactory;
this.spec = spec;
}
/**
* Get activation spec class
*
* @return Activation spec
*/
public ValidActivationSpec getActivationSpec() {
return spec;
}
/**
* Get message endpoint factory
*
* @return Message endpoint factory
*/
public MessageEndpointFactory getMessageEndpointFactory() {
return endpointFactory;
}
/**
* Start the activation
*
* @throws ResourceException Thrown if an error occurs
*/
public void start() throws ResourceException {
}
/**
* Stop the activation
*/
public void stop() {
}
}
| 2,917 | 26.528302 | 117 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleConnection1.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.integration.jca.rar;
import jakarta.resource.cci.Connection;
/**
* MultipleConnection1
*
* @version $Revision: $
*/
public interface MultipleConnection1 extends Connection {
/**
* test
*
* @param s s
* @return String
*/
String test(String s);
/**
* Close
*/
void close();
}
| 1,390 | 29.911111 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/Multiple2ManagedConnectionMetaData.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.integration.jca.rar;
import org.jboss.logging.Logger;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ManagedConnectionMetaData;
/**
* Multiple2ManagedConnectionMetaData
*
* @version $Revision: $
*/
public class Multiple2ManagedConnectionMetaData implements ManagedConnectionMetaData {
/**
* The logger
*/
private static Logger log = Logger.getLogger("Multiple2ManagedConnectionMetaData");
/**
* Default constructor
*/
public Multiple2ManagedConnectionMetaData() {
}
/**
* 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 {
log.trace("getEISProductName()");
return null; //TODO
}
/**
* 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 {
log.trace("getEISProductVersion()");
return null; //TODO
}
/**
* 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 {
log.trace("getMaxConnections()");
return 0; //TODO
}
/**
* 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 {
log.trace("getUserName()");
return null; //TODO
}
}
| 3,098 | 31.28125 | 102 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleAdminObject2Impl.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.integration.jca.rar;
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;
/**
* MultipleAdminObject2Impl
*
* @version $Revision: $
*/
public class MultipleAdminObject2Impl implements MultipleAdminObject2,
ResourceAdapterAssociation, Referenceable, Serializable {
/**
* Serial version uid
*/
private static final long serialVersionUID = 1L;
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* Reference
*/
private Reference reference;
/**
* Name
*/
private String name;
/**
* Default constructor
*/
public MultipleAdminObject2Impl() {
}
/**
* Set name
*
* @param name The value
*/
public void setName(String name) {
this.name = name;
}
/**
* Get name
*
* @return The value
*/
public String getName() {
return name;
}
/**
* 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 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 (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 MultipleAdminObject2Impl)) { return false; }
MultipleAdminObject2Impl obj = (MultipleAdminObject2Impl) other;
boolean result = true;
if (result) {
if (name == null) { result = obj.getName() == null; } else { result = name.equals(obj.getName()); }
}
return result;
}
}
| 4,044 | 25.096774 | 111 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleConnectionFactory2Impl.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.integration.jca.rar;
import org.jboss.logging.Logger;
import javax.naming.NamingException;
import javax.naming.Reference;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionManager;
/**
* MultipleConnectionFactory2Impl
*
* @version $Revision: $
*/
public class MultipleConnectionFactory2Impl implements MultipleConnectionFactory2 {
/**
* The serial version UID
*/
private static final long serialVersionUID = 1L;
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleConnectionFactory2Impl");
/**
* Reference
*/
private Reference reference;
/**
* ManagedConnectionFactory
*/
private MultipleManagedConnectionFactory2 mcf;
/**
* ConnectionManager
*/
private ConnectionManager connectionManager;
/**
* Default constructor
*/
public MultipleConnectionFactory2Impl() {
}
/**
* Default constructor
*
* @param mcf ManagedConnectionFactory
* @param cxManager ConnectionManager
*/
public MultipleConnectionFactory2Impl(MultipleManagedConnectionFactory2 mcf, ConnectionManager cxManager) {
this.mcf = mcf;
this.connectionManager = cxManager;
}
/**
* Get connection from factory
*
* @return MultipleConnection2 instance
* @throws ResourceException Thrown if a connection can't be obtained
*/
@Override
public MultipleConnection2 getConnection() throws ResourceException {
log.trace("getConnection()");
return (MultipleConnection2) connectionManager.allocateConnection(mcf, null);
}
/**
* Get the Reference instance.
*
* @return Reference instance
* @throws NamingException Thrown if a reference can't be obtained
*/
@Override
public Reference getReference() throws NamingException {
log.trace("getReference()");
return reference;
}
/**
* Set the Reference instance.
*
* @param reference A Reference instance
*/
@Override
public void setReference(Reference reference) {
log.trace("setReference()");
this.reference = reference;
}
}
| 3,283 | 27.310345 | 111 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleManagedConnection2.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.integration.jca.rar;
import static org.wildfly.common.Assert.checkNotNullParam;
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.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;
/**
* MultipleManagedConnection2
*
* @version $Revision: $
*/
public class MultipleManagedConnection2 implements ManagedConnection {
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleManagedConnection2");
/**
* The logwriter
*/
private PrintWriter logwriter;
/**
* ManagedConnectionFactory
*/
private MultipleManagedConnectionFactory2 mcf;
/**
* Listeners
*/
private List<ConnectionEventListener> listeners;
/**
* Connection
*/
private Object connection;
/**
* Default constructor
*
* @param mcf mcf
*/
public MultipleManagedConnection2(MultipleManagedConnectionFactory2 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 {
log.trace("getConnection()");
connection = new MultipleConnection2Impl(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 ResourceException generic exception if operation fails
*/
public void associateConnection(Object connection) throws ResourceException {
log.trace("associateConnection()");
}
/**
* 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 {
log.trace("cleanup()");
}
/**
* Destroys the physical connection to the underlying resource manager.
*
* @throws ResourceException generic exception if operation fails
*/
public void destroy() throws ResourceException {
log.trace("destroy()");
}
/**
* Adds a connection event listener to the ManagedConnection instance.
*
* @param listener A new ConnectionEventListener to be registered
*/
public void addConnectionEventListener(ConnectionEventListener listener) {
log.trace("addConnectionEventListener()");
checkNotNullParam("listener", listener);
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) {
log.trace("removeConnectionEventListener()");
checkNotNullParam("listener", listener);
listeners.remove(listener);
}
/**
* Close handle
*
* @param handle The handle
*/
public void closeHandle(MultipleConnection2 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 ResourceException generic exception if operation fails
*/
public PrintWriter getLogWriter() throws ResourceException {
log.trace("getLogWriter()");
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 {
log.trace("setLogWriter()");
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 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 {
log.trace("getMetaData()");
return new Multiple2ManagedConnectionMetaData();
}
}
| 7,377 | 32.384615 | 100 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleActivationSpec.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.integration.jca.rar;
import jakarta.resource.spi.ActivationSpec;
import jakarta.resource.spi.InvalidPropertyException;
import jakarta.resource.spi.ResourceAdapter;
import org.jboss.logging.Logger;
/**
* MultipleActivationSpec
*
* @version $Revision: $
*/
public class MultipleActivationSpec implements ActivationSpec {
/**
* The logger
*/
private static Logger log = Logger.getLogger(MultipleActivationSpec.class);
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* Default constructor
*/
public MultipleActivationSpec() {
}
/**
* This method may be called by a deployment tool to validate the overall
* activation configuration information provided by the endpoint deployer.
*
* @throws InvalidPropertyException indicates invalid onfiguration property settings.
*/
public void validate() throws InvalidPropertyException {
log.trace("validate()");
}
/**
* Get the resource adapter
*
* @return The handle
*/
public ResourceAdapter getResourceAdapter() {
log.trace("getResourceAdapter()");
return ra;
}
/**
* Set the resource adapter
*
* @param ra The handle
*/
public void setResourceAdapter(ResourceAdapter ra) {
log.trace("setResourceAdapter()");
this.ra = ra;
}
}
| 2,449 | 28.518072 | 89 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleConnectionFactory1.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.integration.jca.rar;
import java.io.Serializable;
import jakarta.resource.Referenceable;
import jakarta.resource.ResourceException;
import jakarta.resource.cci.Connection;
import jakarta.resource.cci.ConnectionFactory;
/**
* MultipleConnectionFactory1
*
* @version $Revision: $
*/
public interface MultipleConnectionFactory1 extends Serializable, Referenceable, ConnectionFactory {
/**
* Get connection from factory
*
* @return MultipleConnection1 instance
* @throws ResourceException Thrown if a connection can't be obtained
*/
Connection getConnection() throws ResourceException;
}
| 1,682 | 36.4 | 100 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleConnection2.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.integration.jca.rar;
/**
* MultipleConnection2
*
* @version $Revision: $
*/
public interface MultipleConnection2 {
/**
* test
*
* @param s s
* @return String
*/
String test(String s);
/**
* Close
*/
void close();
}
| 1,330 | 29.953488 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleManagedConnectionFactoryWithSubjectVerification.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.rar;
import java.security.Principal;
import java.util.Set;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ConnectionRequestInfo;
import jakarta.resource.spi.ManagedConnection;
import jakarta.resource.spi.security.PasswordCredential;
import javax.security.auth.Subject;
import org.jboss.logging.Logger;
import org.wildfly.security.auth.principal.NamePrincipal;
public class MultipleManagedConnectionFactoryWithSubjectVerification extends MultipleManagedConnectionFactory1 {
private static Logger log = Logger.getLogger(MultipleManagedConnectionFactoryWithSubjectVerification.class.getName());
@Override
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
log.trace("createManagedConnection()");
Set<Principal> principals = subject.getPrincipals();
if (!principals.contains(new NamePrincipal("sa"))) {
throw new ResourceException("Subject should contain principal with username 'sa'");
}
Set<Object> privateCredentials = subject.getPrivateCredentials();
if (!privateCredentials.contains(new PasswordCredential("sa", "sa".toCharArray()))) {
throw new ResourceException("Subject should contain private credential with password 'sa'");
}
return new MultipleManagedConnection1(this);
}
}
| 2,462 | 42.210526 | 133 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleRaMetaData.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.integration.jca.rar;
import jakarta.resource.cci.ResourceAdapterMetaData;
/**
* MultipleRaMetaData
*
* @version $Revision: $
*/
public class MultipleRaMetaData implements ResourceAdapterMetaData {
/**
* Default constructor
*/
public MultipleRaMetaData() {
}
/**
* Gets the version of the resource adapter.
*
* @return String representing version of the resource adapter
*/
@Override
public String getAdapterVersion() {
return null; //TODO
}
/**
* Gets the name of the vendor that has provided the resource adapter.
*
* @return String representing name of the vendor
*/
@Override
public String getAdapterVendorName() {
return null; //TODO
}
/**
* Gets a tool displayable name of the resource adapter.
*
* @return String representing the name of the resource adapter
*/
@Override
public String getAdapterName() {
return null; //TODO
}
/**
* Gets a tool displayable short desription of the resource adapter.
*
* @return String describing the resource adapter
*/
@Override
public String getAdapterShortDescription() {
return null; //TODO
}
/**
* Returns a string representation of the version
*
* @return String representing the supported version of the connector architecture
*/
@Override
public String getSpecVersion() {
return null; //TODO
}
/**
* Returns an array of fully-qualified names of InteractionSpec
*
* @return Array of fully-qualified class names of InteractionSpec classes
*/
@Override
public String[] getInteractionSpecsSupported() {
return null; //TODO
}
/**
* Returns true if the implementation class for the Interaction
*
* @return boolean Depending on method support
*/
@Override
public boolean supportsExecuteWithInputAndOutputRecord() {
return false; //TODO
}
/**
* Returns true if the implementation class for the Interaction
*
* @return boolean Depending on method support
*/
@Override
public boolean supportsExecuteWithInputRecordOnly() {
return false; //TODO
}
/**
* Returns true if the resource adapter implements the LocalTransaction
*
* @return true If resource adapter supports resource manager local transaction demarcation
*/
@Override
public boolean supportsLocalTransactionDemarcation() {
return false; //TODO
}
}
| 3,638 | 26.778626 | 95 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleErrorResourceAdapter.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.integration.jca.rar;
import java.io.Serializable;
import org.jboss.logging.Logger;
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;
/**
* MultipleResourceAdapter
*
* @version $Revision: $
*/
public class MultipleErrorResourceAdapter implements ResourceAdapter, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleResourceAdapter");
/**
* Name
*/
private String name;
/**
* Default constructor
*/
public MultipleErrorResourceAdapter() {
}
/**
* 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 {
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) {
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;
}
// equals and hashCode intentionally omitted to trigger validation error
}
| 4,086 | 29.5 | 122 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleManagedConnection1.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.integration.jca.rar;
import static org.wildfly.common.Assert.checkNotNullParam;
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.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;
/**
* MultipleManagedConnection1
*
* @version $Revision: $
*/
public class MultipleManagedConnection1 implements ManagedConnection {
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleManagedConnection1");
/**
* The logwriter
*/
private PrintWriter logwriter;
/**
* ManagedConnectionFactory
*/
private MultipleManagedConnectionFactory1 mcf;
/**
* Listeners
*/
private List<ConnectionEventListener> listeners;
/**
* Connection
*/
private Object connection;
/**
* Default constructor
*
* @param mcf mcf
*/
public MultipleManagedConnection1(MultipleManagedConnectionFactory1 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 {
log.trace("getConnection()");
connection = new MultipleConnection1Impl(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 ResourceException generic exception if operation fails
*/
public void associateConnection(Object connection) throws ResourceException {
log.trace("associateConnection()");
}
/**
* 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{
log.trace("cleanup()");
}
/**
* Destroys the physical connection to the underlying resource manager.
*
* @throws ResourceException generic exception if operation fails
*/
public void destroy() throws ResourceException {
log.trace("destroy()");
}
/**
* Adds a connection event listener to the ManagedConnection instance.
*
* @param listener A new ConnectionEventListener to be registered
*/
public void addConnectionEventListener(ConnectionEventListener listener) {
log.trace("addConnectionEventListener()");
checkNotNullParam("listener", listener);
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) {
log.trace("removeConnectionEventListener()");
checkNotNullParam("listener", listener);
listeners.remove(listener);
}
/**
* Close handle
*
* @param handle The handle
*/
public void closeHandle(MultipleConnection1 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 ResourceException generic exception if operation fails
*/
public PrintWriter getLogWriter() throws ResourceException {
log.trace("getLogWriter()");
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 {
log.trace("setLogWriter()");
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 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 {
log.trace("getMetaData()");
return new MultipleManagedConnectionMetaData();
}
}
| 7,375 | 32.375566 | 100 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleConnection2Impl.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.integration.jca.rar;
import org.jboss.logging.Logger;
/**
* MultipleConnection2Impl
*
* @version $Revision: $
*/
public class MultipleConnection2Impl implements MultipleConnection2 {
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleConnection2Impl");
/**
* ManagedConnection
*/
private MultipleManagedConnection2 mc;
/**
* ManagedConnectionFactory
*/
private MultipleManagedConnectionFactory2 mcf;
/**
* Default constructor
*
* @param mc MultipleManagedConnection2
* @param mcf MultipleManagedConnectionFactory2
*/
public MultipleConnection2Impl(MultipleManagedConnection2 mc, MultipleManagedConnectionFactory2 mcf) {
this.mc = mc;
this.mcf = mcf;
}
/**
* Call test
*
* @param s String
* @return String
*/
public String test(String s) {
log.trace("test()");
return null;
}
/**
* Close
*/
public void close() {
mc.closeHandle(this);
}
}
| 2,123 | 26.230769 | 106 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleWarningResourceAdapter.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.integration.jca.rar;
import java.io.Serializable;
import org.jboss.logging.Logger;
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;
/**
* MultipleResourceAdapter
*
* @version $Revision: $
*/
public class MultipleWarningResourceAdapter implements ResourceAdapter, Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleResourceAdapter");
/**
* Name
*/
private int name;
/**
* Default constructor
*/
public MultipleWarningResourceAdapter() {
}
/**
* Set name
*
* @param name The value
*/
public void setName(int name) {
this.name = name;
}
/**
* Get name
*
* @return The value
*/
public int 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 {
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) {
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;
result += 31 * result + 7 * name;
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 MultipleWarningResourceAdapter)) { return false; }
MultipleWarningResourceAdapter obj = (MultipleWarningResourceAdapter) other;
boolean result = true;
if (result) {
result = obj.getName() == name;
}
return result;
}
}
| 4,954 | 28.670659 | 122 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleAdminObject1Impl.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.integration.jca.rar;
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;
/**
* MultipleAdminObject1Impl
*
* @version $Revision: $
*/
public class MultipleAdminObject1Impl implements MultipleAdminObject1,
ResourceAdapterAssociation, Referenceable, Serializable {
/**
* Serial version uid
*/
private static final long serialVersionUID = 1L;
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* Reference
*/
private Reference reference;
/**
* Name
*/
private String name;
/**
* Default constructor
*/
public MultipleAdminObject1Impl() {
setName("AO");
}
/**
* Set name
*
* @param name The value
*/
public void setName(String name) {
this.name = name;
}
/**
* Get name
*
* @return The value
*/
public String getName() {
return name;
}
/**
* 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 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 (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 MultipleAdminObject1Impl)) { return false; }
MultipleAdminObject1Impl obj = (MultipleAdminObject1Impl) other;
boolean result = true;
if (result) {
if (name == null) { result = obj.getName() == null; } else { result = name.equals(obj.getName()); }
}
return result;
}
@Override
public String toString() {
return this.getClass().toString() + "name=" + name;
}
}
| 4,176 | 25.436709 | 111 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleResourceAdapter2.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.integration.jca.rar;
import org.jboss.logging.Logger;
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 jakarta.resource.spi.work.Work;
import jakarta.resource.spi.work.WorkManager;
import javax.transaction.xa.XAResource;
import org.jboss.as.connector.services.bootstrap.NamedBootstrapContext;
import org.jboss.as.connector.services.workmanager.NamedWorkManager;
/**
* MultipleResourceAdapter2
*/
public class MultipleResourceAdapter2 implements ResourceAdapter {
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleResourceAdapter2");
/**
* Name
*/
private String name;
private String bootstrapContextName = "undefined";
public void setBootstrapContextName(String bootstrapContextName) {
this.bootstrapContextName = bootstrapContextName;
}
public void setWorkManagerName(String workManagerName) {
this.workManagerName = workManagerName;
}
private String workManagerName = "undefined";
/**
* Default constructor
*/
public MultipleResourceAdapter2() {
}
/**
* Set name
*
* @param name The value
*/
public void setName(String name) {
this.name = name;
}
/**
* Get name
*
* @return The value
*/
public String getName() {
return name;
}
public String getBootstrapContextName() {
return bootstrapContextName;
}
public String getWorkManagerName() {
return workManagerName;
}
/**
* 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 {
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) {
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()");
if (ctx instanceof NamedBootstrapContext) {
NamedBootstrapContext nc = (NamedBootstrapContext) ctx;
setBootstrapContextName(nc.getName());
log.trace("Bootstrap-context:" + nc.getName());
}
WorkManager wm = ctx.getWorkManager();
if (wm instanceof NamedWorkManager) {
NamedWorkManager nw = (NamedWorkManager) wm;
setWorkManagerName(nw.getName());
log.trace("Work-manager:" + nw.getName());
}
Work myWork1 = new MultipleWork();
Work myWork2 = new MultipleWork();
Work myWork3 = new MultipleWork();
try {
wm.doWork(myWork1);
wm.scheduleWork(myWork2);
wm.startWork(myWork3);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 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;
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 MultipleResourceAdapter2)) { return false; }
MultipleResourceAdapter2 obj = (MultipleResourceAdapter2) other;
boolean result = true;
if (result) {
if (name == null) { result = obj.getName() == null; } else { result = name.equals(obj.getName()); }
}
return result;
}
}
| 6,505 | 30.736585 | 122 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleAdminObject2.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.integration.jca.rar;
import java.io.Serializable;
import jakarta.resource.Referenceable;
/**
* MultipleAdminObject2
*
* @version $Revision: $
*/
public interface MultipleAdminObject2 extends Referenceable, Serializable {
/**
* Set name
*
* @param name The value
*/
void setName(String name);
/**
* Get name
*
* @return The value
*/
String getName();
}
| 1,476 | 28.54 | 75 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleConnectionFactory1Impl.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.integration.jca.rar;
import org.jboss.logging.Logger;
import javax.naming.NamingException;
import javax.naming.Reference;
import jakarta.resource.ResourceException;
import jakarta.resource.cci.Connection;
import jakarta.resource.cci.ConnectionSpec;
import jakarta.resource.cci.RecordFactory;
import jakarta.resource.cci.ResourceAdapterMetaData;
import jakarta.resource.spi.ConnectionManager;
/**
* MultipleConnectionFactory1Impl
*
* @version $Revision: $
*/
public class MultipleConnectionFactory1Impl implements
MultipleConnectionFactory1 {
/**
* The serial version UID
*/
private static final long serialVersionUID = 1L;
/**
* The logger
*/
private static Logger log = Logger
.getLogger("MultipleConnectionFactory1Impl");
/**
* Reference
*/
private Reference reference;
/**
* ManagedConnectionFactory
*/
private MultipleManagedConnectionFactory1 mcf;
/**
* ConnectionManager
*/
private ConnectionManager connectionManager;
/**
* Default constructor
*/
public MultipleConnectionFactory1Impl() {
}
/**
* Default constructor
*
* @param mcf ManagedConnectionFactory
* @param cxManager ConnectionManager
*/
public MultipleConnectionFactory1Impl(
MultipleManagedConnectionFactory1 mcf, ConnectionManager cxManager) {
this.mcf = mcf;
this.connectionManager = cxManager;
}
/**
* Get connection from factory
*
* @return MultipleConnection1 instance
* @throws ResourceException Thrown if a connection can't be obtained
*/
@Override
public Connection getConnection() throws ResourceException {
log.trace("getConnection()");
return (MultipleConnection1) connectionManager.allocateConnection(mcf,
null);
}
/**
* Get the Reference instance.
*
* @return Reference instance
* @throws NamingException Thrown if a reference can't be obtained
*/
@Override
public Reference getReference() throws NamingException {
log.trace("getReference()");
return reference;
}
/**
* Set the Reference instance.
*
* @param reference A Reference instance
*/
@Override
public void setReference(Reference reference) {
log.trace("setReference()");
this.reference = reference;
}
@Override
public Connection getConnection(ConnectionSpec arg0)
throws ResourceException {
// TODO Auto-generated method stub
return null;
}
@Override
public ResourceAdapterMetaData getMetaData() throws ResourceException {
// TODO Auto-generated method stub
return null;
}
@Override
public RecordFactory getRecordFactory() throws ResourceException {
// TODO Auto-generated method stub
return null;
}
@Override
public String toString() {
return this.getClass().toString() + mcf.toString();
}
}
| 4,113 | 26.986395 | 81 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleManagedConnectionFactory2.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.integration.jca.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.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;
/**
* MultipleManagedConnectionFactory2
*
* @version $Revision: $
*/
public class MultipleManagedConnectionFactory2 implements ManagedConnectionFactory, ResourceAdapterAssociation {
/**
* The serial version UID
*/
private static final long serialVersionUID = 1L;
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleManagedConnectionFactory2");
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* The logwriter
*/
private PrintWriter logwriter;
/**
* Name
*/
private String name;
/**
* Default constructor
*/
public MultipleManagedConnectionFactory2() {
}
/**
* Set name
*
* @param name The value
*/
public void setName(String name) {
this.name = name;
}
/**
* Get name
*
* @return The value
*/
public String getName() {
return name;
}
/**
* 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 {
log.trace("createConnectionFactory()");
return new MultipleConnectionFactory2Impl(this, cxManager);
}
/**
* 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 {
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 ResourceException generic exception
*/
public ManagedConnection createManagedConnection(Subject subject,
ConnectionRequestInfo cxRequestInfo) throws ResourceException {
log.trace("createManagedConnection()");
return new MultipleManagedConnection2(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 ResourceException generic exception
*/
public ManagedConnection matchManagedConnections(Set connectionSet,
Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
log.trace("matchManagedConnections()");
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof MultipleManagedConnection2) {
result = mc;
}
}
return result;
}
/**
* Get the log writer for this ManagedConnectionFactory instance.
*
* @return PrintWriter
* @throws ResourceException generic exception
*/
public PrintWriter getLogWriter() throws ResourceException {
log.trace("getLogWriter()");
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 {
log.trace("setLogWriter()");
logwriter = out;
}
/**
* Get the resource adapter
*
* @return The handle
*/
public ResourceAdapter getResourceAdapter() {
log.trace("getResourceAdapter()");
return ra;
}
/**
* Set the resource adapter
*
* @param ra The handle
*/
public void setResourceAdapter(ResourceAdapter ra) {
log.trace("setResourceAdapter()");
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 (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 MultipleManagedConnectionFactory2)) { return false; }
MultipleManagedConnectionFactory2 obj = (MultipleManagedConnectionFactory2) other;
boolean result = true;
if (result) {
if (name == null) { result = obj.getName() == null; } else { result = name.equals(obj.getName()); }
}
return result;
}
}
| 7,379 | 31.227074 | 133 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleWork.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.integration.jca.rar;
import org.jboss.logging.Logger;
import jakarta.resource.spi.work.Work;
public class MultipleWork implements Work {
private static Logger log = Logger.getLogger("MultipleWork");
@Override
public void run() {
log.trace("Work is started");
}
@Override
public void release() {
log.trace("Work is done");
}
}
| 1,437 | 30.955556 | 70 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleResourceAdapter3.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.integration.jca.rar;
import org.jboss.logging.Logger;
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 jakarta.resource.spi.work.WorkManager;
import javax.transaction.xa.XAResource;
import org.jboss.as.connector.services.workmanager.NamedWorkManager;
/**
* MultipleResourceAdapter3
*/
public class MultipleResourceAdapter3 implements ResourceAdapter {
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleResourceAdapter3");
/**
* Default constructor
*/
public MultipleResourceAdapter3() {
}
/**
* Work manager
*/
private NamedWorkManager workManager;
/**
* set WM
*
* @param workManagerName
*/
public void setWorkManager(NamedWorkManager workManagerName) {
this.workManager = workManagerName;
}
/**
* get WM
*
* @return workManager
*/
public NamedWorkManager getWorkManager() {
return workManager;
}
/**
* 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 {
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) {
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()");
WorkManager wm = ctx.getWorkManager();
if (wm instanceof NamedWorkManager) {
NamedWorkManager nw = (NamedWorkManager) wm;
setWorkManager(nw);
log.trace("Work-manager:" + nw);
}
}
/**
* 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 MultipleResourceAdapter3)) { return false; }
MultipleResourceAdapter3 obj = (MultipleResourceAdapter3) other;
boolean result = true;
if (result) {
if (workManager == null) { result = obj.getWorkManager() == null; } else { result = workManager.equals(obj.getWorkManager()); }
}
return result;
}
}
| 5,288 | 30.670659 | 139 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleConnection1Impl.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.integration.jca.rar;
import org.jboss.logging.Logger;
import jakarta.resource.ResourceException;
import jakarta.resource.cci.ConnectionMetaData;
import jakarta.resource.cci.Interaction;
import jakarta.resource.cci.LocalTransaction;
import jakarta.resource.cci.ResultSetInfo;
/**
* MultipleConnection1Impl
*
* @version $Revision: $
*/
public class MultipleConnection1Impl implements MultipleConnection1 {
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleConnection1Impl");
/**
* ManagedConnection
*/
private MultipleManagedConnection1 mc;
/**
* ManagedConnectionFactory
*/
private MultipleManagedConnectionFactory1 mcf;
/**
* Default constructor
*
* @param mc MultipleManagedConnection1
* @param mcf MultipleManagedConnectionFactory1
*/
public MultipleConnection1Impl(MultipleManagedConnection1 mc,
MultipleManagedConnectionFactory1 mcf) {
this.mc = mc;
this.mcf = mcf;
}
/**
* Call test
*
* @param s String
* @return String
*/
public String test(String s) {
log.trace("test()");
return null;
}
/**
* Close
*/
public void close() {
mc.closeHandle(this);
}
@Override
public Interaction createInteraction() throws ResourceException {
// TODO Auto-generated method stub
return null;
}
@Override
public LocalTransaction getLocalTransaction() throws ResourceException {
// TODO Auto-generated method stub
return null;
}
@Override
public ConnectionMetaData getMetaData() throws ResourceException {
// TODO Auto-generated method stub
return null;
}
@Override
public ResultSetInfo getResultSetInfo() throws ResourceException {
// TODO Auto-generated method stub
return null;
}
}
| 3,008 | 26.861111 | 76 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleManagedConnectionMetaData.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.integration.jca.rar;
import org.jboss.logging.Logger;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ManagedConnectionMetaData;
/**
* MultipleManagedConnectionMetaData
*
* @version $Revision: $
*/
public class MultipleManagedConnectionMetaData implements ManagedConnectionMetaData {
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleManagedConnectionMetaData");
/**
* Default constructor
*/
public MultipleManagedConnectionMetaData() {
}
/**
* 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 {
log.trace("getEISProductName()");
return null; //TODO
}
/**
* 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 {
log.trace("getEISProductVersion()");
return null; //TODO
}
/**
* 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 {
log.trace("getMaxConnections()");
return 0; //TODO
}
/**
* 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 {
log.trace("getUserName()");
return null; //TODO
}
}
| 3,094 | 31.239583 | 102 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleManagedConnectionFactory1.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.integration.jca.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.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;
/**
* MultipleManagedConnectionFactory1
*
* @version $Revision: $
*/
public class MultipleManagedConnectionFactory1 implements ManagedConnectionFactory, ResourceAdapterAssociation {
/**
* The serial version UID
*/
private static final long serialVersionUID = 1L;
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleManagedConnectionFactory1");
/**
* The resource adapter
*/
private ResourceAdapter ra;
/**
* The logwriter
*/
private PrintWriter logwriter;
/**
* Name
*/
private String name;
/**
* Default constructor
*/
public MultipleManagedConnectionFactory1() {
setName("MCF");
}
/**
* Set name
*
* @param name The value
*/
public void setName(String name) {
this.name = name;
}
/**
* Get name
*
* @return The value
*/
public String getName() {
return name;
}
/**
* 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 {
log.trace("createConnectionFactory()");
return new MultipleConnectionFactory1Impl(this, cxManager);
}
/**
* 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 {
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 ResourceException generic exception
*/
public ManagedConnection createManagedConnection(Subject subject,
ConnectionRequestInfo cxRequestInfo) throws ResourceException {
log.trace("createManagedConnection()");
return new MultipleManagedConnection1(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 ResourceException generic exception
*/
public ManagedConnection matchManagedConnections(Set connectionSet,
Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
log.trace("matchManagedConnections()");
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof MultipleManagedConnection1) {
result = mc;
}
}
return result;
}
/**
* Get the log writer for this ManagedConnectionFactory instance.
*
* @return PrintWriter
* @throws ResourceException generic exception
*/
public PrintWriter getLogWriter() throws ResourceException {
log.trace("getLogWriter()");
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 {
log.trace("setLogWriter()");
logwriter = out;
}
/**
* Get the resource adapter
*
* @return The handle
*/
public ResourceAdapter getResourceAdapter() {
log.trace("getResourceAdapter()");
return ra;
}
/**
* Set the resource adapter
*
* @param ra The handle
*/
public void setResourceAdapter(ResourceAdapter ra) {
log.trace("setResourceAdapter()");
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 (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 MultipleManagedConnectionFactory1)) { return false; }
MultipleManagedConnectionFactory1 obj = (MultipleManagedConnectionFactory1) other;
boolean result = true;
if (result) {
if (name == null) { result = obj.getName() == null; } else { result = name.equals(obj.getName()); }
}
return result;
}
@Override
public String toString() {
return this.getClass().toString() + "name=" + name + ra.toString();
}
}
| 7,529 | 31.317597 | 133 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleAdminObject1.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.integration.jca.rar;
import java.io.Serializable;
import jakarta.resource.Referenceable;
/**
* MultipleAdminObject1
*
* @version $Revision: $
*/
public interface MultipleAdminObject1 extends Referenceable, Serializable {
/**
* Set name
*
* @param name The value
*/
void setName(String name);
/**
* Get name
*
* @return The value
*/
String getName();
}
| 1,476 | 28.54 | 75 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleResourceAdapter.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.integration.jca.rar;
import java.io.Serializable;
import org.jboss.logging.Logger;
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 jakarta.resource.spi.work.WorkManager;
import javax.transaction.xa.XAResource;
/**
* MultipleResourceAdapter
*
* @version $Revision: $
*/
public class MultipleResourceAdapter implements ResourceAdapter, Serializable {
private transient WorkManager workManager;
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* The logger
*/
private static Logger log = Logger.getLogger("MultipleResourceAdapter");
/**
* Name
*/
private String name;
/**
* Default constructor
*/
public MultipleResourceAdapter() {
setName("RA");
}
/**
* Set name
*
* @param name The value
*/
public void setName(String name) {
this.name = name;
}
/**
* Get name
*
* @return The value
*/
public String getName() {
return name;
}
public WorkManager getWorkManager() {
return workManager;
}
/**
* 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 {
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) {
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()");
workManager = ctx.getWorkManager();
}
/**
* 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;
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 MultipleResourceAdapter)) { return false; }
MultipleResourceAdapter obj = (MultipleResourceAdapter) other;
boolean result = true;
if (result) {
if (name == null) { result = obj.getName() == null; } else { result = name.equals(obj.getName()); }
}
return result;
}
@Override
public String toString() {
return this.getClass().toString() + "name=" + name;
}
}
| 5,511 | 29.793296 | 111 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/rar/MultipleConnectionFactory2.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.integration.jca.rar;
import java.io.Serializable;
import jakarta.resource.Referenceable;
import jakarta.resource.ResourceException;
/**
* MultipleConnectionFactory2
*
* @version $Revision: $
*/
public interface MultipleConnectionFactory2 extends Serializable, Referenceable {
/**
* Get connection from factory
*
* @return MultipleConnection2 instance
* @throws ResourceException Thrown if a connection can't be obtained
*/
MultipleConnection2 getConnection() throws ResourceException;
}
| 1,585 | 35.883721 | 81 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/DataSourceTcclXADatasourceClassTestCase.java
|
package org.jboss.as.test.integration.jca.classloading;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.test.integration.jca.datasource.Datasource;
import org.jboss.dmr.ModelNode;
import org.junit.runner.RunWith;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.NAME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.WRITE_ATTRIBUTE_OPERATION;
@RunWith(Arquillian.class)
@ServerSetup(DataSourceTcclXADatasourceClassTestCase.Setup.class)
public class DataSourceTcclXADatasourceClassTestCase extends AbstractDataSourceClassloadingTestCase {
public static class Setup extends AbstractDataSourceClassloadingTestCase.Setup {
public Setup() {
super("driver-xa-datasource-class-name", ClassloadingXADataSource.class.getName());
}
protected void setupDs(ManagementClient managementClient, String dsName, boolean jta) throws Exception {
Datasource ds = Datasource.Builder(dsName).build();
ModelNode address = new ModelNode();
address.add("subsystem", "datasources");
address.add("xa-data-source", dsName);
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
operation.get("jndi-name").set(ds.getJndiName());
operation.get("use-java-context").set("true");
operation.get("driver-name").set("test");
operation.get("enabled").set("false");
operation.get("user-name").set(ds.getUserName());
operation.get("password").set(ds.getPassword());
managementClient.getControllerClient().execute(operation);
ModelNode prop = new ModelNode();
prop.get(OP).set(ADD);
ModelNode propAddress = address.clone();
propAddress = propAddress.add("xa-datasource-properties", "URL");
prop.get(OP_ADDR).set(propAddress);
prop.get("value").set("foo:bar");
managementClient.getControllerClient().execute(prop);
ModelNode attr = new ModelNode();
attr.get(OP).set(WRITE_ATTRIBUTE_OPERATION);
attr.get(OP_ADDR).set(address);
attr.get(NAME).set("enabled");
attr.get(VALUE).set("true");
managementClient.getControllerClient().execute(attr);
}
}
}
| 2,855 | 45.819672 | 112 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/ClassloadingDriver.java
|
package org.jboss.as.test.integration.jca.classloading;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;
public class ClassloadingDriver implements Driver {
public ClassloadingDriver() {
try {
Class.forName(TestConnection.class.getName(), true, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@Override
public Connection connect(String url, Properties info) throws SQLException {
try {
Class.forName(TestConnection.class.getName(), true, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new SQLException(e);
}
return new TestConnection();
}
@Override
public boolean acceptsURL(String url) throws SQLException {
return true;
}
@Override
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
return new DriverPropertyInfo[0];
}
@Override
public int getMajorVersion() {
return 0;
}
@Override
public int getMinorVersion() {
return 0;
}
@Override
public boolean jdbcCompliant() {
return false;
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return null;
}
}
| 1,584 | 24.15873 | 112 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/AbstractDataSourceClassloadingTestCase.java
|
package org.jboss.as.test.integration.jca.classloading;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.test.integration.jca.datasource.Datasource;
import org.jboss.as.test.shared.ServerReload;
import org.jboss.as.test.shared.ServerSnapshot;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import jakarta.annotation.Resource;
import javax.sql.DataSource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.ResultSet;
import java.sql.Statement;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
public abstract class AbstractDataSourceClassloadingTestCase {
public static JavaArchive getDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "driver.jar");
jar.addClass(ClassloadingDataSource.class);
jar.addClass(ClassloadingDriver.class);
jar.addClass(TestConnection.class);
jar.addClass(ClassloadingXADataSource.class);
jar.addClass(TestXAConnection.class);
jar.addAsServiceProvider(Driver.class, ClassloadingDriver.class);
return jar;
}
@Deployment
public static JavaArchive getTesterDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "tester.jar");
jar.addClass(AbstractDataSourceClassloadingTestCase.class);
jar.addClass(DataSourceTcclDatasourceClassTestCase.class);
return jar;
}
@Resource(mappedName = "java:jboss/datasources/TestDS")
private DataSource ds;
public static class Setup implements ServerSetupTask {
private AutoCloseable snapshot;
private String classNamePropertyName;
private String driverClass;
protected Setup(String classNamePropertyName, String driverClass) {
this.classNamePropertyName = classNamePropertyName;
this.driverClass = driverClass;
}
@Override
public void setup(ManagementClient managementClient, String s) throws Exception {
snapshot = ServerSnapshot.takeSnapshot(managementClient);
setupModule();
setupDriver(managementClient, classNamePropertyName, driverClass);
setupDs(managementClient, "TestDS", false);
ServerReload.executeReloadAndWaitForCompletion(managementClient, 50000);
}
@Override
public void tearDown(ManagementClient managementClient, String s) throws Exception {
snapshot.close();
File testModuleRoot = new File(getModulePath(), "org/jboss/test/testDriver");
if (testModuleRoot.exists()) {
deleteRecursively(testModuleRoot);
}
ServerReload.executeReloadAndWaitForCompletion(managementClient, 50000);
}
private void setupModule() throws IOException {
File testModuleRoot = new File(getModulePath(), "org/jboss/test/testDriver");
File file = new File(testModuleRoot, "main");
if (file.exists()) {
deleteRecursively(file);
}
if (!file.mkdirs()) {
// TODO handle
}
try(FileOutputStream jarFile = new FileOutputStream(new File(file, "module.xml"));
PrintWriter pw = new PrintWriter(jarFile)) {
pw.println("<module name=\"org.jboss.test.testDriver\" xmlns=\"urn:jboss:module:1.8\">\n" +
" <resources>\n" +
" <resource-root path=\"testDriver.jar\"/>\n" +
" </resources>\n" +
"\n" +
" <dependencies>\n" +
" <module name=\"java.sql\"/>\n" +
" <module name=\"java.logging\"/>\n" +
" <module name=\"javax.orb.api\"/>\n" +
" </dependencies>\n" +
"</module>");
}
JavaArchive deployment = getDeployment();
try(FileOutputStream jarFile = new FileOutputStream(new File(file, "testDriver.jar"))) {
deployment.as(ZipExporter.class).exportTo(jarFile);
jarFile.flush();
}
}
private static void deleteRecursively(File file) {
if (file.exists()) {
if (file.isDirectory()) {
for (String name : file.list()) {
deleteRecursively(new File(file, name));
}
}
file.delete();
}
}
private static File getModulePath() {
String modulePath = System.getProperty("module.path", null);
if (modulePath == null) {
String jbossHome = System.getProperty("jboss.home", null);
if (jbossHome == null) {
throw new IllegalStateException("Neither -Dmodule.path nor -Djboss.home were set");
}
modulePath = jbossHome + File.separatorChar + "modules";
} else {
modulePath = modulePath.split(File.pathSeparator)[0];
}
File moduleDir = new File(modulePath);
if (!moduleDir.exists()) {
throw new IllegalStateException("Determined module path does not exist");
}
if (!moduleDir.isDirectory()) {
throw new IllegalStateException("Determined module path is not a dir");
}
return moduleDir;
}
private void setupDriver(ManagementClient managementClient, String classNamePropertyName, String driverClass) throws Exception {
ModelNode address = new ModelNode();
address.add("subsystem", "datasources");
address.add("jdbc-driver", "test");
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
operation.get("driver-module-name").set("org.jboss.test.testDriver");
operation.get("driver-name").set("test");
operation.get("driver-datasource-class-name").set("org.jboss.as.test.integration.jca.classloading.ClassloadingDataSource");
operation.get(classNamePropertyName).set(driverClass);
managementClient.getControllerClient().execute(operation);
}
protected void setupDs(ManagementClient managementClient, String dsName, boolean jta) throws Exception {
Datasource ds = Datasource.Builder(dsName).build();
ModelNode address = new ModelNode();
address.add("subsystem", "datasources");
address.add("data-source", dsName);
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
operation.get("jndi-name").set(ds.getJndiName());
operation.get("use-java-context").set("true");
operation.get("driver-name").set("test");
operation.get("enabled").set("true");
operation.get("user-name").set(ds.getUserName());
operation.get("password").set(ds.getPassword());
operation.get("jta").set(jta);
operation.get("use-ccm").set("true");
operation.get("connection-url").set("jdbc:foo:bar");
managementClient.getControllerClient().execute(operation);
}
}
@Test
public void testGetConnection() throws Exception {
Assert.assertNotNull(ds);
ds.getConnection();
ds.getConnection("", "");
}
@Test
public void testCreateStatement() throws Exception {
Connection connection = ds.getConnection();
connection.createStatement();
connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
@Test
public void testPrepareStatement() throws Exception {
Connection connection = ds.getConnection();
connection.prepareStatement("");
connection.prepareStatement("", new int[]{});
connection.prepareStatement("", new String[]{});
connection.prepareStatement("", Statement.RETURN_GENERATED_KEYS);
connection.prepareStatement("", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
connection.prepareStatement("", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
}
}
| 9,181 | 41.509259 | 137 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/ClassloadingDataSource.java
|
package org.jboss.as.test.integration.jca.classloading;
import javax.sql.DataSource;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;
public class ClassloadingDataSource implements DataSource {
public ClassloadingDataSource() {
try {
Class.forName(TestConnection.class.getName(), true, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@Override
public Connection getConnection() throws SQLException {
try {
Class.forName(TestConnection.class.getName(), true, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new SQLException(e);
}
return new TestConnection();
}
@Override
public Connection getConnection(String username, String password) throws SQLException {
return getConnection();
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return null;
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return false;
}
@Override
public PrintWriter getLogWriter() throws SQLException {
return null;
}
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
}
@Override
public void setLoginTimeout(int seconds) throws SQLException {
}
@Override
public int getLoginTimeout() throws SQLException {
return 0;
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return null;
}
}
| 1,782 | 24.471429 | 112 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/TestXAConnection.java
|
package org.jboss.as.test.integration.jca.classloading;
import javax.sql.ConnectionEventListener;
import javax.sql.StatementEventListener;
import javax.sql.XAConnection;
import javax.transaction.xa.XAResource;
import java.sql.Connection;
import java.sql.SQLException;
public class TestXAConnection implements XAConnection {
@Override
public XAResource getXAResource() throws SQLException {
return null;
}
@Override
public Connection getConnection() throws SQLException {
return new TestConnection();
}
@Override
public void close() throws SQLException {
}
@Override
public void addConnectionEventListener(ConnectionEventListener listener) {
}
@Override
public void removeConnectionEventListener(ConnectionEventListener listener) {
}
@Override
public void addStatementEventListener(StatementEventListener listener) {
}
@Override
public void removeStatementEventListener(StatementEventListener listener) {
}
}
| 1,021 | 21.217391 | 81 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/DataSourceTcclDatasourceClassTestCase.java
|
package org.jboss.as.test.integration.jca.classloading;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
@ServerSetup(DataSourceTcclDatasourceClassTestCase.Setup.class)
public class DataSourceTcclDatasourceClassTestCase extends AbstractDataSourceClassloadingTestCase {
public static class Setup extends AbstractDataSourceClassloadingTestCase.Setup {
public Setup() {
super("driver-datasource-class-name", "org.jboss.as.test.integration.jca.classloading.ClassloadingDataSource");
}
}
}
| 630 | 34.055556 | 123 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/TestConnection.java
|
package org.jboss.as.test.integration.jca.classloading;
import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.Executor;
public class TestConnection implements Connection {
private void loadClass() throws SQLException {
try {
Class.forName(TestConnection.class.getName(), true, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new SQLException(e);
}
}
@Override
public Statement createStatement() throws SQLException {
loadClass();
return null;
}
@Override
public PreparedStatement prepareStatement(String sql) throws SQLException {
loadClass();
return null;
}
@Override
public CallableStatement prepareCall(String sql) throws SQLException {
loadClass();
return null;
}
@Override
public String nativeSQL(String sql) throws SQLException {
return null;
}
@Override
public void setAutoCommit(boolean autoCommit) throws SQLException {
}
@Override
public boolean getAutoCommit() throws SQLException {
return false;
}
@Override
public void commit() throws SQLException {
}
@Override
public void rollback() throws SQLException {
}
@Override
public void close() throws SQLException {
}
@Override
public boolean isClosed() throws SQLException {
return false;
}
@Override
public DatabaseMetaData getMetaData() throws SQLException {
return null;
}
@Override
public void setReadOnly(boolean readOnly) throws SQLException {
}
@Override
public boolean isReadOnly() throws SQLException {
return false;
}
@Override
public void setCatalog(String catalog) throws SQLException {
}
@Override
public String getCatalog() throws SQLException {
return null;
}
@Override
public void setTransactionIsolation(int level) throws SQLException {
}
@Override
public int getTransactionIsolation() throws SQLException {
return 0;
}
@Override
public SQLWarning getWarnings() throws SQLException {
return null;
}
@Override
public void clearWarnings() throws SQLException {
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException {
return null;
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
loadClass();
return null;
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException {
return null;
}
@Override
public Map<String, Class<?>> getTypeMap() throws SQLException {
return null;
}
@Override
public void setTypeMap(Map<String, Class<?>> map) throws SQLException {
}
@Override
public void setHoldability(int holdability) throws SQLException {
}
@Override
public int getHoldability() throws SQLException {
return 0;
}
@Override
public Savepoint setSavepoint() throws SQLException {
return null;
}
@Override
public Savepoint setSavepoint(String name) throws SQLException {
return null;
}
@Override
public void rollback(Savepoint savepoint) throws SQLException {
}
@Override
public void releaseSavepoint(Savepoint savepoint) throws SQLException {
}
@Override
public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
return null;
}
@Override
public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
loadClass();
return null;
}
@Override
public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException {
return null;
}
@Override
public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException {
loadClass();
return null;
}
@Override
public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException {
loadClass();
return null;
}
@Override
public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException {
loadClass();
return null;
}
@Override
public Clob createClob() throws SQLException {
return null;
}
@Override
public Blob createBlob() throws SQLException {
return null;
}
@Override
public NClob createNClob() throws SQLException {
return null;
}
@Override
public SQLXML createSQLXML() throws SQLException {
return null;
}
@Override
public boolean isValid(int timeout) throws SQLException {
return false;
}
@Override
public void setClientInfo(String name, String value) throws SQLClientInfoException {
}
@Override
public void setClientInfo(Properties properties) throws SQLClientInfoException {
}
@Override
public String getClientInfo(String name) throws SQLException {
return null;
}
@Override
public Properties getClientInfo() throws SQLException {
return null;
}
@Override
public Array createArrayOf(String typeName, Object[] elements) throws SQLException {
return null;
}
@Override
public Struct createStruct(String typeName, Object[] attributes) throws SQLException {
return null;
}
@Override
public void setSchema(String schema) throws SQLException {
}
@Override
public String getSchema() throws SQLException {
return null;
}
@Override
public void abort(Executor executor) throws SQLException {
}
@Override
public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
}
@Override
public int getNetworkTimeout() throws SQLException {
return 0;
}
@Override
public <T> T unwrap(Class<T> iface) throws SQLException {
return null;
}
@Override
public boolean isWrapperFor(Class<?> iface) throws SQLException {
return false;
}
}
| 6,981 | 21.522581 | 150 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/DataSourceTcclDriverClassTestCase.java
|
package org.jboss.as.test.integration.jca.classloading;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
@ServerSetup(DataSourceTcclDriverClassTestCase.Setup.class)
public class DataSourceTcclDriverClassTestCase extends AbstractDataSourceClassloadingTestCase {
public static class Setup extends AbstractDataSourceClassloadingTestCase.Setup {
public Setup() {
super("driver-class-name", ClassloadingDriver.class.getName());
}
}
}
| 574 | 30.944444 | 95 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/ClassloadingXADataSource.java
|
package org.jboss.as.test.integration.jca.classloading;
import javax.sql.XAConnection;
import javax.sql.XADataSource;
import java.io.PrintWriter;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.logging.Logger;
public class ClassloadingXADataSource implements XADataSource {
public ClassloadingXADataSource() {
try {
Class.forName(TestConnection.class.getName(), true, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@Override
public XAConnection getXAConnection() throws SQLException {
try {
Class.forName(TestConnection.class.getName(), true, Thread.currentThread().getContextClassLoader());
} catch (ClassNotFoundException e) {
throw new SQLException(e);
}
return new TestXAConnection();
}
@Override
public XAConnection getXAConnection(String user, String password) throws SQLException {
return getXAConnection();
}
@Override
public PrintWriter getLogWriter() throws SQLException {
return null;
}
@Override
public void setLogWriter(PrintWriter out) throws SQLException {
}
@Override
public void setLoginTimeout(int seconds) throws SQLException {
}
@Override
public int getLoginTimeout() throws SQLException {
return 0;
}
@Override
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
return null;
}
public void setURL(String url) {
}
}
| 1,629 | 24.46875 | 112 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/custommodule/TestValidConnectionChecker.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.jboss.as.test.integration.jca.classloading.custommodule;
import org.jboss.jca.adapters.jdbc.spi.ValidConnectionChecker;
import java.sql.Connection;
import java.sql.SQLException;
public class TestValidConnectionChecker implements ValidConnectionChecker {
private static boolean invoked = false;
@Override
public SQLException isValidConnection(Connection c) {
invoked = true;
return null;
}
public static void reset() {
invoked = false;
}
public static boolean wasInvoked() {
return invoked;
}
}
| 1,663 | 32.959184 | 75 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/custommodule/DatasourceCustomModulesTestCase.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.jboss.as.test.integration.jca.classloading.custommodule;
import static org.jboss.as.controller.client.helpers.ClientConstants.ADD;
import static org.jboss.as.controller.client.helpers.ClientConstants.OP;
import static org.jboss.as.controller.client.helpers.ClientConstants.OPERATION_HEADERS;
import static org.jboss.as.controller.client.helpers.ClientConstants.OP_ADDR;
import static org.jboss.as.controller.client.helpers.ClientConstants.OUTCOME;
import static org.jboss.as.controller.client.helpers.ClientConstants.REMOVE_OPERATION;
import static org.jboss.as.controller.client.helpers.ClientConstants.SUBSYSTEM;
import static org.jboss.as.controller.client.helpers.ClientConstants.SUCCESS;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.io.FilePermission;
import java.io.IOException;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.ReflectPermission;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.api.ServerSetupTask;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.controller.PathAddress;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.test.module.util.TestModule;
import org.jboss.as.test.shared.ServerReload;
import org.jboss.dmr.ModelNode;
import org.jboss.jca.adapters.jdbc.BaseWrapperManagedConnection;
import org.jboss.jca.adapters.jdbc.WrappedConnection;
import org.jboss.remoting3.security.RemotingPermission;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(Arquillian.class)
@ServerSetup(DatasourceCustomModulesTestCase.Setup.class)
public class DatasourceCustomModulesTestCase {
@ArquillianResource
private ManagementClient managementClient;
private PathAddress dsAddress;
private String dsName;
private String dsJndiName;
private DataSource dataSource;
private List<Connection> connectionList;
private List<Connection> physicalConnectionList;
private ClassLoader customModuleClassloader;
@Test
public void testModuleValidationClasses() throws Exception {
createDatasource();
initConnections(3);
TestValidConnectionChecker.reset();
TestExceptionSorter.reset();
TestStaleConnectionChecker.reset();
// reflection hack to induce connection error validation
Connection connection = connectionList.get(0);
Field managedConnectionField = WrappedConnection.class.getDeclaredField("mc");
managedConnectionField.setAccessible(true);
Object managedConnection = managedConnectionField.get(connection);
Method connectionErrorMethod = BaseWrapperManagedConnection.class.getDeclaredMethod("connectionError", Throwable.class);
connectionErrorMethod.setAccessible(true);
connectionErrorMethod.invoke(managedConnection, new SQLException());
connectionList.get(0).close();
connectionList.get(1).close();
// flush operation to induce connection validation
runDataSourceOperationAndAssertSuccess("flush-invalid-connection-in-pool");
Assert.assertTrue(TestValidConnectionChecker.wasInvoked());
Assert.assertTrue(TestExceptionSorter.wasInvoked());
Assert.assertTrue(TestStaleConnectionChecker.wasInvoked());
}
public void initConnections(int count) {
connectionList = IntStream.range(0, count)
.mapToObj(i -> connectionSupplier.apply(dataSource))
.collect(Collectors.toList());
physicalConnectionList = connectionList
.stream()
.map(this::getUnderlyingConnection)
.collect(Collectors.toList());
}
public Connection getUnderlyingConnection(Connection handle) {
try {
return ((WrappedConnection) handle).getUnderlyingConnection();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
public Function<DataSource, Connection> connectionSupplier = (dataSource -> {
try {
return dataSource.getConnection("sa", "");
} catch (SQLException e) {
throw new RuntimeException(e);
}
});
public void runDataSourceOperationAndAssertSuccess(String operationName) throws IOException {
final ModelNode op = new ModelNode();
op.get(OP).set(operationName);
op.get(OP_ADDR).set(dsAddress.toModelNode());
executeAndAssertSuccess(op);
}
@Deployment
public static JavaArchive deployment() {
final JavaArchive archive = ShrinkWrap.create(JavaArchive.class, "flush-operations.jar");
archive.addClass(DatasourceCustomModulesTestCase.class);
archive.addAsManifestResource(
new StringAsset(
"Dependencies: org.jboss.as.controller-client, "
+ "org.jboss.as.controller, "
+ "org.jboss.dmr, "
+ "org.jboss.ironjacamar.jdbcadapters, "
+ "org.jboss.test.customModule, "
+ "org.jboss.remoting\n"),
"MANIFEST.MF");
archive.addAsManifestResource(createPermissionsXmlAsset(
// ModelControllerClient needs the following
new RemotingPermission("createEndpoint"),
new RemotingPermission("connect"),
// flushInvalidConnectionsInPool needs the following
new RuntimePermission("accessDeclaredMembers"),
new ReflectPermission("suppressAccessChecks"),
new FilePermission(System.getProperty("jboss.inst") + "/standalone/tmp/auth/*", "read")
), "permissions.xml");
return archive;
}
public void createDatasource() throws Exception {
dsName = java.util.UUID.randomUUID().toString();
dsAddress = PathAddress.pathAddress(SUBSYSTEM, "datasources").append("data-source", dsName);
dsJndiName = "java:/" + dsName;
final ModelNode createDsOp = new ModelNode();
createDsOp.get(OP).set(ADD);
createDsOp.get(OP_ADDR).set(dsAddress.toModelNode());
createDsOp.get("jndi-name").set(dsJndiName);
createDsOp.get("driver-name").set("h2");
createDsOp.get("valid-connection-checker-class-name").set(TestValidConnectionChecker.class.getName());
createDsOp.get("valid-connection-checker-module").set("org.jboss.test.customModule");
createDsOp.get("exception-sorter-class-name").set(TestExceptionSorter.class.getName());
createDsOp.get("exception-sorter-module").set("org.jboss.test.customModule");
createDsOp.get("stale-connection-checker-class-name").set(TestStaleConnectionChecker.class.getName());
createDsOp.get("stale-connection-checker-module").set("org.jboss.test.customModule");
createDsOp.get("min-pool-size").set(2);
createDsOp.get("max-pool-size").set(5);
createDsOp.get("connection-url").set("jdbc:h2:mem:test42");
executeAndAssertSuccess(createDsOp);
dataSource = getDataSourceInstanceFromJndi();
}
public void cleanup() throws Exception {
if (connectionList != null) {
connectionList.forEach(this::closeIfNecessary);
connectionList = null;
}
final ModelNode removeOp = new ModelNode();
removeOp.get(OP).set(REMOVE_OPERATION);
removeOp.get(OP_ADDR).set(dsAddress.toModelNode());
removeOp.get(OPERATION_HEADERS, ModelDescriptionConstants.ALLOW_RESOURCE_SERVICE_RESTART).set(true);
executeAndAssertSuccess(removeOp);
}
public void executeAndAssertSuccess(ModelNode op) throws IOException {
final ModelNode result = managementClient.getControllerClient().execute(op);
if (!result.get(OUTCOME).asString().equals(SUCCESS)) {
Assert.fail("Operation failed: " + result.toJSONString(true));
}
}
public DataSource getDataSourceInstanceFromJndi() throws NamingException {
return (DataSource) new InitialContext().lookup(dsJndiName);
}
public void closeIfNecessary(Connection connection) {
try {
if (!connection.isClosed()) {
connection.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public static class Setup implements ServerSetupTask {
private TestModule customModule;
@Override
public void setup(ManagementClient managementClient, String s) throws Exception {
TestModule customModule = new TestModule("org.jboss.test.customModule",
new String[] {"java.sql", "javax.orb.api", "java.logging", "org.jboss.ironjacamar.jdbcadapters"});
customModule.addResource("customModule.jar")
.addClasses(TestValidConnectionChecker.class, TestExceptionSorter.class, TestStaleConnectionChecker.class);
customModule.create();
ServerReload.executeReloadAndWaitForCompletion(managementClient, 50000);
}
@Override
public void tearDown(ManagementClient managementClient, String s) throws Exception {
if (customModule != null) {
customModule.remove();
}
ServerReload.executeReloadAndWaitForCompletion(managementClient, 50000);
}
}
}
| 11,210 | 40.988764 | 128 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/custommodule/TestStaleConnectionChecker.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.jboss.as.test.integration.jca.classloading.custommodule;
import org.jboss.jca.adapters.jdbc.spi.StaleConnectionChecker;
import java.sql.SQLException;
public class TestStaleConnectionChecker implements StaleConnectionChecker {
private static boolean invoked = false;
@Override
public boolean isStaleConnection(SQLException e) {
invoked = true;
return false;
}
public static void reset() {
invoked = false;
}
public static boolean wasInvoked() {
return invoked;
}
}
| 1,633 | 33.041667 | 75 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/classloading/custommodule/TestExceptionSorter.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.jboss.as.test.integration.jca.classloading.custommodule;
import org.jboss.jca.adapters.jdbc.spi.ExceptionSorter;
import java.sql.SQLException;
public class TestExceptionSorter implements ExceptionSorter {
private static boolean invoked = false;
@Override
public boolean isExceptionFatal(SQLException e) {
invoked = true;
return false;
}
public static void reset() {
invoked = false;
}
public static boolean wasInvoked() {
return invoked;
}
}
| 1,611 | 32.583333 | 73 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/basic/BasicDoubleDeployment16TestCase.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.integration.jca.basic;
import java.util.List;
import jakarta.annotation.Resource;
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.container.ManagementClient;
import org.jboss.as.connector.subsystems.resourceadapters.Namespace;
import org.jboss.as.connector.subsystems.resourceadapters.ResourceAdapterSubsystemParser;
import org.jboss.as.test.integration.jca.basic.BasicDeployment16TestCase.BasicDeploymentTestCaseSetup;
import org.jboss.as.test.integration.jca.rar.MultipleAdminObject1;
import org.jboss.as.test.integration.jca.rar.MultipleConnectionFactory1;
import org.jboss.as.test.integration.management.base.AbstractMgmtServerSetupTask;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Basic test to check if we can activate more than one IDed RA. (there are similar tests but with exploded module)
*
* @author baranowb
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicDoubleDeployment16TestCase.BasicDoubleDeploymentTestCaseSetup.class)
public class BasicDoubleDeployment16TestCase {
// deployment archive name must match "archive" element.
private static final String DEPLOYMENT_MODULE_NAME = "basic";
private static final String DEPLOYMENT_NAME = DEPLOYMENT_MODULE_NAME + ".rar";
private static final String SUB_DEPLOYMENT_MODULE_NAME = "somejar";
private static final String SUB_DEPLOYMENT_NAME = SUB_DEPLOYMENT_MODULE_NAME + ".jar";
private static final String RAR_1_NAME = "XXX1";
private static final String RAR_2_NAME = "XXX2";
static class BasicDoubleDeploymentTestCaseSetup extends AbstractMgmtServerSetupTask {
@Override
public void doSetup(final ManagementClient managementClient) throws Exception {
String xml = FileUtils.readFile(BasicDeployment16TestCase.class, "basic16.1.xml");
List<ModelNode> operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_1.getUriString(),
new ResourceAdapterSubsystemParser());
executeOperation(operationListToCompositeOperation(operations));
String xml2 = FileUtils.readFile(BasicDeployment16TestCase.class, "basic16.1-2.xml");
List<ModelNode> operations2 = xmlToModelOperations(xml2, Namespace.RESOURCEADAPTERS_1_1.getUriString(),
new ResourceAdapterSubsystemParser());
executeOperation(operationListToCompositeOperation(operations2));
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
try {
remove(getAddress(RAR_1_NAME));
} catch (Exception e) {
e.printStackTrace();
}
try {
remove(getAddress(RAR_2_NAME));
} catch (Exception e) {
e.printStackTrace();
}
}
private ModelNode getAddress(final String name) {
final ModelNode address = new ModelNode();
address.add("subsystem", "resource-adapters");
address.add("resource-adapter", name);
address.protect();
return address;
}
}
@Deployment
public static ResourceAdapterArchive createDeployment() {
ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, DEPLOYMENT_NAME);
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, SUB_DEPLOYMENT_NAME);
ja.addPackage(MultipleConnectionFactory1.class.getPackage()).addClasses(BasicDoubleDeployment16TestCase.class,
BasicDeploymentTestCaseSetup.class);
ja.addPackage(AbstractMgmtTestBase.class.getPackage()); // needed to process the @ServerSetup annotation on the server side
raa.addAsLibrary(ja);
raa.addAsManifestResource(BasicDeployment16TestCase.class.getPackage(), "ra16.xml", "ra.xml");
return raa;
}
@Resource(mappedName = "java:jboss/name1")
private MultipleConnectionFactory1 connectionFactory1;
@Resource(mappedName = "java:jboss/Name3")
private MultipleAdminObject1 adminObject1;
@Resource(mappedName = "java:jboss/name1-2")
private MultipleConnectionFactory1 connectionFactory2;
@Resource(mappedName = "java:jboss/Name3-2")
private MultipleAdminObject1 adminObject2;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testConfiguration() throws Throwable {
Assert.assertNotNull("CF1 not found", connectionFactory1);
Assert.assertNotNull("AO1 not found", adminObject1);
Assert.assertNotNull("CF2 not found", connectionFactory2);
Assert.assertNotNull("AO2 not found", adminObject2);
}
}
| 6,232 | 41.986207 | 131 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/basic/BasicDoubleDeploymentFail16_2TestCase.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.integration.jca.basic;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import jakarta.annotation.Resource;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ContainerResource;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.connector.subsystems.resourceadapters.Namespace;
import org.jboss.as.connector.subsystems.resourceadapters.ResourceAdapterSubsystemParser;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.test.integration.jca.rar.MultipleAdminObject1;
import org.jboss.as.test.integration.jca.rar.MultipleConnectionFactory1;
import org.jboss.as.test.integration.management.base.AbstractMgmtServerSetupTask;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test failure of activation for non ID-ed RAs
*
* @author baranowb
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicDoubleDeploymentFail16_2TestCase.BasicDoubleDeploymentTestCaseSetup.class)
public class BasicDoubleDeploymentFail16_2TestCase {
// deployment archive name must match "archive" element.
private static final String DEPLOYMENT_MODULE_NAME = "basic";
private static final String DEPLOYMENT_NAME = DEPLOYMENT_MODULE_NAME + ".rar";
private static final String SUB_DEPLOYMENT_MODULE_NAME = "somejar";
private static final String SUB_DEPLOYMENT_NAME = SUB_DEPLOYMENT_MODULE_NAME + ".jar";
private static final String RAR_1_NAME = "XXX2";
// private static final String RAR_2_NAME = "XXX2";
static class BasicDoubleDeploymentTestCaseSetup extends AbstractMgmtServerSetupTask {
@Override
public void doSetup(final ManagementClient managementClient) throws Exception {
String xml = FileUtils.readFile(BasicDoubleDeploymentFail16_2TestCase.class, "basic16.1-2.xml");
List<ModelNode> operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_1.getUriString(),
new ResourceAdapterSubsystemParser());
executeOperation(operationListToCompositeOperation(operations));
xml = FileUtils.readFile(BasicDoubleDeploymentFail16_2TestCase.class, "basic16.1-3.xml");
operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_1.getUriString(),
new ResourceAdapterSubsystemParser());
final ModelNode result = executeOperation(operationListToCompositeOperation(operations), false);
Assert.assertTrue(!Operations.isSuccessfulOutcome(result));
final String failureDescription = result.get("result").get("step-1").get("failure-description").asString();
Assert.assertTrue(failureDescription.startsWith("WFLYCTL0212: Duplicate resource"));
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
try {
remove(getAddress(RAR_1_NAME));
} catch (Exception e) {
e.printStackTrace();
}
}
private ModelNode getAddress(final String name) {
final ModelNode address = new ModelNode();
address.add("subsystem", "resource-adapters");
address.add("resource-adapter", name);
address.protect();
return address;
}
}
@Deployment
public static ResourceAdapterArchive createDeployment() {
ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, DEPLOYMENT_NAME);
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, SUB_DEPLOYMENT_NAME);
ja.addPackage(MultipleConnectionFactory1.class.getPackage()).addClasses(BasicDoubleDeploymentFail16_2TestCase.class,
BasicDoubleDeploymentTestCaseSetup.class);
ja.addPackage(AbstractMgmtTestBase.class.getPackage()); // needed to process the @ServerSetup annotation on the server side
raa.addAsLibrary(ja);
raa.addAsManifestResource(BasicDoubleDeploymentFail16_2TestCase.class.getPackage(), "ra16.xml", "ra.xml");
return raa;
}
@Resource(mappedName = "java:jboss/name1-2")
private MultipleConnectionFactory1 connectionFactory1;
@Resource(mappedName = "java:jboss/Name3-2")
private MultipleAdminObject1 adminObject1;
@ContainerResource
private InitialContext initialContext;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testConfiguration() throws Throwable {
assertNotNull("CF1 not found", connectionFactory1);
assertNotNull("AO1 not found", adminObject1);
}
@Test(expected = NameNotFoundException.class)
public void testNonExistingConfig_1() throws Exception {
InitialContext initialContext = new InitialContext();
initialContext.lookup("java:jboss/name1-3");
}
@Test(expected = NameNotFoundException.class)
public void testNonExistingConfig_2() throws Exception {
InitialContext initialContext = new InitialContext();
initialContext.lookup("java:jboss/Name3-3");
}
}
| 6,692 | 42.745098 | 131 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/basic/BasicDeployment10TestCase.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.integration.jca.basic;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import jakarta.annotation.Resource;
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.container.ManagementClient;
import org.jboss.as.connector.subsystems.resourceadapters.Namespace;
import org.jboss.as.connector.subsystems.resourceadapters.ResourceAdapterSubsystemParser;
import org.jboss.as.test.integration.jca.rar.MultipleConnectionFactory1;
import org.jboss.as.test.integration.management.base.AbstractMgmtServerSetupTask;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* JBQA-5737 basic subsystem deployment
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicDeployment10TestCase.BasicDeploymentTestCaseSetup.class)
public class BasicDeployment10TestCase {
static class BasicDeploymentTestCaseSetup extends AbstractMgmtServerSetupTask {
@Override
public void doSetup(final ManagementClient managementClient) throws Exception {
String xml = FileUtils.readFile(BasicDeployment10TestCase.class, "basic10.xml");
List<ModelNode> operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_0.getUriString(), new ResourceAdapterSubsystemParser());
executeOperation(operationListToCompositeOperation(operations));
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
final ModelNode address = new ModelNode();
address.add("subsystem", "resource-adapters");
address.add("resource-adapter", "basic10.rar");
address.protect();
remove(address);
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static ResourceAdapterArchive createDeployment() {
String deploymentName = "basic10.rar";
ResourceAdapterArchive raa =
ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName);
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, "multiple.jar");
ja.addPackage(MultipleConnectionFactory1.class.getPackage()).
addClasses(BasicDeployment10TestCase.class, BasicDeploymentTestCaseSetup.class);
ja.addPackage(AbstractMgmtTestBase.class.getPackage()); // needed to process the @ServerSetup annotation on the server side
raa.addAsLibrary(ja);
raa.addAsManifestResource(BasicDeployment10TestCase.class.getPackage(), "ra10.xml", "ra.xml");
return raa;
}
@Resource(mappedName = "java:jboss/name1")
private MultipleConnectionFactory1 connectionFactory1;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testConfiguration() throws Throwable {
assertNotNull("CF1 not found", connectionFactory1);
}
}
| 4,462 | 38.495575 | 152 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/basic/BasicDeployment16TestCase.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.integration.jca.basic;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import jakarta.annotation.Resource;
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.container.ManagementClient;
import org.jboss.as.connector.subsystems.resourceadapters.Namespace;
import org.jboss.as.connector.subsystems.resourceadapters.ResourceAdapterSubsystemParser;
import org.jboss.as.test.integration.jca.rar.MultipleAdminObject1;
import org.jboss.as.test.integration.jca.rar.MultipleConnectionFactory1;
import org.jboss.as.test.integration.management.base.AbstractMgmtServerSetupTask;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* JBQA-5737 basic subsystem deployment
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicDeployment16TestCase.BasicDeploymentTestCaseSetup.class)
public class BasicDeployment16TestCase {
static class BasicDeploymentTestCaseSetup extends AbstractMgmtServerSetupTask {
@Override
public void doSetup(final ManagementClient managementClient) throws Exception {
String xml = FileUtils.readFile(BasicDeployment16TestCase.class, "basic16.xml");
List<ModelNode> operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_0.getUriString(), new ResourceAdapterSubsystemParser());
executeOperation(operationListToCompositeOperation(operations));
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
final ModelNode address = new ModelNode();
address.add("subsystem", "resource-adapters");
address.add("resource-adapter", "basic.rar");
address.protect();
remove(address);
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static ResourceAdapterArchive createDeployment() {
String deploymentName = "basic.rar";
ResourceAdapterArchive raa =
ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName);
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, "multiple.jar");
ja.addPackage(MultipleConnectionFactory1.class.getPackage()).
addClasses(BasicDeployment16TestCase.class, BasicDeploymentTestCaseSetup.class);
ja.addPackage(AbstractMgmtTestBase.class.getPackage()); // needed to process the @ServerSetup annotation on the server side
raa.addAsLibrary(ja);
raa.addAsManifestResource(BasicDeployment16TestCase.class.getPackage(), "ra16.xml", "ra.xml");
return raa;
}
@Resource(mappedName = "java:jboss/name1")
private MultipleConnectionFactory1 connectionFactory1;
@Resource(mappedName = "java:jboss/Name3")
private MultipleAdminObject1 adminObject1;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testConfiguration() throws Throwable {
assertNotNull("CF1 not found", connectionFactory1);
assertNotNull("AO1 not found", adminObject1);
}
}
| 4,676 | 38.302521 | 152 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/basic/BasicDoubleDeploymentFail16_1TestCase.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.integration.jca.basic;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import jakarta.annotation.Resource;
import javax.naming.InitialContext;
import javax.naming.NameNotFoundException;
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.container.ManagementClient;
import org.jboss.as.connector.subsystems.resourceadapters.Namespace;
import org.jboss.as.connector.subsystems.resourceadapters.ResourceAdapterSubsystemParser;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.test.integration.jca.basic.BasicDeployment16TestCase.BasicDeploymentTestCaseSetup;
import org.jboss.as.test.integration.jca.rar.MultipleAdminObject1;
import org.jboss.as.test.integration.jca.rar.MultipleConnectionFactory1;
import org.jboss.as.test.integration.management.base.AbstractMgmtServerSetupTask;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test failure of activation for non ID-ed RAs
*
* @author baranowb
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicDoubleDeploymentFail16_1TestCase.BasicDoubleDeploymentTestCaseSetup.class)
public class BasicDoubleDeploymentFail16_1TestCase {
// deployment archive name must match "archive" element.
private static final String DEPLOYMENT_MODULE_NAME = "basic";
private static final String DEPLOYMENT_NAME = DEPLOYMENT_MODULE_NAME + ".rar";
private static final String SUB_DEPLOYMENT_MODULE_NAME = "somejar";
private static final String SUB_DEPLOYMENT_NAME = SUB_DEPLOYMENT_MODULE_NAME + ".jar";
private static final String RAR_1_NAME = DEPLOYMENT_NAME;
// private static final String RAR_2_NAME = "XXX2";
static class BasicDoubleDeploymentTestCaseSetup extends AbstractMgmtServerSetupTask {
@Override
public void doSetup(final ManagementClient managementClient) throws Exception {
String xml = FileUtils.readFile(BasicDeployment16TestCase.class, "basic16.xml");
List<ModelNode> operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_0.getUriString(),
new ResourceAdapterSubsystemParser());
executeOperation(operationListToCompositeOperation(operations));
xml = FileUtils.readFile(BasicDeployment16TestCase.class, "basic16-duplicate.xml");
operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_0.getUriString(),
new ResourceAdapterSubsystemParser());
final ModelNode result = executeOperation(operationListToCompositeOperation(operations), false);
Assert.assertTrue(!Operations.isSuccessfulOutcome(result));
final String failureDescription = result.get("result").get("step-1").get("failure-description").asString();
Assert.assertTrue(failureDescription.startsWith("WFLYCTL0212: Duplicate resource"));
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
try {
remove(getAddress(RAR_1_NAME));
} catch (Exception e) {
e.printStackTrace();
}
}
private ModelNode getAddress(final String name) {
final ModelNode address = new ModelNode();
address.add("subsystem", "resource-adapters");
address.add("resource-adapter", name);
address.protect();
return address;
}
}
@Deployment
public static ResourceAdapterArchive createDeployment() {
ResourceAdapterArchive raa = ShrinkWrap.create(ResourceAdapterArchive.class, DEPLOYMENT_NAME);
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, SUB_DEPLOYMENT_NAME);
ja.addPackage(MultipleConnectionFactory1.class.getPackage()).addClasses(BasicDoubleDeploymentFail16_1TestCase.class,
BasicDeploymentTestCaseSetup.class);
ja.addPackage(AbstractMgmtTestBase.class.getPackage()); // needed to process the @ServerSetup annotation on the server side
raa.addAsLibrary(ja);
raa.addAsManifestResource(BasicDeployment16TestCase.class.getPackage(), "ra16.xml", "ra.xml");
return raa;
}
@Resource(mappedName = "java:jboss/name1")
private MultipleConnectionFactory1 connectionFactory1;
@Resource(mappedName = "java:jboss/Name3")
private MultipleAdminObject1 adminObject1;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testConfiguration() throws Throwable {
assertNotNull("CF1 not found", connectionFactory1);
assertNotNull("AO1 not found", adminObject1);
}
@Test(expected = NameNotFoundException.class)
public void testNonExistingConfig_1() throws Exception {
InitialContext initialContext = new InitialContext();
initialContext.lookup("java:jboss/name1-2");
}
@Test(expected = NameNotFoundException.class)
public void testNonExistingConfig_2() throws Exception {
InitialContext initialContext = new InitialContext();
initialContext.lookup("java:jboss/Name3-2");
}
}
| 6,640 | 42.980132 | 131 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/basic/BasicDeployment17TestCase.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.integration.jca.basic;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import jakarta.annotation.Resource;
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.container.ManagementClient;
import org.jboss.as.connector.subsystems.resourceadapters.Namespace;
import org.jboss.as.connector.subsystems.resourceadapters.ResourceAdapterSubsystemParser;
import org.jboss.as.test.integration.jca.rar.MultipleAdminObject1;
import org.jboss.as.test.integration.jca.rar.MultipleConnectionFactory1;
import org.jboss.as.test.integration.management.base.AbstractMgmtServerSetupTask;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="[email protected]">Martin Simka</a>
* JBQA-5737 basic subsystem deployment
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicDeployment17TestCase.BasicDeploymentTestCaseSetup.class)
public class BasicDeployment17TestCase {
static class BasicDeploymentTestCaseSetup extends AbstractMgmtServerSetupTask {
@Override
public void doSetup(final ManagementClient managementClient) throws Exception {
String xml = FileUtils.readFile(BasicDeployment17TestCase.class, "basic17.xml");
List<ModelNode> operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_0.getUriString(), new ResourceAdapterSubsystemParser());
executeOperation(operationListToCompositeOperation(operations));
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
final ModelNode address = new ModelNode();
address.add("subsystem", "resource-adapters");
address.add("resource-adapter", "basic17.rar");
address.protect();
remove(address);
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static ResourceAdapterArchive createDeployment() {
String deploymentName = "basic17.rar";
ResourceAdapterArchive raa =
ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName);
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, "multiple.jar");
ja.addPackage(MultipleConnectionFactory1.class.getPackage()).
addClasses(BasicDeployment17TestCase.class, BasicDeploymentTestCaseSetup.class);
ja.addPackage(AbstractMgmtTestBase.class.getPackage()); // needed to process the @ServerSetup annotation on the server side
raa.addAsLibrary(ja);
raa.addAsManifestResource(BasicDeployment17TestCase.class.getPackage(), "ra17.xml", "ra.xml");
return raa;
}
@Resource(mappedName = "java:jboss/name1")
private MultipleConnectionFactory1 connectionFactory1;
@Resource(mappedName = "java:jboss/Name3")
private MultipleAdminObject1 adminObject1;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testConfiguration() throws Throwable {
assertNotNull("CF1 not found", connectionFactory1);
assertNotNull("AO1 not found", adminObject1);
}
}
| 4,670 | 38.252101 | 152 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/basic/BasicDeployment15TestCase.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.integration.jca.basic;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import jakarta.annotation.Resource;
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.container.ManagementClient;
import org.jboss.as.connector.subsystems.resourceadapters.Namespace;
import org.jboss.as.connector.subsystems.resourceadapters.ResourceAdapterSubsystemParser;
import org.jboss.as.test.integration.jca.rar.MultipleAdminObject1;
import org.jboss.as.test.integration.jca.rar.MultipleConnectionFactory1;
import org.jboss.as.test.integration.management.base.AbstractMgmtServerSetupTask;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* JBQA-5737 basic subsystem deployment
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicDeployment15TestCase.BasicDeploymentTestCaseSetup.class)
public class BasicDeployment15TestCase {
static class BasicDeploymentTestCaseSetup extends AbstractMgmtServerSetupTask {
@Override
public void doSetup(final ManagementClient managementClient) throws Exception {
String xml = FileUtils.readFile(BasicDeployment15TestCase.class, "basic15.xml");
List<ModelNode> operations = xmlToModelOperations(xml, Namespace.RESOURCEADAPTERS_1_0.getUriString(), new ResourceAdapterSubsystemParser());
executeOperation(operationListToCompositeOperation(operations));
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
final ModelNode address = new ModelNode();
address.add("subsystem", "resource-adapters");
address.add("resource-adapter", "basic15.rar");
address.protect();
remove(address);
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static ResourceAdapterArchive createDeployment() {
String deploymentName = "basic15.rar";
ResourceAdapterArchive raa =
ShrinkWrap.create(ResourceAdapterArchive.class, deploymentName);
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, "multiple.jar");
ja.addPackage(MultipleConnectionFactory1.class.getPackage()).
addClasses(BasicDeployment15TestCase.class, BasicDeploymentTestCaseSetup.class);
ja.addPackage(AbstractMgmtTestBase.class.getPackage()); // needed to process the @ServerSetup annotation on the server side
raa.addAsLibrary(ja);
raa.addAsManifestResource(BasicDeployment15TestCase.class.getPackage(), "ra15.xml", "ra.xml");
return raa;
}
@Resource(mappedName = "java:jboss/name1")
private MultipleConnectionFactory1 connectionFactory1;
@Resource(mappedName = "java:jboss/Name3")
private MultipleAdminObject1 adminObject1;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testConfiguration() throws Throwable {
assertNotNull("CF1 not found", connectionFactory1);
assertNotNull("AO1 not found", adminObject1);
}
}
| 4,680 | 38.336134 | 152 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/MultiActivationFlatTestCase.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.integration.jca.moduledeployment;
import jakarta.annotation.Resource;
import jakarta.resource.cci.ConnectionFactory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/org
* modulename/main/org/jboss/
* modulename/main/org/jboss/package/
* modulename/main/org/jboss/package/First.class
* modulename/main/org/jboss/package/Second.class ...
*/
@RunWith(Arquillian.class)
@ServerSetup(MultiActivationFlatTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class MultiActivationFlatTestCase extends
AbstractModuleDeploymentTestCase {
private final String cf = "java:/testMeRA";
private final String cf1 = "java:/testMeRA1";
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra1.xml");
setConfiguration("double.xml");
}
@Override
protected String getSlot() {
return MultiActivationFlatTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static JavaArchive getDeployment() throws Exception {
return createDeployment();
}
@Resource(mappedName = cf)
private ConnectionFactory connectionFactory;
@Resource(mappedName = cf1)
private ConnectionFactory connectionFactory1;
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory() throws Throwable {
testConnectionFactory(connectionFactory);
}
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory1() throws Throwable {
testConnectionFactory(connectionFactory1);
}
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testProperties() throws Throwable {
testJndiObject(cf, "name=overRA", "name=overCF1");
}
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testProperties2() throws Throwable {
testJndiObject(cf1, "name=overRA", "name=overCF2");
}
/**
* Tests admin object
*
* @throws Exception
*/
@Test
public void testAdminObject() throws Exception {
testJndiObject("java:/testAO", "MultipleAdminObject1Impl",
"name=overAO1");
}
/**
* Tests admin object
*
* @throws Exception
*/
@Test
public void testAdminObject1() throws Exception {
testJndiObject("java:/testAO1", "MultipleAdminObject1Impl",
"name=overAO2");
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnections() throws Exception {
testConnection(cf);
testConnection(cf1);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 5,275 | 28.80791 | 83 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/TwoModulesFlatTestCase.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.integration.jca.moduledeployment;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/org
* modulename/main/org/jboss/
* modulename/main/org/jboss/package/
* modulename/main/org/jboss/package/First.class
* modulename/main/org/jboss/package/Second.class ...
*/
@RunWith(Arquillian.class)
@ServerSetup(TwoModulesFlatTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class TwoModulesFlatTestCase extends TwoRaFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup extends AbstractModuleDeploymentTestCaseSetup {
public static ModelNode address1;
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra1.xml");
addModule("org/jboss/ironjacamar/ra16out1", "module1.xml");
fillModuleWithFlatClasses("ra1.xml");
setConfiguration("mod-2.xml");
address1 = address.clone();
setConfiguration("basic.xml");
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
remove(address1, managementClient);
removeModule("org/jboss/ironjacamar/ra16out1", true);
super.tearDown(managementClient, containerId);
}
@Override
protected String getSlot() {
return TwoModulesFlatTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnection2() throws Exception {
final ModelNode address1 = ModuleAcDeploymentTestCaseSetup.address1.clone();
address1.add("connection-definitions", cf1);
address1.protect();
final ModelNode operation1 = new ModelNode();
operation1.get(OP).set("test-connection-in-pool");
operation1.get(OP_ADDR).set(address1);
executeOperation(operation1);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 4,182 | 36.684685 | 102 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/BasicFlatTestCase.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.integration.jca.moduledeployment;
import jakarta.annotation.Resource;
import jakarta.resource.cci.ConnectionFactory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/org
* modulename/main/org/jboss/
* modulename/main/org/jboss/package/
* modulename/main/org/jboss/package/First.class
* modulename/main/org/jboss/package/Second.class ...
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicFlatTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class BasicFlatTestCase extends AbstractModuleDeploymentTestCase {
private final String cf = "java:/testMeRA";
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra1.xml");
setConfiguration("basic.xml");
}
@Override
protected String getSlot() {
return BasicFlatTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static JavaArchive getDeployment() throws Exception {
return createDeployment();
}
@Resource(mappedName = cf)
private ConnectionFactory connectionFactory;
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory() throws Throwable {
testConnectionFactory(connectionFactory);
}
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory1() throws Throwable {
testJndiObject(cf, "MultipleConnectionFactory1Impl", "name=MCF", "name=RA");
}
/**
* Tests admin object
*
* @throws Exception
*/
@Test
public void testAdminObject() throws Exception {
testJndiObject("java:/testAO", "MultipleAdminObject1Impl", "name=AO");
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnection() throws Exception {
testConnection(cf);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 4,384 | 30.099291 | 84 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/TwoModulesOfDifferentTypeTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2013, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.moduledeployment;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p/>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes, packed in .jar file
* <p/>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(TwoModulesOfDifferentTypeTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class TwoModulesOfDifferentTypeTestCase extends TwoModulesFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup extends AbstractModuleDeploymentTestCaseSetup {
public static ModelNode address1;
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra1.xml");
addModule("org/jboss/ironjacamar/ra16out1", "module1-jar.xml");
fillModuleWithJar("ra1.xml");
setConfiguration("mod-2.xml");
address1 = address.clone();
setConfiguration("basic.xml");
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
remove(address1, managementClient);
removeModule("org/jboss/ironjacamar/ra16out1", true);
super.tearDown(managementClient, containerId);
}
@Override
protected String getSlot() {
return TwoModulesOfDifferentTypeTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnection2() throws Exception {
final ModelNode address1 = ModuleAcDeploymentTestCaseSetup.address1.clone();
address1.add("connection-definitions", cf1);
address1.protect();
final ModelNode operation1 = new ModelNode();
operation1.get(OP).set("test-connection-in-pool");
operation1.get(OP_ADDR).set(address1);
executeOperation(operation1);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 4,007 | 35.436364 | 102 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/AbstractModuleDeploymentTestCaseSetup.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.integration.jca.moduledeployment;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.FAILURE_DESCRIPTION;
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.OUTCOME;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.PROCESS_STATE;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.RESPONSE_HEADERS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUCCESS;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.regex.Pattern;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.as.connector.subsystems.resourceadapters.Namespace;
import org.jboss.as.connector.subsystems.resourceadapters.ResourceAdapterSubsystemParser;
import org.jboss.as.controller.ControlledProcessState;
import org.jboss.as.test.integration.jca.rar.MultipleConnectionFactory1;
import org.jboss.as.test.integration.management.base.AbstractMgmtServerSetupTask;
import org.jboss.as.test.integration.management.util.MgmtOperationException;
import org.jboss.as.test.shared.FileUtils;
import org.jboss.as.test.shared.ServerReload;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.exporter.ExplodedExporter;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* @author <a href="[email protected]">Ivo Studensky</a>
*/
public abstract class AbstractModuleDeploymentTestCaseSetup extends AbstractMgmtServerSetupTask {
private static final Logger log = Logger.getLogger(AbstractModuleDeploymentTestCaseSetup.class);
private static final Pattern MODULE_SLOT_PATTERN = Pattern.compile("slot=\"main\"");
protected File testModuleRoot;
protected File slot;
public static ModelNode address;
protected final String defaultPath = "org/jboss/ironjacamar/ra16out";
private boolean reloadRequired = false;
private List<Path> toRemove = new LinkedList<>();
public void addModule(final String moduleName) throws Exception {
addModule(moduleName, "module.xml");
}
public void addModule(final String moduleName, String moduleXml) throws Exception {
testModuleRoot = new File(getModulePath(), moduleName);
removeModule(moduleName);
createTestModule(moduleXml);
}
public void removeModule(final String moduleName) throws Exception {
removeModule(moduleName, false);
}
public void removeModule(final String moduleName, boolean deleteParent) throws Exception {
testModuleRoot = new File(getModulePath(), moduleName);
File file = testModuleRoot;
if (deleteParent) {
while (!getModulePath().equals(file.getParentFile())) { file = file.getParentFile(); }
}
toRemove.add(file.toPath());
}
private void deleteRecursively(Path file) throws IOException {
if (Files.exists(file)) {
Files.walkFileTree(file, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
Files.delete(file);
return FileVisitResult.CONTINUE;
}
@Override
public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
Files.delete(dir);
return FileVisitResult.CONTINUE;
}
});
}
}
private void createTestModule(String moduleXml) throws IOException {
slot = new File(testModuleRoot, getSlot());
if (slot.exists()) {
throw new IllegalArgumentException(slot + " already exists");
}
if (!slot.mkdirs()) {
throw new IllegalArgumentException("Could not create " + slot);
}
URL url = this.getClass().getResource(moduleXml);
if (url == null) {
throw new IllegalStateException("Could not find " + moduleXml);
}
copyModuleXml(slot, url.openStream());
}
protected void copyFile(File target, InputStream src) throws IOException {
Files.copy(src, target.toPath());
}
protected void copyModuleXml(File slot, InputStream src) throws IOException {
try (BufferedReader in = new BufferedReader(new InputStreamReader(src, StandardCharsets.UTF_8))) {
String line;
List<String> lines = new ArrayList<>();
while ((line = in.readLine()) != null) {
// replace slot name in the module xml file
line = MODULE_SLOT_PATTERN.matcher(line).replaceAll("slot=\"" + getSlot() + "\"");
lines.add(line);
}
Files.write(slot.toPath().resolve("module.xml"), lines, StandardCharsets.UTF_8);
}
}
private File getModulePath() {
String modulePath = System.getProperty("module.path", null);
if (modulePath == null) {
String jbossHome = System.getProperty("jboss.home", null);
if (jbossHome == null) {
throw new IllegalStateException(
"Neither -Dmodule.path nor -Djboss.home were set");
}
modulePath = jbossHome + File.separatorChar + "modules";
} else {
modulePath = modulePath.split(File.pathSeparator)[0];
}
File moduleDir = new File(modulePath);
if (!moduleDir.exists()) {
throw new IllegalStateException(
"Determined module path does not exist");
}
if (!moduleDir.isDirectory()) {
throw new IllegalStateException(
"Determined module path is not a dir");
}
return moduleDir;
}
@Override
public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception {
try {
remove(address, managementClient);
} finally {
removeModule(defaultPath, true);
}
if (reloadRequired) {
ServerReload.executeReloadAndWaitForCompletion(managementClient);
}
for (Path p : toRemove) {
deleteRecursively(p);
}
toRemove.clear();
}
protected void remove(final ModelNode address, final ManagementClient managementClient) throws IOException, MgmtOperationException {
final ModelNode operation = new ModelNode();
operation.get(OP).set("remove");
operation.get(OP_ADDR).set(address);
final ModelNode result = managementClient.getControllerClient().execute(operation);
if (!SUCCESS.equals(result.get(OUTCOME).asString())) {
throw new MgmtOperationException("Module removal failed: " + result.get(FAILURE_DESCRIPTION), operation, result);
}
final ModelNode responseHeaders = result.get(RESPONSE_HEADERS);
if (responseHeaders.hasDefined(PROCESS_STATE) && ControlledProcessState.State.RELOAD_REQUIRED.toString().equals(responseHeaders.get(PROCESS_STATE).asString())) {
this.reloadRequired = true;
}
}
@Override
protected void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath);
}
protected void setConfiguration(String fileName) throws Exception {
String xml = FileUtils.readFile(this.getClass(), fileName);
// replace slot name in the configuration
xml = MODULE_SLOT_PATTERN.matcher(xml).replaceAll("slot=\"" + getSlot() + "\"");
List<ModelNode> operations = xmlToModelOperations(xml,
Namespace.CURRENT.getUriString(),
new ResourceAdapterSubsystemParser());
address = operations.get(1).get("address");
operations.remove(0);
for (ModelNode op : operations) {
executeOperation(op);
}
final ModelNode operation = new ModelNode();
operation.get(OP).set("activate");
operation.get(OP_ADDR).set(address);
executeOperation(operation);
//executeOperation(operationListToCompositeOperation(operations));
}
/**
* Creates module structure for uncompressed RA archive. RA classes are in
* flat form too
*
* @throws Exception
*/
protected void fillModuleWithFlatClasses(String raFile) throws Exception {
ResourceAdapterArchive rar = ShrinkWrap
.create(ResourceAdapterArchive.class);
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ra16out.jar");
jar.addPackage(MultipleConnectionFactory1.class.getPackage()).addClass(
jakarta.jms.MessageListener.class);
rar.addAsManifestResource(this.getClass().getPackage(), raFile,
"ra.xml");
rar.as(ExplodedExporter.class).exportExploded(testModuleRoot, getSlot());
jar.as(ExplodedExporter.class).exportExploded(testModuleRoot, getSlot());
}
/**
* Creates module structure for uncompressed RA archive.
* RA classes are packed in .jar archive
*
* @throws Exception
*/
protected void fillModuleWithJar(String raFile) throws Exception {
ResourceAdapterArchive rar = ShrinkWrap
.create(ResourceAdapterArchive.class);
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ra16out.jar");
jar.addPackage(MultipleConnectionFactory1.class.getPackage());
rar.addAsManifestResource(
PureJarTestCase.class.getPackage(), raFile, "ra.xml");
rar.as(ExplodedExporter.class).exportExploded(testModuleRoot, getSlot());
copyFile(new File(slot, "ra16out.jar"), jar.as(ZipExporter.class).exportAsInputStream());
}
/**
* Returns basic address
*
* @return address
*/
public static ModelNode getAddress() {
return address;
}
/**
* This should be overridden to return a unique slot name for each test-case class / module.
* We need this since custom modules are not supported to be removing at runtime, see WFLY-1560.
*
* @return a name of the slot of the test module
*/
protected abstract String getSlot();
}
| 12,115 | 40.493151 | 169 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/TwoRaJarTestCase.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.integration.jca.moduledeployment;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p/>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes, packed in .jar file
* <p/>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(TwoRaJarTestCase.ModuleAcDeploymentTestCaseSetup1.class)
public class TwoRaJarTestCase extends TwoRaFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup1 extends AbstractModuleDeploymentTestCaseSetup {
static ModelNode address1;
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath, "module-jar.xml");
fillModuleWithJar("ra1.xml");
setConfiguration("second.xml");
address1 = address.clone();
setConfiguration("basic.xml");
}
@Override
public void tearDown(ManagementClient managementClient,
String containerId) throws Exception {
remove(address1, managementClient);
super.tearDown(managementClient, containerId);
}
@Override
protected String getSlot() {
return TwoRaJarTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnection2() throws Exception {
final ModelNode address1 = ModuleAcDeploymentTestCaseSetup1.address1.clone();
address1.add("connection-definitions", cf1);
address1.protect();
final ModelNode operation1 = new ModelNode();
operation1.get(OP).set("test-connection-in-pool");
operation1.get(OP_ADDR).set(address1);
executeOperation(operation1);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup1.getAddress();
}
}
| 3,793 | 34.792453 | 97 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/PureJarTestCase.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.integration.jca.moduledeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes, packed in .jar file
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(PureJarTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class PureJarTestCase extends PureFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath, "module-jar.xml");
fillModuleWithJar("ra.xml");
setConfiguration("pure.xml");
}
@Override
protected String getSlot() {
return PureJarTestCase.class.getSimpleName().toLowerCase();
}
}
}
| 2,453 | 35.088235 | 81 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/MultiObjectActivationFlatTestCase.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.integration.jca.moduledeployment;
import jakarta.annotation.Resource;
import jakarta.resource.cci.ConnectionFactory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/org
* modulename/main/org/jboss/
* modulename/main/org/jboss/package/
* modulename/main/org/jboss/package/First.class
* modulename/main/org/jboss/package/Second.class ...
*/
@RunWith(Arquillian.class)
@ServerSetup(MultiObjectActivationFlatTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class MultiObjectActivationFlatTestCase extends
AbstractModuleDeploymentTestCase {
private final String cf = "java:/testMeRA";
private final String cf1 = "java:/testMeRA1";
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra2.xml");
setConfiguration("multi.xml");
}
@Override
protected String getSlot() {
return MultiObjectActivationFlatTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static JavaArchive getDeployment() throws Exception {
return createDeployment();
}
@Resource(mappedName = cf)
private ConnectionFactory connectionFactory;
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory() throws Throwable {
testConnectionFactory(connectionFactory);
}
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory1() throws Throwable {
testJndiObject(cf1, "MultipleConnectionFactory2Impl");
}
/**
* Tests admin object
*
* @throws Exception
*/
@Test
public void testAdminObject() throws Exception {
testJndiObject("java:/testAO", "MultipleAdminObject1Impl");
}
/**
* Tests admin object
*
* @throws Exception
*/
@Test
public void testAdminObject1() throws Exception {
testJndiObject("java:/testAO1", "MultipleAdminObject2Impl");
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnections() throws Exception {
testConnection(cf);
testConnection(cf1);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 4,701 | 29.532468 | 89 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/BasicJarTestCase.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.integration.jca.moduledeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes, packed in .jar file
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(BasicJarTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class BasicJarTestCase extends BasicFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup extends AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath, "module-jar.xml");
fillModuleWithJar("ra1.xml");
setConfiguration("basic.xml");
}
@Override
protected String getSlot() {
return BasicJarTestCase.class.getSimpleName().toLowerCase();
}
}
}
| 2,447 | 35.537313 | 96 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/TwoRaFlatTestCase.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.integration.jca.moduledeployment;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import jakarta.annotation.Resource;
import jakarta.resource.cci.ConnectionFactory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/org
* modulename/main/org/jboss/
* modulename/main/org/jboss/package/
* modulename/main/org/jboss/package/First.class
* modulename/main/org/jboss/package/Second.class ...
*/
@RunWith(Arquillian.class)
@ServerSetup(TwoRaFlatTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class TwoRaFlatTestCase extends AbstractModuleDeploymentTestCase {
protected final String cf = "java:/testMeRA";
protected final String cf1 = "java:/testMeRA1";
static class ModuleAcDeploymentTestCaseSetup extends AbstractModuleDeploymentTestCaseSetup {
static ModelNode address1;
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra1.xml");
setConfiguration("second.xml");
address1 = address.clone();
setConfiguration("basic.xml");
}
@Override
public void tearDown(ManagementClient managementClient, String containerId) throws Exception {
remove(address1, managementClient);
super.tearDown(managementClient, containerId);
}
@Override
protected String getSlot() {
return TwoRaFlatTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static JavaArchive getDeployment() throws Exception {
return createDeployment();
}
@Resource(mappedName = cf)
private ConnectionFactory connectionFactory;
@Resource(mappedName = cf1)
private ConnectionFactory connectionFactory1;
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory() throws Throwable {
testConnectionFactory(connectionFactory);
}
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactoryProperties() throws Throwable {
testJndiObject(cf, "MultipleConnectionFactory1Impl", "name=MCF", "name=RA");
}
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory1() throws Throwable {
testConnectionFactory(connectionFactory1);
}
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactoryProperties1() throws Throwable {
testJndiObject(cf1, "MultipleConnectionFactory1Impl", "name=MCF", "name=RA");
}
/**
* Tests admin object
*
* @throws Exception
*/
@Test
public void testAdminObject() throws Exception {
testJndiObject("java:/testAO", "MultipleAdminObject1Impl", "name=AO");
}
/**
* Tests admin object
*
* @throws Exception
*/
@Test
public void testAdminObject1() throws Exception {
testJndiObject("java:/testAO1", "MultipleAdminObject1Impl", "name=AO");
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnection1() throws Exception {
testConnection(cf);
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnection2() throws Exception {
final ModelNode address1 = ModuleAcDeploymentTestCaseSetup.address1.clone();
address1.add("connection-definitions", cf1);
address1.protect();
final ModelNode operation1 = new ModelNode();
operation1.get(OP).set("test-connection-in-pool");
operation1.get(OP_ADDR).set(address1);
executeOperation(operation1);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 6,318 | 30.282178 | 102 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/PureFlatTestCase.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.integration.jca.moduledeployment;
import jakarta.annotation.Resource;
import jakarta.resource.cci.ConnectionFactory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/org
* modulename/main/org/jboss/
* modulename/main/org/jboss/package/
* modulename/main/org/jboss/package/First.class
* modulename/main/org/jboss/package/Second.class ...
*/
@RunWith(Arquillian.class)
@ServerSetup(PureFlatTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class PureFlatTestCase extends AbstractModuleDeploymentTestCase {
private final String cf = "java:/testMeRA";
static class ModuleAcDeploymentTestCaseSetup extends AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra.xml");
setConfiguration("pure.xml");
}
@Override
protected String getSlot() {
return PureFlatTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static JavaArchive getDeployment() throws Exception {
return createDeployment();
}
@Resource(mappedName = cf)
private ConnectionFactory connectionFactory;
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory() throws Throwable {
testConnectionFactory(connectionFactory);
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnection() throws Exception {
testConnection(cf);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 3,880 | 31.889831 | 96 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/MultiActivationJarTestCase.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.integration.jca.moduledeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes, packed in .jar file
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(MultiActivationJarTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class MultiActivationJarTestCase extends MultiActivationFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath, "module-jar.xml");
fillModuleWithJar("ra1.xml");
setConfiguration("double.xml");
}
@Override
protected String getSlot() {
return MultiActivationJarTestCase.class.getSimpleName().toLowerCase();
}
}
}
| 2,500 | 35.779412 | 82 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/InflowJarTestCase.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.integration.jca.moduledeployment;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import java.util.Set;
import jakarta.resource.spi.ActivationSpec;
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.connector.util.ConnectorServices;
import org.jboss.as.test.integration.jca.beanvalidation.NegativeValidationTestCase;
import org.jboss.as.test.integration.jca.beanvalidation.ra.ValidConnectionFactory;
import org.jboss.dmr.ModelNode;
import org.jboss.jca.core.spi.mdr.MetadataRepository;
import org.jboss.jca.core.spi.rar.Endpoint;
import org.jboss.jca.core.spi.rar.MessageListener;
import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(InflowJarTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class InflowJarTestCase extends AbstractModuleDeploymentTestCase {
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath, "module-jar.xml");
fillModuleWithJar("ra3.xml");
setConfiguration("inflow.xml");
}
@Override
protected String getSlot() {
return InflowJarTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static Archive<?> createRarDeployment() throws Exception {
JavaArchive ja = createDeployment(false);
ResourceAdapterArchive raa = ShrinkWrap.create(
ResourceAdapterArchive.class, "inflow.rar");
ja.addPackage(ValidConnectionFactory.class.getPackage());
raa.addAsLibrary(ja);
raa.addAsManifestResource(
NegativeValidationTestCase.class.getPackage(), "ra.xml",
"ra.xml")
.addAsManifestResource(
new StringAsset(
"Dependencies: javax.inject.api,org.jboss.as.connector,org.jboss.as.controller-client,org.jboss.dmr\n"),
"MANIFEST.MF");
return raa;
}
@ArquillianResource
ServiceContainer serviceContainer;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testRegistryConfiguration() throws Throwable {
assertNotNull(serviceContainer);
ServiceController<?> controller = serviceContainer
.getService(ConnectorServices.RA_REPOSITORY_SERVICE);
assertNotNull(controller);
ResourceAdapterRepository repository = (ResourceAdapterRepository) controller
.getValue();
assertNotNull(repository);
Set<String> ids = repository.getResourceAdapters();
assertNotNull(ids);
String piId = getElementContaining(ids, "MultipleResourceAdapter");
assertNotNull(piId);
Endpoint endpoint = repository.getEndpoint(piId);
assertNotNull(endpoint);
List<MessageListener> listeners = repository.getMessageListeners(piId);
assertNotNull(listeners);
assertEquals(1, listeners.size());
MessageListener listener = listeners.get(0);
ActivationSpec as = listener.getActivation().createInstance();
assertNotNull(as);
assertNotNull(as.getResourceAdapter());
}
/**
* Tests metadata configuration
*
* @throws Throwable
*/
@Test
public void testMetadataConfiguration() throws Throwable {
ServiceController<?> controller = serviceContainer
.getService(ConnectorServices.IRONJACAMAR_MDR);
assertNotNull(controller);
MetadataRepository repository = (MetadataRepository) controller
.getValue();
assertNotNull(repository);
Set<String> ids = repository.getResourceAdapters();
assertNotNull(ids);
String piId = getElementContaining(ids, "inflow2");
assertNotNull(piId);
assertNotNull(repository.getResourceAdapter(piId));
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 6,544 | 35.361111 | 136 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/InflowFlatTestCase.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.integration.jca.moduledeployment;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.List;
import java.util.Set;
import jakarta.resource.spi.ActivationSpec;
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.connector.util.ConnectorServices;
import org.jboss.as.test.integration.jca.beanvalidation.NegativeValidationTestCase;
import org.jboss.as.test.integration.jca.beanvalidation.ra.ValidConnectionFactory;
import org.jboss.dmr.ModelNode;
import org.jboss.jca.core.spi.mdr.MetadataRepository;
import org.jboss.jca.core.spi.rar.Endpoint;
import org.jboss.jca.core.spi.rar.MessageListener;
import org.jboss.jca.core.spi.rar.ResourceAdapterRepository;
import org.jboss.msc.service.ServiceContainer;
import org.jboss.msc.service.ServiceController;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/org
* modulename/main/org/jboss/
* modulename/main/org/jboss/package/
* modulename/main/org/jboss/package/First.class
* modulename/main/org/jboss/package/Second.class ...
*/
@RunWith(Arquillian.class)
@ServerSetup(InflowFlatTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class InflowFlatTestCase extends AbstractModuleDeploymentTestCase {
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra3.xml");
setConfiguration("inflow.xml");
}
@Override
protected String getSlot() {
return InflowFlatTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static Archive<?> createRarDeployment() throws Exception {
JavaArchive ja = createDeployment(false);
ResourceAdapterArchive raa = ShrinkWrap.create(
ResourceAdapterArchive.class, "inflow.rar");
ja.addPackage(ValidConnectionFactory.class.getPackage());
raa.addAsLibrary(ja);
raa.addAsManifestResource(
NegativeValidationTestCase.class.getPackage(), "ra.xml",
"ra.xml")
.addAsManifestResource(
new StringAsset(
"Dependencies: javax.inject.api,org.jboss.as.connector,org.jboss.as.controller-client,org.jboss.dmr\n"),
"MANIFEST.MF");
return raa;
}
@ArquillianResource
ServiceContainer serviceContainer;
/**
* Test configuration
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testRegistryConfiguration() throws Throwable {
assertNotNull(serviceContainer);
ServiceController<?> controller = serviceContainer
.getService(ConnectorServices.RA_REPOSITORY_SERVICE);
assertNotNull(controller);
ResourceAdapterRepository repository = (ResourceAdapterRepository) controller
.getValue();
assertNotNull(repository);
Set<String> ids = repository.getResourceAdapters();
assertNotNull(ids);
String piId = getElementContaining(ids, "MultipleResourceAdapter");
assertNotNull(piId);
Endpoint endpoint = repository.getEndpoint(piId);
assertNotNull(endpoint);
List<MessageListener> listeners = repository.getMessageListeners(piId);
assertNotNull(listeners);
assertEquals(1, listeners.size());
MessageListener listener = listeners.get(0);
ActivationSpec as = listener.getActivation().createInstance();
assertNotNull(as);
assertNotNull(as.getResourceAdapter());
}
/**
* Tests metadata configuration
*
* @throws Throwable
*/
@Test
public void testMetadataConfiguration() throws Throwable {
ServiceController<?> controller = serviceContainer
.getService(ConnectorServices.IRONJACAMAR_MDR);
assertNotNull(controller);
MetadataRepository repository = (MetadataRepository) controller
.getValue();
assertNotNull(repository);
Set<String> ids = repository.getResourceAdapters();
assertNotNull(ids);
String piId = getElementContaining(ids, "inflow2");
assertNotNull(piId);
assertNotNull(repository.getResourceAdapter(piId));
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 6,744 | 35.263441 | 136 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/TwoModulesJarTestCase.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.integration.jca.moduledeployment;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p/>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes, packed in .jar file
* <p/>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(TwoModulesJarTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class TwoModulesJarTestCase extends TwoModulesFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup extends AbstractModuleDeploymentTestCaseSetup {
static ModelNode address1;
static ModelNode address2;
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath, "module-jar.xml");
fillModuleWithJar("ra1.xml");
addModule("org/jboss/ironjacamar/ra16out1", "module1-jar.xml");
fillModuleWithJar("ra1.xml");
setConfiguration("mod-2.xml");
address1 = address.clone();
setConfiguration("basic.xml");
}
@Override
public void tearDown(ManagementClient managementClient,
String containerId) throws Exception {
remove(address1, managementClient);
removeModule("org/jboss/ironjacamar/ra16out1", true);
super.tearDown(managementClient, containerId);
}
@Override
protected String getSlot() {
return TwoModulesJarTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnection2() throws Exception {
final ModelNode address1 = ModuleAcDeploymentTestCaseSetup.address1.clone();
address1.add("connection-definitions", cf1);
address1.protect();
final ModelNode operation1 = new ModelNode();
operation1.get(OP).set("test-connection-in-pool");
operation1.get(OP_ADDR).set(address1);
executeOperation(operation1);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 4,029 | 34.982143 | 96 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/MultiObjectActivationJarTestCase.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.integration.jca.moduledeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes, packed in .jar file
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(MultiObjectActivationJarTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class MultiObjectActivationJarTestCase extends MultiObjectActivationFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath, "module-jar.xml");
fillModuleWithJar("ra2.xml");
setConfiguration("multi.xml");
}
@Override
protected String getSlot() {
return MultiObjectActivationJarTestCase.class.getSimpleName().toLowerCase();
}
}
}
| 2,523 | 36.117647 | 89 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/PartialObjectActivationFlatTestCase.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.integration.jca.moduledeployment;
import jakarta.annotation.Resource;
import jakarta.resource.cci.ConnectionFactory;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes in flat form (under package structure)
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/org
* modulename/main/org/jboss/
* modulename/main/org/jboss/package/
* modulename/main/org/jboss/package/First.class
* modulename/main/org/jboss/package/Second.class ...
*/
@RunWith(Arquillian.class)
@ServerSetup(PartialObjectActivationFlatTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class PartialObjectActivationFlatTestCase extends
AbstractModuleDeploymentTestCase {
private final String cf = "java:/testMeRA";
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
super.doSetup(managementClient);
fillModuleWithFlatClasses("ra2.xml");
setConfiguration("basic.xml");
}
@Override
protected String getSlot() {
return PartialObjectActivationFlatTestCase.class.getSimpleName().toLowerCase();
}
}
/**
* Define the deployment
*
* @return The deployment archive
*/
@Deployment
public static JavaArchive getDeployment() throws Exception {
return createDeployment();
}
@Resource(mappedName = cf)
private ConnectionFactory connectionFactory;
/**
* Tests connection factory
*
* @throws Throwable in case of an error
*/
@Test
public void testConnectionFactory() throws Throwable {
testConnectionFactory(connectionFactory);
}
/**
* Tests admin object
*
* @throws Exception
*/
@Test
public void testAdminObject() throws Exception {
testJndiObject("java:/testAO", "MultipleAdminObject1Impl");
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
@Test
@RunAsClient
public void testConnections() throws Exception {
testConnection(cf);
}
@Override
protected ModelNode getAddress() {
return ModuleAcDeploymentTestCaseSetup.getAddress();
}
}
| 4,174 | 30.628788 | 91 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/PartialObjectActivationJarTestCase.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.integration.jca.moduledeployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.arquillian.api.ServerSetup;
import org.jboss.as.arquillian.container.ManagementClient;
import org.junit.runner.RunWith;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
* <p>
* Tests for module deployment of resource adapter archive in
* uncompressed form with classes, packed in .jar file
* <p>
* Structure of module is:
* modulename
* modulename/main
* modulename/main/module.xml
* modulename/main/META-INF
* modulename/main/META-INF/ra.xml
* modulename/main/module.jar
*/
@RunWith(Arquillian.class)
@ServerSetup(PartialObjectActivationJarTestCase.ModuleAcDeploymentTestCaseSetup.class)
public class PartialObjectActivationJarTestCase extends PartialObjectActivationFlatTestCase {
static class ModuleAcDeploymentTestCaseSetup extends
AbstractModuleDeploymentTestCaseSetup {
@Override
public void doSetup(ManagementClient managementClient) throws Exception {
addModule(defaultPath, "module-jar.xml");
fillModuleWithJar("ra2.xml");
setConfiguration("basic.xml");
}
@Override
protected String getSlot() {
return PartialObjectActivationJarTestCase.class.getSimpleName().toLowerCase();
}
}
}
| 2,531 | 36.235294 | 93 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/moduledeployment/AbstractModuleDeploymentTestCase.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.integration.jca.moduledeployment;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.util.Iterator;
import java.util.Set;
import javax.naming.InitialContext;
import jakarta.resource.cci.Connection;
import jakarta.resource.cci.ConnectionFactory;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.integration.management.base.ContainerResourceMgmtTestBase;
import org.jboss.as.test.integration.management.util.MgmtOperationException;
import org.jboss.dmr.ModelNode;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.staxmapper.XMLElementReader;
import org.jboss.staxmapper.XMLElementWriter;
/**
* AS7-5768 -Support for RA module deployment
*
* @author <a href="[email protected]">Vladimir Rastseluev</a>
*/
public abstract class AbstractModuleDeploymentTestCase extends
ContainerResourceMgmtTestBase {
/**
* Define the deployment
*
* @return The deployment archive
*/
public static JavaArchive createDeployment(boolean withDependencies) throws Exception {
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, "multiple.jar");
ja.addClasses(MgmtOperationException.class, XMLElementReader.class,
XMLElementWriter.class);
ja.addPackage(AbstractMgmtTestBase.class.getPackage())
.addPackage(AbstractModuleDeploymentTestCase.class.getPackage());
if (withDependencies) {
ja.addAsManifestResource(
new StringAsset(
"Dependencies: org.jboss.as.controller-client,org.jboss.dmr,javax.inject.api,org.jboss.as.connector,org.wildfly.common\n"),
"MANIFEST.MF");
}
return ja;
}
/**
* Define the deployment
*
* @return The deployment archive
*/
public static JavaArchive createDeployment() throws Exception {
return createDeployment(true);
}
/**
* Test configuration
*
* @throws Throwable in case of an error
*/
public void testConnectionFactory(ConnectionFactory connectionFactory)
throws Throwable {
assertNotNull(connectionFactory);
Connection c = connectionFactory.getConnection();
assertNotNull(c);
c.close();
}
/**
* Tests connection in pool
*
* @throws Exception in case of error
*/
public void testConnection(String conName) throws Exception {
final ModelNode address1 = getAddress().clone();
address1.add("connection-definitions", conName);
address1.protect();
final ModelNode operation1 = new ModelNode();
operation1.get(OP).set("test-connection-in-pool");
operation1.get(OP_ADDR).set(address1);
executeOperation(operation1);
}
/**
* Returns basic address of resource adapter
*
* @return address
*/
protected abstract ModelNode getAddress();
/**
* Finding object by JNDI name and checks, if its String representation
* contains expected substrings
*
* @param jndiName of object
* @param contains - substring, must be contained
* @throws Exception
*/
public void testJndiObject(String jndiName, String... contains)
throws Exception {
Object o = new InitialContext().lookup(jndiName);
assertNotNull(o);
for (String c : contains) {
assertTrue(o.toString() + " should contain " + c, o.toString()
.contains(c));
}
}
/**
* Checks Set if there is a String element, containing some substring and
* returns it
*
* @param ids - Set
* @param contain - substring
* @return String
*/
public String getElementContaining(Set<String> ids, String contain) {
Iterator<String> it = ids.iterator();
while (it.hasNext()) {
String t = it.next();
if (t.contains(contain)) {
return t;
}
}
return null;
}
}
| 5,416 | 32.438272 | 151 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/DatasourceEnableAttributeTestBase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
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.SYSTEM_PROPERTY;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.VALUE;
import java.io.IOException;
import org.jboss.as.test.integration.management.jca.DsMgmtTestBase;
import org.jboss.as.test.integration.management.util.MgmtOperationException;
import org.jboss.as.test.shared.ServerReload;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import org.junit.Assert;
import org.junit.Test;
/**
* A basic testing of setting/unsetting "enable" attribute of datasource.
*
* @author <a href="mailto:[email protected]>Ondra Chaloupka</a>
*/
public abstract class DatasourceEnableAttributeTestBase extends DsMgmtTestBase {
private static final Logger log = Logger.getLogger(DatasourceEnableAttributeTestBase.class);
private static final String DS_ENABLED_SYSTEM_PROPERTY_NAME = "ds.enabled";
@Test
public void addDatasourceEnabled() throws Exception {
Datasource ds = Datasource.Builder("testDatasourceEnabled")
.enabled(true)
.build();
try {
createDataSource(ds);
testConnection(ds);
} finally {
removeDataSourceSilently(ds);
}
}
@Test(expected = MgmtOperationException.class)
public void addDatasourceDisabled() throws Exception {
Datasource ds = Datasource.Builder("testDatasourceDisabled")
.enabled(false)
.build();
try {
createDataSource(ds);
testConnection(ds);
} finally {
removeDataSourceSilently(ds);
}
}
@Test
public void enableLater() throws Exception {
Datasource ds = Datasource.Builder("testDatasourceLater")
.enabled(false)
.build();
try {
createDataSource(ds);
try {
testConnection(ds);
Assert.fail("Datasource " + ds + " is disabled. Test connection can't succeed.");
} catch (MgmtOperationException moe) {
// expecting that datasource won't be available 'online'
}
enableDatasource(ds);
testConnection(ds);
} finally {
removeDataSourceSilently(ds);
}
}
@Test
public void enableBySystemProperty() throws Exception {
Datasource ds = Datasource.Builder("testDatasourceEnableBySystem")
.enabled(wrapProp(DS_ENABLED_SYSTEM_PROPERTY_NAME))
.build();
try {
addSystemProperty(DS_ENABLED_SYSTEM_PROPERTY_NAME, "true");
createDataSource(ds);
testConnection(ds);
} finally {
removeSystemPropertySilently(DS_ENABLED_SYSTEM_PROPERTY_NAME);
removeDataSourceSilently(ds);
}
}
@Test(expected = MgmtOperationException.class)
public void disableBySystemProperty() throws Exception {
Datasource ds = Datasource.Builder("testDatasourceDisableBySystem")
.enabled(wrapProp(DS_ENABLED_SYSTEM_PROPERTY_NAME))
.build();
try {
addSystemProperty(DS_ENABLED_SYSTEM_PROPERTY_NAME, "false");
createDataSource(ds);
testConnection(ds);
} finally {
removeSystemPropertySilently(DS_ENABLED_SYSTEM_PROPERTY_NAME);
removeDataSourceSilently(ds);
}
}
@Test
public void allBySystemProperty() throws Exception {
String url = "ds.url";
String username = "ds.username";
String password = "ds.password";
String jndiName = "ds.jndi";
String driverName = "ds.drivername";
Datasource ds = Datasource.Builder("testAllBySystem")
.connectionUrl(wrapProp(url))
.userName(wrapProp(username))
.password(wrapProp(password))
.jndiName(wrapProp(jndiName))
.driverName(wrapProp(driverName))
.enabled(wrapProp(DS_ENABLED_SYSTEM_PROPERTY_NAME))
.build();
try {
Datasource defaultPropertyDs = Datasource.Builder("temporary").build();
addSystemProperty(url, defaultPropertyDs.getConnectionUrl());
addSystemProperty(username, defaultPropertyDs.getUserName());
addSystemProperty(password, defaultPropertyDs.getPassword());
addSystemProperty(jndiName, defaultPropertyDs.getJndiName());
addSystemProperty(driverName, defaultPropertyDs.getDriverName());
addSystemProperty(DS_ENABLED_SYSTEM_PROPERTY_NAME, "true");
createDataSource(ds);
testConnection(ds);
} finally {
removeDataSourceSilently(ds);
removeSystemPropertySilently(url);
removeSystemPropertySilently(username);
removeSystemPropertySilently(password);
removeSystemPropertySilently(jndiName);
removeSystemPropertySilently(driverName);
removeSystemPropertySilently(DS_ENABLED_SYSTEM_PROPERTY_NAME);
}
}
/*
* Abstract method overriden in test subclasses
*/
protected abstract ModelNode createDataSource(Datasource datasource) throws Exception;
protected abstract void removeDataSourceSilently(Datasource datasource);
protected abstract ModelNode getDataSourceAddress(Datasource datasource);
protected abstract void testConnection(Datasource datasource) throws Exception;
/**
* Common attribute for add datsource operation for non-XA and XA datasource creation.
*/
protected ModelNode getDataSourceOperation(ModelNode address, Datasource datasource) {
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
operation.get("jndi-name").set(datasource.getJndiName());
operation.get("driver-name").set(datasource.getDriverName());
operation.get("enabled").set(datasource.getEnabled());
operation.get("user-name").set(datasource.getUserName());
operation.get("password").set(datasource.getPassword());
return operation;
}
protected void enableDatasource(Datasource ds) throws Exception {
ModelNode address = getDataSourceAddress(ds);
writeAttribute(address, "enabled", "true");
// enabling datasource requires reload
ServerReload.executeReloadAndWaitForCompletion(getManagementClient());
}
protected ModelNode writeAttribute(ModelNode address, String attribute, String value) throws Exception {
final ModelNode operation = new ModelNode();
operation.get(OP_ADDR).set(address);
operation.get(OP).set("write-attribute");
operation.get("name").set(attribute);
operation.get("value").set(value);
return executeOperation(operation);
}
private ModelNode addSystemProperty(String name, String value) throws IOException, MgmtOperationException {
ModelNode address = new ModelNode()
.add(SYSTEM_PROPERTY, name);
address.protect();
final ModelNode operation = new ModelNode();
operation.get(OP_ADDR).set(address);
operation.get(OP).set(ADD);
operation.get(VALUE).set(value);
return executeOperation(operation);
}
protected void removeSystemPropertySilently(String name) {
if (name == null) {
return;
}
try {
ModelNode address = new ModelNode()
.add(SYSTEM_PROPERTY, name);
address.protect();
remove(address);
} catch (Exception e) {
log.debugf(e, "Can't remove system property '%s' by cli", name);
}
}
private String wrapProp(String propertyName) {
return String.format("${%s}", propertyName);
}
}
| 9,263 | 37.123457 | 111 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/DatasourceWrongDsClassTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
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 java.sql.Driver;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.test.integration.jca.JcaMgmtBase;
import org.jboss.as.test.integration.management.util.MgmtOperationException;
import org.jboss.as.test.integration.management.util.ModelUtil;
import org.jboss.dmr.ModelNode;
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;
/**
* Test the situation when abstract DataSource class is specified when creating a data source.
*
* @author lgao
*/
@RunWith(Arquillian.class)
@RunAsClient
public class DatasourceWrongDsClassTestCase extends JcaMgmtBase {
private static final String DEPLOYMENT = "dummydriver";
@Deployment(name = DEPLOYMENT)
public static JavaArchive jdbcArchive() throws Exception {
JavaArchive ja = ShrinkWrap.create(JavaArchive.class, DEPLOYMENT + ".jar");
ja.addClasses(DummyDataSource.class, DummyXADataSource.class, TestDriver.class, TestDriver2.class);
ja.addAsServiceProviderAndClasses(Driver.class, TestDriver.class, TestDriver2.class);
return ja;
}
@Test
public void testJdbcDrivers() throws Exception {
String driverName = DEPLOYMENT + ".jar";
ModelNode address = new ModelNode().add(SUBSYSTEM, "datasources");
ModelNode operation = new ModelNode();
operation.get(OP).set("get-installed-driver");
operation.get(OP_ADDR).set(address);
operation.get("driver-name").set(driverName);
ModelNode result = executeOperation(operation).asList().get(0);
Assert.assertEquals(driverName, result.get("driver-name").asString());
Assert.assertEquals(driverName, result.get("deployment-name").asString());
Assert.assertEquals(TestDriver.class.getName(), result.get("driver-class-name").asString());
Assert.assertEquals(1, result.get("driver-major-version").asInt());
Assert.assertEquals(0, result.get("driver-minor-version").asInt());
Assert.assertFalse(result.get("jdbc-compliant").asBoolean());
String driver1FQCN = driverName + "_" + TestDriver.class.getName() + "_1_0";
operation.get("driver-name").set(driver1FQCN);
result = executeOperation(operation).asList().get(0);
Assert.assertEquals(driver1FQCN, result.get("driver-name").asString());
Assert.assertEquals(driver1FQCN, result.get("deployment-name").asString());
Assert.assertEquals(TestDriver.class.getName(), result.get("driver-class-name").asString());
Assert.assertEquals(1, result.get("driver-major-version").asInt());
Assert.assertEquals(0, result.get("driver-minor-version").asInt());
Assert.assertFalse(result.get("jdbc-compliant").asBoolean());
String driver2FQCN = driverName + "_" + TestDriver2.class.getName() + "_1_1";
operation.get("driver-name").set(driver2FQCN);
result = executeOperation(operation).asList().get(0);
Assert.assertEquals(driver2FQCN, result.get("driver-name").asString());
Assert.assertEquals(driver2FQCN, result.get("deployment-name").asString());
Assert.assertEquals(TestDriver2.class.getName(), result.get("driver-class-name").asString());
Assert.assertEquals(1, result.get("driver-major-version").asInt());
Assert.assertEquals(1, result.get("driver-minor-version").asInt());
Assert.assertTrue(result.get("jdbc-compliant").asBoolean());
}
private ModelNode getDatasourceAddress(Datasource datasource) {
ModelNode address = new ModelNode()
.add(SUBSYSTEM, "datasources")
.add("data-source", datasource.getName());
address.protect();
return address;
}
private ModelNode getAddDatasourceOperation(Datasource datasource) {
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(getDatasourceAddress(datasource));
operation.get("jndi-name").set(datasource.getJndiName());
operation.get("driver-name").set(datasource.getDriverName());
operation.get("enabled").set(datasource.getEnabled());
operation.get("connection-url").set(datasource.getConnectionUrl());
return operation;
}
private ModelNode getRemoveDatasourceOperation(Datasource ds) {
ModelNode removeOperation = Operations.createRemoveOperation(getDatasourceAddress(ds));
removeOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart")
.set(true);
return removeOperation;
}
@Test
public void testDSWithMutipleDrivers() throws Exception {
String driverName = DEPLOYMENT + ".jar";
String driver1FQCN = driverName + "_" + TestDriver.class.getName() + "_1_0";
String driver2FQCN = driverName + "_" + TestDriver2.class.getName() + "_1_1";
Datasource ds1 = Datasource.Builder("test-ds1").connectionUrl("foo").driverName(driverName).enabled(true)
.jndiName("java:jboss/datasources/test-ds1")
.build();
ModelNode addDS1Operation = getAddDatasourceOperation(ds1);
try {
ModelNode addDSResult = getManagementClient().getControllerClient().execute(addDS1Operation);
Assert.assertEquals("success", addDSResult.get("outcome").asString());
} finally {
ModelNode removeDSOperation = getRemoveDatasourceOperation(ds1);
executeOperation(removeDSOperation);
}
Datasource ds1FQCN = Datasource.Builder("test-ds1FQCN").connectionUrl("foo").driverName(driver1FQCN).enabled(true)
.jndiName("java:jboss/datasources/test-ds1FQCN").build();
ModelNode addDS1FQCNOperation = getAddDatasourceOperation(ds1FQCN);
try {
ModelNode addDSResult = getManagementClient().getControllerClient().execute(addDS1FQCNOperation);
Assert.assertEquals("success", addDSResult.get("outcome").asString());
} finally {
ModelNode removeDSOperation = getRemoveDatasourceOperation(ds1FQCN);
executeOperation(removeDSOperation);
}
Datasource ds2FQCN = Datasource.Builder("test-ds2FQCN").connectionUrl("foo").driverName(driver2FQCN)
.enabled(true).jndiName("java:jboss/datasources/test-ds2FQCN").build();
ModelNode addDS2FQCNOperation = getAddDatasourceOperation(ds2FQCN);
try {
ModelNode addDSResult = getManagementClient().getControllerClient().execute(addDS2FQCNOperation);
Assert.assertEquals("success", addDSResult.get("outcome").asString());
} finally {
ModelNode removeDSOperation = getRemoveDatasourceOperation(ds2FQCN);
executeOperation(removeDSOperation);
}
}
@Test
public void testWrongDSClass() throws Exception {
String driverName = DEPLOYMENT + ".jar";
ModelNode address = getDataSourceAddress("wrongClsDs");
ModelNode operation = getDataSourceOperation(address, "java:/wrongClsDs", driverName, DummyDataSource.class.getName());
try {
executeOperation(operation);
Assert.fail("Not supposed to succeed");
} catch (MgmtOperationException e) {
ModelNode result = e.getResult();
Assert.assertEquals("failed", result.get("outcome").asString());
String failDesc = result.get("failure-description").asString();
Assert.assertTrue(failDesc.contains("WFLYJCA0117"));
return;
}
Assert.fail("Not supposed to be here");
}
@Test
public void testWrongXADSClass() throws Exception {
String driverName = DEPLOYMENT + ".jar";
ModelNode address = getXADataSourceAddress("wrongXAClsDs");
ModelNode operation = getXADataSourceOperation(address, "java:/wrongXAClsDs", driverName, DummyXADataSource.class.getName());
try {
executeOperation(operation);
Assert.fail("Not supposed to succeed");
} catch (MgmtOperationException e) {
ModelNode result = e.getResult();
Assert.assertEquals("failed", result.get("outcome").asString());
return;
}
Assert.fail("Not supposed to be here");
}
private ModelNode getXADataSourceAddress(String xaDsName) {
ModelNode address = new ModelNode()
.add(SUBSYSTEM, "datasources")
.add("xa-data-source", xaDsName);
return address;
}
private ModelNode getDataSourceAddress(String dsName) {
ModelNode address = new ModelNode()
.add(SUBSYSTEM, "datasources")
.add("data-source", dsName);
return address;
}
private ModelNode getDataSourceOperation(ModelNode address, String jndiName, String driverName, String dsClsName) {
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
operation.get("jndi-name").set(jndiName);
operation.get("driver-name").set(driverName);
operation.get("datasource-class").set(dsClsName);
return operation;
}
private ModelNode getXADataSourceOperation(ModelNode address, String jndiName, String driverName, String xaDsClsName) {
ModelNode addOp = new ModelNode();
addOp.get(OP).set(ADD);
addOp.get(OP_ADDR).set(address);
addOp.get("jndi-name").set(jndiName);
addOp.get("driver-name").set(driverName);
addOp.get("xa-datasource-class").set(xaDsClsName);
ModelNode connProps = new ModelNode();
connProps.get(OP).set(ADD);
ModelNode connPropAdd = address.add("connection-properties", "url");
connProps.get(OP_ADDR).set(connPropAdd);
connProps.get("value").set("dummy");
List<ModelNode> operationList = new ArrayList<>(Arrays.asList(addOp, connProps));
return ModelUtil.createCompositeNode(operationList.toArray(new ModelNode[1]));
}
}
| 11,821 | 46.099602 | 133 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/TestDriver.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;
/**
* Test JDBC driver
*/
public class TestDriver implements Driver {
/**
* {@inheritDoc}
*/
public Connection connect(String url, Properties info) throws SQLException {
return null;
}
/**
* {@inheritDoc}
*/
public boolean acceptsURL(String url) throws SQLException {
return true;
}
/**
* {@inheritDoc}
*/
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
Driver driver = DriverManager.getDriver(url);
return driver.getPropertyInfo(url, info);
}
/**
* {@inheritDoc}
*/
public int getMajorVersion() {
return 1;
}
/**
* {@inheritDoc}
*/
public int getMinorVersion() {
return 0;
}
/**
* {@inheritDoc}
*/
public boolean jdbcCompliant() {
return false;
}
/**
* {@inheritDoc}
*/
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new SQLFeatureNotSupportedException();
}
}
| 2,392 | 26.193182 | 98 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/DatasourceEnableAttributeTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.*;
/**
* Running tests from {@link DatasourceEnableAttributeTestBase} with standard non-XA datsource.
*
* @author <a href="mailto:[email protected]>Ondra Chaloupka</a>
*/
@RunWith(Arquillian.class)
@RunAsClient
public class DatasourceEnableAttributeTestCase extends DatasourceEnableAttributeTestBase {
private static final Logger log = Logger.getLogger(DatasourceEnableAttributeTestBase.class);
@Override
protected ModelNode createDataSource(Datasource datasource) throws Exception {
ModelNode address = getDataSourceAddress(datasource);
ModelNode operation = getDataSourceOperation(address, datasource);
if (datasource.getConnectionUrl() != null) {
operation.get("connection-url").set(datasource.getConnectionUrl());
}
if (datasource.getDataSourceClass() != null) {
operation.get("datasource-class").set(datasource.getDataSourceClass());
}
executeOperation(operation);
return address;
}
@Override
protected void removeDataSourceSilently(Datasource datasource) {
if (datasource == null || datasource.getName() == null) {
return;
}
ModelNode address = getDataSourceAddress(datasource);
try {
ModelNode removeOperation = Operations.createRemoveOperation(address);
removeOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
executeOperation(removeOperation);
} catch (Exception e) {
log.debugf(e, "Can't remove datasource at address '%s'", address);
}
}
@Override
protected ModelNode getDataSourceAddress(Datasource datasource) {
ModelNode address = new ModelNode()
.add(SUBSYSTEM, "datasources")
.add("data-source", datasource.getName());
address.protect();
return address;
}
@Override
protected void testConnection(Datasource datasource) throws Exception {
testConnection(datasource.getName());
}
@Test
public void testNoConnectionURLWithDatasourceClass() throws Exception {
final String dsName = "testDatasourceNoConnectionURLWithDataSourceClass";
Datasource ds = Datasource.Builder(dsName)
.enabled(false)
.connectionUrl(null)
.dataSourceClass("org.h2.jdbcx.JdbcDataSource")
.build();
try {
createDataSource(ds);
addDataSourceConnectionProps(ds);
enableDatasource(ds);
testConnection(ds);
} finally {
removeDataSourceSilently(ds);
}
}
private void addDataSourceConnectionProps(Datasource ds) throws Exception {
String ConnPropURL = "URL";
String URLValue = "jdbc:h2:mem:testDS";
ModelNode address = new ModelNode()
.add(SUBSYSTEM, "datasources")
.add("data-source", ds.getName())
.add("connection-properties", ConnPropURL);
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
operation.get(VALUE).set(URLValue);
executeOperation(operation);
}
}
| 4,868 | 37.338583 | 125 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/Datasource.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
/**
* @author <a href="mailto:[email protected]>Ondra Chaloupka</a>
*/
public class Datasource {
private final String name, jndiName, driverName, connectionUrl, userName, password, enabled, dataSourceClass;
private Datasource(Builder builder) {
this.name = builder.datasourceName;
this.jndiName = builder.jndiName;
this.driverName = builder.driverName;
this.connectionUrl = builder.connectionUrl;
this.userName = builder.userName;
this.password = builder.password;
this.enabled = builder.enabled;
this.dataSourceClass = builder.dataSourceClass;
}
public static Builder Builder(String datasourceName) {
return new Builder(datasourceName);
}
public String getName() {
return name;
}
public String getJndiName() {
return jndiName;
}
public String getDriverName() {
return driverName;
}
public String getConnectionUrl() {
return connectionUrl;
}
public String getUserName() {
return userName;
}
public String getPassword() {
return password;
}
public String getEnabled() {
return enabled;
}
public String getDataSourceClass() {
return dataSourceClass;
}
@Override
public String toString() {
return String.format("Datasource name: %s, jndi: %s, driver name: %s, url: %s, user name: %s, password: %s, enabled: %s, datasource-class: %s",
name, jndiName, driverName, connectionUrl, userName, password, enabled, dataSourceClass);
}
public static final class Builder {
private final String datasourceName;
private String jndiName;
private String enabled = "true";
private String driverName = System.getProperty("ds.jdbc.driver");
private String connectionUrl = System.getProperty("ds.jdbc.url");
private String userName = System.getProperty("ds.jdbc.user");
private String password = System.getProperty("ds.jdbc.pass");
private String dataSourceClass;
private Builder(String datasourceName) {
this.datasourceName = datasourceName;
this.jndiName = "java:jboss/datasources/" + datasourceName;
if (this.driverName == null) { driverName = "h2"; }
if (this.connectionUrl == null) { connectionUrl = "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE"; }
if (this.userName == null) { userName = "sa"; }
if (this.password == null) { password = "sa"; }
}
public Builder jndiName(String jndiName) {
this.jndiName = jndiName;
return this;
}
public Builder driverName(String driverName) {
this.driverName = driverName;
return this;
}
public Builder enabled(Boolean enabled) {
this.enabled = enabled.toString();
return this;
}
public Builder enabled(String enabled) {
this.enabled = enabled;
return this;
}
public Builder connectionUrl(String connectionUrl) {
this.connectionUrl = connectionUrl;
return this;
}
public Builder userName(String userName) {
this.userName = userName;
return this;
}
public Builder password(String password) {
this.password = password;
return this;
}
public Builder dataSourceClass(String dataSourceClass) {
this.dataSourceClass = dataSourceClass;
return this;
}
public Datasource build() {
return new Datasource(this);
}
}
}
| 4,809 | 31.281879 | 151 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/DatasourceNonCcmTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import java.io.FilePermission;
import java.sql.Connection;
import jakarta.annotation.Resource;
import javax.sql.DataSource;
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.test.integration.jca.JcaMgmtBase;
import org.jboss.as.test.integration.jca.JcaMgmtServerSetupTask;
import org.jboss.as.test.integration.jca.JcaTestsUtil;
import org.jboss.as.test.integration.management.ManagementOperations;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.integration.management.base.ContainerResourceMgmtTestBase;
import org.jboss.as.test.integration.management.jca.DsMgmtTestBase;
import org.jboss.as.test.integration.management.util.MgmtOperationException;
import org.jboss.dmr.ModelNode;
import org.jboss.remoting3.security.RemotingPermission;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Running tests on data-source in non-Jakarta Transactions mode.
*
* @author <a href="mailto:[email protected]>Lin Gao</a>
*/
@RunWith(Arquillian.class)
@ServerSetup(DatasourceNonCcmTestCase.DatasourceServerSetupTask.class)
public class DatasourceNonCcmTestCase {
private static final String NON_TX_DS_NAME = "NonJTADS";
private static final String TX_DS_NAME = "JTADS";
@ArquillianResource
private ManagementClient managementClient;
static class DatasourceServerSetupTask extends JcaMgmtServerSetupTask {
boolean debug = false;
@Override
protected void doSetup(ManagementClient managementClient) throws Exception {
ModelNode address = new ModelNode();
address.add("subsystem", "jca");
address.add("cached-connection-manager", "cached-connection-manager");
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).set(address);
operation.get(OP).set("read-attribute");
operation.get("name").set("debug");
ModelNode result = managementClient.getControllerClient().execute(operation);
if (result.hasDefined("debug")) {
debug = result.require("debug").asBoolean();
}
operation = new ModelNode();
operation.get(OP_ADDR).set(address);
operation.get(OP).set("write-attribute");
operation.get("name").set("debug");
operation.get("value").set("true");
managementClient.getControllerClient().execute(operation);
// set up a DS
setupDs(managementClient, NON_TX_DS_NAME, false);
setupDs(managementClient, TX_DS_NAME, true);
reload();
}
private void setupDs(ManagementClient managementClient, String dsName, boolean jta) throws Exception {
Datasource ds = Datasource.Builder(dsName).build();
ModelNode address = new ModelNode();
address.add("subsystem", "datasources");
address.add("data-source", dsName);
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
operation.get("jndi-name").set(ds.getJndiName());
operation.get("use-java-context").set("true");
operation.get("driver-name").set(ds.getDriverName());
operation.get("enabled").set("true");
operation.get("user-name").set(ds.getUserName());
operation.get("password").set(ds.getPassword());
operation.get("jta").set(jta);
operation.get("use-ccm").set("true");
operation.get("connection-url").set(ds.getConnectionUrl());
managementClient.getControllerClient().execute(operation);
}
}
@Resource(mappedName = "java:jboss/datasources/" + NON_TX_DS_NAME)
private DataSource nonTXDS;
@Resource(mappedName = "java:jboss/datasources/" + TX_DS_NAME)
private DataSource txDS;
@Deployment
public static Archive<?> getDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "dummy.jar");
jar.addClasses(
DatasourceNonCcmTestCase.class,
Datasource.class,
JcaMgmtBase.class,
ManagementOperations.class,
ContainerResourceMgmtTestBase.class,
AbstractMgmtTestBase.class,
JcaMgmtServerSetupTask.class,
MgmtOperationException.class,
DsMgmtTestBase.class,
JcaTestsUtil.class);
jar.addAsManifestResource(new StringAsset(
"Dependencies: javax.inject.api,org.jboss.as.connector," +
"org.jboss.as.controller, " +
"org.jboss.dmr, " +
"org.jboss.staxmapper, " +
// Needed for RemotingPermission class if security manager is enabled
(System.getProperty("security.manager") == null ? "" : "org.jboss.remoting,") +
"org.jboss.ironjacamar.impl, " +
"org.jboss.ironjacamar.jdbcadapters\n"
), "MANIFEST.MF");
jar.addAsManifestResource(createPermissionsXmlAsset(
new RemotingPermission("createEndpoint"),
new RemotingPermission("connect"),
new FilePermission(System.getProperty("jboss.inst") + "/standalone/tmp/auth/*", "read")
), "permissions.xml");
return jar;
}
@Test
public void testNonJTADS() throws Exception {
Assert.assertNotNull(nonTXDS);
Connection c1 = nonTXDS.getConnection();
Assert.assertNotNull(c1);
Assert.assertEquals(1, getNumberOfConnections(false));
Connection c2 = nonTXDS.getConnection();
Assert.assertNotNull(c2);
Assert.assertEquals(2, getNumberOfConnections(false));
c1.close();
Assert.assertEquals(1, getNumberOfConnections(false));
c2.close();
Assert.assertEquals(0, getNumberOfConnections(false));
}
@Test
public void testJTADS() throws Exception {
Assert.assertNotNull(txDS);
Connection c1 = txDS.getConnection();
Assert.assertNotNull(c1);
Assert.assertEquals(1, getNumberOfConnections(true));
Connection c2 = txDS.getConnection();
Assert.assertNotNull(c2);
Assert.assertEquals(2, getNumberOfConnections(true));
c1.close();
Assert.assertEquals(1, getNumberOfConnections(true));
c2.close();
Assert.assertEquals(0, getNumberOfConnections(true));
}
private int getNumberOfConnections(boolean tx) throws Exception {
ModelNode address = new ModelNode();
address.add("subsystem", "jca");
address.add("cached-connection-manager", "cached-connection-manager");
ModelNode operation = new ModelNode();
operation.get(OP_ADDR).set(address);
operation.get(OP).set("get-number-of-connections");
ModelNode result = managementClient.getControllerClient().execute(operation).get("result");
ModelNode txNode = result.get("TX");
ModelNode nonTxNode = result.get("NonTX");
if (tx) {
if (txNode.isDefined()) {
return txNode.asInt();
}
} else {
if (nonTxNode.isDefined()) {
return nonTxNode.asInt();
}
}
return 0;
}
}
| 9,246 | 39.557018 | 110 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/DatasourceXaEnableAttributeTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.COMPOSITE;
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.STEPS;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM;
import java.io.IOException;
import org.jboss.arquillian.container.test.api.RunAsClient;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.controller.client.helpers.Operations;
import org.jboss.as.controller.descriptions.ModelDescriptionConstants;
import org.jboss.as.test.integration.management.util.MgmtOperationException;
import org.jboss.dmr.ModelNode;
import org.jboss.logging.Logger;
import org.junit.runner.RunWith;
/**
* Running tests from {@link DatasourceEnableAttributeTestBase} with XA datsource.
*
* @author <a href="mailto:[email protected]>Ondra Chaloupka</a>
*/
@RunWith(Arquillian.class)
@RunAsClient
public class DatasourceXaEnableAttributeTestCase extends DatasourceEnableAttributeTestBase {
private static final Logger log = Logger.getLogger(DatasourceXaEnableAttributeTestCase.class);
@Override
protected ModelNode createDataSource(Datasource datasource) throws Exception {
ModelNode address = getDataSourceAddress(datasource);
ModelNode batch = new ModelNode();
batch.get(OP).set(COMPOSITE);
batch.get(OP_ADDR).setEmptyList();
ModelNode operation = getDataSourceOperation(address, datasource);
batch.get(STEPS).add(operation);
ModelNode operationXAProperty = getAddXADataSourcePropertyOperation(address, "URL", datasource.getConnectionUrl());
batch.get(STEPS).add(operationXAProperty);
executeOperation(batch);
return address;
}
@Override
protected void removeDataSourceSilently(Datasource datasource) {
if (datasource == null || datasource.getName() == null) {
return;
}
ModelNode address = getDataSourceAddress(datasource);
try {
ModelNode removeOperation = Operations.createRemoveOperation(address);
removeOperation.get(ModelDescriptionConstants.OPERATION_HEADERS).get("allow-resource-service-restart").set(true);
executeOperation(removeOperation);
} catch (Exception e) {
log.debugf(e, "Can't remove xa datasource at address '%s'", address);
}
}
@Override
protected ModelNode getDataSourceAddress(Datasource datasource) {
ModelNode address = new ModelNode()
.add(SUBSYSTEM, "datasources")
.add("xa-data-source", datasource.getName());
address.protect();
return address;
}
@Override
protected void testConnection(Datasource datasource) throws Exception {
testConnectionXA(datasource.getName());
}
private ModelNode getAddXADataSourcePropertyOperation(final ModelNode address, final String name, final String value) throws IOException, MgmtOperationException {
final ModelNode propertyAddress = address.clone();
propertyAddress.add("xa-datasource-properties", name);
propertyAddress.protect();
final ModelNode operation = new ModelNode();
operation.get(OP).set("add");
operation.get(OP_ADDR).set(propertyAddress);
operation.get("value").set(value);
return operation;
}
}
| 4,613 | 39.831858 | 166 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/TestDriver2.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2019, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.DriverPropertyInfo;
import java.sql.SQLException;
import java.sql.SQLFeatureNotSupportedException;
import java.util.Properties;
import java.util.logging.Logger;
/**
* Test JDBC driver
*/
public class TestDriver2 implements Driver {
/**
* {@inheritDoc}
*/
public Connection connect(String url, Properties info) throws SQLException {
return null;
}
/**
* {@inheritDoc}
*/
public boolean acceptsURL(String url) throws SQLException {
return true;
}
/**
* {@inheritDoc}
*/
public DriverPropertyInfo[] getPropertyInfo(String url, Properties info) throws SQLException {
Driver driver = DriverManager.getDriver(url);
return driver.getPropertyInfo(url, info);
}
/**
* {@inheritDoc}
*/
public int getMajorVersion() {
return 1;
}
/**
* {@inheritDoc}
*/
public int getMinorVersion() {
return 1;
}
/**
* {@inheritDoc}
*/
public boolean jdbcCompliant() {
return true;
}
/**
* {@inheritDoc}
*/
public Logger getParentLogger() throws SQLFeatureNotSupportedException {
throw new SQLFeatureNotSupportedException();
}
}
| 2,304 | 25.193182 | 96 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/DummyDataSource.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import javax.sql.DataSource;
/**
* Dummy abstract DataSource, used to verify that it cannot be specified during data source setup.
*
* @author <a href="mailto:[email protected]>Lin Gao</a>
*/
public abstract class DummyDataSource implements DataSource {
}
| 1,339 | 37.285714 | 98 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/DatasourceSetTxQueryTimeoutTestCase.java
|
/*
* Copyright 2018 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jboss.as.test.integration.jca.datasource;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.ADD;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP;
import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR;
import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset;
import java.io.FilePermission;
import java.sql.Connection;
import java.sql.PreparedStatement;
import jakarta.annotation.Resource;
import javax.sql.DataSource;
import jakarta.transaction.UserTransaction;
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.container.ManagementClient;
import org.jboss.as.test.integration.jca.JcaMgmtBase;
import org.jboss.as.test.integration.jca.JcaMgmtServerSetupTask;
import org.jboss.as.test.integration.management.base.AbstractMgmtTestBase;
import org.jboss.as.test.integration.management.base.ContainerResourceMgmtTestBase;
import org.jboss.dmr.ModelNode;
import org.jboss.remoting3.security.RemotingPermission;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Verifies that query timeout is set to the remaining transaction timeout, when the set-tx-query-timeout attribute
* is enabled in the data source.
*
* https://issues.jboss.org/browse/JBEAP-13301
*
* @author <a href="mailto:[email protected]>Tomas Hofman</a>
*/
@RunWith(Arquillian.class)
@ServerSetup(DatasourceSetTxQueryTimeoutTestCase.DatasourceServerSetupTask.class)
public class DatasourceSetTxQueryTimeoutTestCase {
private static final String TX_DS_NAME = "JTADS";
static class DatasourceServerSetupTask extends JcaMgmtServerSetupTask {
@Override
protected void doSetup(ManagementClient managementClient) throws Exception {
setupDs(managementClient, TX_DS_NAME, true);
reload();
}
private void setupDs(ManagementClient managementClient, String dsName, boolean jta) throws Exception {
Datasource ds = Datasource.Builder(dsName).build();
ModelNode address = new ModelNode();
address.add("subsystem", "datasources");
address.add("data-source", dsName);
ModelNode operation = new ModelNode();
operation.get(OP).set(ADD);
operation.get(OP_ADDR).set(address);
operation.get("jndi-name").set(ds.getJndiName());
operation.get("use-java-context").set("true");
operation.get("driver-name").set(ds.getDriverName());
operation.get("enabled").set("true");
operation.get("user-name").set(ds.getUserName());
operation.get("password").set(ds.getPassword());
operation.get("jta").set(jta);
operation.get("use-ccm").set("true");
operation.get("connection-url").set(ds.getConnectionUrl());
operation.get("set-tx-query-timeout").set("true");
managementClient.getControllerClient().execute(operation);
}
}
@Resource(mappedName = "java:jboss/datasources/" + TX_DS_NAME)
private DataSource txDS;
@Resource(mappedName = "java:jboss/UserTransaction")
private UserTransaction transaction;
@Deployment
public static Archive<?> getDeployment() {
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "dummy.jar");
jar.addClasses(
DatasourceSetTxQueryTimeoutTestCase.class,
Datasource.class,
JcaMgmtBase.class,
ContainerResourceMgmtTestBase.class,
AbstractMgmtTestBase.class,
JcaMgmtServerSetupTask.class);
jar.addAsManifestResource(new StringAsset(
"Dependencies: javax.inject.api,org.jboss.as.connector," +
"org.jboss.staxmapper, " +
"org.jboss.ironjacamar.impl, " +
"org.jboss.ironjacamar.jdbcadapters\n"
), "MANIFEST.MF");
jar.addAsManifestResource(createPermissionsXmlAsset(
new RemotingPermission("createEndpoint"),
new RemotingPermission("connect"),
new FilePermission(System.getProperty("jboss.inst") + "/standalone/tmp/auth/*", "read")
), "permissions.xml");
return jar;
}
@Test
public void testJTADS() throws Exception {
transaction.begin();
try (Connection connection = txDS.getConnection()) {
try (PreparedStatement statement = connection.prepareStatement("select 1")) {
Assert.assertEquals(0, statement.getQueryTimeout());
statement.execute();
int queryTimeout = statement.getQueryTimeout();
// during statement execution the query timeout was supposed to be set to default transaction timeout,
// which is set to 300 seconds, but lets give it some allowance
Assert.assertTrue(queryTimeout > 290 && queryTimeout <= 300);
}
transaction.commit();
} catch (Exception e) {
transaction.rollback();
throw e;
}
}
}
| 6,082 | 39.825503 | 118 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/datasource/DummyXADataSource.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2018, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.datasource;
import javax.sql.XADataSource;
/**
* Dummy abstract XADataSource, used to verify that it cannot be specified during xa data source setup.
*
* @author <a href="mailto:[email protected]>Lin Gao</a>
*/
public abstract class DummyXADataSource implements XADataSource {
}
| 1,350 | 37.6 | 103 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/LazyAssociationSharableFalseTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import jakarta.annotation.Resource;
import jakarta.resource.ResourceException;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactory;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test cases for deploying a lazy association resource adapter archive with sharable=false
*
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
@RunWith(Arquillian.class)
public class LazyAssociationSharableFalseTestCase extends LazyAssociationAbstractTestCase {
private static Logger logger = Logger.getLogger(LazyAssociationSharableFalseTestCase.class);
@Deployment(name = LazyAssociationAbstractTestCase.RAR_NAME)
public static Archive<ResourceAdapterArchive> createDeployment() {
return createResourceAdapter("ra-notx.xml",
"ironjacamar-sharablefalse.xml",
LazyAssociationSharableFalseTestCase.class);
}
@Resource(mappedName = "java:/eis/Lazy")
private LazyConnectionFactory lcf;
@Test
public void verifyDisabledLazyAssociation() {
assertNotNull(lcf);
LazyConnection lc1 = null;
LazyConnection lc2 = null;
try {
lc1 = lcf.getConnection();
assertTrue(lc1.isManagedConnectionSet());
try {
lc2 = lcf.getConnection();
fail("Exception should have been thrown");
} catch (ResourceException re) {
// expected
}
} catch (Throwable t) {
logger.error(t.getMessage(), t);
fail("Throwable:" + t.getLocalizedMessage());
} finally {
if (lc1 != null) { lc1.close(); }
if (lc2 != null) { lc2.close(); }
}
}
@Test
public void testDefaultBehaviorWithoutLazyAssociation() {
assertNotNull(lcf);
LazyConnection lc1 = null;
LazyConnection lc2 = null;
try {
lc1 = lcf.getConnection();
assertTrue(lc1.isManagedConnectionSet());
lc1.close();
lc2 = lcf.getConnection();
assertTrue(lc2.isManagedConnectionSet());
lc2.close();
} catch (Throwable t) {
logger.error(t.getMessage(), t);
fail("Throwable:" + t.getLocalizedMessage());
} finally {
if (lc1 != null) { lc1.close(); }
if (lc2 != null) { lc2.close(); }
}
}
}
| 4,045 | 35.781818 | 96 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/LazyAssociationLocalTransactionTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import jakarta.annotation.Resource;
import jakarta.transaction.UserTransaction;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactory;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test cases for deploying a lazy association resource adapter archive using LocalTransaction
*
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
@RunWith(Arquillian.class)
public class LazyAssociationLocalTransactionTestCase extends LazyAssociationAbstractTestCase {
private static Logger logger = Logger.getLogger(LazyAssociationLocalTransactionTestCase.class);
@Deployment(name = LazyAssociationAbstractTestCase.RAR_NAME)
public static Archive<ResourceAdapterArchive> createDeployment() {
return createResourceAdapter("ra-localtx.xml",
"ironjacamar-default.xml",
LazyAssociationLocalTransactionTestCase.class);
}
@Resource(mappedName = "java:/eis/Lazy")
private LazyConnectionFactory lcf;
@Resource(mappedName = "java:jboss/UserTransaction")
private UserTransaction userTransaction;
@Test
public void testBasic() throws Throwable {
assertNotNull(lcf);
assertNotNull(userTransaction);
boolean status = true;
userTransaction.begin();
LazyConnection lc = null;
try {
lc = lcf.getConnection();
assertTrue(lc.isManagedConnectionSet());
assertTrue(lc.closeManagedConnection());
assertFalse(lc.isManagedConnectionSet());
assertTrue(lc.associate());
assertTrue(lc.isManagedConnectionSet());
assertFalse(lc.isEnlisted());
assertTrue(lc.enlist());
assertTrue(lc.isEnlisted());
} catch (Throwable t) {
logger.error(t.getMessage(), t);
status = false;
fail("Throwable:" + t.getMessage());
} finally {
if (lc != null) { lc.close(); }
if (status) {
userTransaction.commit();
} else {
userTransaction.rollback();
}
}
}
/**
* Two connections - one managed connection - without enlistment
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testTwoConnectionsWithoutEnlistment() throws Throwable {
assertNotNull(lcf);
assertNotNull(userTransaction);
boolean status = true;
userTransaction.begin();
LazyConnection lc1 = null;
LazyConnection lc2 = null;
try {
lc1 = lcf.getConnection();
assertTrue(lc1.isManagedConnectionSet());
logger.trace("testTwoConnectionsWithoutEnlistment: Before 2nd getConnection");
lc2 = lcf.getConnection();
assertTrue(lc2.isManagedConnectionSet());
assertFalse(lc1.isManagedConnectionSet());
logger.trace("testTwoConnectionsWithoutEnlistment: Before closeManagedConnection");
assertTrue(lc2.closeManagedConnection());
assertFalse(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
logger.trace("testTwoConnectionsWithoutEnlistment: Before associate");
assertTrue(lc1.associate());
assertTrue(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
logger.debug("testTwoConnectionsWithoutEnlistment: After associate");
} catch (Throwable t) {
logger.error(t.getMessage(), t);
status = false;
fail("Throwable:" + t.getMessage());
} finally {
if (lc1 != null) { lc1.close(); }
if (lc2 != null) { lc2.close(); }
if (status) {
userTransaction.commit();
} else {
userTransaction.rollback();
}
}
}
/**
* Two connections - one managed connection - with enlistment
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testTwoConnectionsWithEnlistment() throws Throwable {
assertNotNull(lcf);
assertNotNull(userTransaction);
boolean status = true;
userTransaction.begin();
LazyConnection lc1 = null;
LazyConnection lc2 = null;
try {
lc1 = lcf.getConnection();
assertTrue(lc1.isManagedConnectionSet());
assertFalse(lc1.isEnlisted());
assertTrue(lc1.enlist());
assertTrue(lc1.isEnlisted());
lc2 = lcf.getConnection();
assertTrue(lc2.isManagedConnectionSet());
assertFalse(lc1.isManagedConnectionSet());
assertTrue(lc2.closeManagedConnection());
assertFalse(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
assertTrue(lc1.associate());
assertTrue(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
} catch (Throwable t) {
logger.error(t.getMessage(), t);
status = false;
fail("Throwable:" + t.getMessage());
} finally {
if (lc1 != null) { lc1.close(); }
if (lc2 != null) { lc2.close(); }
if (status) {
userTransaction.commit();
} else {
userTransaction.rollback();
}
}
}
}
| 7,158 | 33.253589 | 99 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/LazyAssociationSharableDefaultTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import jakarta.annotation.Resource;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactory;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test cases for deploying a lazy association resource adapter archive
*
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
@RunWith(Arquillian.class)
public class LazyAssociationSharableDefaultTestCase extends LazyAssociationAbstractTestCase {
private static Logger logger = Logger.getLogger(LazyAssociationSharableDefaultTestCase.class);
@Deployment(name = LazyAssociationAbstractTestCase.RAR_NAME)
public static Archive<ResourceAdapterArchive> createDeployment() {
return createResourceAdapter("ra-notx.xml",
"ironjacamar-default.xml",
LazyAssociationSharableDefaultTestCase.class);
}
@Resource(mappedName = "java:/eis/Lazy")
private LazyConnectionFactory lcf;
@Test
public void testBasic() {
assertNotNull(lcf);
LazyConnection lc = null;
try {
lc = lcf.getConnection();
assertTrue(lc.isManagedConnectionSet());
assertTrue(lc.closeManagedConnection());
assertFalse(lc.isManagedConnectionSet());
assertTrue(lc.associate());
assertTrue(lc.isManagedConnectionSet());
assertFalse(lc.isEnlisted());
assertTrue(lc.enlist());
assertFalse(lc.isEnlisted());
} catch (Throwable t) {
logger.error(t.getMessage(), t);
fail("Throwable:" + t.getMessage());
} finally {
if (lc != null) { lc.close(); }
}
}
/**
* Two connections - one managed connection
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testTwoConnections() {
assertNotNull(lcf);
LazyConnection lc1 = null;
LazyConnection lc2 = null;
try {
lc1 = lcf.getConnection();
assertTrue(lc1.isManagedConnectionSet());
lc2 = lcf.getConnection();
assertTrue(lc2.isManagedConnectionSet());
assertFalse(lc1.isManagedConnectionSet());
assertTrue(lc2.closeManagedConnection());
assertFalse(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
assertTrue(lc1.associate());
assertTrue(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
} catch (Throwable t) {
logger.error(t.getMessage(), t);
fail("Throwable:" + t.getMessage());
} finally {
if (lc1 != null) { lc1.close(); }
if (lc2 != null) { lc2.close(); }
}
}
}
| 4,444 | 33.726563 | 98 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/LazyAssociationAbstractTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactory;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactoryImpl;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionImpl;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyLocalTransaction;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyManagedConnection;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyManagedConnectionFactory;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyManagedConnectionMetaData;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyResourceAdapter;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyXAResource;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
/**
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
public abstract class LazyAssociationAbstractTestCase {
protected static final String RAR_NAME = "lazy.rar";
protected static final String LIB_JAR_NAME = "common.jar";
protected static Archive<ResourceAdapterArchive> createResourceAdapter(String raFileName,
String configurationFileName,
Class testClass) {
ResourceAdapterArchive rar = ShrinkWrap.create(ResourceAdapterArchive.class, RAR_NAME);
rar.addAsManifestResource(LazyResourceAdapter.class.getPackage(), raFileName, "ra.xml");
rar.addAsManifestResource(LazyResourceAdapter.class.getPackage(), configurationFileName, "ironjacamar.xml");
JavaArchive jar = ShrinkWrap.create(JavaArchive.class, LIB_JAR_NAME);
jar.addClass(LazyResourceAdapter.class)
.addClass(LazyManagedConnectionFactory.class)
.addClass(LazyManagedConnection.class)
.addClass(LazyConnection.class)
.addClass(LazyConnectionImpl.class)
.addClass(LazyXAResource.class)
.addClass(LazyLocalTransaction.class)
.addClass(LazyManagedConnectionMetaData.class)
.addClass(LazyConnectionFactory.class)
.addClass(LazyConnectionFactoryImpl.class);
jar.addClass(LazyAssociationAbstractTestCase.class);
jar.addClass(testClass);
rar.addAsLibrary(jar);
return rar;
}
}
| 3,895 | 52.369863 | 116 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/LazyAssociationXATransactionTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import jakarta.annotation.Resource;
import jakarta.transaction.UserTransaction;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactory;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test cases for deploying a lazy association resource adapter archive using XATransaction
*
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
@RunWith(Arquillian.class)
public class LazyAssociationXATransactionTestCase extends LazyAssociationAbstractTestCase {
private static Logger logger = Logger.getLogger(LazyAssociationXATransactionTestCase.class);
@Deployment(name = LazyAssociationAbstractTestCase.RAR_NAME)
public static Archive<ResourceAdapterArchive> createDeployment() {
return createResourceAdapter("ra-xatx.xml",
"ironjacamar-xa-default.xml",
LazyAssociationXATransactionTestCase.class);
}
@Resource(mappedName = "java:/eis/Lazy")
private LazyConnectionFactory lcf;
@Resource(mappedName = "java:jboss/UserTransaction")
private UserTransaction userTransaction;
@Test
public void testBasic() throws Throwable {
assertNotNull(lcf);
assertNotNull(userTransaction);
boolean status = true;
userTransaction.begin();
LazyConnection lc = null;
try {
lc = lcf.getConnection();
assertTrue(lc.isManagedConnectionSet());
lc.closeManagedConnection();
assertFalse(lc.isManagedConnectionSet());
lc.associate();
assertTrue(lc.isManagedConnectionSet());
assertFalse(lc.isEnlisted());
assertTrue(lc.enlist());
assertTrue(lc.isEnlisted());
} catch (Throwable t) {
logger.error(t.getMessage(), t);
status = false;
fail("Throwable:" + t.getMessage());
} finally {
if (lc != null) { lc.close(); }
if (status) {
userTransaction.commit();
} else {
userTransaction.rollback();
}
}
}
/**
* Two connections - one managed connection - without enlistment
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testTwoConnectionsWithoutEnlistment() throws Throwable {
assertNotNull(lcf);
assertNotNull(userTransaction);
boolean status = true;
userTransaction.begin();
LazyConnection lc1 = null;
LazyConnection lc2 = null;
try {
lc1 = lcf.getConnection();
assertTrue(lc1.isManagedConnectionSet());
lc2 = lcf.getConnection();
assertTrue(lc2.isManagedConnectionSet());
assertFalse(lc1.isManagedConnectionSet());
assertTrue(lc2.closeManagedConnection());
assertFalse(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
assertTrue(lc1.associate());
assertTrue(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
} catch (Throwable t) {
logger.error(t.getMessage(), t);
status = false;
fail("Throwable:" + t.getMessage());
} finally {
if (lc1 != null) { lc1.close(); }
if (lc2 != null) { lc2.close(); }
if (status) {
userTransaction.commit();
} else {
userTransaction.rollback();
}
}
}
/**
* Two connections - one managed connection - with enlistment
*
* @throws Throwable Thrown if case of an error
*/
@Test
public void testTwoConnectionsWithEnlistment() throws Throwable {
assertNotNull(lcf);
assertNotNull(userTransaction);
boolean status = true;
userTransaction.begin();
LazyConnection lc1 = null;
LazyConnection lc2 = null;
try {
lc1 = lcf.getConnection();
assertTrue(lc1.isManagedConnectionSet());
assertFalse(lc1.isEnlisted());
assertTrue(lc1.enlist());
assertTrue(lc1.isEnlisted());
lc2 = lcf.getConnection();
assertTrue(lc2.isManagedConnectionSet());
assertFalse(lc1.isManagedConnectionSet());
assertTrue(lc2.closeManagedConnection());
assertFalse(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
assertTrue(lc1.associate());
assertTrue(lc1.isManagedConnectionSet());
assertFalse(lc2.isManagedConnectionSet());
} catch (Throwable t) {
logger.error(t.getMessage(), t);
status = false;
fail("Throwable:" + t.getMessage());
} finally {
if (lc1 != null) { lc1.close(); }
if (lc2 != null) { lc2.close(); }
if (status) {
userTransaction.commit();
} else {
userTransaction.rollback();
}
}
}
}
| 6,776 | 31.118483 | 96 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/LazyAssociationLocalTransactionEnlistmentFalseTestCase.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import jakarta.annotation.Resource;
import jakarta.transaction.UserTransaction;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnection;
import org.jboss.as.test.integration.jca.lazyconnectionmanager.rar.LazyConnectionFactory;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.spec.ResourceAdapterArchive;
import org.junit.Test;
import org.junit.runner.RunWith;
/**
* Test cases for deploying a lazy association resource adapter archive using LocalTransaction with enlistment=false
*
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
@RunWith(Arquillian.class)
public class LazyAssociationLocalTransactionEnlistmentFalseTestCase extends LazyAssociationAbstractTestCase {
private static Logger logger = Logger.getLogger(LazyAssociationLocalTransactionEnlistmentFalseTestCase.class);
@Deployment(name = LazyAssociationAbstractTestCase.RAR_NAME)
public static Archive<ResourceAdapterArchive> createDeployment() {
return createResourceAdapter("ra-localtx.xml",
"ironjacamar-enlistmentfalse.xml",
LazyAssociationLocalTransactionEnlistmentFalseTestCase.class);
}
@Resource(mappedName = "java:/eis/Lazy")
private LazyConnectionFactory lcf;
@Resource(mappedName = "java:jboss/UserTransaction")
private UserTransaction userTransaction;
@Test
public void verifyEagerlyEnlisted() throws Throwable {
assertNotNull(lcf);
assertNotNull(userTransaction);
boolean status = true;
userTransaction.begin();
LazyConnection lc = null;
try {
lc = lcf.getConnection();
assertTrue(lc.isManagedConnectionSet());
assertTrue(lc.closeManagedConnection());
assertFalse(lc.isManagedConnectionSet());
assertTrue(lc.associate());
assertTrue(lc.isManagedConnectionSet());
assertTrue(lc.isEnlisted());
} catch (Throwable t) {
logger.error(t.getMessage(), t);
status = false;
fail("Throwable:" + t.getMessage());
} finally {
if (lc != null) { lc.close(); }
if (status) {
userTransaction.commit();
} else {
userTransaction.rollback();
}
}
}
}
| 3,820 | 37.59596 | 116 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/rar/LazyResourceAdapter.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager.rar;
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;
/**
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
public class LazyResourceAdapter implements ResourceAdapter {
private static Logger logger = Logger.getLogger(LazyResourceAdapter.class);
private Boolean enable;
private Boolean localTransaction;
private Boolean xaTransaction;
public LazyResourceAdapter() {
logger.trace("#LazyResourceAdapter");
enable = Boolean.TRUE;
localTransaction = Boolean.FALSE;
xaTransaction = Boolean.FALSE;
}
@Override
public void start(BootstrapContext ctx) throws ResourceAdapterInternalException {
logger.trace("#LazyResourceAdapter.start");
}
@Override
public void stop() {
logger.trace("#LazyResourceAdapter.stop");
}
@Override
public void endpointActivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) throws ResourceException {
logger.trace("#LazyResourceAdapter.endpointActivation");
}
@Override
public void endpointDeactivation(MessageEndpointFactory endpointFactory, ActivationSpec spec) {
logger.trace("#LazyResourceAdapter.endpointDeactivation");
}
@Override
public XAResource[] getXAResources(ActivationSpec[] specs) throws ResourceException {
logger.trace("#LazyResourceAdapter.getXAResources");
return null;
}
public Boolean getEnable() {
return enable;
}
public void setEnable(Boolean enable) {
this.enable = enable;
}
public Boolean getXATransaction() {
return xaTransaction;
}
public void setXATransaction(Boolean xaTransaction) {
this.xaTransaction = xaTransaction;
}
public Boolean getLocalTransaction() {
return localTransaction;
}
public void setLocalTransaction(Boolean localTransaction) {
this.localTransaction = localTransaction;
}
@Override
public int hashCode() {
int result = 17;
if (enable != null) { result += 31 * result + 7 * enable.hashCode(); } else { result += 31 * result + 7; }
if (localTransaction != null) { result += 31 * result + 7 * localTransaction.hashCode(); } else { result += 31 * result + 7; }
if (xaTransaction != null) { result += 31 * result + 7 * xaTransaction.hashCode(); } else { result += 31 * result + 7; }
return result;
}
@Override
public boolean equals(Object other) {
if (other == null) { return false; }
if (other == this) { return true; }
if (!(other instanceof LazyResourceAdapter)) { return false; }
LazyResourceAdapter obj = (LazyResourceAdapter) other;
boolean result = true;
if (result) {
if (localTransaction == null) { result = obj.getLocalTransaction() == null; } else { result = localTransaction.equals(obj.getLocalTransaction()); }
}
if (result) {
if (xaTransaction == null) { result = obj.getXATransaction() == null; } else { result = xaTransaction.equals(obj.getXATransaction()); }
}
return result;
}
}
| 4,635 | 35.21875 | 159 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/rar/LazyManagedConnectionFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager.rar;
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;
import org.jboss.logging.Logger;
/**
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
public class LazyManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation {
private static final long serialVersionUID = 8167326732027615486L;
private static Logger logger = Logger.getLogger(LazyManagedConnectionFactory.class);
private ConnectionManager cm;
private ResourceAdapter ra;
private PrintWriter logwriter;
public LazyManagedConnectionFactory() {
}
@Override
public Object createConnectionFactory(ConnectionManager connectionManager) throws ResourceException {
logger.trace("#LazyManagedConnectionFactory.createConnectionFactory");
this.cm = connectionManager;
return new LazyConnectionFactoryImpl(this, connectionManager);
}
@Override
public Object createConnectionFactory() throws ResourceException {
throw new ResourceException("This resource adapter doesn't support non-managed environments");
}
@Override
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
logger.trace("#LazyManagedConnectionFactory.createManagedConnection");
LazyResourceAdapter lra = (LazyResourceAdapter) ra;
return new LazyManagedConnection(lra.getLocalTransaction().booleanValue(),
lra.getXATransaction().booleanValue(),
cm, this);
}
@Override
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
logger.trace("#LazyManagedConnectionFactory.matchManagedConnections");
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof LazyManagedConnection) {
result = mc;
}
}
return result;
}
@Override
public void setLogWriter(PrintWriter printWriter) throws ResourceException {
logger.trace("#LazyManagedConnectionFactory.setLogWriter");
}
@Override
public PrintWriter getLogWriter() throws ResourceException {
logger.trace("#LazyManagedConnectionFactory.getLogWriter");
return null;
}
@Override
public ResourceAdapter getResourceAdapter() {
logger.trace("#LazyManagedConnectionFactory.getResourceAdapter");
return null;
}
@Override
public void setResourceAdapter(ResourceAdapter resourceAdapter) throws ResourceException {
logger.trace("#LazyManagedConnectionFactory.setResourceAdapter");
this.ra = resourceAdapter;
}
@Override
public int hashCode() {
int result = 17;
return result;
}
@Override
public boolean equals(Object other) {
if (other == null) { return false; }
if (other == this) { return true; }
if (!(other instanceof LazyManagedConnectionFactory)) { return false; }
LazyManagedConnectionFactory obj = (LazyManagedConnectionFactory) other;
boolean result = true;
return result;
}
}
| 4,936 | 36.120301 | 160 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/rar/LazyManagedConnectionMetaData.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager.rar;
import jakarta.resource.ResourceException;
import jakarta.resource.spi.ManagedConnectionMetaData;
import org.jboss.logging.Logger;
/**
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
public class LazyManagedConnectionMetaData implements ManagedConnectionMetaData {
private static Logger logger = Logger.getLogger(LazyManagedConnectionMetaData.class);
@Override
public String getEISProductName() throws ResourceException {
logger.trace("#LazyManagedConnectionMetaData.getEISProductName");
return "LAZY";
}
@Override
public String getEISProductVersion() throws ResourceException {
logger.trace("#LazyManagedConnectionMetaData.getEISProductVersion");
return "1.0";
}
@Override
public int getMaxConnections() throws ResourceException {
logger.trace("#LazyManagedConnectionMetaData.getMaxConnections");
return 0;
}
@Override
public String getUserName() throws ResourceException {
logger.trace("#LazyManagedConnectionMetaData.getUserName");
return null;
}
}
| 2,266 | 36.783333 | 89 |
java
|
null |
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jca/lazyconnectionmanager/rar/LazyConnectionFactory.java
|
/*
* JBoss, Home of Professional Open Source.
* Copyright 2015, Red Hat, Inc., and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.as.test.integration.jca.lazyconnectionmanager.rar;
import java.io.Serializable;
import jakarta.resource.Referenceable;
import jakarta.resource.ResourceException;
/**
* @author <a href="mailto:[email protected]">Jesper Pedersen</a>
* @author <a href="mailto:[email protected]">Martin Simka</a>
*/
public interface LazyConnectionFactory extends Serializable, Referenceable {
LazyConnection getConnection() throws ResourceException;
}
| 1,497 | 40.611111 | 79 |
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.