KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > servicemix > components > xslt > OptionalAxisQueriesTest


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * 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 JavaDoc;
25
26
27 public class OptionalAxisQueriesTest extends TestSupport {
28
29     public void testOptionalAxisQuery() throws Exception JavaDoc {
30         QName JavaDoc service = new QName JavaDoc("http://servicemix.org/cheese/", "transformer");
31
32        String JavaDoc 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>" +
50                " </prod:response>" +
51                " </prod:resolveItemXrefResponse>";
52
53         // send a custom xml message
54
sendMessages(service, 1, message);
55         assertMessagesReceived(1);
56
57         MessageList messageList1 = assertMessagesReceived("service1", 1);
58         MessageList messageList2 = assertMessagesReceived("service2", 1);
59         MessageList messageList3 = assertMessagesReceived("service3", 1);
60         MessageList messageList4 = assertMessagesReceived("service4", 1);
61         MessageList messageList5 = assertMessagesReceived("service5", 1);
62         MessageList messageList6 = assertMessagesReceived("service6", 1);
63
64         assertMessageHeader(messageList1, 0, "foo", "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 JavaDoc(4));
69         assertMessageHeader(messageList6, 0, "foo", "PPR,CPY,20#,84B,LGL,WE");
70
71     }
72
73     protected AbstractXmlApplicationContext createBeanFactory() {
74         return new ClassPathXmlApplicationContext("org/apache/servicemix/components/xslt/optional-axis-example.xml");
75     }
76
77 }
78
Popular Tags