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: */
19:
20: package org.apache.axis2.policy.model;
21:
22: import junit.framework.TestCase;
23: import org.apache.axiom.om.OMElement;
24: import org.apache.axiom.om.impl.builder.StAXOMBuilder;
25: import org.apache.neethi.Assertion;
26: import org.apache.neethi.Policy;
27: import org.apache.neethi.PolicyEngine;
28:
29: import java.util.Iterator;
30: import java.util.List;
31:
32: public class MTOMAssertionTest extends TestCase {
33:
34: public void testSymmBinding() {
35: try {
36: Policy p = this .getPolicy(System
37: .getProperty("basedir", ".")
38: + "/test-resources/policy-mtom-security.xml");
39: List assertions = (List) p.getAlternatives().next();
40:
41: boolean isMTOMAssertionFound = false;
42:
43: for (Iterator iter = assertions.iterator(); iter.hasNext();) {
44: Assertion assertion = (Assertion) iter.next();
45: if (assertion instanceof MTOMAssertion) {
46: isMTOMAssertionFound = true;
47: MTOMAssertion mtomModel = (MTOMAssertion) assertion;
48: assertEquals(
49: "MIME Serialization assertion not processed",
50: false, mtomModel.isOptional());
51: }
52:
53: }
54: //The Asymm binding mean is not built in the policy processing :-(
55: assertTrue("MTOM Assertion not found.",
56: isMTOMAssertionFound);
57:
58: } catch (Exception e) {
59: e.printStackTrace();
60: fail(e.getMessage());
61: }
62: }
63:
64: private Policy getPolicy(String filePath) throws Exception {
65: StAXOMBuilder builder = new StAXOMBuilder(filePath);
66: OMElement elem = builder.getDocumentElement();
67: return PolicyEngine.getPolicy(elem);
68: }
69: }
|