01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.apache.cxf.transport.http_jetty.spring;
19:
20: import org.w3c.dom.Document;
21:
22: import org.apache.cxf.helpers.DOMUtils;
23: import org.apache.cxf.transport.http.spring.HttpConduitBeanDefinitionParser;
24: import org.apache.cxf.transport.http.spring.HttpDestinationBeanDefinitionParser;
25: import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
26: import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
27: import org.junit.Assert;
28: import org.junit.Test;
29: import org.springframework.beans.PropertyValue;
30: import org.springframework.beans.factory.support.BeanDefinitionBuilder;
31:
32: public class BeanDefinitionParsersTest extends Assert {
33: @Test
34: public void testDest() throws Exception {
35: BeanDefinitionBuilder bd = BeanDefinitionBuilder
36: .childBeanDefinition("child");
37:
38: HttpDestinationBeanDefinitionParser parser = new HttpDestinationBeanDefinitionParser();
39:
40: Document d = DOMUtils.readXml(getClass().getResourceAsStream(
41: "destination.xml"));
42: parser.doParse(d.getDocumentElement(), null, bd);
43:
44: PropertyValue[] pvs = bd.getRawBeanDefinition()
45: .getPropertyValues().getPropertyValues();
46: assertEquals(2, pvs.length);
47: assertEquals("foobar", ((HTTPServerPolicy) pvs[0].getValue())
48: .getContentEncoding());
49: assertEquals("exact", pvs[1].getValue());
50: }
51:
52: @Test
53: public void testConduit() throws Exception {
54: BeanDefinitionBuilder bd = BeanDefinitionBuilder
55: .childBeanDefinition("child");
56:
57: HttpConduitBeanDefinitionParser parser = new HttpConduitBeanDefinitionParser();
58:
59: Document d = DOMUtils.readXml(getClass().getResourceAsStream(
60: "conduit.xml"));
61: parser.doParse(d.getDocumentElement(), null, bd);
62:
63: PropertyValue[] pvs = bd.getRawBeanDefinition()
64: .getPropertyValues().getPropertyValues();
65: assertEquals(1, pvs.length);
66: assertEquals(97, ((HTTPClientPolicy) pvs[0].getValue())
67: .getConnectionTimeout(), 0);
68: }
69:
70: }
|