|
From: <tre...@us...> - 2007-09-02 20:04:50
|
Revision: 337
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=337&view=rev
Author: trevorolio
Date: 2007-09-02 13:04:44 -0700 (Sun, 02 Sep 2007)
Log Message:
-----------
Added a basic sanity check with the viewer applet during the integration tests.
It doesn't do much more than load a space with a test cube for the moment.
This test does not check that the applet will load properly from the server, but simply that the java code will actually open a space client, load a thing via the web api, and render it once.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java 2007-09-02 20:04:41 UTC (rev 336)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java 2007-09-02 20:04:44 UTC (rev 337)
@@ -14,7 +14,6 @@
package com.ogoglio.client.test;
-import java.applet.Applet;
import java.applet.AppletContext;
import java.applet.AppletStub;
import java.awt.BorderLayout;
@@ -24,70 +23,55 @@
import java.awt.GraphicsEnvironment;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import com.ogoglio.client.WebAPIAuthenticator;
import com.ogoglio.client.WebAPIClientWire;
import com.ogoglio.client.WebAPIDescriptor;
+import com.ogoglio.util.ArgumentUtils;
import com.ogoglio.util.PropStorage;
import com.ogoglio.viewer.applet.ViewerApplet;
public class AppletTestWindow extends Frame {
- //static Dimension appDimension = new Dimension(640, 500);
- //static Dimension appDimension = new Dimension(500, 522);
- static Dimension appDimension = new Dimension(1000, 640);
+ Dimension appDimension = new Dimension(500, 500);
- Applet applet = null;
+ public ViewerApplet applet = null;
EnvironmentStub clientStub1 = null;
- String host = "127.0.0.1:8080";
+ URI serviceURI = null;
- String serviceURI = "http://" + host + "/og/";
+ public AppletTestWindow(URI serviceURI, long spaceID, String authCookie, Dimension appDimension, boolean decorated) {
+ ArgumentUtils.assertNotNull(appDimension);
+ this.appDimension = appDimension;
+ ArgumentUtils.assertNotNull(serviceURI);
+ this.serviceURI = serviceURI;
- URL codeBase = getURL(serviceURI);
-
- static boolean fullScreen = false;
-
- public AppletTestWindow() {
setLayout(new BorderLayout());
setSize(appDimension);
setLocation(30, 50);
setResizable(false);
- if (fullScreen) {
+ if (!decorated) {
this.setUndecorated(true);
}
-
HashMap parameters1 = new HashMap();
- try {
- PropStorage ps=new PropStorage();
- ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS);
- WebAPIAuthenticator authenticator = new WebAPIAuthenticator(new WebAPIClientWire(), new WebAPIDescriptor(new URI(serviceURI)),
- ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"),
- ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
- parameters1.put("loginCookie", authenticator.getAuthCookie());
- } catch (Exception e) {
- e.printStackTrace();
- }
- //parameters1.put("loginCookie", "guestApplet_Test_Window2");
+ parameters1.put("loginCookie", authCookie);
+ parameters1.put("spaceID", "" + spaceID);
+ parameters1.put("serviceURI", serviceURI.toString());
- parameters1.put("spaceID", "" + System.getProperty("AppletTestWindow.space"));
- parameters1.put("serviceURI", serviceURI);
-
//parameters1.put("x", "0");
//parameters1.put("y", "1000");
//parameters1.put("z", "0");
//parameters1.put("rx", "-1.6");
//parameters1.put("ry", "0");
//parameters1.put("rz", "0");
-
//parameters1.put("movable", "false");
clientStub1 = new EnvironmentStub(parameters1);
applet = new ViewerApplet();
- //applet = new BodyEditorApplet();
applet.setStub(clientStub1);
add(applet, BorderLayout.CENTER);
}
@@ -108,11 +92,19 @@
}
public URL getCodeBase() {
- return codeBase;
+ try {
+ return serviceURI.toURL();
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException("Could not convert serviceURI to URL: " + serviceURI);
+ }
}
public URL getDocumentBase() {
- return codeBase;
+ try {
+ return serviceURI.toURL();
+ } catch (MalformedURLException e) {
+ throw new IllegalStateException("Could not convert serviceURI to URL: " + serviceURI);
+ }
}
public String getParameter(String name) {
@@ -130,26 +122,43 @@
applet.start();
}
- private static URL getURL(String url) {
- try {
- return new URL(url);
- } catch (MalformedURLException e) {
- throw new IllegalStateException("Bad url: " + url);
- }
+ public void cleanup(){
+ applet.destroy();
}
public static void main(String[] args) {
GraphicsEnvironment graphicsEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice device = graphicsEnv.getDefaultScreenDevice();
+ Dimension dim = new Dimension(1024, 800);
+ boolean fullScreen = args.length > 0 && "fullscreen".equals(args[0]);
if (fullScreen) {
- appDimension = new Dimension(device.getDisplayMode().getWidth(), device.getDisplayMode().getWidth());
+ dim = new Dimension(device.getDisplayMode().getWidth(), device.getDisplayMode().getWidth());
}
- AppletTestWindow test = new AppletTestWindow();
- test.setVisible(true);
- if (fullScreen) {
- device.setFullScreenWindow(test);
+ String serviceURI = "http://127.0.0.1:8080/og/";
+ String loginCookie = null;
+ try {
+ PropStorage ps = new PropStorage();
+ ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS);
+ WebAPIAuthenticator authenticator = new WebAPIAuthenticator(new WebAPIClientWire(), new WebAPIDescriptor(new URI(serviceURI)), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
+ loginCookie = authenticator.getAuthCookie();
+ } catch (Exception e) {
+ e.printStackTrace();
+ System.exit(1);
}
- test.start();
+
+ long spaceID = Long.parseLong(System.getProperty("AppletTestWindow.space"));
+
+ try {
+ AppletTestWindow test = new AppletTestWindow(new URI(serviceURI), spaceID, loginCookie, dim, fullScreen);
+ test.setVisible(true);
+ if (fullScreen) {
+ device.setFullScreenWindow(test);
+ }
+ test.start();
+ } catch (URISyntaxException e) {
+ e.printStackTrace();
+ System.exit(1);
+ }
}
}
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-09-02 20:04:41 UTC (rev 336)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-09-02 20:04:44 UTC (rev 337)
@@ -13,6 +13,7 @@
limitations under the License. */
package com.ogoglio.client.test;
+import java.awt.Dimension;
import java.awt.Shape;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -28,6 +29,7 @@
import junit.framework.TestCase;
import nanoxml.XMLElement;
+import com.ogoglio.client.AuthenticationFailedException;
import com.ogoglio.client.SpaceClient;
import com.ogoglio.client.WebAPIAuthenticator;
import com.ogoglio.client.WebAPIAuthenticatorFactory;
@@ -97,88 +99,83 @@
}
- public void testWebAdmin() {
- try {
- PropStorage ps = new PropStorage();
- if (ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS) == false) {
- fail("unable to load properties bootstrap.properties!");
- }
+ public void testWebAdmin() throws AuthenticationFailedException, IOException {
+ PropStorage ps = new PropStorage();
+ if (ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS) == false) {
+ fail("unable to load properties bootstrap.properties!");
+ }
- WebAPIAuthenticator adminAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
+ WebAPIAuthenticator adminAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUser"), ps.getKeyFromSet(PropStorage.BOOTSTRAP_PROPS, "bootstrapUserPW"));
- assertNotNull("got null auth cookie", adminAuthenticator.getAuthCookie());
+ assertNotNull("got null auth cookie", adminAuthenticator.getAuthCookie());
- WebAPIClient adminWebClient = new WebAPIClient(descriptor1, adminAuthenticator, wire1);
- adminWebClient.createAccount(USERNAME1, AccountDocument.ACCOUNT_LEVEL_ADVANCED, "Susan", "Examplar", "http://example.com/susan/", "su...@ex...", PASSWORD1);
- adminWebClient.createAccount(USERNAME2, AccountDocument.ACCOUNT_LEVEL_ADVANCED, "Tina", "Examplar", "http://example.com/tina/", "ti...@ex...", PASSWORD1);
+ WebAPIClient adminWebClient = new WebAPIClient(descriptor1, adminAuthenticator, wire1);
+ adminWebClient.createAccount(USERNAME1, AccountDocument.ACCOUNT_LEVEL_ADVANCED, "Susan", "Examplar", "http://example.com/susan/", "su...@ex...", PASSWORD1);
+ adminWebClient.createAccount(USERNAME2, AccountDocument.ACCOUNT_LEVEL_ADVANCED, "Tina", "Examplar", "http://example.com/tina/", "ti...@ex...", PASSWORD1);
- assertNotNull(adminWebClient.getAccountDocument(USERNAME1));
- assertNotNull(adminWebClient.getAccountDocument(USERNAME2));
+ assertNotNull(adminWebClient.getAccountDocument(USERNAME1));
+ assertNotNull(adminWebClient.getAccountDocument(USERNAME2));
- WebAPIAuthenticator basicAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, USERNAME1, PASSWORD1);
- assertNotNull("got null auth cookie", basicAuthenticator.getAuthCookie());
- WebAPIClient basicWebClient = new WebAPIClient(descriptor1, basicAuthenticator, wire1);
- try {
- String failedUsername = "Bogosity" + System.currentTimeMillis();
- AccountDocument doc = basicWebClient.createAccount(failedUsername, AccountDocument.ACCOUNT_LEVEL_BASIC, "Shouldnt", "Exist", null, failedUsername + "@example.com", "1234");
- if (doc != null) {
- fail();
- }
- } catch (Exception e) {
- //this should happen, because basic accounts can't create new accounts
+ WebAPIAuthenticator basicAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, USERNAME1, PASSWORD1);
+ assertNotNull("got null auth cookie", basicAuthenticator.getAuthCookie());
+ WebAPIClient basicWebClient = new WebAPIClient(descriptor1, basicAuthenticator, wire1);
+ try {
+ String failedUsername = "Bogosity" + System.currentTimeMillis();
+ AccountDocument doc = basicWebClient.createAccount(failedUsername, AccountDocument.ACCOUNT_LEVEL_BASIC, "Shouldnt", "Exist", null, failedUsername + "@example.com", "1234");
+ if (doc != null) {
+ fail();
}
+ } catch (Exception e) {
+ //this should happen, because basic accounts can't create new accounts
+ }
- WebAPIGuestAuthenticator guestAuthenticator = new WebAPIAuthenticatorFactory().authenticate(descriptor1, WebConstants.GUEST_COOKIE_PREFIX + "Test_Suite_Guest1");
- WebAPIClient guestWebClient = new WebAPIClient(descriptor1, guestAuthenticator, wire1);
+ WebAPIGuestAuthenticator guestAuthenticator = new WebAPIAuthenticatorFactory().authenticate(descriptor1, WebConstants.GUEST_COOKIE_PREFIX + "Test_Suite_Guest1");
+ WebAPIClient guestWebClient = new WebAPIClient(descriptor1, guestAuthenticator, wire1);
- ServiceStateDocument serviceStateDoc = adminWebClient.setRegistrationState(ServiceStateDocument.REGISTRATION_STATE_CLOSED);
- assertEquals(ServiceStateDocument.REGISTRATION_STATE_CLOSED, serviceStateDoc.getRegistrationState());
- assertNull(adminWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- assertNull(basicWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- assertNull(guestWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ ServiceStateDocument serviceStateDoc = adminWebClient.setRegistrationState(ServiceStateDocument.REGISTRATION_STATE_CLOSED);
+ assertEquals(ServiceStateDocument.REGISTRATION_STATE_CLOSED, serviceStateDoc.getRegistrationState());
+ assertNull(adminWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ assertNull(basicWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ assertNull(guestWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- serviceStateDoc = adminWebClient.setRegistrationState(ServiceStateDocument.REGISTRATION_STATE_OPEN);
- assertEquals(ServiceStateDocument.REGISTRATION_STATE_OPEN, serviceStateDoc.getRegistrationState());
- assertNotNull(adminWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- assertNotNull(basicWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- assertNotNull(guestWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ serviceStateDoc = adminWebClient.setRegistrationState(ServiceStateDocument.REGISTRATION_STATE_OPEN);
+ assertEquals(ServiceStateDocument.REGISTRATION_STATE_OPEN, serviceStateDoc.getRegistrationState());
+ assertNotNull(adminWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ assertNotNull(basicWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ assertNotNull(guestWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- serviceStateDoc = adminWebClient.setRegistrationState(ServiceStateDocument.REGISTRATION_STATE_ADMIN_ONLY);
- assertEquals(ServiceStateDocument.REGISTRATION_STATE_ADMIN_ONLY, serviceStateDoc.getRegistrationState());
- assertNotNull(adminWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- assertNull(basicWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- assertNull(guestWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ serviceStateDoc = adminWebClient.setRegistrationState(ServiceStateDocument.REGISTRATION_STATE_ADMIN_ONLY);
+ assertEquals(ServiceStateDocument.REGISTRATION_STATE_ADMIN_ONLY, serviceStateDoc.getRegistrationState());
+ assertNotNull(adminWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ assertNull(basicWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
+ assertNull(guestWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, System.currentTimeMillis() + "@example.com", "1234"));
- String username = "testuser" + Math.abs(new Random().nextLong());
- adminWebClient.createAccount(username, AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, username + "@example.com", "1234");
+ String username = "testuser" + Math.abs(new Random().nextLong());
+ adminWebClient.createAccount(username, AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, username + "@example.com", "1234");
- AccountDocument accountDoc = adminWebClient.getAccountDocument(username);
- assertNotNull(accountDoc);
- assertEquals("Test", accountDoc.getFirstName());
- assertEquals("Sims", accountDoc.getLastName());
+ AccountDocument accountDoc = adminWebClient.getAccountDocument(username);
+ assertNotNull(accountDoc);
+ assertEquals("Test", accountDoc.getFirstName());
+ assertEquals("Sims", accountDoc.getLastName());
- Date frozenDate = new Date(System.currentTimeMillis() + 1000000);
- accountDoc.setFrozenUntil(frozenDate);
- accountDoc.setAccountLevel(AccountDocument.ACCOUNT_LEVEL_ADMIN);
- adminWebClient.updateAccount(accountDoc);
- accountDoc = adminWebClient.getAccountDocument(username);
- assertTrue(frozenDate.getTime() - accountDoc.getFrozenUntil().getTime() < 1000);
- assertEquals(AccountDocument.ACCOUNT_LEVEL_ADMIN, accountDoc.getAccountLevel());
- accountDoc.setFrozenUntil(new Date(1000));
- accountDoc.setAccountLevel(AccountDocument.ACCOUNT_LEVEL_BASIC);
- accountDoc = adminWebClient.updateAccount(accountDoc);
- AccountDocument ac2 = adminWebClient.getAccountDocument(username);
- assertNull(accountDoc.getFrozenUntil());
- assertNull(ac2.getFrozenUntil());
- assertEquals(AccountDocument.ACCOUNT_LEVEL_BASIC, accountDoc.getAccountLevel());
+ Date frozenDate = new Date(System.currentTimeMillis() + 1000000);
+ accountDoc.setFrozenUntil(frozenDate);
+ accountDoc.setAccountLevel(AccountDocument.ACCOUNT_LEVEL_ADMIN);
+ adminWebClient.updateAccount(accountDoc);
+ accountDoc = adminWebClient.getAccountDocument(username);
+ assertTrue(frozenDate.getTime() - accountDoc.getFrozenUntil().getTime() < 1000);
+ assertEquals(AccountDocument.ACCOUNT_LEVEL_ADMIN, accountDoc.getAccountLevel());
+ accountDoc.setFrozenUntil(new Date(1000));
+ accountDoc.setAccountLevel(AccountDocument.ACCOUNT_LEVEL_BASIC);
+ accountDoc = adminWebClient.updateAccount(accountDoc);
+ AccountDocument ac2 = adminWebClient.getAccountDocument(username);
+ assertNull(accountDoc.getFrozenUntil());
+ assertNull(ac2.getFrozenUntil());
+ assertEquals(AccountDocument.ACCOUNT_LEVEL_BASIC, accountDoc.getAccountLevel());
- } catch (Exception e) {
- e.printStackTrace();
- fail("Might want to check to make sure database exists and library account exists...");
- }
}
- public void testWebAPIClient() {
+ public void testWebAPIClient() throws IOException {
SpaceClient spaceClient1 = null;
SpaceClient guestSpaceClient1 = null;
@@ -214,7 +211,7 @@
assertEquals(1, thingDocs.length);
checkThingScripting(webClient1, thingDocs[0], spaceDocument);
-
+
checkPageManipulation(webClient1, thingDocs[0], spaceDocument);
//figure out the last template added
@@ -233,10 +230,6 @@
guestSpaceClient1 = checkGuestCookieOperation(spaceDocument.getSpaceID(), webClient1, WebConstants.GUEST_COOKIE_PREFIX + "Test_Suite_Guest");
checkDeletingSpaceDestroysThings(spaceDocument.getSpaceID(), webClient1, USERNAME1);
-
- } catch (IOException e) {
- e.printStackTrace();
- fail();
} finally {
if (spaceClient1 != null) {
spaceClient1.cleanup();
@@ -248,6 +241,58 @@
}
+ public void testApplet() throws AuthenticationFailedException, IOException {
+ WebAPIAuthenticator basicAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, USERNAME1, PASSWORD1);
+ assertNotNull("got null auth cookie", basicAuthenticator.getAuthCookie());
+ WebAPIClient basicWebClient = new WebAPIClient(descriptor1, basicAuthenticator, wire1);
+
+ TemplateDocument newTemplateDoc = basicWebClient.createTemplate("Viewed Test Template");
+ assertNotNull(newTemplateDoc);
+ basicWebClient.uploadTemplateGeometryStream(newTemplateDoc.getOwnerUsername(), newTemplateDoc.getTemplateID(), 0, UIConstants.getResource("sample-art3d/TestCube.obj"));
+ basicWebClient.uploadTemplateResourceStream(newTemplateDoc.getOwnerUsername(), newTemplateDoc.getTemplateID(), "TestCube.mtl", UIConstants.getResource("sample-art3d/TestCube.mtl"));
+ basicWebClient.uploadTemplateResourceStream(newTemplateDoc.getOwnerUsername(), newTemplateDoc.getTemplateID(), "TestCube.gif", UIConstants.getResource("sample-art3d/TestCube.gif"));
+ basicWebClient.updateTemplateScript(newTemplateDoc.getOwnerUsername(), newTemplateDoc.getTemplateID(), StreamUtils.readInput(UIConstants.getResource("sample-art3d/TestCube.js")));
+
+ TemplateDocument[] templateDocs = basicWebClient.getTemplateDocuments(basicAuthenticator.getUsername());
+ assertNotNull(templateDocs);
+ assertTrue(templateDocs.length > 0);
+
+ SpaceDocument spaceDocument = basicWebClient.createSpace("Applet Test Space");
+ assertNotNull(spaceDocument);
+ PossessionDocument possDoc = basicWebClient.createPossession(newTemplateDoc.getTemplateID());
+ assertNotNull(possDoc);
+ possDoc = basicWebClient.addPossessionToSpace(possDoc.getPossessionID(), spaceDocument.getSpaceID());
+ assertTrue(possDoc.getThingID() != -1);
+
+ ThingDocument thingDoc = basicWebClient.getThingDocument(spaceDocument.getSpaceID(), possDoc.getThingID());
+ thingDoc.setZ(-10);
+ basicWebClient.updateThing(spaceDocument.getSpaceID(), thingDoc);
+
+ AppletTestWindow testWindow = openAppletTestWindow(spaceDocument, basicAuthenticator);
+
+ testWindow.applet.sendChatMessage("Hey, this is a chat message");
+ assertEquals(basicAuthenticator.getAuthDocument(true).getUsername(), testWindow.applet.getUsername());
+ testWindow.cleanup();
+
+ basicWebClient.deleteSpace(spaceDocument.getSpaceID());
+ }
+
+ private AppletTestWindow openAppletTestWindow(SpaceDocument spaceDocument, WebAPIAuthenticator authenticator){
+ AppletTestWindow testWindow = new AppletTestWindow(descriptor1.getServiceURI(), spaceDocument.getSpaceID(), authenticator.getAuthCookie(), new Dimension(500, 500), true);
+ testWindow.setVisible(true);
+ testWindow.start();
+
+ long startTime = System.currentTimeMillis();
+ while(!testWindow.applet.completedInitialLoad() && System.currentTimeMillis() < startTime + 10000){
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ }
+ }
+ assertTrue(testWindow.applet.completedInitialLoad());
+ return testWindow;
+ }
+
private void checkThingScripting(WebAPIClient webClient, ThingDocument thingDocument, SpaceDocument spaceDocument) throws IOException {
//make sure script will return a value
String script = webClient.getTemplateScript(webClient.getAuthenticator().getUsername(), thingDocument.getTemplateID());
@@ -255,13 +300,13 @@
assertFalse(script.indexOf("onService(") == -1);
//look for the monkey
- String thingServiceResponse = webClient.getThingService(spaceDocument.getSpaceID(), thingDocument.getThingID());
+ String thingServiceResponse = webClient.getThingService(spaceDocument.getSpaceID(), thingDocument.getThingID());
assertEquals("monkey", thingServiceResponse);
//try with no script
webClient.updateTemplateScript(webClient.getAuthenticator().getUsername(), thingDocument.getTemplateID(), "");
webClient.reloadThing(spaceDocument.getSpaceID(), thingDocument.getThingID());
- thingServiceResponse = webClient.getThingService(spaceDocument.getSpaceID(), thingDocument.getThingID());
+ thingServiceResponse = webClient.getThingService(spaceDocument.getSpaceID(), thingDocument.getThingID());
assertEquals("", thingServiceResponse);
//reinstall script
@@ -278,7 +323,7 @@
return userDocs;
}
- private void checkAuthDoc(WebAPIAuthenticator auth1, WebAPIAuthenticator auth2) {
+ private void checkAuthDoc(WebAPIAuthenticator auth1, WebAPIAuthenticator auth2) throws IOException {
AuthDocument authDoc = getAuthDoc(null);
assertFalse(authDoc.isAuthenticated());
assertNull(authDoc.getUsername());
@@ -296,14 +341,9 @@
assertEquals(USERNAME2, authDoc.getUsername());
}
- private AuthDocument getAuthDoc(String authCookie) {
- try {
- XMLElement element = wire1.fetchAuthenticatedXML(descriptor1.getMeAuthURI(), authCookie);
- return new AuthDocument(element);
- } catch (IOException e) {
- fail("Error fetching auth document with no auth cookie: " + e);
- return null;
- }
+ private AuthDocument getAuthDoc(String authCookie) throws IOException {
+ XMLElement element = wire1.fetchAuthenticatedXML(descriptor1.getMeAuthURI(), authCookie);
+ return new AuthDocument(element);
}
private void checkSpaceAuthWithMembership(WebAPIAuthenticator memberAuth, WebAPIClient memberClient, WebAPIClient ownerClient, SpaceDocument spaceDocument) throws IOException {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-09-18 16:03:59
|
Revision: 419
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=419&view=rev
Author: trevorolio
Date: 2007-09-18 09:03:54 -0700 (Tue, 18 Sep 2007)
Log Message:
-----------
Added the ability to choose a male or female avatar.
Both avatar models still need work.
Consolidated the two UIConstants classes into one.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/BodyAppletTestWindow.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/BodyAppletTestWindow.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/BodyAppletTestWindow.java 2007-09-18 16:03:36 UTC (rev 418)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/BodyAppletTestWindow.java 2007-09-18 16:03:54 UTC (rev 419)
@@ -19,8 +19,6 @@
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Frame;
-import java.awt.GraphicsDevice;
-import java.awt.GraphicsEnvironment;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -36,7 +34,7 @@
public class BodyAppletTestWindow extends Frame {
- Dimension appDimension = new Dimension(500, 500);
+ Dimension appDimension = new Dimension(500, 520);
public BodyEditorApplet applet = null;
@@ -44,19 +42,17 @@
URI serviceURI = null;
- public BodyAppletTestWindow(URI serviceURI, String authCookie, Dimension appDimension, boolean decorated) {
- ArgumentUtils.assertNotNull(appDimension);
- this.appDimension = appDimension;
+ public BodyAppletTestWindow(URI serviceURI, String authCookie) {
+ setTitle("Body Editor");
+
ArgumentUtils.assertNotNull(serviceURI);
this.serviceURI = serviceURI;
-
+
setLayout(new BorderLayout());
setSize(appDimension);
setLocation(30, 50);
setResizable(false);
- if (!decorated) {
- this.setUndecorated(true);
- }
+
HashMap parameters1 = new HashMap();
parameters1.put("loginCookie", authCookie);
parameters1.put("serviceURI", serviceURI.toString());
@@ -118,13 +114,6 @@
}
public static void main(String[] args) {
- GraphicsEnvironment graphicsEnv = GraphicsEnvironment.getLocalGraphicsEnvironment();
- GraphicsDevice device = graphicsEnv.getDefaultScreenDevice();
- Dimension dim = new Dimension(1024, 800);
- boolean fullScreen = args.length > 0 && "fullscreen".equals(args[0]);
- if (fullScreen) {
- dim = new Dimension(device.getDisplayMode().getWidth(), device.getDisplayMode().getWidth());
- }
String serviceURI=null;
String loginCookie=null;
try {
@@ -140,11 +129,8 @@
}
try {
- BodyAppletTestWindow test = new BodyAppletTestWindow(new URI(serviceURI), loginCookie, dim, fullScreen);
+ BodyAppletTestWindow test = new BodyAppletTestWindow(new URI(serviceURI), loginCookie);
test.setVisible(true);
- if (fullScreen) {
- device.setFullScreenWindow(test);
- }
test.start();
} catch (URISyntaxException e) {
e.printStackTrace();
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-09-18 16:03:36 UTC (rev 418)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-09-18 16:03:54 UTC (rev 419)
@@ -49,8 +49,8 @@
import com.ogoglio.util.Log;
import com.ogoglio.util.PropStorage;
import com.ogoglio.util.StreamUtils;
+import com.ogoglio.util.UIConstants;
import com.ogoglio.util.WebConstants;
-import com.ogoglio.viewer.render.UIConstants;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
import com.ogoglio.xml.BodyDocument;
@@ -315,9 +315,28 @@
assertEquals(basicAuthenticator.getAuthDocument(true).getUsername(), testWindow.applet.getUsername());
testWindow.cleanup();
+ BodyAppletTestWindow bodyWindow = openBodyAppletTestWindow(basicAuthenticator);
+ bodyWindow.cleanup();
+
basicWebClient.deleteSpace(spaceDocument.getSpaceID());
}
+ private BodyAppletTestWindow openBodyAppletTestWindow(WebAPIAuthenticator authenticator) {
+ BodyAppletTestWindow bodyWindow = new BodyAppletTestWindow(descriptor1.getServiceURI(), authenticator.getAuthCookie());
+ bodyWindow.setVisible(true);
+ bodyWindow.start();
+
+ long startTime = System.currentTimeMillis();
+ while (!bodyWindow.applet.completedInitialLoad() && System.currentTimeMillis() < startTime + 10000) {
+ try {
+ Thread.sleep(500);
+ } catch (InterruptedException e) {
+ }
+ }
+ assertTrue(bodyWindow.applet.completedInitialLoad());
+ return bodyWindow;
+ }
+
private AppletTestWindow openAppletTestWindow(SpaceDocument spaceDocument, WebAPIAuthenticator authenticator) {
AppletTestWindow testWindow = new AppletTestWindow(descriptor1.getServiceURI(), spaceDocument.getSpaceID(), authenticator.getAuthCookie(), new Dimension(500, 500), true);
testWindow.setVisible(true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-10-02 02:28:31
|
Revision: 466
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=466&view=rev
Author: trevorolio
Date: 2007-10-01 19:28:36 -0700 (Mon, 01 Oct 2007)
Log Message:
-----------
THIS CHECKIN REQUIRES A DB DROP
Introducing a new world of user configurable body settings. Ditched the old BodyRecord and created three new record types:
BodyDataRecords: hold information about the wadges of data which make up a body's base (e.g. mesh, morphs, textures...)
BodyConfigurationRecords: a user level representation of a body configuration, with a display name and a set of...
BodySettingRecords: morph interpolation values for a given body configuration (e.g. height, 0.9 or chin width, 0.2)
Halfway through documentifying and RESTifying these records. I can smell the day when this is autogenerated from annotated classes.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/WebAPITest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-10-02 02:28:33 UTC (rev 465)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-10-02 02:28:36 UTC (rev 466)
@@ -55,7 +55,7 @@
import com.ogoglio.util.WebConstants;
import com.ogoglio.xml.AccountDocument;
import com.ogoglio.xml.AuthDocument;
-import com.ogoglio.xml.BodyDocument;
+import com.ogoglio.xml.BodyDataDocument;
import com.ogoglio.xml.DoorDocument;
import com.ogoglio.xml.PageDocument;
import com.ogoglio.xml.PossessionDocument;
@@ -226,6 +226,15 @@
assertNull(ac2.getFrozenUntil());
assertEquals(AccountDocument.ACCOUNT_LEVEL_BASIC, accountDoc.getAccountLevel());
+
+ BodyDataDocument bodyDataDoc = adminWebClient.createBodyData("Super Puppy", "ogoglio-body-superpuppy.jar");
+ assertNotNull(bodyDataDoc);
+ assertFalse(bodyDataDoc.getBodyDataID() == -1);
+ bodyDataDoc = adminWebClient.getBodyDataDocument(bodyDataDoc.getBodyDataID());
+ assertNotNull(bodyDataDoc);
+ assertEquals("Super Puppy", bodyDataDoc.getDisplayName());
+ adminWebClient.deleteBodyData(bodyDataDoc.getBodyDataID());
+
}
public void testWebAPIClient() throws IOException {
@@ -255,8 +264,6 @@
checkSettings(spaceDocument.getSpaceID(), advancedClient);
- checkBody(advancedClient, advancedAuth);
-
TemplateDocument newTemplateDoc = checkTemplateScriptAPI(advancedClient);
ThingDocument[] thingDocs = checkTemplateGeomMaterialsAndPossessions(advancedClient, newTemplateDoc, spaceDocument);
@@ -514,32 +521,6 @@
}
- private void checkBody(WebAPIClient webClient1, WebAPIAuthenticator authenticator) throws IOException {
- AccountDocument ownerDoc = authenticator.getAccountDocument(true);
- assertNotNull(ownerDoc);
- assertEquals(USERNAME1, ownerDoc.getUsername());
- long defaultBody = ownerDoc.getDefaultBodyID();
- BodyDocument bodyDoc = webClient1.createBody("Testing Body");
- assertFalse(bodyDoc.getBodyID() == -1);
- assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
- assertEquals(0, bodyDoc.getHairIndex());
- assertEquals(0, bodyDoc.getEyesIndex());
- assertEquals(0, bodyDoc.getNoseIndex());
- assertEquals(0, bodyDoc.getMouthIndex());
- assertEquals(0, bodyDoc.getFaceIndex());
- ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
- assertEquals(bodyDoc.getBodyID(), ownerDoc.getDefaultBodyID());
- assertEquals(ownerDoc.getUsername(), bodyDoc.getOwnerUsername());
- bodyDoc.setEyesIndex(3);
- bodyDoc = webClient1.updateBody(bodyDoc);
- assertEquals(3, bodyDoc.getEyesIndex());
- assertFalse(webClient1.deleteBody(bodyDoc.getBodyID()));
- webClient1.setDefaultBody(defaultBody);
- assertTrue(webClient1.deleteBody(bodyDoc.getBodyID()));
- ownerDoc = webClient1.setDefaultBody(bodyDoc.getBodyID());
- assertEquals(defaultBody, ownerDoc.getDefaultBodyID());
- }
-
private SpaceDocument checkSpaceSeaLevel(WebAPIClient webClient1, SpaceDocument spaceDocument) throws IOException {
assertFalse(spaceDocument.getDisplaySea());
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/WebAPITest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/WebAPITest.java 2007-10-02 02:28:33 UTC (rev 465)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/WebAPITest.java 2007-10-02 02:28:36 UTC (rev 466)
@@ -47,7 +47,7 @@
notAuthedAuthDoc = new AuthDocument("Ian", false);
authedAuthDoc = new AuthDocument("Ian", true);
- accountDoc = new AccountDocument(authedAuthDoc.getUsername(), AccountDocument.ACCOUNT_LEVEL_ADVANCED, null, null, null, null, null, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE, -1);
+ accountDoc = new AccountDocument(authedAuthDoc.getUsername(), AccountDocument.ACCOUNT_LEVEL_ADVANCED, null, null, null, null, null, AccountDocument.NO_TIME_VALUE, null, AccountDocument.NO_TIME_VALUE);
} catch (URISyntaxException e) {
fail("Bad URIL: " + e);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2007-11-27 13:00:25
|
Revision: 609
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=609&view=rev
Author: trevorolio
Date: 2007-11-27 05:00:25 -0800 (Tue, 27 Nov 2007)
Log Message:
-----------
Added a help message to the viewer applet. It is displayed at start and can be shown again with /help.
Third party apps can set their own help messages via javascript.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java 2007-11-27 13:00:21 UTC (rev 608)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java 2007-11-27 13:00:25 UTC (rev 609)
@@ -36,6 +36,8 @@
public class AppletTestWindow extends Frame {
+ public static final String TEST_HELP_MESSAGE = "This is the help message.\nDo you feel helped?";
+
Dimension appDimension = new Dimension(500, 500);
public ViewerApplet applet = null;
@@ -62,6 +64,8 @@
parameters1.put("spaceID", "" + spaceID);
parameters1.put("serviceURI", serviceURI.toString());
+ parameters1.put("helpMessage", TEST_HELP_MESSAGE);
+
//parameters1.put("x", "0");
//parameters1.put("y", "1000");
//parameters1.put("z", "0");
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-11-27 13:00:21 UTC (rev 608)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-11-27 13:00:25 UTC (rev 609)
@@ -377,7 +377,7 @@
try {
long now=new Date().getTime();
long lastMod=TemplateSupportFileDocument.fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
- assertTrue(now-lastMod < 1000); //1 sec seems pretty safe
+ assertTrue(now-lastMod < 2000); //1 sec seems pretty safe
assertTrue(now-lastMod > 0); // asked for now AFTER we created the space
} catch (ParseException e) {
fail("can't parse the server's timestamp on last modified time of the space");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <tre...@us...> - 2008-01-30 22:44:08
|
Revision: 699
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=699&view=rev
Author: trevorolio
Date: 2008-01-30 14:44:12 -0800 (Wed, 30 Jan 2008)
Log Message:
-----------
Added the requested IP number to the service doc so the applet can work against round robin dns clusters, on Windows, in Firefox. Also tweaked the renderer graphics config to indicate a lowest level of texture bit depth, which also has the nice side effect of making the card use higher bit depth if possible.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java 2008-01-30 22:43:45 UTC (rev 698)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/AppletTestWindow.java 2008-01-30 22:44:12 UTC (rev 699)
@@ -21,10 +21,12 @@
import java.awt.Frame;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
+import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.net.UnknownHostException;
import java.util.HashMap;
import com.ogoglio.client.WebAPIAuthenticator;
@@ -39,14 +41,14 @@
public static final String TEST_HELP_MESSAGE = "This is the help message.\nDo you feel helped?";
Dimension appDimension = new Dimension(500, 500);
-
+
public ViewerApplet applet = null;
EnvironmentStub clientStub1 = null;
URI serviceURI = null;
- public AppletTestWindow(URI serviceURI, long spaceID, String authCookie, Dimension appDimension, boolean fullScreen) {
+ public AppletTestWindow(URI serviceURI, long spaceID, String serverIP, String authCookie, Dimension appDimension, boolean fullScreen) {
ArgumentUtils.assertNotNull(appDimension);
this.appDimension = appDimension;
ArgumentUtils.assertNotNull(serviceURI);
@@ -63,6 +65,7 @@
parameters1.put("loginCookie", authCookie);
parameters1.put("spaceID", "" + spaceID);
parameters1.put("serviceURI", serviceURI.toString());
+ parameters1.put("serverIP", serverIP);
parameters1.put("helpMessage", TEST_HELP_MESSAGE);
@@ -159,18 +162,19 @@
}
}
- long spaceID = Long.parseLong(System.getProperty("AppletTestWindow.space"));
-
try {
- AppletTestWindow test = new AppletTestWindow(new URI(serviceURI), spaceID, loginCookie, dim, fullScreen);
+ long spaceID = Long.parseLong(System.getProperty("AppletTestWindow.space"));
+ URI actualServiceURI = URI.create(serviceURI);
+ String serverIP = InetAddress.getByName(actualServiceURI.getHost()).getHostAddress();
+ AppletTestWindow test = new AppletTestWindow(actualServiceURI, spaceID, serverIP, loginCookie, dim, fullScreen);
test.setVisible(true);
if (fullScreen) {
device.setFullScreenWindow(test);
}
test.start();
- } catch (URISyntaxException e) {
+ } catch (UnknownHostException e) {
+ // TODO Auto-generated catch block
e.printStackTrace();
- System.exit(1);
}
}
}
Modified: maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-01-30 22:43:45 UTC (rev 698)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2008-01-30 22:44:12 UTC (rev 699)
@@ -22,9 +22,11 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.LineNumberReader;
+import java.net.InetAddress;
import java.net.Socket;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.UnknownHostException;
import java.text.DateFormat;
import java.text.ParseException;
import java.util.Date;
@@ -209,15 +211,15 @@
serviceStateDoc = adminWebClient.setRegistrationState(ServiceStateDocument.REGISTRATION_STATE_OPEN);
assertEquals(ServiceStateDocument.REGISTRATION_STATE_OPEN, serviceStateDoc.getRegistrationState());
- assertNotNull(adminWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo"+System.currentTimeMillis() + "@example.com", "1234"));
- assertNotNull(basicWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo"+System.currentTimeMillis() + "@example.com", "1234"));
- assertNotNull(guestWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo"+System.currentTimeMillis() + "@example.com", "1234"));
+ assertNotNull(adminWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo" + System.currentTimeMillis() + "@example.com", "1234"));
+ assertNotNull(basicWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo" + System.currentTimeMillis() + "@example.com", "1234"));
+ assertNotNull(guestWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo" + System.currentTimeMillis() + "@example.com", "1234"));
serviceStateDoc = adminWebClient.setRegistrationState(ServiceStateDocument.REGISTRATION_STATE_ADMIN_ONLY);
assertEquals(ServiceStateDocument.REGISTRATION_STATE_ADMIN_ONLY, serviceStateDoc.getRegistrationState());
- assertNotNull(adminWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo"+System.currentTimeMillis() + "@example.com", "1234"));
- assertNull(basicWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo"+System.currentTimeMillis() + "@example.com", "1234"));
- assertNull(guestWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo"+System.currentTimeMillis() + "@example.com", "1234"));
+ assertNotNull(adminWebClient.createAccount("shouldexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo" + System.currentTimeMillis() + "@example.com", "1234"));
+ assertNull(basicWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo" + System.currentTimeMillis() + "@example.com", "1234"));
+ assertNull(guestWebClient.createAccount("shouldnotexist" + System.currentTimeMillis(), AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, "foo" + System.currentTimeMillis() + "@example.com", "1234"));
String username = "testuser" + Math.abs(new Random().nextLong());
AccountDocument accountDoc = adminWebClient.createAccount(username, AccountDocument.ACCOUNT_LEVEL_BASIC, "Test", "Sims", null, username + "@example.com", "1234");
@@ -231,7 +233,7 @@
StreamUtils.discardInput(wire1.performGET(URI.create(emailValidationURL), null));
accountDoc = adminWebClient.getAccountDocument(username);
assertTrue(accountDoc.isEmailValid());
-
+
Date frozenDate = new Date(System.currentTimeMillis() + 1000000);
accountDoc.setFrozenUntil(frozenDate);
accountDoc.setAccountLevel(AccountDocument.ACCOUNT_LEVEL_ADMIN);
@@ -298,22 +300,22 @@
public boolean accept(File dir, String name) {
return name.startsWith("Mail-Message-");
}
-
+
});
File emailFile = null;
for (int i = 0; i < mailFiles.length; i++) {
- if(containsString(email, mailFiles[i])){
+ if (containsString(email, mailFiles[i])) {
emailFile = mailFiles[i];
break;
}
}
- if(emailFile == null){
+ if (emailFile == null) {
return null;
}
LineNumberReader input = new LineNumberReader(new FileReader(emailFile));
String line;
- while((line = input.readLine()) != null){
- if(line.startsWith("http://")){
+ while ((line = input.readLine()) != null) {
+ if (line.startsWith("http://")) {
return line.trim();
}
}
@@ -323,14 +325,14 @@
private boolean containsString(String target, File file) throws IOException {
LineNumberReader input = new LineNumberReader(new FileReader(file));
String line;
- while((line = input.readLine()) != null){
- if(line.indexOf(target) != -1){
+ while ((line = input.readLine()) != null) {
+ if (line.indexOf(target) != -1) {
return true;
}
}
return false;
}
-
+
public void testWebAPIClient() throws IOException {
SpaceClient spaceClient1 = null;
SpaceClient guestSpaceClient1 = null;
@@ -443,7 +445,7 @@
}
- public void testApplet() throws AuthenticationFailedException, IOException {
+ public void testApplet() throws AuthenticationFailedException, IOException, UnknownHostException {
WebAPIAuthenticator basicAuthenticator = new WebAPIAuthenticatorFactory().authenticate(wire1, descriptor1, USERNAME1, PASSWORD1);
assertNotNull("got null auth cookie", basicAuthenticator.getAuthCookie());
WebAPIClient basicWebClient = new WebAPIClient(descriptor1, basicAuthenticator, wire1);
@@ -477,11 +479,11 @@
assertEquals(basicAuthenticator.getAuthDocument(true).getUsername(), testWindow.applet.getUsername());
testWindow.cleanup();
testWindow.setVisible(false);
-
+
BodyAppletTestWindow bodyWindow = openBodyAppletTestWindow(basicAuthenticator);
bodyWindow.cleanup();
bodyWindow.setVisible(false);
-
+
basicWebClient.deleteSpace(spaceDocument.getSpaceID());
}
@@ -501,8 +503,10 @@
return bodyWindow;
}
- private AppletTestWindow openAppletTestWindow(SpaceDocument spaceDocument, WebAPIAuthenticator authenticator) {
- AppletTestWindow testWindow = new AppletTestWindow(descriptor1.getServiceURI(), spaceDocument.getSpaceID(), authenticator.getAuthCookie(), new Dimension(500, 500), true);
+ private AppletTestWindow openAppletTestWindow(SpaceDocument spaceDocument, WebAPIAuthenticator authenticator) throws UnknownHostException {
+
+ String serverIP = InetAddress.getByName(descriptor1.getServiceURI().getHost()).getHostAddress();
+ AppletTestWindow testWindow = new AppletTestWindow(descriptor1.getServiceURI(), spaceDocument.getSpaceID(), serverIP, authenticator.getAuthCookie(), new Dimension(500, 500), true);
testWindow.setVisible(true);
testWindow.start();
@@ -515,6 +519,7 @@
}
assertTrue(testWindow.applet.completedInitialLoad());
return testWindow;
+
}
private void checkThingScripting(WebAPIClient webClient, ThingDocument thingDocument, SpaceDocument spaceDocument) throws IOException {
@@ -1158,7 +1163,7 @@
public void receivedTellMessage(String username, String message) {
// TODO Auto-generated method stub
-
+
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|