|
From: <ian...@us...> - 2007-08-16 19:33:37
|
Revision: 244
http://ogoglio.svn.sourceforge.net/ogoglio/?rev=244&view=rev
Author: iansmith
Date: 2007-08-16 12:33:40 -0700 (Thu, 16 Aug 2007)
Log Message:
-----------
More cleanup to insure that the ogoglio server can be shutdown properly via a program.
Ant changes to allow "ant test" to work properly from the command line. Warning: If you are using eclipse, changes made to source code via eclipse don't seem to be automatically recompiled via the "compile" ant task. It always works to do "ant clean test".
For reasons I don't understand, rmock's expectThatExceptionThrown doesn't work when run via ant. There is some seriously weird classpath stuff going on so for now I just converted the tests that used that function to work the more traditional way. No test logic was lost.
Modified Paths:
--------------
spaces/trunk/build.xml
spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java
spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java
spaces/trunk/src/com/ogoglio/client/WebAPITests.java
spaces/trunk/src/com/ogoglio/message/SenderQueue.java
spaces/trunk/src/com/ogoglio/message/TCPChannel.java
spaces/trunk/src/com/ogoglio/message/TCPMessageReader.java
spaces/trunk/src/com/ogoglio/templatesync/OgoglioSpecBase.java
spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
Modified: spaces/trunk/build.xml
===================================================================
--- spaces/trunk/build.xml 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/build.xml 2007-08-16 19:33:40 UTC (rev 244)
@@ -15,8 +15,11 @@
</filterchain>
</loadproperties>
-
<echo message="tomcat 5.5 dir found to be ${ant.tomcatDir}"/>
+
+ <target name="junitOk">
+ <available property="junitPresent" classname="junit.framework.TestCase" />
+ </target>
<target name="clean">
<delete>
@@ -43,13 +46,14 @@
<fileset dir="shared-lib">
<include name="**/*.jar" />
</fileset>
- <fileset dir="${tomcatHome}/common/lib/">
+ <fileset dir="${ant.tomcatDir}/common/lib/">
<include name="**/*.jar" />
</fileset>
<fileset dir="${java.home}/lib/">
<include name="plugin.jar" />
</fileset>
- </path>
+ <filelist dir="war/WEB-INF" files="classes"/>
+ </path>
<!-- these are files which will end up in ogoglio-shared.jar in Tomcat's shared lib, and not in ogoglio.war -->
<fileset id="sharedFiles" dir="${dest}">
@@ -160,10 +164,20 @@
errorProperty="ignored" outputProperty="ignoredalso"/>
</target>
- <target name="test" depends="war,insureNoServer">
+ <target name="test" depends="war,insureNoServer,junitOk">
+ <fail message="Couldn't find JUnit classes in classpath! You need to put shared-lib/junit-3.8.1.jar in ~/.ant/lib so ant can find it!" unless="junitPresent"/>
+ <echo message="starting ogoglio server..."/>
<exec executable="${ant.tomcatDir}/bin/startup.sh" failonerror="true"/>
<sleep seconds="5"/>
+
+ <junit>
+ <classpath refid="classpath"/>
+ <formatter type="brief" usefile="false" />
+ <test name="com.ogoglio.OgoglioTestSuite" />
+ </junit>
+
<exec executable="${ant.tomcatDir}/bin/shutdown.sh" failonerror="true"/>
</target>
+
</project>
Modified: spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java
===================================================================
--- spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/OgoglioTestSuite.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -29,7 +29,7 @@
TestSuite suite = new TestSuite();
suite.addTestSuite(ObjTest.class);
suite.addTestSuite(XMLTests.class);
- //suite.addTestSuite(PersistTests.class);
+ suite.addTestSuite(PersistTests.class);
suite.addTestSuite(WebAPITests.class);
suite.addTestSuite(ClientTests.class);
suite.addTestSuite(ScriptTests.class);
Modified: spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/client/WebAPIClientWire.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -294,18 +294,20 @@
// XXX seems to be required
String headerValue = null;
Object makeLinuxHappy = (connection.getRequestProperties().get(headerName));
- if (makeLinuxHappy instanceof String) {
- headerValue = (String) makeLinuxHappy;
- } else if (makeLinuxHappy instanceof List) {
- headerValue = (String) ((List) makeLinuxHappy).get(0);
- } else {
- // we don't understand this type at all
- System.err.println("Unable to understand the type returned by Linux workaround in WebAPIClient!");
+ if (makeLinuxHappy!=null) {
+ if (makeLinuxHappy instanceof String) {
+ headerValue = (String) makeLinuxHappy;
+ } else if (makeLinuxHappy instanceof List) {
+ headerValue = (String) ((List) makeLinuxHappy).get(0);
+ } else {
+ // we don't understand this type at all
+ System.err.println("Unable to understand the type returned by Linux workaround in WebAPIClient:"+makeLinuxHappy.getClass().getName());
+ return null;
+ }
+ }
+ if (makeLinuxHappy == null) {
return null;
}
- if (headerValue == null) {
- return null;
- }
return headerValue;
} catch (IOException e) {
return null;
Modified: spaces/trunk/src/com/ogoglio/client/WebAPITests.java
===================================================================
--- spaces/trunk/src/com/ogoglio/client/WebAPITests.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/client/WebAPITests.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -84,8 +84,9 @@
modify().multiplicity(expect.atMost(2));
modify().forward();
- expectThatExceptionThrown(is.instanceOf(AuthenticationFailedException.class));
-
+ //for reasons I don't understand this doesn't work when running via ant
+ //so we are going to not use it for now
+ //expectThatExceptionThrown(is.instanceOf(AuthenticationFailedException.class));
//###################################
startVerification();
@@ -94,9 +95,13 @@
assertEquals(GOOD_COOKIE, auth.getAuthCookie());
assertEquals(authedAuthDoc.getUsername(), auth.getUsername());
assertEquals(accountDoc, auth.getAccountDocument(true));
-
- mockAuthFactory.authenticate(mockWire, descriptor, BAD_COOKIE);
-
+
+ try {
+ auth = mockAuthFactory.authenticate(mockWire, descriptor, BAD_COOKIE);
+ fail("Should not be able to reach this point after bad authentication!");
+ } catch (AuthenticationFailedException e) {
+ assertThat(e, is.instanceOf(AuthenticationFailedException.class));
+ }
}
public void testWebAPIAuthenticatorViaUsernameAndPass() throws AuthenticationFailedException, URISyntaxException, IOException {
@@ -114,7 +119,9 @@
mockAuthFactory.authenticate(mockWire, descriptor, "Ian", "goodPW");
modify().forward();
- expectThatExceptionThrown(is.instanceOf(AuthenticationFailedException.class));
+ //for reasons I don't understand this doesn't work when running via ant
+ //so we are going to not use it for now
+ //expectThatExceptionThrown(is.instanceOf(AuthenticationFailedException.class));
//###################################
startVerification();
@@ -124,7 +131,12 @@
assertThat(auth.getAuthCookie(), is.eq(GOOD_COOKIE));
//try bad pw
- mockAuthFactory.authenticate(mockWire, descriptor, "Ian", "farts");
+ try {
+ mockAuthFactory.authenticate(mockWire, descriptor, "Ian", "farts");
+ fail("Should not be able to reach this point after bad pw!");
+ } catch (AuthenticationFailedException e) {
+ assertThat(e, is.instanceOf(AuthenticationFailedException.class));
+ }
}
}
Modified: spaces/trunk/src/com/ogoglio/message/SenderQueue.java
===================================================================
--- spaces/trunk/src/com/ogoglio/message/SenderQueue.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/message/SenderQueue.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -47,10 +47,17 @@
public void cleanup() {
cleaned = true;
try {
- clientSocket.close();
- socketOutput.close();
- messageQueue.close();
+ if (clientSocket!=null) {
+ clientSocket.close();
+ }
+ if (socketOutput!=null) {
+ socketOutput.close();
+ }
+ if (messageQueue!=null) {
+ messageQueue.close();
+ }
} catch (IOException e) {
+ System.out.println("IOException trying cleanup SenderQueue:"+e.getMessage());
}
}
Modified: spaces/trunk/src/com/ogoglio/message/TCPChannel.java
===================================================================
--- spaces/trunk/src/com/ogoglio/message/TCPChannel.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/message/TCPChannel.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -84,12 +84,16 @@
public void cleanup() {
cleaned = true;
try {
- readerThread.cleanup();
+ if (readerThread!=null) {
+ readerThread.cleanup();
+ }
} catch (Exception e) {
System.out.println("TCPChannel: Trying to cleanup to readerThread:"+(e.getClass().getName())+":"+e.getMessage());
}
try {
- senderQueue.cleanup();
+ if (senderQueue!=null) {
+ senderQueue.cleanup();
+ }
} catch (Exception e) {
System.out.println("TCPChannel: Trying to cleanup to senderQueue:"+(e.getClass().getName())+":"+e.getMessage());
}
Modified: spaces/trunk/src/com/ogoglio/message/TCPMessageReader.java
===================================================================
--- spaces/trunk/src/com/ogoglio/message/TCPMessageReader.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/message/TCPMessageReader.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -75,8 +75,11 @@
public void cleanup() {
cleaned = true;
try {
- socketInput.close();
+ if (socketInput!=null) {
+ socketInput.close();
+ }
} catch (IOException e) {
+ System.out.println("IOException caught trying to clean up TCPMessageReader:"+e.getMessage());
}
}
Modified: spaces/trunk/src/com/ogoglio/templatesync/OgoglioSpecBase.java
===================================================================
--- spaces/trunk/src/com/ogoglio/templatesync/OgoglioSpecBase.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/templatesync/OgoglioSpecBase.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -5,7 +5,7 @@
public class OgoglioSpecBase extends RMockTestCase {
public Object mock_ignoreEqualsAndToString(Class clazz) {
- return mock_ignoreEqualsAndToString(clazz,new Object[0], "mockOf:"+clazz.getName());
+ return mock_ignoreEqualsAndToString(clazz,new Object[0], "mockOf_"+clazz.toString().replace('.','_'));
}
public Object mock_ignoreEqualsAndToString(Class clazz, Object[] constructorParams, String name) {
Object result = mock(clazz,constructorParams,name);
Modified: spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java
===================================================================
--- spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java 2007-08-16 17:04:44 UTC (rev 243)
+++ spaces/trunk/src/com/ogoglio/templatesync/SyncTool.java 2007-08-16 19:33:40 UTC (rev 244)
@@ -262,7 +262,6 @@
File template = ((File) serverTemplatesToAdd.get(i));
verifyDirContent(template);
long newID = createTemplate(template, client);
- System.out.println("ADDING:" + template.getName() + "," + newID);
serverTemplateNamesToIds.put(template.getName(), new Long(newID));
}
deleteTemplates(client, serverTemplatesToDelete);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|