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.policy;
19:
20: import org.apache.cxf.transports.http.configuration.HTTPServerPolicy;
21: import org.apache.cxf.ws.policy.builder.jaxb.JaxbAssertion;
22: import org.apache.neethi.Assertion;
23: import org.junit.Assert;
24: import org.junit.Test;
25:
26: /**
27: *
28: */
29: public class HTTPServerAssertionBuilderTest extends Assert {
30:
31: @Test
32: public void testBuildCompatible() throws Exception {
33: HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
34: JaxbAssertion<HTTPServerPolicy> a = ab.buildAssertion();
35: HTTPServerPolicy pa = new HTTPServerPolicy();
36: a.setData(pa);
37: JaxbAssertion<HTTPServerPolicy> b = ab.buildAssertion();
38: HTTPServerPolicy pb = new HTTPServerPolicy();
39: b.setData(pb);
40: JaxbAssertion<HTTPServerPolicy> c = JaxbAssertion.cast(ab
41: .buildCompatible(a, b), HTTPServerPolicy.class);
42: assertNotNull(c);
43: }
44:
45: @Test
46: public void testBuildAssertion() throws Exception {
47: HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
48: Assertion a = ab.buildAssertion();
49: assertTrue(a instanceof JaxbAssertion);
50: assertTrue(a instanceof HTTPServerAssertionBuilder.HTTPServerPolicyAssertion);
51: assertEquals(PolicyUtils.HTTPSERVERPOLICY_ASSERTION_QNAME, a
52: .getName());
53: assertTrue(!a.isOptional());
54: }
55:
56: @Test
57: public void testHTTPServerPolicyAssertionEqual() throws Exception {
58: HTTPServerAssertionBuilder ab = new HTTPServerAssertionBuilder();
59: JaxbAssertion<HTTPServerPolicy> a = ab.buildAssertion();
60: a.setData(new HTTPServerPolicy());
61: assertTrue(a.equal(a));
62: JaxbAssertion<HTTPServerPolicy> b = ab.buildAssertion();
63: b.setData(new HTTPServerPolicy());
64: assertTrue(a.equal(b));
65: HTTPServerPolicy pa = new HTTPServerPolicy();
66: a.setData(pa);
67: assertTrue(a.equal(a));
68: HTTPServerPolicy pb = new HTTPServerPolicy();
69: b.setData(pb);
70: assertTrue(a.equal(b));
71: pa.setSuppressClientSendErrors(true);
72: assertTrue(!a.equal(b));
73: }
74:
75: }
|