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: */
019: package org.apache.axis2.jaxws.client;
020:
021: import java.util.Map;
022:
023: import javax.xml.namespace.QName;
024: import javax.xml.ws.BindingProvider;
025: import javax.xml.ws.Dispatch;
026: import javax.xml.ws.Service;
027: import javax.xml.ws.Service.Mode;
028: import javax.xml.ws.WebServiceException;
029:
030: import junit.framework.TestCase;
031: import org.apache.axis2.jaxws.TestLogger;
032:
033: /**
034: * A suite to test the validation of the client request/response context properties
035: */
036: public class PropertyValueTests extends TestCase {
037:
038: public PropertyValueTests(String name) {
039: super (name);
040: }
041:
042: public void testSetInvalidClientProperties() throws Exception {
043: Service svc = Service.create(new QName("http://test",
044: "TestService"));
045: QName portQName = new QName("http://test", "TestPort");
046: svc.addPort(portQName, null, null);
047: Dispatch dispatch = svc.createDispatch(portQName, String.class,
048: Mode.PAYLOAD);
049:
050: Map<String, Object> map = dispatch.getRequestContext();
051:
052: try {
053: map.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
054: new Integer(4));
055: fail();
056: } catch (WebServiceException wse) {
057: TestLogger.logger
058: .debug("[pass] - exception thrown as expected");
059: }
060:
061: try {
062: map.put(BindingProvider.USERNAME_PROPERTY, new Integer(4));
063: fail();
064: } catch (WebServiceException wse) {
065: TestLogger.logger
066: .debug("[pass] - exception thrown as expected");
067: }
068:
069: try {
070: map.put(BindingProvider.PASSWORD_PROPERTY, new Integer(4));
071: fail();
072: } catch (WebServiceException wse) {
073: TestLogger.logger
074: .debug("[pass] - exception thrown as expected");
075: }
076:
077: try {
078: map.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, "true");
079: fail();
080: } catch (WebServiceException wse) {
081: TestLogger.logger
082: .debug("[pass] - exception thrown as expected");
083: }
084:
085: try {
086: map.put(BindingProvider.SOAPACTION_USE_PROPERTY, "true");
087: fail();
088: } catch (WebServiceException wse) {
089: TestLogger.logger
090: .debug("[pass] - exception thrown as expected");
091: }
092:
093: try {
094: map.put(BindingProvider.SOAPACTION_URI_PROPERTY,
095: new Integer(4));
096: fail();
097: } catch (WebServiceException wse) {
098: TestLogger.logger
099: .debug("[pass] - exception thrown as expected");
100: }
101: }
102:
103: }
|