1
2
3
4 package com.github.smokestack.jca.spi;
5
6 import java.io.PrintWriter;
7 import java.util.Set;
8
9 import javax.resource.ResourceException;
10 import javax.resource.spi.ConnectionManager;
11 import javax.resource.spi.ConnectionRequestInfo;
12 import javax.resource.spi.ManagedConnection;
13 import javax.resource.spi.ManagedConnectionFactory;
14 import javax.security.auth.Subject;
15
16 import org.apache.commons.lang.builder.ReflectionToStringBuilder;
17 import org.apache.commons.lang.builder.ToStringStyle;
18
19 import com.github.smokestack.exception.NeedsMockDefinitionException;
20
21
22
23
24
25 public class MockManagedConnectionFactory implements ManagedConnectionFactory {
26
27
28
29
30 private static final long serialVersionUID = -8203801341248772653L;
31
32 protected PrintWriter printWriter;
33
34
35
36
37 public Object createConnectionFactory() throws ResourceException {
38 return _createConnectionFactory();
39 }
40
41 public Object _createConnectionFactory() throws ResourceException {
42 throw new NeedsMockDefinitionException();
43 }
44
45
46
47
48 public Object createConnectionFactory(ConnectionManager connectionManager) throws ResourceException {
49 return _createConnectionFactory(connectionManager);
50 }
51
52 public Object _createConnectionFactory(ConnectionManager connectionManager) throws ResourceException {
53 return connectionManager.allocateConnection(this, null);
54 }
55
56
57
58
59 public ManagedConnection createManagedConnection(Subject subject,
60 ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
61 return _createManagedConnection(subject, connectionRequestInfo);
62 }
63
64 public ManagedConnection _createManagedConnection(Subject subject,
65 ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
66 throw new NeedsMockDefinitionException();
67 }
68
69
70
71
72 public PrintWriter getLogWriter() throws ResourceException {
73 _getLogWriter();
74 return printWriter;
75 }
76
77 public PrintWriter _getLogWriter() throws ResourceException {
78 return null;
79 }
80
81
82
83
84 public ManagedConnection matchManagedConnections(Set set, Subject subject,
85 ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
86 return _matchManagedConnections(set, subject, connectionRequestInfo);
87 }
88
89 public ManagedConnection _matchManagedConnections(Set set, Subject subject,
90 ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
91 throw new NeedsMockDefinitionException();
92 }
93
94
95
96
97 public void setLogWriter(PrintWriter printWriter) throws ResourceException {
98 _setLogWriter(printWriter);
99 this.printWriter=printWriter;
100 }
101
102 public void _setLogWriter(PrintWriter printWriter) throws ResourceException {
103 }
104
105 public String toString(){
106 return ReflectionToStringBuilder.toString(this, ToStringStyle.MULTI_LINE_STYLE);
107 }
108 }