|
From: <tre...@us...> - 2007-08-28 23:53:05
|
Revision: 287
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=287&view=rev
Author: trevorolio
Date: 2007-08-28 16:53:00 -0700 (Tue, 28 Aug 2007)
Log Message:
-----------
Added test template resources.
Removed some debug printlns.
Modified Paths:
--------------
maven/trunk/ogoglio-server/.classpath
maven/trunk/ogoglio-server/pom.xml
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/mail/MailClient.java
maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java
maven/trunk/ogoglio-server/src/test/java/com/ogoglio/sim/script/test/ScriptTest.java
Added Paths:
-----------
maven/trunk/ogoglio-server/src/test/resources/templates/
maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.gif
maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.js
maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.mtl
maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.obj
Modified: maven/trunk/ogoglio-server/.classpath
===================================================================
--- maven/trunk/ogoglio-server/.classpath 2007-08-28 23:51:30 UTC (rev 286)
+++ maven/trunk/ogoglio-server/.classpath 2007-08-28 23:53:00 UTC (rev 287)
@@ -1,14 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/test/java"/>
- <classpathentry excluding="**" kind="src" output="src/main/resources/hibernate" path="src/main/resources/hibernate"/>
- <classpathentry excluding="**" kind="src" output="src/main/resources/log4j" path="src/main/resources/log4j"/>
- <classpathentry excluding="**" kind="src" output="src/test/resources/hibernate" path="src/test/resources/hibernate"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
- <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="/usr/local/jdk1.5.0_12/jre/lib/i386"/>
+ <attribute value="/usr/local/jdk1.5.0_12/jre/lib/i386" name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
Modified: maven/trunk/ogoglio-server/pom.xml
===================================================================
--- maven/trunk/ogoglio-server/pom.xml 2007-08-28 23:51:30 UTC (rev 286)
+++ maven/trunk/ogoglio-server/pom.xml 2007-08-28 23:53:00 UTC (rev 287)
@@ -66,6 +66,7 @@
<includes>
<include>test-config.properties</include>
<include>mail/*</include>
+ <include>templates/*</include>
</includes>
</testResource>
</testResources>
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/mail/MailClient.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/mail/MailClient.java 2007-08-28 23:51:30 UTC (rev 286)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/mail/MailClient.java 2007-08-28 23:53:00 UTC (rev 287)
@@ -38,10 +38,10 @@
public MailClient() {
writeToDisk = false;
}
-
+
public void sendEmail(String to, String from, String subject, String body) throws MailSendException {
try {
- if (writeToDisk) {
+ if (writeToDisk) {
sendToDisk(to, from, subject, body);
} else {
sendViaContextSession(to, from, subject, body);
Modified: maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java
===================================================================
--- maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-08-28 23:51:30 UTC (rev 286)
+++ maven/trunk/ogoglio-server/src/main/java/com/ogoglio/sim/site/SimServlet.java 2007-08-28 23:53:00 UTC (rev 287)
@@ -154,7 +154,6 @@
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
try {
long spaceID = Long.parseLong(pathElements[pathElements.length - 1]);
- System.out.println("FART TRYING TO GET SPACE DOC FOR "+spaceID);
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(spaceID, getSessionFactory());
if (spaceRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
@@ -265,7 +264,6 @@
public void doGet(HttpServletRequest request, HttpServletResponse response, String[] pathElements) throws ServletException, IOException {
long spaceID = Long.parseLong(pathElements[2]);
try {
- System.out.println("SIM FART GET:"+spaceID);
SpaceRecord spaceRecord = SpacePersistTasks.findSpaceBySpaceID(spaceID, getSessionFactory());
if (spaceRecord == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
@@ -278,14 +276,12 @@
return;
}
- System.out.println("SIM FART GET2:"+authedAccount.getUsername());
SpaceSimulator simulator = sim.getOrCreateSpaceSimulator(spaceRecord);
String value = simulator.getSetting(pathElements[pathElements.length - 1]);
if (value == null) {
response.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
- System.out.println("SIM FART GET3:"+value);
sendStringResponse(value, "text/plain", response);
} catch (PersistException e) {
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
Modified: maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java
===================================================================
--- maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java 2007-08-28 23:51:30 UTC (rev 286)
+++ maven/trunk/ogoglio-server/src/test/java/com/ogoglio/persist/test/PersistTest.java 2007-08-28 23:53:00 UTC (rev 287)
@@ -68,9 +68,6 @@
}
}
public void setUp() {
-
- System.out.println("FART FART FART:" +(getClass().getResourceAsStream("com/ogoglio/migrate/migration-0.xml")==null));
-
super.setUp();
username1 = AccountRecord.cleanUsername("MoonUnitZappa");
email1 = AccountRecord.cleanEmail("mu...@ex...");
Modified: maven/trunk/ogoglio-server/src/test/java/com/ogoglio/sim/script/test/ScriptTest.java
===================================================================
--- maven/trunk/ogoglio-server/src/test/java/com/ogoglio/sim/script/test/ScriptTest.java 2007-08-28 23:51:30 UTC (rev 286)
+++ maven/trunk/ogoglio-server/src/test/java/com/ogoglio/sim/script/test/ScriptTest.java 2007-08-28 23:53:00 UTC (rev 287)
@@ -4,60 +4,68 @@
import java.io.InputStream;
import java.util.HashMap;
+import javax.media.j3d.Transform3D;
+
import junit.framework.TestCase;
import com.ogoglio.sim.SpaceSimulator;
+import com.ogoglio.viewer.render.UIConstants;
import com.ogoglio.xml.SpaceDocument;
import com.ogoglio.xml.SpaceEvent;
import com.ogoglio.xml.TemplateDocument;
+import com.ogoglio.xml.ThingDocument;
public class ScriptTest extends TestCase {
public static final String simplestScript = "var i = 0; i++; ++i";
-
+
public static final String constructorScript = "function construct(thingID) { return 'script constructed ' + thingID; }";
//TODO test the script API for regressions
-
+
public void testSpaceScriptEngine() {
-
+
TestSpaceListener listener = new TestSpaceListener();
SpaceSimulator spaceSimulator = null;
- // try {
+ try {
SpaceDocument spaceDocument = new SpaceDocument(1, "Space", "trevor", true, 0, false, 0, 1);
spaceSimulator = new SpaceSimulator(spaceDocument, listener);
spaceSimulator.startSim();
-
+
TemplateDocument templateDoc1 = new TemplateDocument(1, "Template 1", "trevor", "A cool template", null);
listener.templateMap.put(new Long(1), templateDoc1);
listener.scriptMap.put(new Long(1), simplestScript);
- //ThingDocument thingDoc = spaceSimulator.addThing(templateDoc1.getTemplateID(), templateDoc1.getOwnerUsername(), templateDoc1.getDisplayName(), "trevor", 1, new Transform3D());
- //assertTrue(spaceSimulator.removeThing(thingDoc.getThingID()));
+ listener.objMap.put(new Long(1), "templates/TestCube.obj");
+ listener.resourceMap.put(new Long(1), "templates/TestCube.mtl");
+ ThingDocument thingDoc = spaceSimulator.addThing(templateDoc1.getTemplateID(), templateDoc1.getOwnerUsername(), templateDoc1.getDisplayName(), "trevor", 1, new Transform3D());
+ assertTrue(spaceSimulator.removeThing(thingDoc.getThingID()));
TemplateDocument templateDoc2 = new TemplateDocument(2, "Template 2", "trevor", "Another cool template", null);
listener.templateMap.put(new Long(2), templateDoc2);
listener.scriptMap.put(new Long(2), constructorScript);
- //thingDoc = spaceSimulator.addThing(templateDoc2.getTemplateID(), templateDoc2.getOwnerUsername(), templateDoc2.getDisplayName(), "trevor", 2, new Transform3D());
- //assertTrue(spaceSimulator.removeThing(thingDoc.getThingID()));
+ listener.objMap.put(new Long(2), "templates/TestCube.obj");
+ listener.resourceMap.put(new Long(2), "templates/TestCube.mtl");
+ thingDoc = spaceSimulator.addThing(templateDoc2.getTemplateID(), templateDoc2.getOwnerUsername(), templateDoc2.getDisplayName(), "trevor", 2, new Transform3D());
+ assertTrue(spaceSimulator.removeThing(thingDoc.getThingID()));
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
- // }finally {
- // spaceSimulator.cleanup();
- // }
+ } finally {
+ spaceSimulator.cleanup();
+ }
}
private static void delete(File dir) {
File[] children = dir.listFiles();
- if(children == null) {
+ if (children == null) {
return;
}
for (int i = 0; i < children.length; i++) {
- if(children[i].isDirectory()) {
+ if (children[i].isDirectory()) {
delete(children[i]);
} else {
children[i].delete();
@@ -65,34 +73,45 @@
}
dir.delete();
}
-
-
+
private class TestSpaceListener implements SpaceSimulator.Listener {
HashMap scriptMap = new HashMap(); //Long templateIDs to String scripts
-
+
HashMap templateMap = new HashMap(); //Long templateIDs to TemplateDocuments
+
+ HashMap objMap = new HashMap(); //Long templateIDs to obj resource names
+ HashMap resourceMap = new HashMap(); //Long templateIDs to template resource names
+
public void generatedSpaceEvent(SpaceEvent event, SpaceSimulator spaceSimulator) {
}
public String getTemplateScript(long templateID) {
- return (String)scriptMap.get(new Long(templateID));
+ return (String) scriptMap.get(new Long(templateID));
}
public TemplateDocument getTemplateDocument(long templateID) {
- return (TemplateDocument)templateMap.get(new Long(templateID));
+ return (TemplateDocument) templateMap.get(new Long(templateID));
}
public void requestSave(SpaceSimulator simulator) {
}
public InputStream getTemplateGeometryStream(long templateID, int lodIndex) {
- return null;
+ String resourcePath = (String)objMap.get(new Long(templateID));
+ if(resourcePath == null){
+ return null;
+ }
+ return UIConstants.getResource(resourcePath);
}
public InputStream getTemplateResourceStream(long templateID, String name) {
- return null;
+ String resourcePath = (String)resourceMap.get(new Long(templateID));
+ if(resourcePath == null){
+ return null;
+ }
+ return UIConstants.getResource(resourcePath);
}
public boolean setPageContent(long spaceID, long thingID, long pageID, String content) {
Added: maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.gif
===================================================================
(Binary files differ)
Property changes on: maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.js
===================================================================
--- maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.js (rev 0)
+++ maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.js 2007-08-28 23:53:00 UTC (rev 287)
@@ -0,0 +1,42 @@
+var thingID = -1;
+
+function construct(id){
+ thingID = id;
+}
+
+function onClick(person, shapeName){
+ space.log(person + " clicked " + thingID + " on its " + shapeName);
+
+ var currentPosition = space.getThingPosition(thingID);
+
+ var path = new SplinePath(2000, false, false);
+ path.addKeyFrame(new SplineKeyFrame(currentPosition.x, currentPosition.y, currentPosition.z, 0, 0));
+ path.addKeyFrame(new SplineKeyFrame(currentPosition.x, currentPosition.y + 1, currentPosition.z, math.PI, 0.5));
+ path.addKeyFrame(new SplineKeyFrame(currentPosition.x, currentPosition.y, currentPosition.z, 2 * math.PI, 1));
+
+ space.startThingMotion(thingID, path);
+}
+
+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);
+}
+
+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/";
+}
+
+
Added: maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.mtl
===================================================================
--- maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.mtl (rev 0)
+++ maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.mtl 2007-08-28 23:53:00 UTC (rev 287)
@@ -0,0 +1,13 @@
+# Blender3D MTL File: TestCube.blend
+# Material Count: 1
+newmtl Material_Numbers.gif
+Ns 96.078431
+Ka 0.000000 0.000000 0.000000
+Kd 0.640000 0.640000 0.640000
+Ks 0.500000 0.500000 0.500000
+Ni 1.000000
+d 1.000000
+illum 2
+map_Kd TestCube.gif
+
+
Added: maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.obj
===================================================================
--- maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.obj (rev 0)
+++ maven/trunk/ogoglio-server/src/test/resources/templates/TestCube.obj 2007-08-28 23:53:00 UTC (rev 287)
@@ -0,0 +1,44 @@
+# Blender3D v243 OBJ File: TestCube.blend
+# www.blender3d.org
+mtllib TestCube.mtl
+o Cube
+v 1.000000 2.000000 -1.000000
+v 1.000000 0.000000 -1.000000
+v -1.000000 0.000000 -1.000000
+v -1.000000 2.000000 -1.000000
+v 1.000000 2.000000 1.000000
+v 0.999999 -0.000001 1.000000
+v -1.000000 0.000000 1.000000
+v -1.000000 2.000000 1.000000
+vt 0.499999 0.249999 0.0
+vt 0.499999 0.499999 0.0
+vt 0.250000 0.499999 0.0
+vt 0.250000 0.249999 0.0
+vt 0.500000 0.999999 0.0
+vt 0.249999 0.999999 0.0
+vt 0.249999 0.749998 0.0
+vt 0.500000 0.749998 0.0
+vt 0.749999 0.499998 0.0
+vt 0.749999 0.749998 0.0
+vt 0.500000 0.749998 0.0
+vt 0.499999 0.499999 0.0
+vt 0.499999 0.499999 0.0
+vt 0.500000 0.749998 0.0
+vt 0.249999 0.749998 0.0
+vt 0.250000 0.499999 0.0
+vt 0.250000 0.499999 0.0
+vt 0.249999 0.749998 0.0
+vt 0.000000 0.749998 0.0
+vt 0.000000 0.499999 0.0
+vt 0.499999 0.000000 0.0
+vt 0.499999 0.249999 0.0
+vt 0.250000 0.249999 0.0
+vt 0.249999 0.000000 0.0
+usemtl Material_Numbers.gif
+s 1
+f 1/1 2/2 3/3 4/4
+f 5/5 8/6 7/7 6/8
+f 1/9 5/10 6/11 2/12
+f 2/13 6/14 7/15 3/16
+f 3/17 7/18 8/19 4/20
+f 5/21 1/22 4/23 8/24
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|