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.ws.policy;
19:
20: import java.util.Collections;
21:
22: import javax.xml.namespace.QName;
23:
24: import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertion;
25: import org.apache.cxf.ws.policy.builder.primitive.PrimitiveAssertionBuilder;
26: import org.apache.neethi.Policy;
27: import org.easymock.classextension.EasyMock;
28: import org.easymock.classextension.IMocksControl;
29: import org.junit.Assert;
30: import org.junit.Before;
31: import org.junit.Test;
32:
33: /**
34: *
35: */
36: public class IntersectorTest extends Assert {
37:
38: private static final QName NAME1 = new QName("http://x.y.z", "a");
39: private static final QName NAME2 = new QName("http://x.y.z", "a");
40:
41: private IMocksControl control = EasyMock.createNiceControl();
42: private Intersector intersector;
43: private AssertionBuilderRegistry reg;
44: private PrimitiveAssertionBuilder pab1;
45: private PrimitiveAssertionBuilder pab2;
46:
47: @Before
48: public void setUp() {
49: reg = control.createMock(AssertionBuilderRegistry.class);
50: intersector = new Intersector(reg);
51: pab1 = new PrimitiveAssertionBuilder();
52: pab1.setKnownElements(Collections.singleton(NAME1));
53: pab2 = new PrimitiveAssertionBuilder();
54: pab2.setKnownElements(Collections.singleton(NAME2));
55: }
56:
57: @Test
58: public void testCompatiblePoliciesBothEmpty() {
59: Policy p1 = new Policy();
60: Policy p2 = new Policy();
61: assertTrue(intersector.compatiblePolicies(p1, p2));
62: }
63:
64: @Test
65: public void testCompatiblePoliciesOneEmpty() {
66: Policy p1 = new Policy();
67: Policy p2 = new Policy();
68: p2.addPolicyComponent(new PrimitiveAssertion(NAME1));
69: assertTrue(intersector.compatiblePolicies(p1, p2));
70: }
71:
72: @Test
73: public void testIntersectPoliciesBothEmpty() {
74: Policy p1 = new Policy();
75: Policy p2 = new Policy();
76: Policy p = intersector.intersect(p1, p2);
77: assertNotNull(p);
78: // control.replay();
79: }
80:
81: }
|