|
From: <tre...@us...> - 2007-12-04 14:21:49
|
Revision: 614
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=614&view=rev
Author: trevorolio
Date: 2007-12-04 06:21:54 -0800 (Tue, 04 Dec 2007)
Log Message:
-----------
Added user role to space model.
Modified Paths:
--------------
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/ClientTest.java
===================================================================
--- maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-12-04 14:21:46 UTC (rev 613)
+++ maven/trunk/ogoglio-integration-test/src/test/java/com/ogoglio/client/test/ClientTest.java 2007-12-04 14:21:54 UTC (rev 614)
@@ -96,13 +96,13 @@
WebAPIDescriptor descriptor1 = null;
String mikeBodyTextureResourcePath = "sample-art3d/TestBodyTexture-Mike.jpg";
-
+
public void setUp() {
try {
- PropStorage ps=new PropStorage();
- if (!ps.loadPropertySet(PropStorage.BASIC_PROPS)) {
- fail("couldn't load property set (BASIC)");
- }
+ PropStorage ps = new PropStorage();
+ if (!ps.loadPropertySet(PropStorage.BASIC_PROPS)) {
+ fail("couldn't load property set (BASIC)");
+ }
serviceURI1 = new URI(ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseUrl"));
mediaURI = new URI(ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.mediaUrl"));
simURI = new URI(ps.getKeyFromSet(PropStorage.BASIC_PROPS, "ogoglio.baseSimUrl"));
@@ -125,7 +125,7 @@
checkCantReachURI(simURI);
checkCantReachURI(mediaURI);
try {
- new Socket(serviceURI1.getHost(),3306/*mysql port*/);
+ new Socket(serviceURI1.getHost(), 3306/*mysql port*/);
fail("Shouldn't be able to connect to the MySql server!");
} catch (IOException e) {
//pass
@@ -136,12 +136,12 @@
private void checkCantReachURI(URI uri) {
try {
uri.toURL().openConnection();
- fail("should not be able to see the URI"+uri+"!");
+ fail("should not be able to see the URI" + uri + "!");
} catch (IOException e) {
//pass
}
}
-
+
public void testAppletsCanBeDownloaded() throws IOException, URISyntaxException {
checkSupportFile("ogoglio-viewer-applet.jar");
checkSupportFile("ogoglio-test-applet.jar");
@@ -150,17 +150,17 @@
}
private void checkSupportFile(String name) throws URISyntaxException, IOException {
- URI supportURI=new URI(serviceURI1.toString()+name);
- InputStream is=null;
- try {
- is=wire1.performGET(supportURI, null);
- } catch (IOException e) {
- fail("unable to get the support URI:"+supportURI+" (exception:"+e.getMessage()+")");
- }
- assertNotNull(is);
- is.close();
+ URI supportURI = new URI(serviceURI1.toString() + name);
+ InputStream is = null;
+ try {
+ is = wire1.performGET(supportURI, null);
+ } catch (IOException e) {
+ fail("unable to get the support URI:" + supportURI + " (exception:" + e.getMessage() + ")");
+ }
+ assertNotNull(is);
+ is.close();
}
-
+
public void testWebAdmin() throws AuthenticationFailedException, IOException {
PropStorage ps = new PropStorage();
if (ps.loadPropertySet(PropStorage.BOOTSTRAP_PROPS) == false) {
@@ -235,7 +235,6 @@
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);
@@ -263,7 +262,7 @@
assertEquals(0, configDoc.getBodySettingDocuments().length);
configDoc = basicWebClient.updateBodyConfiguration(configDoc);
assertEquals(0, configDoc.getBodySettingDocuments().length);
-
+
assertNull(configDoc.getBaseTextureName());
configDoc.setBaseTextureName("La Texture Base.jpg");
configDoc = basicWebClient.updateBodyConfiguration(configDoc);
@@ -271,7 +270,7 @@
configDoc.setBaseTextureName(null);
configDoc = basicWebClient.updateBodyConfiguration(configDoc);
assertNull(configDoc.getBaseTextureName());
-
+
InputStream textureData = UIConstants.getResource(mikeBodyTextureResourcePath);
assertNotNull(textureData);
basicWebClient.setBodyTexture(basicAuthenticator.getUsername(), configDoc.getBodyConfigurationID(), textureData, "image/jpeg");
@@ -292,14 +291,14 @@
SpaceDocument spaceDocument = advancedClient.createSpace("Susan's Space");
assertNotNull(spaceDocument);
checkSpaceDocumentCreateTime(spaceDocument);
-
+
assertNotNull(spaceDocument);
advancedClient.setSpacePublished(spaceDocument.getSpaceID(), true);
-
+
WebAPIAuthenticator basicAuth = new WebAPIAuthenticator(wire1, descriptor1, USERNAME2, PASSWORD1);
WebAPIClient basicClient = new WebAPIClient(descriptor1, basicAuth, wire1);
assertNull(basicClient.createSpace("Tina's Illegal Space Which She Should Not Be Able To Create"));
-
+
checkNoConnectionToSpaceWithoutAuth(spaceDocument.getSpaceID());
checkAuthDoc(advancedAuth, basicAuth);
@@ -339,10 +338,9 @@
guestSpaceClient1 = checkGuestCookieOperation(spaceDocument.getSpaceID(), advancedClient, WebConstants.GUEST_COOKIE_PREFIX + "Test_Suite_Guest");
checkUserSitting(spaceDocument, thingDocs, spaceClient1, guestSpaceClient1);
-
+
checkDeletingSpaceDestroysThings(spaceDocument.getSpaceID(), advancedClient, USERNAME1);
-
-
+
} finally {
if (spaceClient1 != null) {
spaceClient1.cleanup();
@@ -362,7 +360,7 @@
User remoteUser = guestSpaceClient1.getSpace().getUser(spaceClient1.getUsername());
long startTime = System.currentTimeMillis();
- while(System.currentTimeMillis() - startTime < 30000 && remoteUser.getSeat() == null){
+ while (System.currentTimeMillis() - startTime < 30000 && remoteUser.getSeat() == null) {
try {
Thread.sleep(500);
} catch (Exception e) {
@@ -375,14 +373,14 @@
private void checkSpaceDocumentCreateTime(SpaceDocument spaceDocument) {
try {
- long now=new Date().getTime();
- long lastMod=TemplateSupportFileDocument.fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
- assertTrue(now-lastMod < 2000); //1 sec seems pretty safe
- assertTrue(now-lastMod > 0); // asked for now AFTER we created the space
+ long now = new Date().getTime();
+ long lastMod = TemplateSupportFileDocument.fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
+ 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");
}
-
+
}
public void testApplet() throws AuthenticationFailedException, IOException {
@@ -422,7 +420,7 @@
BodyAppletTestWindow bodyWindow = openBodyAppletTestWindow(basicAuthenticator);
bodyWindow.cleanup();
-
+
basicWebClient.deleteSpace(spaceDocument.getSpaceID());
}
@@ -529,16 +527,23 @@
assertEquals(numMemberships, membershipDocs.length);
}
- private ThingDocument tryToUpdateThing(long spaceID, ThingDocument thingDocument, WebAPIClient client) throws IOException{
+ private ThingDocument tryToUpdateThing(long spaceID, ThingDocument thingDocument, WebAPIClient client) throws IOException {
Vector3d scale = thingDocument.getScale();
scale.x += 0.5;
thingDocument.setScale(scale);
return client.updateThing(spaceID, thingDocument);
}
-
+
private void checkSpaceMembership(long spaceID, WebAPIClient advancedClient, WebAPIClient basicClient) throws IOException {
advancedClient.addSpaceMember(spaceID, basicClient.getAuthenticator().getUsername(), SpaceMemberDocument.MEMBER);
-
+
+ TestSpaceClientListener scListener = new TestSpaceClientListener();
+ SpaceClient spaceClient = new SpaceClient(spaceID, basicClient.getDescriptor().getServiceURI(), basicClient.getAuthenticator().getAuthCookie(), scListener);
+ User user = spaceClient.getSpace().getUser(basicClient.getAuthenticator().getUsername());
+ assertNotNull(user);
+ assertEquals(SpaceMemberDocument.MEMBER, user.getRole());
+ spaceClient.cleanup();
+
ThingDocument[] thingDocuments = basicClient.getThingDocuments(spaceID);
assertTrue(thingDocuments.length > 0);
assertNotNull(tryToUpdateThing(spaceID, thingDocuments[0], advancedClient));
@@ -549,7 +554,7 @@
assertEquals(USERNAME2, membershipDocs[0].getMemberUsername());
assertEquals(SpaceMemberDocument.MEMBER, membershipDocs[0].getRole());
assertNull(tryToUpdateThing(spaceID, thingDocuments[0], basicClient));
-
+
membershipDocs[0].setRole(SpaceMemberDocument.EDITOR);
assertNotNull(advancedClient.updateSpaceMember(spaceID, membershipDocs[0]));
membershipDocs = advancedClient.getSpaceMemberDocuments(spaceID);
@@ -558,7 +563,13 @@
assertEquals(SpaceMemberDocument.EDITOR, membershipDocs[0].getRole());
assertNotNull(tryToUpdateThing(spaceID, thingDocuments[0], basicClient));
thingDocuments = basicClient.getThingDocuments(spaceID);
-
+
+ spaceClient = new SpaceClient(spaceID, basicClient.getDescriptor().getServiceURI(), basicClient.getAuthenticator().getAuthCookie(), scListener);
+ user = spaceClient.getSpace().getUser(basicClient.getAuthenticator().getUsername());
+ assertNotNull(user);
+ assertEquals(SpaceMemberDocument.EDITOR, user.getRole());
+ spaceClient.cleanup();
+
advancedClient.removeSpaceMember(spaceID, USERNAME2);
membershipDocs = advancedClient.getSpaceMemberDocuments(spaceID);
assertEquals(0, membershipDocs.length);
@@ -592,7 +603,7 @@
assertFalse(spaceDocument.getDisplaySea());
//redefine this here b/c we don't want linkage against internal server code
- DateFormat fmt=TemplateSupportFileDocument.fmt;
+ DateFormat fmt = TemplateSupportFileDocument.fmt;
try {
long lastUpdateBeforeSet = fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
@@ -603,8 +614,8 @@
spaceDocument = webClient1.getSpaceDocument(spaceDocument.getSpaceID(), false);
//side test, make sure update time changes
long lastUpdateAfterSet = fmt.parse(spaceDocument.getLastModifiedAsUTC()).getTime();
- assertTrue(lastUpdateAfterSet-lastUpdateBeforeSet>=1000);
-
+ assertTrue(lastUpdateAfterSet - lastUpdateBeforeSet >= 1000);
+
assertEquals(-2, spaceDocument.getSeaLevel(), 0.000001);
webClient1.setSpaceDisplaySea(spaceDocument.getSpaceID(), true);
spaceDocument = webClient1.getSpaceDocument(spaceDocument.getSpaceID(), false);
@@ -675,11 +686,11 @@
//now connect as a guest
SpaceClient guestSpaceClient1 = new SpaceClient(spaceID, serviceURI1, guestCookie1, new TestSpaceClientListener());
long startTime = System.currentTimeMillis();
- while(System.currentTimeMillis() - startTime < 60000){
+ while (System.currentTimeMillis() - startTime < 60000) {
try {
Thread.sleep(1000);
- if(webClient1.getUserDocuments(spaceID).length == 2){
- break;
+ if (webClient1.getUserDocuments(spaceID).length == 2) {
+ break;
}
} catch (InterruptedException e) {
e.printStackTrace();
@@ -924,7 +935,7 @@
newTemplateDoc = webClient1.updateTemplate(newTemplateDoc);
assertEquals(templateName, newTemplateDoc.getDisplayName());
assertTrue(newTemplateDoc.isSeat());
-
+
assertEquals(false, newTemplateDoc.hasScriptFile());
assertNull(newTemplateDoc.getScriptModifiedTime());
@@ -956,7 +967,7 @@
newTemplateDoc = webClient1.getTemplateDocument(webClient1.getAuthenticator().getUsername(), newTemplateDoc.getTemplateID());
assertEquals(false, newTemplateDoc.hasScriptFile());
-
+
newTemplateDoc.setSeat(true);
Point3d seatPosition = new Point3d(3, 4, 5);
newTemplateDoc.setSeatPosition(seatPosition);
@@ -972,34 +983,33 @@
}
private XMLElement getStatusXML() throws IOException, URISyntaxException {
- InputStream s=new URI(serviceURI1.toString()+"status?format=xml").toURL().openConnection().getInputStream();
- XMLElement result=XMLElement.parseElementFromString(StreamUtils.readInput(s));
+ InputStream s = new URI(serviceURI1.toString() + "status?format=xml").toURL().openConnection().getInputStream();
+ XMLElement result = XMLElement.parseElementFromString(StreamUtils.readInput(s));
s.close();
return result;
}
-
+
public void testStatus() throws IOException, URISyntaxException {
try {
-
- InputStream forEffect=new URI(serviceURI1.toString()+"status?clear=true").toURL().openConnection().getInputStream();
+
+ InputStream forEffect = new URI(serviceURI1.toString() + "status?clear=true").toURL().openConnection().getInputStream();
forEffect.close();
//it's pretty hard to know what *should* be in the status message unless you dummy
//up a bunch of stuff in /proc ....this test, thus, is very weak
checkStatusReportChildren(1);
-
+
getStatusXML();
getStatusXML();
checkStatusReportChildren(4);
- forEffect=new URI(serviceURI1.toString()+"status?clear=true").toURL().openConnection().getInputStream();
+ forEffect = new URI(serviceURI1.toString() + "status?clear=true").toURL().openConnection().getInputStream();
forEffect.close();
checkStatusReportChildren(1);//make sure clear works and wasn't lucky above
-
-
+
} catch (IOException e) {
if (e.getMessage().startsWith("Server returned HTTP response code: 412")) {
Log.info("Ignoring response code 412 for status URL. You probably aren't on linux.");
@@ -1010,25 +1020,26 @@
}
private XMLElement checkStatusReportChildren(int n) throws IOException, URISyntaxException {
- XMLElement element=getStatusXML();
- assertEquals(element.getName(),"statusreports");
- assertEquals(n,element.getChildren().size());
+ XMLElement element = getStatusXML();
+ assertEquals(element.getName(), "statusreports");
+ assertEquals(n, element.getChildren().size());
return element;
}
+
private void assertStreamsEqual(InputStream input1, InputStream input2) throws IOException {
- if(input1 == null || input2 == null){
+ if (input1 == null || input2 == null) {
fail("Not equal, null inputs: " + input1 + ", " + input2);
return;
}
- while(true){
+ while (true) {
int read = input1.read();
assertEquals(read, input2.read());
- if(read == -1){
+ if (read == -1) {
return;
}
}
}
-
+
private void consume(InputStream input) throws IOException {
byte[] buffer = new byte[2048];
while (input.read(buffer) != -1) {
@@ -1093,7 +1104,7 @@
Vector thingMotionStops = new Vector();
Vector userSats = new Vector();
-
+
public void userAdded(User person) {
if (person == null) {
fail();
@@ -1217,14 +1228,16 @@
}
public void userSat(User user, Thing seatThing) {
- if(user == null) fail();
- if(seatThing == null) fail();
+ if (user == null)
+ fail();
+ if (seatThing == null)
+ fail();
userSats.add(user);
}
public void userStood(User user, Thing seat) {
// TODO Auto-generated method stub
-
+
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|