1 22 package org.jboss.test.jca.adapter; 23 24 import javax.resource.ResourceException ; 25 import javax.resource.cci.Connection ; 26 import javax.resource.cci.ConnectionMetaData ; 27 import javax.resource.cci.Interaction ; 28 import javax.resource.cci.LocalTransaction ; 29 import javax.resource.cci.ResultSetInfo ; 30 31 40 public class TestConnection implements Connection 41 { 42 private TestManagedConnection mc; 43 44 private boolean mcIsNull = true; 45 46 public TestConnection(TestManagedConnection mc) 47 { 48 this.mc = mc; 49 mcIsNull = false; 50 } 51 52 public boolean getMCIsNull() 53 { 54 return mcIsNull; 55 } 56 57 public void setFailInPrepare(final boolean fail, final int xaCode) 58 { 59 mc.setFailInPrepare(fail, xaCode); 60 } 61 62 public void setFailInStart(final boolean fail, final int xaCode) 63 { 64 65 } 66 public void setFailInCommit(final boolean fail, final int xaCode) 67 { 68 mc.setFailInCommit(fail, xaCode); 69 } 70 71 public void fireConnectionError() 72 { 73 mc.connectionError(this, new Exception ("ConnectionError")); 74 } 75 76 public boolean isInTx() 77 { 78 return mc.isInTx(); 79 } 80 81 void setMc(TestManagedConnection mc) 82 { 83 if (mc == null) 84 { 85 mcIsNull = true; 86 } else 88 { 89 this.mc = mc; 90 } } 92 93 public String getLocalState() 94 { 95 return mc.getLocalState(); 96 } 97 98 public void begin() throws Exception 99 { 100 mc.sendBegin(); 101 } 102 103 public void commit() throws Exception 104 { 105 mc.sendCommit(); 106 } 107 108 public void rollback() throws Exception 109 { 110 mc.sendRollback(); 111 } 112 113 115 119 public void close() 120 { 121 mc.connectionClosed(this); 122 mcIsNull = true; 123 } 124 125 public TestManagedConnection getMC() 126 { 127 return mc; 128 } 129 130 135 public Interaction createInteraction() throws ResourceException 136 { 137 return null; 139 } 140 141 146 public LocalTransaction getLocalTransaction() throws ResourceException 147 { 148 return null; 150 } 151 152 157 public ConnectionMetaData getMetaData() throws ResourceException 158 { 159 return null; 161 } 162 163 168 public ResultSetInfo getResultSetInfo() throws ResourceException 169 { 170 return null; 172 } 173 174 177 public void simulateConnectionError() throws Exception 178 { 179 Exception e = new Exception ("Simulated exception"); 180 mc.connectionError(this, e); 181 throw e; 182 } 183 184 } 186 | Popular Tags |