diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2013-10-07 13:23:08 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2013-10-07 13:23:08 +0200 |
commit | 663ad546237fe9102c97e0eed2970e703d3034d9 (patch) | |
tree | 5c4ecf3fd1a1a2ed3e55958e926b972584962f5e /id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java | |
parent | b0f09b21746380c80b738a051f313caf0b0b684d (diff) | |
download | moa-id-spss-663ad546237fe9102c97e0eed2970e703d3034d9.tar.gz moa-id-spss-663ad546237fe9102c97e0eed2970e703d3034d9.tar.bz2 moa-id-spss-663ad546237fe9102c97e0eed2970e703d3034d9.zip |
Code CleanUP
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java')
-rw-r--r-- | id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java index bbebbed57..dadbc494b 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/monitoring/TestManager.java @@ -1,27 +1,45 @@ package at.gv.egovernment.moa.id.monitoring; -import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import at.gv.egovernment.moa.id.config.ConfigurationException; +import at.gv.egovernment.moa.id.config.auth.AuthConfigurationProvider; import at.gv.egovernment.moa.logging.Logger; public class TestManager { private static TestManager instance; - private List<TestModuleInterface> tests = new ArrayList<TestModuleInterface>(); + private Map<String, TestModuleInterface> tests = new HashMap<String, TestModuleInterface>(); - public static TestManager getInstance() { + public static TestManager getInstance() throws ConfigurationException { if (instance == null) instance = new TestManager(); return instance; } - private TestManager() { - tests.add(new DatabaseTestModule()); - tests.add(new IdentityLinkTestModule()); + private TestManager() throws ConfigurationException { + + AuthConfigurationProvider config = AuthConfigurationProvider.getInstance(); + + //add Database test + DatabaseTestModule test1 = new DatabaseTestModule(); + tests.put(test1.getName(), test1); + + //add IdentityLink verification test + IdentityLinkTestModule test2 = new IdentityLinkTestModule(); + String idlurl = config.getMonitoringTestIdentityLinkURL(); + try { + test2.initializeTest(0, idlurl); + tests.put(test2.getName(), test2);; + + } catch (Exception e) { + Logger.warn("MOA-ID IdentityLink Test can not performed without IdentityLink. Insert IdentityLink file to MOA-ID configuration", e); + } } public List<String> executeTests() { @@ -30,7 +48,7 @@ public class TestManager { List<String> errors; - for (TestModuleInterface test : tests) { + for (TestModuleInterface test : tests.values()) { try { errors = test.performTests(); if (errors != null && errors.size() > 0) @@ -44,4 +62,27 @@ public class TestManager { return null; } + + public List<String> executeTest(String testname) { + + TestModuleInterface test = tests.get(testname); + + if (test != null) { + try { + return test.performTests(); + + } catch (Exception e) { + Logger.warn("General Testing Eception during Test " + test.getName() + ": ", e); + return Arrays.asList(e.getMessage()); + } + + } else { + Logger.info("TestModule with Name " + testname + " is not implemented"); + return null; + } + } + + public boolean existsModule(String modulename) { + return tests.containsKey(modulename); + } } |