01: /******************************************************************************
02: * Copyright (C) Lars Ivar Almli. All rights reserved. *
03: * ---------------------------------------------------------------------------*
04: * This file is part of MActor. *
05: * *
06: * MActor is free software; you can redistribute it and/or modify *
07: * it under the terms of the GNU General Public License as published by *
08: * the Free Software Foundation; either version 2 of the License, or *
09: * (at your option) any later version. *
10: * *
11: * MActor is distributed in the hope that it will be useful, *
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14: * GNU General Public License for more details. *
15: * *
16: * You should have received a copy of the GNU General Public License *
17: * along with MActor; if not, write to the Free Software *
18: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *
19: ******************************************************************************/package org.mactor.tests;
20:
21: import java.io.File;
22: import org.mactor.framework.HtmlTestSuiteParser;
23: import org.mactor.framework.TestContext;
24: import org.mactor.framework.TestEvent;
25: import org.mactor.framework.TestFeedbackListener;
26: import org.mactor.framework.TestSuiteRunner;
27: import org.mactor.framework.spec.TestSpec;
28:
29: public class TestSpecRunnerTest {
30: public void test() throws Exception {
31: Util.clearDir("/tmp/mactor/channels/IncomingOrderStatus");
32: Util.clearDir("/tmp/mactor/channels/OutgoingOrder");
33: Util.clearDir("/tmp/mactor/channels/IncomingAck");
34: Util.clearDir("/tmp/mactor/channels/OutgoingAck");
35: new Thread(new Runnable() {
36: public void run() {
37: runMock();
38: }
39: }).start();
40: Thread.sleep(1000);
41: HtmlTestSuiteParser td = HtmlTestSuiteParser.parseFile(
42: "tests/mactor_test/test-suite-data_large.html").get(0);
43: TestSpec ts = TestSpec.loadFromFile(new File(td
44: .getTestSpecPath()));
45: // int errorCount = new TestSuiteRunner(ts).run(td.getData(), new
46: // HtmlLogFeedBackListener(ts, td.getData()));
47: // Assert.assertEquals(0, errorCount);
48: Thread.sleep(2000000);
49: }
50:
51: private void runMock() {
52: try {
53: TestSpec ts = TestSpec.loadFromFile(new File(
54: "tests/mactor_test/order_mock-spec.xml"));
55: new TestSuiteRunner(ts)
56: .runAsMock(new SilentTestFeedbackListener());
57: } catch (Exception e) {
58: e.printStackTrace();
59: }
60: }
61:
62: private static class SilentTestFeedbackListener implements
63: TestFeedbackListener {
64: public void onEvent(TestEvent event, TestContext context) {
65: if (!event.isSuccessful())
66: System.err.println(event.getNode().getName());
67: }
68: }
69: }
|