001: /**
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */package org.apache.cxf.service.model;
019:
020: import javax.xml.namespace.QName;
021:
022: import org.junit.Assert;
023: import org.junit.Before;
024: import org.junit.Test;
025:
026: public class BindingOperationInfoTest extends Assert {
027: private static final String TEST_NS = "urn:test:ns";
028: private BindingOperationInfo bindingOperationInfo;
029:
030: @Before
031: public void setUp() throws Exception {
032: OperationInfo operationInfo = new OperationInfo(null,
033: new QName(TEST_NS, "operationTest"));
034: MessageInfo inputMessage = operationInfo
035: .createMessage(new QName(
036: "http://apache.org/hello_world_soap_http",
037: "testInputMessage"));
038: operationInfo.setInput("input", inputMessage);
039:
040: MessageInfo outputMessage = operationInfo
041: .createMessage(new QName(
042: "http://apache.org/hello_world_soap_http",
043: "testOutputMessage"));
044: operationInfo.setOutput("output", outputMessage);
045: operationInfo.addFault(new QName(TEST_NS, "fault"), new QName(
046: "http://apache.org/hello_world_soap_http",
047: "faultMessage"));
048: bindingOperationInfo = new BindingOperationInfo(null,
049: operationInfo);
050: }
051:
052: @Test
053: public void testName() throws Exception {
054: assertEquals(bindingOperationInfo.getName(), new QName(TEST_NS,
055: "operationTest"));
056: }
057:
058: @Test
059: public void testBinding() throws Exception {
060: assertNull(bindingOperationInfo.getBinding());
061: }
062:
063: @Test
064: public void testOperation() throws Exception {
065: assertEquals(bindingOperationInfo.getOperationInfo().getName(),
066: new QName(TEST_NS, "operationTest"));
067: assertTrue(bindingOperationInfo.getOperationInfo().hasInput());
068: assertTrue(bindingOperationInfo.getOperationInfo().hasOutput());
069: assertEquals(bindingOperationInfo.getOperationInfo()
070: .getInputName(), "input");
071: assertEquals(bindingOperationInfo.getOperationInfo()
072: .getOutputName(), "output");
073: assertEquals(bindingOperationInfo.getFaults().iterator().next()
074: .getFaultInfo().getFaultName(), new QName(TEST_NS,
075: "fault"));
076: assertEquals(1, bindingOperationInfo.getFaults().size());
077: }
078:
079: @Test
080: public void testInputMessage() throws Exception {
081: BindingMessageInfo inputMessage = bindingOperationInfo
082: .getInput();
083: assertNotNull(inputMessage);
084: assertEquals(inputMessage.getMessageInfo().getName()
085: .getLocalPart(), "testInputMessage");
086: assertEquals(inputMessage.getMessageInfo().getName()
087: .getNamespaceURI(),
088: "http://apache.org/hello_world_soap_http");
089: }
090:
091: @Test
092: public void testOutputMessage() throws Exception {
093: BindingMessageInfo outputMessage = bindingOperationInfo
094: .getOutput();
095: assertNotNull(outputMessage);
096: assertEquals(outputMessage.getMessageInfo().getName()
097: .getLocalPart(), "testOutputMessage");
098: assertEquals(outputMessage.getMessageInfo().getName()
099: .getNamespaceURI(),
100: "http://apache.org/hello_world_soap_http");
101: }
102:
103: @Test
104: public void testFaultMessage() throws Exception {
105: BindingFaultInfo faultMessage = bindingOperationInfo
106: .getFaults().iterator().next();
107: assertNotNull(faultMessage);
108: assertEquals(faultMessage.getFaultInfo().getName()
109: .getLocalPart(), "faultMessage");
110: assertEquals(faultMessage.getFaultInfo().getName()
111: .getNamespaceURI(),
112: "http://apache.org/hello_world_soap_http");
113: }
114: }
|