diff options
author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2019-12-04 19:43:32 +0100 |
---|---|---|
committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2019-12-04 19:43:32 +0100 |
commit | 759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f (patch) | |
tree | 2132024fc058b1ef5338bf50df575a3244cc3f9f /eaaf_core/src/test/java/at/gv/egiz/eaaf/core/impl/idp/process/spring/test/DummyTransactionStorage.java | |
parent | 4f15bdc45b08724d20c66c9fd74ea6a43a03c32f (diff) | |
download | EAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.tar.gz EAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.tar.bz2 EAAF-Components-759ac5f42c6aff901dbeede4fbf1a1d2e08cad0f.zip |
common EGIZ code-style refactoring
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.java | 335 |
1 files changed, 166 insertions, 169 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 index 4795fdf4..cc1d57cd 100644 --- 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 @@ -1,189 +1,186 @@ -/******************************************************************************* - * Copyright 2017 Graz University of Technology - * EAAF-Core Components has been developed in a cooperation between EGIZ, - * A-SIT Plus, A-SIT, and Graz University of Technology. +/* + * Copyright 2017 Graz University of Technology EAAF-Core Components has been developed in a + * cooperation between EGIZ, A-SIT Plus, A-SIT, and Graz University of Technology. * - * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: + * Licensed under the EUPL, Version 1.2 or - as soon they will be approved by the European + * Commission - subsequent versions of the EUPL (the "Licence"); You may not use this work except in + * compliance with the Licence. You may obtain a copy of the Licence at: * https://joinup.ec.europa.eu/news/understanding-eupl-v12 * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - *******************************************************************************/ -/******************************************************************************* - *******************************************************************************/ -/******************************************************************************* - *******************************************************************************/ + * Unless required by applicable law or agreed to in writing, software distributed under the Licence + * is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the Licence for the specific language governing permissions and limitations under + * the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text file for details on the + * various modules and licenses. The "NOTICE" text file is part of the distribution. Any derivative + * works that you distribute must include a readable copy of the "NOTICE" text file. +*/ + 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 at.gv.egiz.eaaf.core.api.storage.ITransactionStorage; +import at.gv.egiz.eaaf.core.exceptions.EaafException; 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. + * 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 + private static final Logger log = LoggerFactory.getLogger(DummyTransactionStorage.class); + + + public class DummyDbEntry { + public DummyDbEntry(final String key, final Object value) { + this.obj = value; + this.key = key; + } + + public String getKey() { + return key; + } + + public void setKey(final String key) { + this.key = key; + } + + public Object getObj() { + return obj; + } + + public void setObj(final Object obj) { + this.obj = obj; + } + + private String key; + private Object obj; + } + + private final ArrayList<DummyDbEntry> ds = new ArrayList<>(); + + + + @Override + public boolean containsKey(final String key) { + // TODO Auto-generated method stub + final Iterator<DummyDbEntry> it = ds.iterator(); + while (it.hasNext()) { + final DummyDbEntry t = it.next(); + if (t.getKey().equals(key)) { + return true; + } + } + return false; + } + + @Override + public void put(final String key, final Object value, final int timeout) throws EaafException { + // TODO Auto-generated method stub + this.remove(key); + this.ds.add(new DummyDbEntry(key, value)); + + } + + @Override + public Object get(final String key) throws EaafException { + // TODO Auto-generated method stub + final Iterator<DummyDbEntry> it = ds.iterator(); + while (it.hasNext()) { + final DummyDbEntry t = it.next(); + if (t.getKey().equals(key)) { + return t; + } + } + return null; + } + + @Override + public <T> T get(final String key, final Class<T> clazz) throws EaafException { + + final DummyDbEntry o = (DummyDbEntry) get(key); + if (o == null) { + return null; + } + try { + @SuppressWarnings("unchecked") + final T test = (clazz.cast(o.getObj())); + return test; + + } catch (final Exception e) { + log.warn("Sessioninformation Cast-Exception by using Artifact=" + key); + throw new EaafException("Sessioninformation Cast-Exception"); + + } + } + + @Override + public <T> T get(final String key, final Class<T> clazz, final long dataTimeOut) + throws EaafException { + // TODO Auto-generated method stub + return get(key, clazz); + } + + @Override + public void changeKey(final String oldKey, final String newKey, final Object value) + throws EaafException { + this.remove(oldKey); + this.put(newKey, value, -1); + + } + + @Override + public void remove(final String key) { + final Iterator<DummyDbEntry> it = ds.iterator(); + while (it.hasNext()) { + final DummyDbEntry t = it.next(); + if (t.getKey().equals(key)) { + this.ds.remove(t); + return; + } + } + + } + + @Override + public List<String> clean(final Date now, final long dataTimeOut) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Object getRaw(final String key) throws EaafException { + // TODO Auto-generated method stub + return null; + } + + @Override + public void putRaw(final String key, final 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 + // + // } + + +} |