    1   /*
    2    *
    3    * The Seasar Software License, Version 1.1
    4    *
    5    * Copyright (c) 2003-2004 The Seasar Project. All rights reserved.
    6    *
    7    * Redistribution and use in source and binary forms, with or
    8    * without modification, are permitted provided that the following
    9    * conditions are met:
    10   *
    11   * 1. Redistributions of source code must retain the above
    12   *    copyright notice, this list of conditions and the following
    13   *    disclaimer.
    14   *
    15   * 2. Redistributions in binary form must reproduce the above
    16   *    copyright notice, this list of conditions and the following
    17   *    disclaimer in the documentation and/or other materials provided
    18   *    with the distribution.
    19   *
    20   * 3. The end-user documentation included with the redistribution,
    21   *    if any, must include the following acknowledgement:
    22   *    "This product includes software developed by the
    23   *    Seasar Project (http://www.seasar.org/)."
    24   *    Alternately, this acknowledgement may appear in the software
    25   *    itself, if and wherever such third-party acknowledgements
    26   *    normally appear.
    27   *
    28   * 4. Neither the name "The Seasar Project" nor the names of its
    29   *    contributors may be used to endorse or promote products derived
    30   *    from this software without specific prior written permission of
    31   *    the Seasar Project.
    32   *
    33   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR
    34   * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
    35   * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
    36   * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE SEASAR PROJECT
    37   * OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
    38   * INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
    39   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    40   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    41   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
    42   * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING
    43   * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
    44   * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    45   */
    46  package org.seasar.remoting.axis.deployer;
    47
    48  import javax.xml.namespace.QName;
    49
    50  import org.apache.axis.providers.java.JavaProvider;
    51  import org.seasar.extension.unit.S2TestCase;
    52  import org.seasar.framework.container.ComponentDef;
    53  import org.seasar.framework.container.MetaDef;
    54  import org.seasar.remoting.axis.DeployFailedException;
    55  import org.seasar.remoting.axis.deployment.WSDDS2Service;
    56  import org.w3c.dom.Element;
    57
    58  /***
    59   * @author koichik
    60   */
    61  public class ServiceDeployerTest extends S2TestCase {
    62      public ServiceDeployerTest(String name) {
    63          super(name);
    64      }
    65
    66      public void testCreateWSDDS2Service() {
    67          include("ServiceDeployerTest.createWSDDS2Service.dicon");
    68          AxisDeployer deployer = new AxisDeployer();
    69          ServiceDeployer serviceDeployer = (ServiceDeployer) deployer.serviceDeployer;
    70
    71          ComponentDef def1 = getComponentDef("null");
    72          MetaDef meta1 = def1.getMetaDef("s2-axis:service");
    73          WSDDS2Service service1 = serviceDeployer.createWSDDS2Service(def1, meta1);
    74          assertNotNull(service1);
    75          assertEquals(new QName("null"), service1.getQName());
    76
    77          ComponentDef def2 = getComponentDef("serviceDef");
    78          MetaDef meta2 = def2.getMetaDef("s2-axis:service");
    79          WSDDS2Service service2 = serviceDeployer.createWSDDS2Service(def2, meta2);
    80          assertNotNull(service2);
    81          assertEquals(new QName("serviceDef"), service2.getQName());
    82          assertEquals("java.lang.Boolean", service2.getParameter(JavaProvider.OPTION_CLASSNAME));
    83
    84          ComponentDef def3 = getComponentDef("wsdd");
    85          MetaDef meta3 = def3.getMetaDef("s2-axis:service");
    86          WSDDS2Service service3 = serviceDeployer.createWSDDS2Service(def3, meta3);
    87          assertNotNull(service3);
    88          assertEquals(new QName("FromWSDD"), service3.getQName());
    89          assertEquals("java.lang.Double", service3.getParameter(JavaProvider.OPTION_CLASSNAME));
    90
    91          try {
    92              ComponentDef def4 = getComponentDef("int");
    93              MetaDef meta4 = def4.getMetaDef("s2-axis:service");
    94              serviceDeployer.createWSDDS2Service(def4, meta4);
    95              fail();
    96          }
    97          catch (DeployFailedException expected) {
    98          }
    99      }
    100
    101     public void testGetServiceElement() {
    102         AxisDeployer deployer = new AxisDeployer();
    103         ServiceDeployer serviceDeployer = (ServiceDeployer) deployer.serviceDeployer;
    104
    105         Element e1 = serviceDeployer
    106                 .getServiceElement("org/seasar/remoting/axis/deployer/ServiceDeployerTest.getServiceElement1.wsdd");
    107         assertNotNull(e1);
    108         assertEquals("service", e1.getNodeName());
    109         assertEquals("one", e1.getAttribute("name"));
    110
    111         try {
    112             serviceDeployer
    113                     .getServiceElement("org/seasar/remoting/axis/deployer/ServiceDeployerTest.getServiceElement0.wsdd");
    114             fail();
    115         }
    116         catch (DeployFailedException expected) {
    117         }
    118
    119         try {
    120             serviceDeployer
    121                     .getServiceElement("org/seasar/remoting/axis/deployer/ServiceDeployerTest.getServiceElement2.wsdd");
    122             fail();
    123         }
    124         catch (DeployFailedException expected) {
    125         }
    126     }
    127 }