summaryrefslogtreecommitdiff
path: root/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java
diff options
context:
space:
mode:
Diffstat (limited to 'eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java')
-rw-r--r--eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java165
1 files changed, 165 insertions, 0 deletions
diff --git a/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java
new file mode 100644
index 00000000..15359261
--- /dev/null
+++ b/eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java
@@ -0,0 +1,165 @@
+/*******************************************************************************
+ *******************************************************************************/
+package at.gv.egiz.eaaf.core.impl.idp.process.spring.test;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import at.gv.egiz.eaaf.core.api.storage.ITransactionStorage;
+import at.gv.egiz.eaaf.core.exceptions.EAAFException;
+
+/**
+ * Dummy DataSource implementation for convenience in test cases where a
+ * database connection will never actually be acquired.
+ *
+ * @see DataSource
+ * @author Chris Beams
+ */
+public class DummyTransactionStorage implements ITransactionStorage {
+
+ private static final Logger log = LoggerFactory.getLogger(DummyTransactionStorage.class);
+
+
+ public class DummyDBEntry{
+ public DummyDBEntry(String key, Object value){
+ this.obj =value;
+ this.key = key;
+ }
+ public String getKey() {
+ return key;
+ }
+ public void setKey(String key) {
+ this.key = key;
+ }
+ public Object getObj() {
+ return obj;
+ }
+ public void setObj(Object obj) {
+ this.obj = obj;
+ }
+ private String key;
+ private Object obj;
+ }
+
+ private ArrayList<DummyDBEntry> ds = new ArrayList<DummyDBEntry>();
+
+
+
+ @Override
+ public boolean containsKey(String key) {
+ // TODO Auto-generated method stub
+ Iterator<DummyDBEntry> it = ds.iterator();
+ while(it.hasNext()){
+ DummyDBEntry t = it.next();
+ if(t.getKey().equals(key))
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void put(String key, Object value, int timeout)
+ throws EAAFException {
+ // TODO Auto-generated method stub
+ this.remove(key);
+ this.ds.add(new DummyDBEntry(key, value));
+
+ }
+
+ @Override
+ public Object get(String key) throws EAAFException {
+ // TODO Auto-generated method stub
+ Iterator<DummyDBEntry> it = ds.iterator();
+ while(it.hasNext()){
+ DummyDBEntry t = it.next();
+ if(t.getKey().equals(key))
+ return t;
+ }
+ return null;
+ }
+
+ @Override
+ public <T> T get(String key, Class<T> clazz) throws EAAFException {
+
+ DummyDBEntry o = (DummyDBEntry) get(key);
+ if(o == null)
+ return null;
+ try {
+ @SuppressWarnings("unchecked")
+ T test = (T) (clazz.cast(o.getObj()));
+ return test;
+
+ } catch (Exception e) {
+ log.warn("Sessioninformation Cast-Exception by using Artifact=" + key);
+ throw new EAAFException("Sessioninformation Cast-Exception");
+
+ }
+ }
+
+ @Override
+ public <T> T get(String key, Class<T> clazz, long dataTimeOut)
+ throws EAAFException {
+ // TODO Auto-generated method stub
+ return get(key,clazz);
+ }
+
+ @Override
+ public void changeKey(String oldKey, String newKey, Object value)
+ throws EAAFException {
+ this.remove(oldKey);
+ this.put(newKey, value, -1);
+
+ }
+
+ @Override
+ public void remove(String key) {
+ Iterator<DummyDBEntry> it = ds.iterator();
+ while(it.hasNext()){
+ DummyDBEntry t = it.next();
+ if(t.getKey().equals(key)){
+ this.ds.remove(t);
+ return;
+ }
+ }
+
+ }
+
+ @Override
+ public List<String> clean(Date now, long dataTimeOut) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public Object getRaw(String key) throws EAAFException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void putRaw(String key, Object element) throws EAAFException {
+ // TODO Auto-generated method stub
+
+ }
+
+// @Override
+// public Object getAssertionStore(String key) throwsEAAFException {
+// // TODO Auto-generated method stub
+// return null;
+// }
+//
+// @Override
+// public void putAssertionStore(Object element) throws EAAFException {
+// // TODO Auto-generated method stub
+//
+// }
+
+
+} \ No newline at end of file