001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.wsrp;
023:
024: import javax.naming.InitialContext;
025: import javax.naming.NamingException;
026: import javax.xml.rpc.Service;
027:
028: import junit.framework.Test;
029:
030: import org.jboss.test.webservice.WebserviceTestBase;
031: import org.jboss.test.wsrp.core.Extension;
032: import org.jboss.test.wsrp.core.ModifyRegistration;
033: import org.jboss.test.wsrp.core.Property;
034: import org.jboss.test.wsrp.core.RegistrationContext;
035: import org.jboss.test.wsrp.core.RegistrationData;
036: import org.jboss.test.wsrp.core.RegistrationState;
037: import org.jboss.test.wsrp.core.ReturnAny;
038:
039: //$Id: RegistrationTestCase.java 57211 2006-09-26 12:39:46Z dimitris@jboss.org $
040:
041: /**
042: * Testcase for the WSRP Registration service
043: * @author <a href="mailto:Anil.Saldhana@jboss.org">Anil Saldhana</a>
044: * @since Mar 27, 2006
045: * @version $Revision: 57211 $
046: */
047: public class RegistrationTestCase extends WebserviceTestBase {
048: public RegistrationTestCase(String name) {
049: super (name);
050: }
051:
052: /**
053: * deploy the test archives
054: */
055: public static Test suite() throws Exception {
056: return getDeploySetup(RegistrationTestCase.class,
057: "wsrp.war, wsrp-client.jar");
058: }
059:
060: public void testRegister() throws Exception {
061: Service service = getService();
062: WSRP_v1_Registration_PortType endpoint = (WSRP_v1_Registration_PortType) service
063: .getPort(WSRP_v1_Registration_PortType.class);
064: RegistrationData cp = new RegistrationData("consumerName",
065: "consumerAgent", true, new String[] {},
066: new String[] {}, new String[] {}, new String[] {},
067: new Property[] {}, new Extension[] {});
068: //Invoke the Web Service
069: RegistrationContext ra = endpoint.register(cp);
070: assertNotNull("RegistrationContext != null", ra);
071: }
072:
073: public void testDeRegister() throws Exception {
074: Service service = getService();
075: WSRP_v1_Registration_PortType endpoint = (WSRP_v1_Registration_PortType) service
076: .getPort(WSRP_v1_Registration_PortType.class);
077: RegistrationContext cp = new RegistrationContext();
078: //Invoke the Web Service
079: ReturnAny ra = endpoint.deregister(cp);
080: assertNotNull("ReturnAny != null", ra);
081: }
082:
083: public void testModifyRegistration() throws Exception {
084: Service service = getService();
085: WSRP_v1_Registration_PortType endpoint = (WSRP_v1_Registration_PortType) service
086: .getPort(WSRP_v1_Registration_PortType.class);
087: ModifyRegistration cp = new ModifyRegistration();
088: //Invoke the Web Service
089: RegistrationState ra = endpoint.modifyRegistration(cp);
090: assertNotNull("RegistrationState != null", ra);
091: }
092:
093: private Service getService() throws NamingException {
094: InitialContext iniCtx = getClientContext("wsrp-client");
095: Service service = (Service) iniCtx
096: .lookup("java:comp/env/service/RegistrationService");
097: assertNotNull("Service != null", service);
098: return service;
099: }
100: }
|