|
From: <tre...@us...> - 2007-08-31 23:39:13
|
Revision: 315
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=315&view=rev
Author: trevorolio
Date: 2007-08-31 16:39:11 -0700 (Fri, 31 Aug 2007)
Log Message:
-----------
Updated bootstrap.properties to include the cookies for the bootstrapped accounts, which will lessen the pain of whitebox testing.
Modified Paths:
--------------
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/migrate/AccountsForTesting.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/ServiceInitializationPersistTasks.java
maven/trunk/ogoglio-server/src/test/resources/bootstrap.properties
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/migrate/AccountsForTesting.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/migrate/AccountsForTesting.java 2007-08-31 23:08:57 UTC (rev 314)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/migrate/AccountsForTesting.java 2007-08-31 23:39:11 UTC (rev 315)
@@ -13,14 +13,14 @@
import com.ogoglio.persist.ServiceInitializationPersistTasks;
import com.ogoglio.util.PropStorage;
-
public class AccountsForTesting implements Migration {
public boolean patch(SessionFactory sessionFactory, ServletConfig config, Context ctx, int from, int to) {
- return true;
+ return true;
}
- public boolean populate(SessionFactory sessionFactory, int from, int to) throws PersistException{
+ public boolean populate(SessionFactory sessionFactory, int from, int to) throws PersistException {
+
if ((from != 0) || (to != 1)) {
System.out.println("Migration called in the wrong place! Expected 0->1 but was:" + from + "->" + to + "!");
System.out.println("Migration called in the wrong place! Check the ordering of migration array!");
@@ -28,37 +28,37 @@
}
try {
- String uriString, users, pws;
-
- PropStorage zap=new PropStorage();
- if (zap.loadPropertySet(PropStorage.BOOTSTRAP_PROPS)==false) {
- return false;
+ PropStorage zap = new PropStorage();
+ if (zap.loadPropertySet(PropStorage.BOOTSTRAP_PROPS) == false) {
+ return false;
}
- if (zap.loadPropertySet(PropStorage.BASIC_PROPS)==false) {
- return false;
+ if (zap.loadPropertySet(PropStorage.BASIC_PROPS) == false) {
+ return false;
}
- uriString = zap.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseUrl");
- users=zap.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "allBootstrapUsers");
- pws=zap.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "allBootstrapUsersPW");
-
- if ((uriString==null) || (users==null) || (pws==null)) {
- System.err.println("URI Offender in settings.xml:"+(uriString==null));
- System.err.println("USERS Offender in settings.xml:"+(users==null));
- System.err.println("PWS Offender in settings.xml:"+(pws==null));
- return false;
+ String uriString = zap.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseUrl");
+ String users = zap.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "allBootstrapUsers");
+ String pws = zap.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "allBootstrapUsersPW");
+ String cookies = zap.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "allBootstrapUsersCookies");
+
+ if ((uriString == null) || (users == null) || (pws == null) || cookies == null) {
+ System.err.println("URI Offender in settings.xml:" + (uriString == null));
+ System.err.println("USERS Offender in settings.xml:" + (users == null));
+ System.err.println("PWS Offender in settings.xml:" + (pws == null));
+ System.err.println("COOKIES Offender in settings.xml:" + (cookies == null));
+ return false;
}
String[] userList = users.split(Pattern.quote(","));
String[] pwList = pws.split(Pattern.quote(","));
-
- if (userList.length!=pwList.length) {
- System.err.println("Whoa! Settings.xml gave us a bootstrap user list and pw list of different lengths!");
- return false;
+ String[] cookiesList = cookies.split(Pattern.quote(","));
+ if (userList.length != pwList.length || userList.length != cookiesList.length) {
+ System.err.println("Whoa! Settings.xml gave us a bootstrap user, pw or cookie list of different lengths!");
+ return false;
}
URI uri = new URI(uriString);
- for (int i=0; i<userList.length;++i) {
- ServiceInitializationPersistTasks.initializeBootstrapAccount(sessionFactory, uri.getHost(), userList[i], pwList[i]);
+ for (int i = 0; i < userList.length; ++i) {
+ ServiceInitializationPersistTasks.initializeBootstrapAccount(sessionFactory, uri.getHost(), userList[i], pwList[i], cookiesList[i]);
}
ServiceInitializationPersistTasks.initializeLocalSim(uri, sessionFactory);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/ServiceInitializationPersistTasks.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/ServiceInitializationPersistTasks.java 2007-08-31 23:08:57 UTC (rev 314)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/persist/ServiceInitializationPersistTasks.java 2007-08-31 23:39:11 UTC (rev 315)
@@ -37,15 +37,15 @@
SimPersistTasks.createSim(LOCAL_SIM_DISPLAY_NAME, WebAPIUtil.appendToURI(serviceURI, "sim/"), SimRecord.DEFAULT_EVENT_PORT, true, sessionFactory);
}
- public static void initializeBootstrapAccount(SessionFactory sessionFactory,String host,String user, String pw) throws PersistException, IOException {
+ public static void initializeBootstrapAccount(SessionFactory sessionFactory,String host,String user, String pw, String cookie) throws PersistException, IOException {
AccountRecord accountRec = AccountPersistTasks.findAccountByUsername(user, sessionFactory);
if (accountRec != null) {
return;
}
accountRec = AccountPersistTasks.createAccount(user, "admin", user+"@"+host, sessionFactory);
accountRec.setPassword(pw);
+ accountRec.setCookie(cookie);
AccountPersistTasks.update(accountRec, sessionFactory);
-
}
public static void initializeServiceState(SessionFactory sessionFactory) throws PersistException, IOException{
Modified: maven/trunk/ogoglio-server/src/test/resources/bootstrap.properties
===================================================================
--- maven/trunk/ogoglio-server/src/test/resources/bootstrap.properties 2007-08-31 23:08:57 UTC (rev 314)
+++ maven/trunk/ogoglio-server/src/test/resources/bootstrap.properties 2007-08-31 23:39:11 UTC (rev 315)
@@ -1,4 +1,6 @@
allBootstrapUsers=${ogoglio.allBootstrapUsers}
allBootstrapUsersPW=${ogoglio.allBootstrapUsersPW}
+allBootstrapUsersCookies=${ogoglio.allBootstrapUsersCookies}
bootstrapUser=${ogoglio.bootstrapUser}
bootstrapUserPW=${ogoglio.bootstrapUserPW}
+allBootstrapUsersCookies=${ogoglio.allBootstrapUsersCookies}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|