Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2009-01-26 22:25:35 +0000
committerslewis2009-01-26 22:25:35 +0000
commit036ebb4911070512675892cceed804fb63480a60 (patch)
tree09f7dbd29bcb7072b5de3f870018dd9773b4d0a3 /tests/bundles/org.eclipse.ecf.tests
parente8fa6399c79f790bc4105c4191a7c0ba184e2330 (diff)
downloadorg.eclipse.ecf-036ebb4911070512675892cceed804fb63480a60.tar.gz
org.eclipse.ecf-036ebb4911070512675892cceed804fb63480a60.tar.xz
org.eclipse.ecf-036ebb4911070512675892cceed804fb63480a60.zip
Fix for use of usernames and passwords whether needed or not
Diffstat (limited to 'tests/bundles/org.eclipse.ecf.tests')
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/ContainerAbstractTestCase.java40
1 files changed, 29 insertions, 11 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/ContainerAbstractTestCase.java b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/ContainerAbstractTestCase.java
index 2c12d7e29..6fb23181c 100755
--- a/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/ContainerAbstractTestCase.java
+++ b/tests/bundles/org.eclipse.ecf.tests/src/org/eclipse/ecf/tests/ContainerAbstractTestCase.java
@@ -12,8 +12,10 @@
package org.eclipse.ecf.tests;
import java.net.Socket;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.ecf.core.ContainerConnectException;
import org.eclipse.ecf.core.ContainerFactory;
@@ -52,6 +54,7 @@ public abstract class ContainerAbstractTestCase extends ECFAbstractTestCase {
protected void setUp() throws Exception {
super.setUp();
findEmptySocket();
+ loadUsernamesAndPasswords();
}
/**
@@ -147,22 +150,36 @@ public abstract class ContainerAbstractTestCase extends ECFAbstractTestCase {
protected IContainer[] createClients() throws Exception {
final IContainer[] result = new IContainer[getClientCount()];
- usernames = new String[getClientCount()];
- passwords = new String[getClientCount()];
for (int i = 0; i < result.length; i++) {
result[i] = createClient(i);
- String uname = System.getProperty("username" + i);
- if (uname == null && i == 0)
+ }
+ return result;
+ }
+
+ protected void loadUsernamesAndPasswords() {
+ // Default behavior is to look for system properties
+ int i = 0;
+ boolean done = false;
+ List us = new ArrayList();
+ List ps = new ArrayList();
+ while (!done) {
+ String uname = System.getProperty("username"+i);
+ String pword = System.getProperty("password"+i);
+ if (uname == null && i==0) {
uname = System.getProperty("username");
- if (uname != null)
- usernames[i] = uname;
- String pword = System.getProperty("password" + i);
- if (pword == null && i == 0)
pword = System.getProperty("password");
- if (pword != null)
- passwords[i] = pword;
+ }
+ if (uname == null) {
+ done = true;
+ } else {
+ us.add(uname);
+ ps.add(pword);
+ }
+ }
+ if (us.size() > 0) {
+ usernames = (String []) us.toArray(new String [] {});
+ passwords = (String []) ps.toArray(new String [] {});
}
- return result;
}
protected IContainer createClient(int index) throws Exception {
@@ -201,6 +218,7 @@ public abstract class ContainerAbstractTestCase extends ECFAbstractTestCase {
}
protected IConnectContext getConnectContext(int client) {
+ if (usernames == null) return null;
return createUsernamePasswordConnectContext(getUsername(client), getPassword(client));
}

Back to the top