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.aegis.type.java5;
019:
020: import java.util.Collection;
021: import java.util.List;
022: import java.util.Map;
023: import javax.jws.Oneway;
024: import javax.jws.WebMethod;
025: import javax.jws.WebParam;
026: import javax.jws.WebResult;
027: import javax.jws.WebService;
028: import javax.xml.xpath.XPathConstants;
029:
030: import org.w3c.dom.Document;
031:
032: import org.apache.cxf.aegis.AbstractAegisTest;
033: import org.apache.cxf.aegis.databinding.AegisDatabinding;
034: import org.apache.cxf.aegis.util.XmlConstants;
035: import org.apache.cxf.helpers.XPathUtils;
036: import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
037: import org.junit.Before;
038: import org.junit.Test;
039:
040: public class OperationNSTest extends AbstractAegisTest {
041:
042: @Before
043: public void setUp() throws Exception {
044: super .setUp();
045:
046: JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean();
047: sf.setServiceClass(NotificationLogImpl.class);
048: sf.setAddress("local://NotificationLogImpl");
049: sf.getServiceFactory().setDataBinding(new AegisDatabinding());
050:
051: sf.create();
052: }
053:
054: @Test
055: public void testWSDL() throws Exception {
056: Collection<Document> wsdls = getWSDLDocuments("NotificationService");
057:
058: addNamespace("xsd", XmlConstants.XSD);
059: //assertValid("//xsd:element[@name='Notify']", wsdl);
060: assertTrue(isExist(wsdls, "//xsd:element[@name='Notify']",
061: getNamespaces()));
062: }
063:
064: private boolean isExist(Collection<Document> docs, String xpath,
065: Map<String, String> ns) {
066: XPathUtils xpather = new XPathUtils(ns);
067: for (Document doc : docs) {
068: if (xpather.isExist(xpath, doc, XPathConstants.NODE)) {
069: return true;
070: }
071: }
072: return false;
073: }
074:
075: @WebService(name="NotificationLog",targetNamespace="http://www.sics.se/NotificationLog")
076: public static interface NotificationLog {
077:
078: @WebMethod(operationName="Notify",action="")
079: @Oneway
080: void notify(
081: @WebParam(name="Notify",targetNamespace="http://docs.oasis-open.org/wsn/b-2")
082: Document notify);
083:
084: @WebMethod(operationName="query",action="")
085: @WebResult(name="queryResponse",targetNamespace="http://www.sics.se/NotificationLog")
086: List<Document> query(
087: @WebParam(name="xpath",targetNamespace="http://www.sics.se/NotificationLog")
088: String xpath);
089:
090: @WebMethod(operationName="Notify2",action="")
091: @Oneway
092: void notify2(
093: @WebParam(name="Notify",targetNamespace="http://docs.oasis-open.org/wsn/2004/" + "06/wsn-WS-BaseNotification-1.2-draft-01.xsd")
094: Document notify);
095: }
096:
097: @WebService(endpointInterface="org.apache.cxf.aegis.type.java5.OperationNSTest$NotificationLog",serviceName="NotificationService")
098: public static class NotificationLogImpl implements NotificationLog {
099:
100: public void notify(Document notify) {
101: }
102:
103: public void notify2(Document notify) {
104: }
105:
106: public List<Document> query(String xpath) {
107: return null;
108: }
109: }
110: }
|