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.junit.Assert;
23: import org.junit.Test;
24: import org.mactor.framework.spec.GlobalConfig;
25: import org.mactor.framework.spec.MessageBrokersConfig;
26: import org.mactor.framework.spec.TestSpec;
27: import org.mactor.framework.spec.MessageBrokersConfig.MessageBrokerConfig;
28:
29: public class SpecTest {
30: @Test
31: public void readTestSpec() throws Exception {
32: TestSpec ts = TestSpec.loadFromFile(new File(
33: "tests/mactor_sample_test/order-spec.xml"));
34: /*
35: * // ValueSpec Assert.assertEquals("MessageId",
36: * ts.getSpecNodes().get(0).getName());
37: * Assert.assertEquals("sequence:msgid", ((ValueSpec)
38: * ts.getSpecNodes().get(0)).getCommand()); Assert.assertEquals("100",
39: * ((ValueSpec) ts.getSpecNodes().get(0)).getParams().get(0)); //
40: * MessageSubscribeSpec
41: * Assert.assertEquals("java:org.mactor.extensions.xml.BasicMessageSelector",
42: * ((MessageSubscribeSpec) ts.getSpecNodes().get(2))
43: * .getMessageSelector().getCommand());
44: * Assert.assertEquals("Header/CorrelationId=##{MessageId}",
45: * ((MessageSubscribeSpec)
46: * ts.getSpecNodes().get(2)).getMessageSelector().getParams() .get(0)); //
47: * MessagePubslishSpec
48: * Assert.assertEquals("java:org.mactor.extensions.xml.BasicTemplateMessageBuilder",
49: * ((MessagePublishSpec) ts.getSpecNodes().get(4))
50: * .getMessageBuilder().getCommand());
51: * Assert.assertEquals("Data/ProductId=##{ProductId}",
52: * ((MessagePublishSpec)
53: * ts.getSpecNodes().get(4)).getMessageBuilder().getParams().get(2)); //
54: * MessageReceiveSpec Assert.assertEquals(3, ((MessageReceiveSpec)
55: * ts.getSpecNodes().get(6)).getMaxMessageCount());
56: * Assert.assertEquals(5, ((MessageReceiveSpec)
57: * ts.getSpecNodes().get(6)).getMinMessageCount());
58: * Assert.assertEquals(60, ((MessageReceiveSpec)
59: * ts.getSpecNodes().get(6)).getMaxTimeoutSeconds());
60: * Assert.assertEquals("java:org.mactor.extensions.xml.BasicValueExtractor",
61: * ((ValueSpec) ((MessageReceiveSpec) ts.getSpecNodes().get(6))
62: * .getSpecNodes().get(1)).getCommand());
63: * Assert.assertEquals("Header/MessageId", ((ValueSpec)
64: * ((MessageReceiveSpec)
65: * ts.getSpecNodes().get(6)).getSpecNodes().get(1)).getParams()
66: * .get(0)); // ActionSpec
67: * Assert.assertEquals("java:org.mactor.extensions.NodeMessageCountValidator",
68: * ((ActionSpec) ts.getSpecNodes().get(7)).getCommand());
69: */}
70:
71: @Test
72: public void loadMessageBrokerConfig() throws Exception {
73: // message_broker_config
74: MessageBrokerConfig config = MessageBrokersConfig
75: .readFromFile(
76: "config/mactor_sample_test_config/file-message-broker-config.xml")
77: .getMessageBrokers().get(0);
78: Assert.assertEquals(
79: "org.mactor.brokers.file.FileMessageBroker", config
80: .getBrokerClass());
81: Assert.assertEquals("/tmp/mactor/channels/IncomingAck", config
82: .getChannelConfig("IncomingAck").getValue("dir"));
83: Assert.assertEquals("MactorTestFileBroker", config.getName());
84: }
85:
86: @Test
87: public void loadGlobalConfig() throws Exception {
88: // message_broker_config
89: GlobalConfig config = GlobalConfig
90: .readFromFile("config/mactor_sample_test_config/global-config.xml");
91: Assert.assertEquals("123", config.getValue("myval1"));
92: Assert.assertEquals("abc", config.getValue("myval2"));
93: }
94: }
|