|
From: <tre...@us...> - 2007-08-31 03:40:33
|
Revision: 299
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=299&view=rev
Author: trevorolio
Date: 2007-08-30 20:40:29 -0700 (Thu, 30 Aug 2007)
Log Message:
-----------
Added a bridge between the external URL space and things, so now template scripts can be directly addressed via HTTP, and info panels are just iFrames showing a thing's service page.
Modified Paths:
--------------
maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java
maven/trunk/ogoglio-integration-test/src/test/resources/sample-art3d/TestCube.js
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-08-31 03:40:25 UTC (rev 298)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-08-31 03:40:29 UTC (rev 299)
@@ -99,15 +99,13 @@
public void testWebAdmin() {
try {
- 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"));
-
+ 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"));
+
assertNotNull("got null auth cookie", adminAuthenticator.getAuthCookie());
WebAPIClient adminWebClient = new WebAPIClient(descriptor1, adminAuthenticator, wire1);
@@ -116,7 +114,7 @@
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);
@@ -215,6 +213,8 @@
thingDocs = webClient1.getThingDocuments(spaceDocument.getSpaceID());
assertEquals(1, thingDocs.length);
+ checkThingScripting(webClient1, thingDocs[0], spaceDocument);
+
checkPageManipulation(webClient1, thingDocs[0], spaceDocument);
//figure out the last template added
@@ -248,9 +248,30 @@
}
+ 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());
+ assertNotNull(script);
+ assertFalse(script.indexOf("onService(") == -1);
+
+ //look for the monkey
+ 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());
+ assertEquals("", thingServiceResponse);
+
+ //reinstall script
+ webClient.updateTemplateScript(webClient.getAuthenticator().getUsername(), thingDocument.getTemplateID(), script);
+ webClient.reloadThing(spaceDocument.getSpaceID(), thingDocument.getThingID());
+ }
+
private UserDocument[] verifyUserDocsBySize(WebAPIClient webClient1, long spaceID, int expectedLen, String expectedUsername) throws IOException {
UserDocument[] userDocs = webClient1.getUserDocuments(spaceID);
- assertEquals(expectedLen,userDocs.length);
+ assertEquals(expectedLen, userDocs.length);
if (expectedUsername != null) {
assertEquals(expectedUsername, userDocs[0].getUsername());
}
@@ -745,9 +766,7 @@
public void contextItemChosen(Thing thing, long nonce, String id) {
}
- public void receivedInfoPanel(long sourceThingID, String panelHTML) {
- // TODO Auto-generated method stub
-
+ public void receivedInfoPanel(long sourceThingID, String nonce) {
}
}
Modified: maven/trunk/ogoglio-integration-test/src/test/resources/sample-art3d/TestCube.js
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/resources/sample-art3d/TestCube.js 2007-08-31 03:40:25 UTC (rev 298)
+++ maven/trunk/ogoglio-integration-test/src/test/resources/sample-art3d/TestCube.js 2007-08-31 03:40:29 UTC (rev 299)
@@ -5,8 +5,6 @@
}
function onClick(person, shapeName){
- space.log(person + " clicked " + thingID + " on its " + shapeName);
-
var currentPosition = space.getThingPosition(thingID);
var path = new SplinePath(2000, false, false);
@@ -15,28 +13,20 @@
path.addKeyFrame(new SplineKeyFrame(currentPosition.x, currentPosition.y, currentPosition.z, 2 * math.PI, 1));
space.startThingMotion(thingID, path);
+ return person + " clicked on " + shapeName + " in thing " + thingID;
}
function onContextClick(person, shapeName){
- space.log(person + " context clicked " + thingID + " on its " + shapeName);
-
- i1 = new ContextMenuInfo("Google",true,"google");
- i2 = new ContextMenuInfo("Yahoo",true,"yahoo");
- i3 = new ContextMenuInfo("Altavista",false,"NOTUSED");
- i4 = new ContextMenuInfo("Transmutable",true,"transmutable");
-
- return new Array(i1,i2,i3,i4);
+ var moveItem = new ContextMenuInfo("Move",true,"move");
+ var monkeyItem = new ContextMenuInfo("Monkey", true, "monkey");
+ var deadItem = new ContextMenuInfo("Groove",false,"groove");
+ return new Array(moveItem, monkeyItem, deadItem);
}
-function onContextMenuItemChosen(username,id)
-{
- var key = "favoriteSite";
- var preferred = space.getSetting(key);
-
- space.putSetting(key,id);
-
- //causes browser to jump to that page!
- return "http://www."+id+".com/";
+function onContextMenuItemChosen(username,id){
+ space.showInfoPanel(thingID, username, id);
}
-
+function onService(){
+ return new HTTPResponse(200, "monkey", "text/plain");
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|