01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.components.xslt;
18:
19: import org.springframework.context.support.AbstractXmlApplicationContext;
20: import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
21: import org.apache.servicemix.tck.TestSupport;
22: import org.apache.servicemix.tck.MessageList;
23:
24: import javax.xml.namespace.QName;
25:
26: public class OptionalAxisQueriesTest extends TestSupport {
27:
28: public void testOptionalAxisQuery() throws Exception {
29: QName service = new QName("http://servicemix.org/cheese/",
30: "transformer");
31:
32: String message = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
33: + " <prod:resolveItemXrefResponse "
34: + " xmlns:prod=\"http://foo.org/prod\" "
35: + " xmlns:xsi=\"http://foo.org/msi\""
36: + " xmlns:ms=\"http://foo.org/ms\">"
37: + " <prod:response xsi:type=\"wn4:HashMap\">"
38: + " <ms:Keys>"
39: + " <ms:Item xsi:type=\"d:string\">DESCR</ms:Item>"
40: + " <ms:Item xsi:type=\"d:string\">LIST</ms:Item>"
41: + " <ms:Item xsi:type=\"d:string\">XREF</ms:Item>"
42: + " <ms:Item xsi:type=\"d:string\">MSTR</ms:Item>"
43: + " </ms:Keys>"
44: + " <ms:Values>"
45: + " <ms:Item xsi:type=\"d:string\">PPR,CPY,20#,84B,LGL,WE</ms:Item>"
46: + " <ms:Item xsi:type=\"d:double\">17.25</ms:Item>"
47: + " <ms:Item xsi:type=\"d:string\">EXP8514</ms:Item>"
48: + " <ms:Item xsi:type=\"d:string\">10040300</ms:Item>"
49: + " </ms:Values>" + " </prod:response>"
50: + " </prod:resolveItemXrefResponse>";
51:
52: // send a custom xml message
53: sendMessages(service, 1, message);
54: assertMessagesReceived(1);
55:
56: MessageList messageList1 = assertMessagesReceived("service1", 1);
57: MessageList messageList2 = assertMessagesReceived("service2", 1);
58: MessageList messageList3 = assertMessagesReceived("service3", 1);
59: MessageList messageList4 = assertMessagesReceived("service4", 1);
60: MessageList messageList5 = assertMessagesReceived("service5", 1);
61: MessageList messageList6 = assertMessagesReceived("service6", 1);
62:
63: assertMessageHeader(messageList1, 0, "foo",
64: "PPR,CPY,20#,84B,LGL,WE");
65: assertMessageHeader(messageList2, 0, "foo", "17.25");
66: assertMessageHeader(messageList3, 0, "foo", "EXP8514");
67: assertMessageHeader(messageList4, 0, "foo", "10040300");
68: assertMessageHeader(messageList5, 0, "foo", new Integer(4));
69: assertMessageHeader(messageList6, 0, "foo",
70: "PPR,CPY,20#,84B,LGL,WE");
71:
72: }
73:
74: protected AbstractXmlApplicationContext createBeanFactory() {
75: return new ClassPathXmlApplicationContext(
76: "org/apache/servicemix/components/xslt/optional-axis-example.xml");
77: }
78:
79: }
|