Index: java/com/panorama/discussions/DiscussionsStartup.java =================================================================== RCS file: /home/cvspublic/jakarta-hivemind/examples/src/java/com/panorama/discussions/DiscussionsStartup.java,v retrieving revision 1.2 diff -u -r1.2 DiscussionsStartup.java --- java/com/panorama/discussions/DiscussionsStartup.java 6 Jan 2005 01:45:14 -0000 1.2 +++ java/com/panorama/discussions/DiscussionsStartup.java 3 Feb 2005 07:26:22 -0000 @@ -24,8 +24,11 @@ */ public class DiscussionsStartup { + static boolean _initialized = false; + public static void init() { System.out.println("DiscussionsStartup invoked."); + _initialized = true; } } Index: java/com/panorama/mail/MailStartup.java =================================================================== RCS file: /home/cvspublic/jakarta-hivemind/examples/src/java/com/panorama/mail/MailStartup.java,v retrieving revision 1.2 diff -u -r1.2 MailStartup.java --- java/com/panorama/mail/MailStartup.java 6 Jan 2005 01:45:15 -0000 1.2 +++ java/com/panorama/mail/MailStartup.java 3 Feb 2005 07:26:22 -0000 @@ -23,9 +23,12 @@ */ public class MailStartup implements Executable { + boolean _startupInvoked = false; + public void execute() throws Exception { System.out.println("MailStartup invoked."); + _startupInvoked = true; } } Index: java/org/apache/hivemind/examples/impl/ProxyLoggingInvocationHandler.java =================================================================== RCS file: /home/cvspublic/jakarta-hivemind/examples/src/java/org/apache/hivemind/examples/impl/ProxyLoggingInvocationHandler.java,v retrieving revision 1.2 diff -u -r1.2 ProxyLoggingInvocationHandler.java --- java/org/apache/hivemind/examples/impl/ProxyLoggingInvocationHandler.java 5 Jan 2005 18:04:51 -0000 1.2 +++ java/org/apache/hivemind/examples/impl/ProxyLoggingInvocationHandler.java 3 Feb 2005 07:26:22 -0000 @@ -44,20 +44,16 @@ { boolean debug = _log.isDebugEnabled(); - if (debug) - LoggingUtils.entry(_log, method.getName(), args); + LoggingUtils.entry(_log, method.getName(), args); try { Object result = method.invoke(_inner, args); - if (debug) - { - if (method.getReturnType() == void.class) - LoggingUtils.voidExit(_log, method.getName()); - else - LoggingUtils.exit(_log, method.getName(), result); - } + if (method.getReturnType() == void.class) + LoggingUtils.voidExit(_log, method.getName()); + else + LoggingUtils.exit(_log, method.getName(), result); return result; } @@ -65,8 +61,7 @@ { Throwable targetException = ex.getTargetException(); - if (debug) - LoggingUtils.exception(_log, method.getName(), targetException); + LoggingUtils.exception(_log, method.getName(), targetException); throw targetException; } Index: test/com/panorama/startup/impl/TestTaskExecutor.java =================================================================== RCS file: /home/cvspublic/jakarta-hivemind/examples/src/test/com/panorama/startup/impl/TestTaskExecutor.java,v retrieving revision 1.9 diff -u -r1.9 TestTaskExecutor.java --- test/com/panorama/startup/impl/TestTaskExecutor.java 5 Jan 2005 18:06:00 -0000 1.9 +++ test/com/panorama/startup/impl/TestTaskExecutor.java 3 Feb 2005 07:26:22 -0000 @@ -73,7 +73,7 @@ return new MessagesImpl(r, Locale.getDefault()); } - public void testSuccess() + public void testSuccessAfter() { ExecutableFixture f1 = new ExecutableFixture("f1"); @@ -124,6 +124,57 @@ verifyControls(); } + public void testSuccessBefore() + { + ExecutableFixture f1 = new ExecutableFixture("f1"); + + Task t1 = new Task(); + + t1.setExecutable(f1); + t1.setId("first"); + t1.setTitle("Fixture #1"); + + ExecutableFixture f2 = new ExecutableFixture("f2"); + + Task t2 = new Task(); + t2.setExecutable(f2); + t2.setId("second"); + t2.setBefore("first"); + t2.setTitle("Fixture #2"); + + List tasks = new ArrayList(); + tasks.add(t1); + tasks.add(t2); + + MockControl logControl = newControl(Log.class); + Log log = (Log) logControl.getMock(); + + TaskExecutor e = new TaskExecutor(); + + ErrorLog errorLog = (ErrorLog) newMock(ErrorLog.class); + + e.setErrorLog(errorLog); + e.setLog(log); + e.setMessages(getMessages()); + e.setTasks(tasks); + + // Note the ordering; explicitly set, to check that ordering does + // take place. + log.info("Executing task Fixture #2."); + log.info("Executing task Fixture #1."); + log.info("Executed 2 tasks \\(in \\d+ milliseconds\\)\\."); + logControl.setMatcher(new AggregateArgumentsMatcher(new RegexpMatcher())); + + replayControls(); + + e.run(); + + assertListsEqual(new String[] + { "f2", "f1" }, _tokens); + + verifyControls(); + } + public void testFailure() { Executable f = new Executable() Index: test/com/panorama/discussions/TestDiscussionsStartup.java =================================================================== RCS file: test/com/panorama/discussions/TestDiscussionsStartup.java diff -N test/com/panorama/discussions/TestDiscussionsStartup.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ test/com/panorama/discussions/TestDiscussionsStartup.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,35 @@ +// Copyright 2004, 2005 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.panorama.discussions; + +import junit.framework.TestCase; + +/** + * Tests {@link TestDiscussionsStartup}. + * + * @author Howard Lewis Ship + */ +public class TestDiscussionsStartup extends TestCase +{ + + public void testInit() throws Exception + { + assertFalse(DiscussionsStartup._initialized); + + DiscussionsStartup.init(); + + assertTrue(DiscussionsStartup._initialized); + } +} Index: test/com/panorama/mail/TestMailStartup.java =================================================================== RCS file: test/com/panorama/mail/TestMailStartup.java diff -N test/com/panorama/mail/TestMailStartup.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ test/com/panorama/mail/TestMailStartup.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,37 @@ +// Copyright 2004, 2005 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.panorama.mail; + +import junit.framework.TestCase; + +/** + * Tests {@link TestMailStartup}. + * + * @author Howard Lewis Ship + */ +public class TestMailStartup extends TestCase +{ + + public void testInit() throws Exception + { + MailStartup ms = new MailStartup(); + + assertFalse(ms._startupInvoked); + + ms.execute(); + + assertTrue(ms._startupInvoked); + } +} Index: test/com/panorama/startup/TestPanoramaMain.java =================================================================== RCS file: test/com/panorama/startup/TestPanoramaMain.java diff -N test/com/panorama/startup/TestPanoramaMain.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ test/com/panorama/startup/TestPanoramaMain.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,39 @@ +// Copyright 2004, 2005 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.panorama.startup; + +import junit.framework.TestCase; + +/** + * Tests {@link TestPanoramaMain}. + * + * @author Howard Lewis Ship + */ +public class TestPanoramaMain extends TestCase +{ + + public void testMain() throws Exception + { + boolean exceptionThrown = true; + + try { + PanoramaMain.main(null); + exceptionThrown = false; + } catch (Throwable t) { + exceptionThrown = true; + } + assertFalse(exceptionThrown); + } +} Index: test/org/apache/hivemind/examples/TestCalculatorMain.java =================================================================== RCS file: test/org/apache/hivemind/examples/TestCalculatorMain.java diff -N test/org/apache/hivemind/examples/TestCalculatorMain.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ test/org/apache/hivemind/examples/TestCalculatorMain.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,43 @@ +// Copyright 2004, 2005 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.apache.hivemind.examples; + +import junit.framework.TestCase; + +/** + * Tests {@link TestCalculatorMain}. + * + * @author Howard Lewis Ship + */ +public class TestCalculatorMain extends TestCase +{ + + public void testMain() throws Exception + { + String[] args = new String[2]; + args[0] = "24"; + args[1] = "7"; + + boolean exceptionThrown = true; + + try { + CalculatorMain.main(args); + exceptionThrown = false; + } catch (Throwable t) { + exceptionThrown = true; + } + assertFalse(exceptionThrown); + } +} Index: test/org/apache/hivemind/examples/TestLoggingMain.java =================================================================== RCS file: test/org/apache/hivemind/examples/TestLoggingMain.java diff -N test/org/apache/hivemind/examples/TestLoggingMain.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ test/org/apache/hivemind/examples/TestLoggingMain.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,39 @@ +// Copyright 2004, 2005 The Apache Software Foundation +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package org.apache.hivemind.examples; + +import junit.framework.TestCase; + +/** + * Tests {@link TestLoggingMain}. + * + * @author Howard Lewis Ship + */ +public class TestLoggingMain extends TestCase +{ + + public void testMain() throws Exception + { + boolean exceptionThrown = true; + + try { + LoggingMain.main(null); + exceptionThrown = false; + } catch (Throwable t) { + exceptionThrown = true; + } + assertFalse(exceptionThrown); + } +}