    1   package org.seasar.remoting.axis.deployer;
    2
    3   import javax.xml.namespace.QName;
    4
    5   import org.apache.axis.providers.java.JavaProvider;
    6   import org.seasar.extension.unit.S2TestCase;
    7   import org.seasar.framework.container.ComponentDef;
    8   import org.seasar.framework.container.MetaDef;
    9   import org.seasar.remoting.axis.DeployFailedException;
    10  import org.seasar.remoting.axis.deployment.WSDDS2Service;
    11  import org.w3c.dom.Element;
    12
    13  /***
    14   * @author koichik
    15   */
    16  public class ServiceDeployerTest extends S2TestCase {
    17
    18      public ServiceDeployerTest(String name) {
    19          super(name);
    20      }
    21
    22      public void testCreateWSDDS2Service() {
    23          include("ServiceDeployerTest.createWSDDS2Service.dicon");
    24          Deployer deployer = new Deployer();
    25          ServiceDeployer serviceDeployer = (ServiceDeployer) deployer.serviceDeployer;
    26
    27          ComponentDef def1 = getComponentDef("null");
    28          MetaDef meta1 = def1.getMetaDef("s2-axis:service");
    29          WSDDS2Service service1 = serviceDeployer.createWSDDS2Service(def1, meta1);
    30          assertNotNull(service1);
    31          assertEquals(new QName("null"), service1.getQName());
    32
    33          ComponentDef def2 = getComponentDef("serviceDef");
    34          MetaDef meta2 = def2.getMetaDef("s2-axis:service");
    35          WSDDS2Service service2 = serviceDeployer.createWSDDS2Service(def2, meta2);
    36          assertNotNull(service2);
    37          assertEquals(new QName("serviceDef"), service2.getQName());
    38          assertEquals("java.lang.Boolean", service2.getParameter(JavaProvider.OPTION_CLASSNAME));
    39
    40          ComponentDef def3 = getComponentDef("wsdd");
    41          MetaDef meta3 = def3.getMetaDef("s2-axis:service");
    42          WSDDS2Service service3 = serviceDeployer.createWSDDS2Service(def3, meta3);
    43          assertNotNull(service3);
    44          assertEquals(new QName("FromWSDD"), service3.getQName());
    45          assertEquals("java.lang.Double", service3.getParameter(JavaProvider.OPTION_CLASSNAME));
    46
    47          try {
    48              ComponentDef def4 = getComponentDef("int");
    49              MetaDef meta4 = def4.getMetaDef("s2-axis:service");
    50              serviceDeployer.createWSDDS2Service(def4, meta4);
    51              fail();
    52          }
    53          catch (DeployFailedException expected) {
    54          }
    55      }
    56
    57      public void testGetServiceElement() {
    58          Deployer deployer = new Deployer();
    59          ServiceDeployer serviceDeployer = (ServiceDeployer) deployer.serviceDeployer;
    60
    61          Element e1 = serviceDeployer
    62                  .getServiceElement("org/seasar/remoting/axis/deployer/ServiceDeployerTest.getServiceElement1.wsdd");
    63          assertNotNull(e1);
    64          assertEquals("service", e1.getNodeName());
    65          assertEquals("one", e1.getAttribute("name"));
    66
    67          try {
    68              serviceDeployer
    69                      .getServiceElement("org/seasar/remoting/axis/deployer/ServiceDeployerTest.getServiceElement0.wsdd");
    70              fail();
    71          }
    72          catch (DeployFailedException expected) {
    73          }
    74
    75          try {
    76              serviceDeployer
    77                      .getServiceElement("org/seasar/remoting/axis/deployer/ServiceDeployerTest.getServiceElement2.wsdd");
    78              fail();
    79          }
    80          catch (DeployFailedException expected) {
    81          }
    82      }
    83  }