001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */package org.apache.geronimo.transaction.mockjpa;
017:
018: import java.util.Map;
019:
020: import javax.persistence.EntityManager;
021: import javax.persistence.FlushModeType;
022: import javax.persistence.LockModeType;
023: import javax.persistence.Query;
024: import javax.persistence.EntityTransaction;
025:
026: /**
027: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
028: */
029: public class MockEntityManager implements EntityManager {
030:
031: private final Map properties;
032: private boolean closed = false;
033: private boolean cleared = false;
034: private boolean joined = false;
035:
036: public MockEntityManager() {
037: properties = null;
038: }
039:
040: public MockEntityManager(Map properties) {
041: this .properties = properties;
042: }
043:
044: public void persist(Object object) {
045: }
046:
047: public <T> T merge(T t) {
048: return null;
049: }
050:
051: public void remove(Object object) {
052: }
053:
054: public <T> T find(Class<T> aClass, Object object) {
055: if (aClass == Map.class && "properties".equals(object)) {
056: return (T) properties;
057: }
058: if (aClass == EntityManager.class && "this".equals(object)) {
059: return (T) this ;
060: }
061: return null;
062: }
063:
064: public <T> T getReference(Class<T> aClass, Object object) {
065: return null;
066: }
067:
068: public void flush() {
069: }
070:
071: public void setFlushMode(FlushModeType flushModeType) {
072: }
073:
074: public FlushModeType getFlushMode() {
075: return null;
076: }
077:
078: public void lock(Object object, LockModeType lockModeType) {
079: }
080:
081: public void refresh(Object object) {
082: }
083:
084: public void clear() {
085: cleared = true;
086: }
087:
088: public boolean contains(Object object) {
089: return false;
090: }
091:
092: public Query createQuery(String string) {
093: return null;
094: }
095:
096: public Query createNamedQuery(String string) {
097: return null;
098: }
099:
100: public Query createNativeQuery(String string) {
101: return null;
102: }
103:
104: public Query createNativeQuery(String string, Class aClass) {
105: return null;
106: }
107:
108: public Query createNativeQuery(String string, String string1) {
109: return null;
110: }
111:
112: public void close() {
113: closed = true;
114: }
115:
116: public boolean isOpen() {
117: return !closed;
118: }
119:
120: public EntityTransaction getTransaction() {
121: return null;
122: }
123:
124: public void joinTransaction() {
125: joined = true;
126: }
127:
128: public Object getDelegate() {
129: return null;
130: }
131:
132: public Map getProperties() {
133: return properties;
134: }
135:
136: public boolean isClosed() {
137: return closed;
138: }
139:
140: public boolean isCleared() {
141: return cleared;
142: }
143:
144: public boolean isJoined() {
145: return joined;
146: }
147: }
|