User: d_jencks
Date: 02/03/24 14:00:44
Added: src/main/org/jboss/test/jca/adapter TestConnection.java
TestConnectionFactory.java
TestConnectionRequestInfo.java
TestManagedConnection.java
TestManagedConnectionFactory.java
TestXAResource.java
Log:
Tests for new ConnectionManager implementation. Many of these fail with the current
less-than-spec-compliant jca-jdbc wrappers, but work ok with e.g. the firebird
connector. Also, nojars combined targets removed, any test target can be run with
-Dnojars=t. Also, log4j logging fixed and moved to xml config.
Revision Changes Path
1.1
jbosstest/src/main/org/jboss/test/jca/adapter/TestConnection.java
Index: TestConnection.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*
*/
package org.jboss.test.jca.adapter;
/**
* TestConnection.java
*
*
* Created: Sun Mar 10 19:35:48 2002
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
* @version
*/
public class TestConnection
{
private TestManagedConnection mc;
private boolean mcIsNull = true;
public TestConnection (TestManagedConnection mc)
{
this.mc = mc;
mcIsNull = false;
}
public void close()
{
mc.connectionClosed(this);
mcIsNull = true;
}
public boolean isInTx()
{
return mc.isInTx();
}
void setMc(TestManagedConnection mc)
{
if (mc == null)
{
mcIsNull = true;
} // end of if ()
else
{
this.mc = mc;
} // end of else
}
}// TestConnection
1.1
jbosstest/src/main/org/jboss/test/jca/adapter/TestConnectionFactory.java
Index: TestConnectionFactory.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*
*/
package org.jboss.test.jca.adapter;
import javax.naming.NamingException;
import javax.naming.Reference;
import javax.resource.ResourceException;
import javax.resource.cci.Connection;
import javax.resource.cci.ConnectionFactory;
import javax.resource.cci.ConnectionSpec;
import javax.resource.cci.RecordFactory;
import javax.resource.cci.ResourceAdapterMetaData;
// Generated package name
/**
* TestConnectionFactory.java
*
*
* Created: Tue Jan 1 01:02:16 2002
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
* @version
*/
public class TestConnectionFactory implements ConnectionFactory
{
public TestConnectionFactory ()
{
}
// implementation of javax.resource.Referenceable interface
/**
*
* @param param1 <description>
*/
public void setReference(Reference param1)
{
// TODO: implement this javax.resource.Referenceable method
}
// implementation of javax.naming.Referenceable interface
/**
*
* @return <description>
* @exception javax.naming.NamingException <description>
*/
public Reference getReference() throws NamingException
{
// TODO: implement this javax.naming.Referenceable method
return null;
}
// implementation of javax.resource.cci.ConnectionFactory interface
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public Connection getConnection() throws ResourceException
{
// TODO: implement this javax.resource.cci.ConnectionFactory method
return null;
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public Connection getConnection(ConnectionSpec param1) throws ResourceException
{
// TODO: implement this javax.resource.cci.ConnectionFactory method
return null;
}
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public RecordFactory getRecordFactory() throws ResourceException
{
// TODO: implement this javax.resource.cci.ConnectionFactory method
return null;
}
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public ResourceAdapterMetaData getMetaData() throws ResourceException
{
// TODO: implement this javax.resource.cci.ConnectionFactory method
return null;
}
}
1.1
jbosstest/src/main/org/jboss/test/jca/adapter/TestConnectionRequestInfo.java
Index: TestConnectionRequestInfo.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*
*/
package org.jboss.test.jca.adapter; // Generated package name
import javax.resource.spi.ConnectionRequestInfo;
/**
* TestConnectionRequestInfo.java
*
*
* Created: Mon Dec 31 17:14:13 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
* @version
*/
public class TestConnectionRequestInfo implements ConnectionRequestInfo
{
public TestConnectionRequestInfo ()
{
}
// implementation of javax.resource.spi.ConnectionRequestInfo interface
/**
*
* @return <description>
*/
/*public int hashCode()
{
// TODO: implement this javax.resource.spi.ConnectionRequestInfo method
return 0;
}*/
/**
*
* @param param1 <description>
* @return <description>
*/
/* public boolean equals(Object param1)
{
// TODO: implement this javax.resource.spi.ConnectionRequestInfo method
return false;
}*/
}
1.1
jbosstest/src/main/org/jboss/test/jca/adapter/TestManagedConnection.java
Index: TestManagedConnection.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*
*/
package org.jboss.test.jca.adapter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionEvent;
import javax.resource.spi.ConnectionEventListener;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.LocalTransaction;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionMetaData;
import javax.security.auth.Subject;
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
import org.jboss.logging.Logger;
// Generated package name
/**
* TestManagedConnection.java
*
*
* Created: Mon Dec 31 17:07:16 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
* @version
*/
public class TestManagedConnection implements ManagedConnection, XAResource
{
private Logger log = Logger.getLogger(getClass());
private List handles = new LinkedList();
private List listeners = new LinkedList();
private Subject subject;
private TestConnectionRequestInfo cri;
private Xid xid;
private boolean destroyed = false;
public TestManagedConnection (final Subject subject, final
TestConnectionRequestInfo cri)
{
this.subject = subject;
this.cri = cri;
}
// implementation of javax.resource.spi.ManagedConnection interface
/**
*
* @exception javax.resource.ResourceException <description>
*/
public void destroy() throws ResourceException
{
cleanup();
destroyed = true;
}
/**
*
* @exception javax.resource.ResourceException <description>
*/
public void cleanup() throws ResourceException
{
for (Iterator i = handles.iterator(); i.hasNext(); )
{
TestConnection c = (TestConnection)i.next();
c.setMc(null);
i.remove();
} // end of for ()
}
/**
*
* @param param1 <description>
* @param param2 <description>
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public Object getConnection(Subject param1, ConnectionRequestInfo param2) throws
ResourceException
{
TestConnection c = new TestConnection(this);
handles.add(c);
return c;
}
/**
*
* @param param1 <description>
* @exception javax.resource.ResourceException <description>
*/
public void associateConnection(Object p) throws ResourceException
{
if (p instanceof TestConnection)
{
((TestConnection)p).setMc(this);
handles.add(p);
} // end of if ()
else
{
throw new ResourceException("wrong kind of Connection");
} // end of else
}
/**
*
* @param param1 <description>
*/
public void addConnectionEventListener(ConnectionEventListener cel)
{
log.info("adding 1 cel");
listeners.add(cel);
}
/**
*
* @param param1 <description>
*/
public void removeConnectionEventListener(ConnectionEventListener cel)
{
log.info("removing 1 cel");
listeners.remove(cel);
}
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public XAResource getXAResource() throws ResourceException
{
return this;
}
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public LocalTransaction getLocalTransaction() throws ResourceException
{
// TODO: implement this javax.resource.spi.ManagedConnection method
return null;
}
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public ManagedConnectionMetaData getMetaData() throws ResourceException
{
// TODO: implement this javax.resource.spi.ManagedConnection method
return null;
}
/**
*
* @param param1 <description>
* @exception javax.resource.ResourceException <description>
*/
public void setLogWriter(PrintWriter param1) throws ResourceException
{
// TODO: implement this javax.resource.spi.ManagedConnection method
}
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public PrintWriter getLogWriter() throws ResourceException
{
// TODO: implement this javax.resource.spi.ManagedConnection method
return null;
}
// implementation of javax.transaction.xa.XAResource interface
/**
*
* @param param1 <description>
* @param param2 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void start(Xid xid, int flags) throws XAException
{
log.info("start with xid " + xid);
this.xid = xid;
}
/**
*
* @param param1 <description>
* @param param2 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void end(final Xid xid, final int flags) throws XAException
{
log.info("end with xid " + xid);
if (!xid.equals(this.xid))
{
log.info("wrong xid ended: have " + this.xid + ", got: " + xid);
} // end of if ()
this.xid = null;
}
/**
*
* @param param1 <description>
* @param param2 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void commit(Xid xid, boolean onePhase) throws XAException
{
log.info("commit with xid " + xid);
// do nothing
}
/**
*
* @param param1 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void rollback(Xid param1) throws XAException
{
log.info("rollback with xid " + xid);
// do nothing
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public int prepare(Xid param1) throws XAException
{
// do nothing
return 0;
}
/**
*
* @param param1 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void forget(Xid param1) throws XAException
{
// nothing doing
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public Xid[] recover(int param1) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
return null;
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public boolean isSameRM(XAResource xar) throws XAException
{
return this == xar;
}
/**
*
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public int getTransactionTimeout() throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
return 0;
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public boolean setTransactionTimeout(int param1) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
return false;
}
boolean isInTx()
{
log.info("isInTx, xid: " + xid);
return xid != null;
}
void connectionClosed(TestConnection handle)
{
ConnectionEvent ce = new ConnectionEvent(this
,ConnectionEvent.CONNECTION_CLOSED);
ce.setConnectionHandle(handle);
Collection copy = new ArrayList(listeners);
for (Iterator i = copy.iterator(); i.hasNext(); )
{
log.info("notifying 1 cel connectionClosed");
ConnectionEventListener cel = (ConnectionEventListener)i.next();
cel.connectionClosed(ce);
} // end of for ()
handles.remove(handle);
}
}
1.1
jbosstest/src/main/org/jboss/test/jca/adapter/TestManagedConnectionFactory.java
Index: TestManagedConnectionFactory.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*
*/
package org.jboss.test.jca.adapter;
import java.io.PrintWriter;
import java.util.Set;
import javax.resource.ResourceException;
import javax.resource.spi.ConnectionManager;
import javax.resource.spi.ConnectionRequestInfo;
import javax.resource.spi.ManagedConnection;
import javax.resource.spi.ManagedConnectionFactory;
import javax.security.auth.Subject;
// Generated package name
/**
* ManagedConnectionFactory.java
*
*
* Created: Mon Dec 31 17:01:55 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
* @version
*/
public class TestManagedConnectionFactory implements ManagedConnectionFactory
{
public TestManagedConnectionFactory ()
{
}
// implementation of javax.resource.spi.ManagedConnectionFactory interface
/**
*
* @return <description>
*/
public int hashCode()
{
// TODO: implement this javax.resource.spi.ManagedConnectionFactory method
return 0;
}
/**
*
* @param param1 <description>
* @return <description>
*/
public boolean equals(Object param1)
{
// TODO: implement this javax.resource.spi.ManagedConnectionFactory method
return false;
}
/**
*
* @param param1 <description>
* @exception javax.resource.ResourceException <description>
*/
public void setLogWriter(PrintWriter param1) throws ResourceException
{
// TODO: implement this javax.resource.spi.ManagedConnectionFactory method
}
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public PrintWriter getLogWriter() throws ResourceException
{
// TODO: implement this javax.resource.spi.ManagedConnectionFactory method
return null;
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public Object createConnectionFactory(ConnectionManager param1) throws
ResourceException
{
// TODO: implement this javax.resource.spi.ManagedConnectionFactory method
return null;
}
/**
*
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public Object createConnectionFactory() throws ResourceException
{
// TODO: implement this javax.resource.spi.ManagedConnectionFactory method
return null;
}
/**
*
* @param param1 <description>
* @param param2 <description>
* @return <description>
* @exception javax.resource.ResourceException <description>
*/
public ManagedConnection createManagedConnection(Subject subject,
ConnectionRequestInfo cri) throws ResourceException
{
return new TestManagedConnection(subject, (TestConnectionRequestInfo)cri);
}
/**
* Describe <code>matchManagedConnections</code> method here.
*
* @param candidates a <code>Set</code> value
* @param subject a <code>Subject</code> value
* @param cri a <code>ConnectionRequestInfo</code> value
* @return a <code>ManagedConnection</code> value
* @exception ResourceException if an error occurs
*/
public ManagedConnection matchManagedConnections(Set candidates, Subject subject,
ConnectionRequestInfo cri) throws ResourceException
{
if (candidates.isEmpty())
{
return null;
} // end of if ()
return (ManagedConnection)candidates.iterator().next();
}
}
1.1
jbosstest/src/main/org/jboss/test/jca/adapter/TestXAResource.java
Index: TestXAResource.java
===================================================================
/*
* JBoss, the OpenSource J2EE webOS
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*
*/
package org.jboss.test.jca.adapter; // Generated package name
import javax.transaction.xa.XAException;
import javax.transaction.xa.XAResource;
import javax.transaction.xa.Xid;
/**
* TestXAResource.java
*
*
* Created: Mon Dec 31 19:55:31 2001
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Jencks</a>
* @version
*/
public class TestXAResource
implements XAResource {
public TestXAResource ()
{
}
// implementation of javax.transaction.xa.XAResource interface
/**
*
* @param param1 <description>
* @param param2 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void start(Xid param1, int param2) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
}
/**
*
* @param param1 <description>
* @param param2 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void end(Xid param1, int param2) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
}
/**
*
* @param param1 <description>
* @param param2 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void commit(Xid param1, boolean param2) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
}
/**
*
* @param param1 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void rollback(Xid param1) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public int prepare(Xid param1) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
return 0;
}
/**
*
* @param param1 <description>
* @exception javax.transaction.xa.XAException <description>
*/
public void forget(Xid param1) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public Xid[] recover(int param1) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
return null;
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public boolean isSameRM(XAResource param1) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
return false;
}
/**
*
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public int getTransactionTimeout() throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
return 0;
}
/**
*
* @param param1 <description>
* @return <description>
* @exception javax.transaction.xa.XAException <description>
*/
public boolean setTransactionTimeout(int param1) throws XAException
{
// TODO: implement this javax.transaction.xa.XAResource method
return false;
}
}// TestXAResource
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development