FileDocCategorySizeDatePackage
ClientTest.javaAPI DocExample2379Wed Jul 16 16:09:08 BST 2003com.develop.ss.axis

ClientTest.java

package com.develop.ss.axis;

import junit.framework.TestCase;

import javax.xml.rpc.ServiceException;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.IOException;
import java.rmi.RemoteException;

import com.develop.ss.test.ConfigBean;

public class ClientTest extends TestCase {

  private ConfigBean config;

  public ClientTest(String name) {
    super(name);
  }

  protected void setUp() throws Exception {
    super.setUp();
    config = new ConfigBean();
  }

  public void testEndpointExists() throws IOException {
    URL url = new URL(config.getWebServiceEndpoint());
    Object o = url.getContent();
  }
  public void testWSDLEndpointExists() throws IOException {
    URL url = new URL(config.getWebServiceWsdl());
    Object o = url.getContent();
  }

  private ResponseType[] doQuery(String queryString) throws RemoteException, MalformedURLException, ServiceException {
    return doQuery(queryString, 0.0f);
  }

  private ResponseType[] doQuery(String queryString, float threshold) throws RemoteException, MalformedURLException, ServiceException {
    SiteSearchServiceLocator locator = new SiteSearchServiceLocator();
    SiteSearch siteSearchSoap = locator.getSiteSearchSoap(new URL(config.getWebServiceEndpoint()));
    QueryType query = new QueryType();
    query.setSeachString(queryString);
    query.setThreshold(threshold);
    return siteSearchSoap.searchContents(query);
  }
  public void testEmptyResult() throws Exception {
    ResponseType[] resp = doQuery("nada");
    //bit surprised that this marshals to null instead of an empty array
    assertNull(resp);
  }
  public void testOneResult() throws Exception {
    ResponseType[] resp = doQuery("one");
    assertNotNull(resp);
    assertEquals(1, resp.length);
  }
  public void testThreshold() throws Exception {
    ResponseType[] resp = doQuery("one", 1.0f);
    assertNull("no result should have match threshold of 1.0", resp);
  }
  public void testMultipleResults() throws Exception {
    ResponseType[] resp = doQuery("spider");
    assertNotNull(resp);
    assertEquals("result is one because Axis marshalling broken, should be 3", 1, resp.length);
    //TODO: Axis marshalling appears broken, the pipe is returning three but Axis only gets the first
    //assertEquals(3, resp.length);
  }
}