KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > geronimo > transaction > mockjpa > MockEntityManager


1 /**
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.geronimo.transaction.mockjpa;
19
20 import java.util.Map JavaDoc;
21
22 import javax.persistence.EntityManager;
23 import javax.persistence.FlushModeType;
24 import javax.persistence.LockModeType;
25 import javax.persistence.Query;
26 import javax.persistence.EntityTransaction;
27
28 /**
29  * @version $Rev: 476049 $ $Date: 2006-11-16 23:35:17 -0500 (Thu, 16 Nov 2006) $
30  */

31 public class MockEntityManager implements EntityManager {
32
33     private final Map JavaDoc properties;
34     private boolean closed = false;
35     private boolean cleared = false;
36     private boolean joined = false;
37
38     public MockEntityManager() {
39         properties = null;
40     }
41
42     public MockEntityManager(Map JavaDoc properties) {
43         this.properties = properties;
44     }
45
46     public void persist(Object JavaDoc object) {
47     }
48
49     public <T> T merge(T t) {
50         return null;
51     }
52
53     public void remove(Object JavaDoc object) {
54     }
55
56     public <T> T find(Class JavaDoc<T> aClass, Object JavaDoc object) {
57         if (aClass == Map JavaDoc.class && "properties".equals(object)) {
58             return (T)properties;
59         }
60         if (aClass == EntityManager.class && "this".equals(object)) {
61             return (T)this;
62         }
63         return null;
64    }
65
66     public <T> T getReference(Class JavaDoc<T> aClass, Object JavaDoc object) {
67         return null;
68     }
69
70     public void flush() {
71     }
72
73     public void setFlushMode(FlushModeType flushModeType) {
74     }
75
76     public FlushModeType getFlushMode() {
77         return null;
78     }
79
80     public void lock(Object JavaDoc object, LockModeType lockModeType) {
81     }
82
83     public void refresh(Object JavaDoc object) {
84     }
85
86     public void clear() {
87         cleared = true;
88     }
89
90     public boolean contains(Object JavaDoc object) {
91         return false;
92     }
93
94     public Query createQuery(String JavaDoc string) {
95         return null;
96     }
97
98     public Query createNamedQuery(String JavaDoc string) {
99         return null;
100     }
101
102     public Query createNativeQuery(String JavaDoc string) {
103         return null;
104     }
105
106     public Query createNativeQuery(String JavaDoc string, Class JavaDoc aClass) {
107         return null;
108     }
109
110     public Query createNativeQuery(String JavaDoc string, String JavaDoc string1) {
111         return null;
112     }
113
114     public void close() {
115         closed = true;
116     }
117
118     public boolean isOpen() {
119         return !closed;
120     }
121
122     public EntityTransaction getTransaction() {
123         return null;
124     }
125
126     public void joinTransaction() {
127         joined = true;
128     }
129
130     public Object JavaDoc getDelegate() {
131         return null;
132     }
133
134     public Map JavaDoc getProperties() {
135         return properties;
136     }
137
138     public boolean isClosed() {
139         return closed;
140     }
141
142     public boolean isCleared() {
143         return cleared;
144     }
145
146     public boolean isJoined() {
147         return joined;
148     }
149 }
150
Popular Tags