001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common Development
008: * and Distribution License("CDDL") (collectively, the "License"). You
009: * may not use this file except in compliance with the License. You can obtain
010: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
011: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
012: * language governing permissions and limitations under the License.
013: *
014: * When distributing the software, include this License Header Notice in each
015: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
016: * Sun designates this particular file as subject to the "Classpath" exception
017: * as provided by Sun in the GPL Version 2 section of the License file that
018: * accompanied this code. If applicable, add the following below the License
019: * Header, with the fields enclosed by brackets [] replaced by your own
020: * identifying information: "Portions Copyrighted [year]
021: * [name of copyright owner]"
022: *
023: * Contributor(s):
024: *
025: * If you wish your version of this file to be governed by only the CDDL or
026: * only the GPL Version 2, indicate your decision by adding "[Contributor]
027: * elects to include this software in this distribution under the [CDDL or GPL
028: * Version 2] license." If you don't indicate a single choice of license, a
029: * recipient has the option to distribute your version of this file under
030: * either the CDDL, the GPL Version 2 or to extend the choice of license to
031: * its licensees as provided above. However, if you add GPL Version 2 code
032: * and therefore, elected the GPL Version 2 license, then the option applies
033: * only if the new code is made subject to such option by the copyright
034: * holder.
035: */
036:
037: package com.sun.xml.ws.policy;
038:
039: import java.util.Collection;
040: import java.util.LinkedList;
041: import junit.framework.TestCase;
042:
043: import com.sun.xml.ws.policy.testutils.PolicyResourceLoader;
044:
045: /**
046: *
047: * @author Marek Potociar
048: */
049: public class PolicyMergerTest extends TestCase {
050: private PolicyMerger merger = PolicyMerger.getMerger();
051:
052: public PolicyMergerTest(String testName) {
053: super (testName);
054: }
055:
056: protected void setUp() throws Exception {
057: }
058:
059: protected void tearDown() throws Exception {
060: }
061:
062: public void testMergeTwoPolicies() throws Exception {
063: Collection<Policy> policies = new LinkedList<Policy>();
064: policies.add(PolicyResourceLoader
065: .loadPolicy("merge/policy1.xml"));
066: policies.add(PolicyResourceLoader
067: .loadPolicy("merge/policy2.xml"));
068: policies.add(PolicyResourceLoader
069: .loadPolicy("merge/policy3.xml"));
070:
071: Policy result = merger.merge(policies);
072: Policy expected = PolicyResourceLoader
073: .loadPolicy("merge/merge_1-2-3.xml");
074:
075: assertEquals(expected, result);
076: }
077:
078: public void testMergeEmtpyNonEmptyPolicies() throws Exception {
079: Collection<Policy> policies = new LinkedList<Policy>();
080: policies.add(PolicyResourceLoader
081: .loadPolicy("merge/policy1.xml"));
082: policies.add(PolicyResourceLoader
083: .loadPolicy("merge/policy-empty-alt.xml"));
084:
085: Policy result = merger.merge(policies);
086: Policy expected = PolicyResourceLoader
087: .loadPolicy("merge/policy1.xml");
088:
089: assertEquals(expected, result);
090: }
091:
092: public void testMergeNoAltPolicies() throws Exception {
093: Collection<Policy> policies = new LinkedList<Policy>();
094: policies.add(PolicyResourceLoader
095: .loadPolicy("merge/policy1.xml"));
096: policies.add(PolicyResourceLoader
097: .loadPolicy("merge/policy-no-alt.xml"));
098:
099: Policy result = merger.merge(policies);
100: Policy expected = PolicyResourceLoader
101: .loadPolicy("merge/policy-no-alt.xml");
102:
103: assertEquals(expected, result);
104: }
105:
106: }
|