00001
00025 package org.openmobileis.test.database;
00026
00027 import org.openmobileis.common.user.UserNotFoundException;
00028 import org.openmobileis.common.util.collection.Array;
00029 import org.openmobileis.common.util.exception.ServiceException;
00030 import org.openmobileis.database.fastobjectdb.FastObjectDB;
00031 import org.openmobileis.database.fastobjectdb.synchro.server.FODBSyncTarget;
00032 import org.openmobileis.synchro.algo.replication.AlwaysUpdateServerSynchroConflicResolver;
00033 import org.openmobileis.synchro.algo.replication.SynchroAtomicObject;
00034 import org.openmobileis.synchro.algo.replication.SynchroConflicResolver;
00035 import org.openmobileis.synchro.openmsp.OpenMSPException;
00036 import org.openmobileis.synchro.security.auth.Credential;
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 public final class TestDummyFODBSyncTarget implements FODBSyncTarget {
00047 public boolean connectCall = false;
00048 public String deleteCollectionObjectId = null;
00049 public boolean disconnectCall = false;
00050 public SynchroAtomicObject currentAO;
00051 public int updateMaxNbRow = 2;
00052 public Object synchroMetaData;
00053 public Object updateCollectionObject;
00054 public boolean updateSynchroDBCall = false;
00058 public TestDummyFODBSyncTarget() {
00059 }
00060
00061
00062
00063
00064 public void connect(Credential cred) throws UserNotFoundException, ServiceException {
00065 connectCall = true;
00066 deleteCollectionObjectId = null;
00067 disconnectCall = false;
00068 updateCollectionObject = null;
00069 synchroMetaData = null;
00070 updateSynchroDBCall = false;
00071 }
00072
00073
00074
00075
00076 public void deleteCollectionObject(String id) throws OpenMSPException {
00077 deleteCollectionObjectId = id;
00078 }
00079
00080
00081
00082
00083 public void disconnect() {
00084 disconnectCall = true;
00085 }
00086
00087
00088
00089
00090 public Array getAllCollectionObject() throws OpenMSPException {
00091 Array ret = new Array();
00092 DummyObject dum = new DummyObject("COMPLETE");
00093 dum.value = "complete synchro";
00094 ret.add(dum);
00095 return ret;
00096 }
00097
00098
00099
00100
00101 public SynchroAtomicObject[] getAllModifiedAtomicObjectSince(long syncnumber) throws OpenMSPException {
00102 if (currentAO != null) {
00103 SynchroAtomicObject[] ret = new SynchroAtomicObject[1];
00104 ret[0] = currentAO;
00105 return ret;
00106 } else {
00107 return new SynchroAtomicObject[0];
00108 }
00109 }
00110
00111
00112
00113
00114 public String getCollectionName() {
00115 return "dummy";
00116 }
00117
00118
00119
00120
00121 public Object getCollectionObjectWithId(String id) throws OpenMSPException {
00122 DummyObject ret = new DummyObject(id);
00123 ret.value = "getCollectionObjectWithId";
00124 return ret;
00125 }
00126
00127
00128
00129
00130 public SynchroConflicResolver getConflicResolver() {
00131 return new AlwaysUpdateServerSynchroConflicResolver();
00132 }
00133
00134
00135
00136
00137 public int getUpdateMaxNbRow() {
00138 return updateMaxNbRow;
00139 }
00140
00141
00142
00143
00144 public void setSendSynchroMetaData(Object metadata) throws OpenMSPException {
00145 synchroMetaData = metadata;
00146
00147 }
00148
00149
00150
00151
00152 public void updateCollectionObject(Object obj) throws OpenMSPException {
00153 updateCollectionObject = obj;
00154
00155 }
00156
00157
00158
00159
00160 public void updateSynchroDB(FastObjectDB db) throws OpenMSPException {
00161 updateSynchroDBCall = true;
00162 }
00163
00164 }