You are viewing a plain text version of this content. The canonical link for it is here.
Posted to muse-dev@ws.apache.org by wi...@apache.org on 2005/08/12 22:45:46 UTC

svn commit: r232376 [105/112] - in /webservices/muse/trunk/src/examples/client: ./ bin/ bin/axis/ bin/axis/com/ bin/axis/com/xyz/ bin/org/ bin/org/apache/ bin/org/apache/ws/ bin/org/apache/ws/client/ bin/org/apache/ws/client/async/ bin/org/apache/ws/cl...

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/DynamicSchemaClassBuilderTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/DynamicSchemaClassBuilderTestCase.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/DynamicSchemaClassBuilderTestCase.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/DynamicSchemaClassBuilderTestCase.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,230 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*/
+package org.apache.ws.client;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.util.Iterator;
+
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+import javax.xml.soap.MessageFactory;
+import javax.xml.soap.SOAPElement;
+import javax.xml.soap.SOAPException;
+import javax.xml.soap.SOAPMessage;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.xmlbeans.XmlObject;
+
+import org.apache.commons.io.IoUtils;
+
+/**
+ * Test case for the DynamicSchemaClassBuilder.
+ *
+ * @author wire
+ *
+ */
+public class DynamicSchemaClassBuilderTestCase extends TestCase {
+	File m_tempDir;
+	URL m_wsdl_url;
+
+	/*
+	 * @see TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+
+		// Write out a test wsdl
+		String hashAsString=this.getClass().getName()+"@"+this.hashCode();
+		m_tempDir=new File(System.getProperty("java.io.tmpdir")+"/"+hashAsString);
+		m_tempDir.mkdir();
+		Assert.assertTrue(m_tempDir.exists());
+		File tempFile= new File("./src/wsdl/muse/registry.wsdl");
+		m_wsdl_url=tempFile.getAbsoluteFile().toURL();
+		m_builder = new DynamicSchemaClassBuilder("src\\wsdl\\muse",m_wsdl_url);
+		m_builder.compile();
+	}
+
+
+	/*
+	 * @see TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		DynamicSchemaClassBuilder.dispose();
+		IoUtils.deleteDir(m_tempDir);
+	}
+
+
+	/**
+	 * Objective: Excersize schema compiler to create empty instances of classes from the smaple schema.
+	 * @throws WSDLException
+	 * @throws IOException
+	 * @throws SecurityException
+	 * @throws IllegalArgumentException
+	 * @throws ClassNotFoundException
+	 * @throws NoSuchMethodException
+	 * @throws IllegalAccessException
+	 * @throws InvocationTargetException
+	 */
+
+	public void testCreateInstance() throws WSDLException, IOException, SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException{
+		XmlObject xmlBean=m_builder.getEmptyInstanceOfXMLBean(new QName("http://schemas.xmlsoap.org/ws/2004/03/addressing","EndpointReference"));
+		Assert.assertNotNull(xmlBean);
+		String className=xmlBean.getClass().getName();
+		Assert.assertEquals(xmlBean.getClass().getName() , "org.xmlsoap.schemas.ws.x2004.x03.addressing.impl.EndpointReferenceDocumentImpl");
+
+		XmlObject xmlBean1=m_builder.getEmptyInstanceOfXMLBean(new QName("http://registry.generated.ws.apache.org","FindResourceRequest"));
+		Assert.assertNotNull(xmlBean1);
+		String className1=xmlBean1.getClass().getName();
+		Assert.assertEquals(xmlBean1.getClass().getName(),"org.apache.ws.generated.registry.impl.FindResourceRequestDocumentImpl");
+	}
+
+
+	public void testCreateInstanceFromXML() throws WSDLException, IOException, SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, SOAPException{
+
+		// Build a SOAP message
+		InputStream in=new ByteArrayInputStream(m_test_envelope.getBytes());
+		SOAPMessage soapResponseMsg = MessageFactory.newInstance().createMessage(null,in);
+		Iterator propElemsIter = soapResponseMsg.getSOAPPart().getEnvelope().getBody().getChildElements();
+		Assert.assertTrue(propElemsIter.hasNext());
+
+		// Iterate into it to find FindResponse element, an array of EndpointReferences
+		SOAPElement e=(SOAPElement)propElemsIter.next();
+		Iterator children = e.getChildElements();
+		Assert.assertTrue(children.hasNext());
+		SOAPElement elementFindResponse=(SOAPElement)children.next();
+
+		// Get a document bean
+		QName findResponseQName=new QName(e.getNamespaceURI(),e.getLocalName());
+		XmlObject xmlBean=m_builder.getInstanceOfXMLBean(findResponseQName,e);
+		Assert.assertNotNull(xmlBean);
+		String className=xmlBean.getClass().getName();
+		Assert.assertEquals("org.apache.ws.generated.registry.impl.FindResponseDocumentImpl",className);
+
+		// Extract an xmlBean
+		Method getFindResponseMethod=xmlBean.getClass().getMethod("getFindResponse",null);
+		Assert.assertNotNull(getFindResponseMethod);
+		XmlObject findResponse=(XmlObject)getFindResponseMethod.invoke(xmlBean,null);
+		Method getItemArrayMethod=findResponse.getClass().getMethod("getItemArray",null);
+		Object[] array=(Object[])getItemArrayMethod.invoke(findResponse,null);
+
+		// See if the returned array has for parts
+		Assert.assertEquals(4,array.length);
+		XmlObject endpointReferenceType=(XmlObject)array[0];
+		Method[] methods=endpointReferenceType.getClass().getMethods();
+
+		// Use introspection to tests some values
+//		XmlObject portType=(XmlObject)DynamicSchemaClassBuilder.getProperty(endpointReferenceType,"PortType");
+//		String localPart=(String)DynamicSchemaClassBuilder.getProperty(portType,"StringValue");//
+//		Assert.assertEquals("ns5:DiskPortType",localPart);
+
+		// Get ResourceID
+//		XmlObject refProps=(XmlObject)DynamicSchemaClassBuilder.getProperty(endpointReferenceType,"ReferenceProperties");
+		//Method[] methods = refProps.getClass().getMethods();
+		//String[] meths = DynamicSchemaClassBuilder.getProperties(refProps);
+		//XmlObject d=(XmlObject)DynamicSchemaClassBuilder.getProperty(endpointReferenceType,"refProps");
+		//Object id=DynamicSchemaClassBuilder.getProperty(refProps,"EnumValue");
+		//Method selectPathMethod = refProps.getClass().getMethod("selectPath",new Class[]{java.lang.String.class});
+		//Object ret = selectPathMethod.invoke(refProps,new Object[]{"ResourceID"});
+
+		System.out.println();
+	}
+
+	String m_test_envelope1="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"+
+	"   <soapenv:Body>\n"+
+	"      <ns1:findResourcesByServiceNameResponse xmlns:ns1=\"http://registry.generated.ws.apache.org\" >\n"+
+	"         <ns1:FindResponse xmlns:ns1=\"http://registry.generated.ws.apache.org\">\n"+
+	"            <ns1:item>\n"+
+	"               <ns2:Address xmlns:ns2=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">http://localhost:8080/wsdm/services/disk</ns2:Address>\n"+
+	"               <ns3:ReferenceProperties xmlns:ns3=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">\n"+
+	"                  <ns4:ResourceID xmlns:ns4=\"http://www.apache.org/props\">8765</ns4:ResourceID>\n"+
+	"               </ns3:ReferenceProperties>\n"+
+	"               <ns6:PortType xmlns:ns5=\"http://xyz.com/\" xmlns:ns6=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">ns5:DiskPortType</ns6:PortType>\n"+
+	"               <ns8:ServiceName PortName=\"disk\" xmlns:ns7=\"http://xyz.com/\" xmlns:ns8=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">ns7:DiskWsdmService</ns8:ServiceName>\n"+
+	"            </ns1:item>\n"+
+	"            <ns1:item>\n"+
+	"               <ns9:Address xmlns:ns9=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">http://localhost:8080/wsdm/services/disk</ns9:Address>\n"+
+	"               <ns10:ReferenceProperties xmlns:ns10=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">\n"+
+	"                  <ns11:ResourceID xmlns:ns11=\"http://www.apache.org/props\">5678</ns11:ResourceID>\n"+
+	"               </ns10:ReferenceProperties>\n"+
+	"               <ns13:PortType xmlns:ns12=\"http://xyz.com/\" xmlns:ns13=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">ns12:DiskPortType</ns13:PortType>\n"+
+	"               <ns15:ServiceName PortName=\"disk\" xmlns:ns14=\"http://xyz.com/\" xmlns:ns15=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">ns14:DiskWsdmService</ns15:ServiceName>\n"+
+	"            </ns1:item>\n"+
+	"            <ns1:item>\n"+
+	"               <ns16:Address xmlns:ns16=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">http://localhost:8080/wsdm/services/disk</ns16:Address>\n"+
+	"               <ns17:ReferenceProperties xmlns:ns17=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">\n"+
+	"                  <ns18:ResourceID xmlns:ns18=\"http://www.apache.org/props\">4321</ns18:ResourceID>\n"+
+	"               </ns17:ReferenceProperties>\n"+
+	"               <ns20:PortType xmlns:ns19=\"http://xyz.com/\" xmlns:ns20=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">ns19:DiskPortType</ns20:PortType>\n"+
+	"               <ns22:ServiceName PortName=\"disk\" xmlns:ns21=\"http://xyz.com/\" xmlns:ns22=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">ns21:DiskWsdmService</ns22:ServiceName>\n"+
+	"            </ns1:item>\n"+
+	"            <ns1:item>\n"+
+	"               <ns23:Address xmlns:ns23=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">http://localhost:8080/wsdm/services/disk</ns23:Address>\n"+
+	"               <ns24:ReferenceProperties xmlns:ns24=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">\n"+
+	"                  <ns25:ResourceID xmlns:ns25=\"http://www.apache.org/props\">1234</ns25:ResourceID>\n"+
+	"               </ns24:ReferenceProperties>\n"+
+	"               <ns27:PortType xmlns:ns26=\"http://xyz.com/\" xmlns:ns27=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">ns26:DiskPortType</ns27:PortType>\n"+
+	"               <ns29:ServiceName PortName=\"disk\" xmlns:ns28=\"http://xyz.com/\" xmlns:ns29=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">ns28:DiskWsdmService</ns29:ServiceName>\n"+
+	"            </ns1:item>\n"+
+	"         </ns1:FindResponse>\n"+
+	"      </ns1:findResourcesByServiceNameResponse>\n"+
+	"   </soapenv:Body></soapenv:Envelope>";
+
+	String m_test_envelope="<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:wsa=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">"+
+	"  <soapenv:Header>"+
+	"    <wsa:MessageID soapenv:mustUnderstand=\"0\">uuid:51B07250-0DDA-11D9-A169-845A89F5F967</wsa:MessageID>"+
+	"    <wsa:To soapenv:mustUnderstand=\"0\">http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:To>"+
+	"    <wsa:Action soapenv:mustUnderstand=\"0\">http://127.0.0.1:9009/axis/services/registry/actionResponse</wsa:Action>"+
+	"    <wsa:From soapenv:mustUnderstand=\"0\">"+
+	"      <Address xmlns=\"http://schemas.xmlsoap.org/ws/2004/03/addressing\">http://127.0.0.1:9009/axis/services/registry</Address>"+
+	"    </wsa:From>"+
+	"  </soapenv:Header>"+
+	"  <soapenv:Body>"+
+	"    <FindResponse xmlns=\"http://apache.org/ws/generated/registry\">"+
+	"      <item xsi:type=\"wsa:EndpointReferenceType\">"+
+	"        <wsa:Address>http://localhost:8080/wsdm/services/disk</wsa:Address>"+
+	"        <wsa:ReferenceProperties>"+
+	"          <ns1:ResourceID xmlns:ns1=\"urn:proposedstandard.org/muse/addressing\">1234</ns1:ResourceID>"+
+	"        </wsa:ReferenceProperties>"+
+	"        <wsa:PortType xmlns:ns2=\"http://xyz.com/\">ns2:DiskPortType</wsa:PortType>"+
+	"        <wsa:ServiceName PortName=\"disk\" xmlns:ns3=\"http://xyz.com/\">ns3:DiskWsdmService</wsa:ServiceName>"+
+	"      </item>"+
+	"      <item xsi:type=\"wsa:EndpointReferenceType\">"+
+	"        <wsa:Address>http://localhost:8080/wsdm/services/disk</wsa:Address>"+
+	"        <wsa:ReferenceProperties>"+
+	"          <ns4:ResourceID xmlns:ns4=\"urn:proposedstandard.org/muse/addressing\">8765</ns4:ResourceID>"+
+	"        </wsa:ReferenceProperties>"+
+	"        <wsa:PortType xmlns:ns5=\"http://xyz.com/\">ns5:DiskPortType</wsa:PortType>"+
+	"        <wsa:ServiceName PortName=\"disk\" xmlns:ns6=\"http://xyz.com/\">ns6:DiskWsdmService</wsa:ServiceName>"+
+	"      </item>"+
+	"      <item xsi:type=\"wsa:EndpointReferenceType\">"+
+	"        <wsa:Address>http://localhost:8080/wsdm/services/disk</wsa:Address>"+
+	"        <wsa:ReferenceProperties>"+
+	"          <ns7:ResourceID xmlns:ns7=\"urn:proposedstandard.org/muse/addressing\">4321</ns7:ResourceID>"+
+	"        </wsa:ReferenceProperties>"+
+	"        <wsa:PortType xmlns:ns8=\"http://xyz.com/\">ns8:DiskPortType</wsa:PortType>"+
+	"        <wsa:ServiceName PortName=\"disk\" xmlns:ns9=\"http://xyz.com/\">ns9:DiskWsdmService</wsa:ServiceName>"+
+	"      </item>"+
+	"      <item xsi:type=\"wsa:EndpointReferenceType\">"+
+	"        <wsa:Address>http://localhost:8080/wsdm/services/disk</wsa:Address>"+
+	"        <wsa:ReferenceProperties>"+
+	"          <ns10:ResourceID xmlns:ns10=\"urn:proposedstandard.org/muse/addressing\">5678</ns10:ResourceID>"+
+	"        </wsa:ReferenceProperties>"+
+	"        <wsa:PortType xmlns:ns11=\"http://xyz.com/\">ns11:DiskPortType</wsa:PortType>"+
+	"        <wsa:ServiceName PortName=\"disk\" xmlns:ns12=\"http://xyz.com/\">ns12:DiskWsdmService</wsa:ServiceName>"+
+	"      </item>"+
+	"    </FindResponse>"+
+	"  </soapenv:Body>"+
+	"</soapenv:Envelope>";
+
+	private DynamicSchemaClassBuilder m_builder;
+}

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/DynamicSoapClientTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/DynamicSoapClientTestCase.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/DynamicSoapClientTestCase.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/DynamicSoapClientTestCase.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,218 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*/
+package org.apache.ws.client;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.Vector;
+
+import javax.wsdl.Operation;
+import javax.wsdl.WSDLException;
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.ws.resource.discovery.RegistrationManagerFactory;
+import org.apache.ws.test.AbstractOneAxisTestCase;
+import org.apache.xmlbeans.XmlObject;
+import org.xmlsoap.schemas.soap.envelope.impl.FaultImpl;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+
+/**
+ * @author wire
+ */
+public class DynamicSoapClientTestCase extends AbstractOneAxisTestCase {
+    private static final int        CALL_TIMEOUT               = 300000;
+    private static final String testServiceName="registry";
+    private URL m_testWSDLUrl;
+    private URL m_testEndpoint;
+	private DynamicSoapClient m_client;
+    
+    /**
+     * @throws IOException
+     * @throws WSDLException
+     * 
+     */
+    public DynamicSoapClientTestCase() throws WSDLException, IOException {
+        super();
+    }
+	/*
+	 * @see TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		m_testEndpoint=new URL(getAxisBaseUrl().toExternalForm()+testServiceName);
+		m_testWSDLUrl=new URL(getAxisBaseUrl().toExternalForm()+testServiceName+"?wsdl");
+		DynamicSchemaClassBuilder.dispose(); // Flush previously generated classes
+		m_client=new DynamicSoapClient(m_testWSDLUrl,m_testEndpoint);
+		RegistrationManagerFactory.discoverResources(  );
+}
+
+	/*
+	 * @see TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	    RegistrationManagerFactory.shutdown(  );
+	}
+	
+	/**
+	 * Objective: Enumerate Operations of a WSDL
+	 *
+	 */
+	public void testGetOperations(){
+		Operation[] operations = m_client.getWsdlOperations();
+		Assert.assertNotNull(operations);
+		Assert.assertEquals(5,operations.length);
+		Assert.assertEquals("GetResourceProperty",((Operation)operations[0]).getName());
+		Assert.assertEquals("findResourcesByServiceName",((Operation)operations[1]).getName());
+		Assert.assertEquals("findResource",((Operation)operations[2]).getName());
+		Assert.assertEquals("findAllServiceNames",((Operation)operations[3]).getName());
+		Assert.assertEquals("QueryResourceProperties",((Operation)operations[4]).getName());
+		
+	//	System.out.println();
+	}
+	
+	/**
+	 * Objective: Enummerate the parameters of an operation.
+	 * @throws SecurityException
+	 * @throws IllegalArgumentException
+	 * @throws ClassNotFoundException
+	 * @throws NoSuchMethodException
+	 * @throws IllegalAccessException
+	 * @throws InvocationTargetException
+	 */
+	public void testGetParameters() throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException{
+		Operation[] operations = m_client.getWsdlOperations();
+		Assert.assertNotNull(operations);
+		Assert.assertEquals(5,operations.length);
+		Operation opfindResourcesByServiceName=((Operation)operations[1]);
+		String[] params = m_client.getParameters(opfindResourcesByServiceName);
+		Assert.assertNotNull(params);
+		Assert.assertEquals(1,params.length);
+		Assert.assertEquals("ServiceName[java.lang.String]",params[0]);		
+	}
+	
+	/**
+	 * Objective: Execute a simple web service call. Test Result.
+	 * @throws Exception
+	 */
+	public void testExecuteNoParams() throws Exception{
+		Operation[] operations = m_client.findOperation("findAllServiceNames");
+		Assert.assertEquals(1,operations.length);
+		Operation opGetVersion=operations[0];		
+		XmlObject[] responses = m_client.execute(opGetVersion,null);
+		Assert.assertEquals(1,responses.length);
+		Assert.assertFalse("A soap fault was returned. Message was "+responses[0],responses[0] instanceof FaultImpl);
+		String[] props=DynamicSchemaClassBuilder.getProperties(responses[0]);
+		String[] arrayOfServiceNames=(String[])DynamicSchemaClassBuilder.getProperty(responses[0],"ItemArray");
+		Assert.assertEquals("registry",arrayOfServiceNames[1]);
+		Assert.assertEquals("disk",arrayOfServiceNames[0]);
+	}
+	
+	
+	/**
+	 * Objective: Call the resource property for version number to test the GetResourceProp access
+	 * for registry singleton.
+	 * @throws Exception
+	 *
+	 */
+	public void testGetVersionNumber() throws Exception{
+		Operation[] operations = m_client.findOperation("GetResourceProperty");
+		Assert.assertEquals(1,operations.length);
+		Operation opGetVersion=operations[0];
+		
+		String[] props = m_client.getParameters(opGetVersion);
+		Hashtable params=new Hashtable();
+		//NamespaceURI[java.lang.String], Prefix[java.lang.String], LocalPart[java.lang.String]]
+		params.put("QName",new QName("http://docs.oasis-open.org/wsdm/2004/04/muws-0.5/schema","Version"));
+		//params.put("LocalPart",);
+		XmlObject[] responses = m_client.execute(opGetVersion,params);
+		Assert.assertEquals(1,responses.length);
+		XmlObject response=responses[0];
+		Assert.assertFalse("A soap fault was returned. Message was "+response,response instanceof FaultImpl);
+		String responseText=response.toString();
+		Assert.assertTrue(responseText.indexOf("Revision")>0);
+				
+	}
+	
+	/**
+	 * Make a call with 2 parameters. This excercizes the code to generate requests.
+	 * @throws Exception
+	 */
+	public void testExecute1Parameter() throws Exception{
+		Operation[] operations = m_client.findOperation("findResourcesByServiceName");
+		Assert.assertEquals(1,operations.length);
+		Operation opfindResource=operations[0];
+		String[] paramsExample = m_client.getParameters(opfindResource);
+		Hashtable params=new Hashtable();
+		params.put("ServiceName","disk");
+		XmlObject[] responses = m_client.execute(opfindResource,params);
+		Assert.assertEquals(1,responses.length);
+		XmlObject response=responses[0];
+		Assert.assertFalse("A soap fault was returned. Message was "+response,response instanceof FaultImpl);
+		String[] props=DynamicSchemaClassBuilder.getProperties(responses[0]);
+		Object objItemArry=DynamicSchemaClassBuilder.getProperty(responses[0],"ItemArray");
+		String cname=objItemArry.getClass().getName();
+		Assert.assertTrue(objItemArry instanceof EndpointReferenceType[]);
+		Assert.assertEquals(2,props.length);
+		//Address, PortType, ReferenceProperties, ServiceName
+//		Assert.assertEquals("Address",props[0]);
+//		Assert.assertEquals("PortType",props[1]);
+//		Assert.assertEquals("ReferenceProperties",props[2]);
+//		Assert.assertEquals("ServiceName",props[3]);
+		
+		
+		
+		// TODO wire Veryfy some of the contents
+	}
+
+	/**
+	 * Make a call with 2 parameters. This excercizes the code to generate requests.
+	 * @throws Exception
+	 */
+	public void testExecute2Parameters() throws Exception{
+		Operation[] operations = m_client.findOperation("findResource");
+		Assert.assertEquals(1,operations.length);
+		Operation opfindResource=operations[0];
+		String[] paramsExample = m_client.getParameters(opfindResource);
+		Hashtable params=new Hashtable();
+		params.put("ServiceName","disk");
+		params.put("Id","1234");
+		XmlObject[] responses = m_client.execute(opfindResource,params);
+		Assert.assertEquals(1,responses.length);
+		XmlObject response=responses[0];
+		Assert.assertFalse("A soap fault was returned. Message was "+response,response instanceof FaultImpl);
+		String[] props=DynamicSchemaClassBuilder.getProperties(responses[0]);
+		Assert.assertEquals(4,props.length);
+		
+		
+		Vector propNames=new Vector();
+		for (int index = 0; index < props.length; index++) {
+            String propName = props[index];
+            propNames.add(propName);
+        }
+		
+		
+		//Address, PortType, ReferenceProperties, ServiceName
+		
+		Assert.assertTrue(propNames.contains("Address"));
+		Assert.assertTrue(propNames.contains("PortType"));
+		Assert.assertTrue(propNames.contains("ReferenceProperties"));
+		Assert.assertTrue(propNames.contains("ServiceName"));
+		
+		
+		
+		//TODO wire Veryfy some of the contents
+	}
+	
+	
+	protected String getAxisConfigFileName() {
+		
+		return "server-config.wsdd";
+	}
+	
+}

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/async/AsyncCallProviderTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/async/AsyncCallProviderTestCase.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/async/AsyncCallProviderTestCase.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/async/AsyncCallProviderTestCase.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,106 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*
+ * Created on Sep 27, 2004
+ *
+ * $RCSfile: AsyncCallProviderTestCase.java,v $ $Revision: 1.1 $
+ * $Author: scamp $ $Date: 2004/11/12 21:08:49 $
+ * Branch or Tag : $Name:  $
+ *
+ * ______________Recent Changes_______________________________
+ *
+ */
+package org.apache.ws.client.async;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * @author wire
+ *
+ */
+public class AsyncCallProviderTestCase extends TestCase implements AsyncListener {
+
+    private AsyncEvent m_event;
+    int m_secondsToWait=20;
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        m_event=null;
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testPerformAsyncCall() throws SecurityException, NoSuchMethodException {
+        AsyncUnitTestImpl asyncImpl = new AsyncUnitTestImpl(5000);
+        asyncImpl.addListener(this);
+        asyncImpl.mockOperationAsync(new Long(3000));
+        
+        // Returns right away but must wait for an event to be received or a timeout
+        waitForEvent(m_secondsToWait);
+        
+        // An event has been received
+        Object retValue=m_event.getReturnValue();
+        Assert.assertNotNull(retValue);
+        Assert.assertTrue(retValue instanceof String);
+        String retString=(String)retValue;
+        Assert.assertEquals("Success",retString);
+        
+        asyncImpl.removeListener(this);
+    }
+
+    public void testFailAsyncCall() throws SecurityException, NoSuchMethodException {
+        AsyncUnitTestImpl asyncImpl = new AsyncUnitTestImpl(2000);
+        asyncImpl.addListener(this);
+        asyncImpl.mockOperationAsync(new Long(5000));
+        
+        // Returns right away but must wait for an event to be received or a timeout
+        waitForEvent(m_secondsToWait);
+        
+        // An event has been received
+        Object retValue=m_event.getReturnValue();
+        Assert.assertNotNull(retValue);
+
+        // This line should be re-enabled!
+        //Assert.assertTrue(retValue instanceof TimeoutException);
+        
+        asyncImpl.removeListener(this);
+    }
+
+    
+    /**
+     * 
+     */
+    private void waitForEvent(int secondsToWait) {
+        int checks=0;
+        while(checks<secondsToWait){
+            if(m_event!=null){
+                break;
+            }
+            try {
+                Thread.sleep(1000);
+            } catch (InterruptedException e) {
+            }
+        }
+        if(checks==20){
+            Assert.fail("Timout exceeded on test");
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.ws.client.async.AsyncListener#asyncCompletionEvent(java.lang.Object)
+     */
+    public void asyncCompletionEvent(AsyncEvent event) {
+        
+        m_event=event;
+    }
+
+}

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/async/AsyncUnitTestImpl.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/async/AsyncUnitTestImpl.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/async/AsyncUnitTestImpl.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/async/AsyncUnitTestImpl.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,48 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*
+ * Created on Sep 27, 2004
+ *
+ * $RCSfile: AsyncUnitTestImpl.java,v $ $Revision: 1.1 $
+ * $Author: scamp $ $Date: 2004/11/12 21:08:49 $
+ * Branch or Tag : $Name:  $
+ *
+ * ______________Recent Changes_______________________________
+ *
+ */
+package org.apache.ws.client.async;
+
+import java.lang.reflect.Method;
+
+/**
+ * @author wire
+ *
+ */
+public class AsyncUnitTestImpl extends AsyncCallProvider {
+    long m_operationTimeout=5000;
+    /**
+     * 
+     */
+    public AsyncUnitTestImpl() {
+        super();
+    }
+
+    public AsyncUnitTestImpl(long timeout) {
+        super();
+        m_operationTimeout=timeout;
+    }
+    
+    public void mockOperationAsync(Long duration) throws SecurityException, NoSuchMethodException{
+        Method mockOperationMethod=getClass().getMethod("mockOperation",new Class[]{Long.class});
+        performAsync(mockOperationMethod,new Object[]{duration},m_operationTimeout);
+    }
+
+    public String mockOperation(Long duration){
+        try {
+            Thread.sleep(duration.longValue());
+        } catch (InterruptedException e) {
+        }
+        return "Success";
+    }
+
+}

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmClientTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmClientTestCase.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmClientTestCase.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmClientTestCase.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,88 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*/
+package org.apache.ws.client.model;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.EndpointReferenceType;
+
+import junit.framework.Assert;
+
+import org.apache.ws.client.model.impl.WsdmClientImpl;
+import org.apache.ws.resource.discovery.RegistrationManagerFactory;
+import org.apache.ws.test.AbstractOneAxisTestCase;
+
+/**
+ * @author wire
+ */
+public class WsdmClientTestCase extends AbstractOneAxisTestCase {
+    private static final int        CALL_TIMEOUT               = 300000;
+    private URL m_testEndpoint;
+	private WsdmClient m_wsdmClient;
+    
+	/*
+	 * @see TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		m_testEndpoint=new URL(getAxisBaseUrl().toExternalForm());
+		WsdmClientFactory.clearGeneratedClassCache();
+		m_wsdmClient=WsdmClientFactory.create(WsdmClientFactory.AXIS_CLIENT_TYPE,m_testEndpoint.getHost()+":"+m_testEndpoint.getPort(),"axis");
+	    RegistrationManagerFactory.discoverResources(  );
+}
+
+	/*
+	 * @see TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	    RegistrationManagerFactory.shutdown(  );
+	}
+	
+	
+	/**
+	 * Objective: Test the ping method which returns a count in millis of
+	 * how long it takes for a simple call to be made to a server. Can be used
+	 * to display status or judge health of the system remotly.
+	 * @throws Exception
+	 */public void testPing() throws Exception{
+		long time=m_wsdmClient.ping();
+		Assert.assertTrue(time>0);
+	}
+	
+	/**
+	 * Objective: Use this client to get a set of Wsdm Resources. Verify 
+	 * they are returned and check their names.
+	 * @throws SecurityException
+	 * @throws IllegalArgumentException
+	 * @throws NoSuchMethodException
+	 * @throws IllegalAccessException
+	 * @throws InvocationTargetException
+	 * @throws Exception
+	 */
+	 public void testGetResources() throws SecurityException, IllegalArgumentException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, Exception{
+		WsdmResource[] resources=m_wsdmClient.getResources();
+		Assert.assertEquals(2,resources.length);
+		Assert.assertEquals("registry",resources[1].getName());
+		Assert.assertEquals("disk",resources[0].getName());
+	}
+	 
+	/**
+	 * Objective: Test the format of a returned Client Name.
+	 *
+	 */
+	 public void testGetName(){
+	     Assert.assertNotNull(m_wsdmClient.getName());
+	     Assert.assertTrue(m_wsdmClient.getName().startsWith("Server - 127.0.0.1"));
+	}
+	 
+	public void testFindInstance() throws Exception{
+	    WsdmClientImpl impl = (WsdmClientImpl)m_wsdmClient;
+	     EndpointReferenceType erp = impl.getErpFor("disk","1234");	     
+	     WsdmInstance instance=impl.findInstance(erp);
+	     Assert.assertNotNull(instance);
+	}
+	 
+}

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmInstanceTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmInstanceTestCase.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmInstanceTestCase.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmInstanceTestCase.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,109 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*
+ * Created on Sep 14, 2004
+ *
+ * $RCSfile: WsdmInstanceTestCase.java,v $ $Revision: 1.1 $
+ * $Author: scamp $ $Date: 2004/11/12 21:08:49 $
+ * Branch or Tag : $Name:  $
+ *
+ * ______________Recent Changes_______________________________
+ *
+ */
+package org.apache.ws.client.model;
+
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.Hashtable;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Assert;
+
+import org.apache.ws.resource.discovery.RegistrationManagerFactory;
+import org.apache.ws.test.AbstractMultipleAxisTestCase;
+import org.apache.xmlbeans.XmlCursor;
+import org.apache.xmlbeans.XmlObject;
+import org.xmlsoap.schemas.ws.x2003.x03.addressing.impl.EndpointReferenceTypeImpl;
+
+/**
+ * @author wire
+ *
+ */
+public class WsdmInstanceTestCase extends AbstractMultipleAxisTestCase {
+
+    private static final int        CALL_TIMEOUT               = 300000;
+    private URL m_testEndpoint;
+	private WsdmClient m_wsdmServer;
+	private WsdmResource m_resourceDisk;
+    private WsdmInstance m_instanceDisk1234;
+    private WsdmInstance m_resourceRegistrySingleton;
+    
+	/*
+	 * @see TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		m_testEndpoint=new URL(getAxisBaseUrl().toExternalForm());
+		WsdmClientFactory.clearGeneratedClassCache();
+		m_wsdmServer=WsdmClientFactory.create(WsdmClientFactory.AXIS_CLIENT_TYPE,m_testEndpoint.getHost()+":"+m_testEndpoint.getPort(),"axis");
+	    RegistrationManagerFactory.discoverResources(  );
+	    m_resourceDisk=m_wsdmServer.getResources()[0];
+	    m_instanceDisk1234=m_resourceDisk.getInstances()[0];
+	    m_resourceRegistrySingleton=m_wsdmServer.getResources()[1].getInstances()[0];
+
+	}
+
+	/*
+	 * @see TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	    RegistrationManagerFactory.shutdown(  );
+	}
+
+	/**
+	 * Objective: get a list of properties and verify a value.
+	 * @throws Exception
+	 */
+	public void testGetPropertyNames() throws Exception{
+	    String[] propnames=m_instanceDisk1234.getPropertyNames();
+	    Assert.assertNotNull(propnames);
+	    Assert.assertEquals("{http://xyz.com/}TopicSpace[0]",propnames[0]);
+	}
+	
+	public void testGetPropertyNamesOfASingleton() throws Exception{
+	    String[] propnames=m_resourceRegistrySingleton.getPropertyNames();
+	    Assert.assertNotNull(propnames);
+	    Assert.assertEquals("{http://docs.oasis-open.org/wsdm/2004/04/muws-0.5/schema}Name[0]",propnames[0]);
+	}
+
+	public void testGetOperations() throws SecurityException, IllegalArgumentException, ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException{
+	    WsdmOperation[] ops = m_instanceDisk1234.getOperations();
+	    Assert.assertNotNull(ops);
+	    Assert.assertTrue(ops.length>0);
+	}
+	
+	public void testInvoke() throws Exception{
+	    WsdmOperation[] ops = m_instanceDisk1234.getOperations();
+	    WsdmOperation destroyOperation = ops[ops.length-1];
+	    Assert.assertNotNull(destroyOperation);
+	    Assert.assertEquals("Destroy",destroyOperation.getName());
+	    XmlObject[] responses = m_instanceDisk1234.invoke(destroyOperation,new Hashtable());
+	}
+	
+	public void testGetPropertyValueFromQName() throws Exception{
+	    QName propName=new QName("http://xyz.com/","Manufacturer");
+	    XmlObject[] ret=m_instanceDisk1234.getPropertyValue(propName);
+	    XmlCursor cursor = ret[0].newCursor();
+	    String manufacturerName=cursor.getTextValue();
+	    cursor.dispose();
+	    Assert.assertEquals("Hewlett-Packard Company",manufacturerName);
+	}
+	
+	public void testGetERP() throws Exception{
+	    XmlObject erp=m_instanceDisk1234.getEPR();
+	    Assert.assertTrue(erp instanceof EndpointReferenceTypeImpl);
+	}
+
+}

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmOperationTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmOperationTestCase.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmOperationTestCase.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmOperationTestCase.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,62 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*
+ * Created on Sep 11, 2004
+ *
+ * $RCSfile: WsdmOperationTestCase.java,v $ $Revision: 1.1 $
+ * $Author: scamp $ $Date: 2004/11/12 21:08:49 $
+ * Branch or Tag : $Name:  $
+ *
+ * ______________Recent Changes_______________________________
+ *
+ */
+package org.apache.ws.client.model;
+
+import org.apache.ws.client.model.impl.WsdmOperationImpl;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**
+ * @author wire
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class WsdmOperationTestCase extends TestCase {
+
+    private WsdmOperation m_operation;
+
+    /*
+     * @see TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        super.setUp();
+        m_operation=new WsdmOperationImpl("testOperation",new String[]{"hostname[java.lang.String]","port[java.lang.Long]"});
+    }
+
+    /*
+     * @see TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    public void testGetName() {
+        Assert.assertEquals("testOperation",m_operation.getName());
+    }
+
+    public void testGetParameterNames() {
+        String[] names = m_operation.getParameterNames();
+        Assert.assertEquals(2,names.length);
+        Assert.assertEquals("hostname",names[1]);
+        Assert.assertEquals("port",names[0]);
+    }
+
+    public void testGetParameterType() {
+        String[] names = m_operation.getParameterNames();
+        Assert.assertEquals("java.lang.String",m_operation.getParameterType(names[1]));
+        Assert.assertEquals("java.lang.Long",m_operation.getParameterType(names[0]));
+    }
+
+}

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmResourceTestCase.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmResourceTestCase.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmResourceTestCase.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/model/WsdmResourceTestCase.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,77 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*
+ * Created on Sep 11, 2004
+ *
+ * $RCSfile: WsdmResourceTestCase.java,v $ $Revision: 1.1 $
+ * $Author: scamp $ $Date: 2004/11/12 21:08:49 $
+ * Branch or Tag : $Name:  $
+ *
+ * ______________Recent Changes_______________________________
+ *
+ */
+package org.apache.ws.client.model;
+
+import java.net.URL;
+
+import junit.framework.Assert;
+
+import org.apache.ws.resource.discovery.RegistrationManagerFactory;
+import org.apache.ws.test.AbstractOneAxisTestCase;
+
+/**
+ * @author wire
+ *
+ */
+public class WsdmResourceTestCase extends AbstractOneAxisTestCase {
+    private static final int        CALL_TIMEOUT               = 300000;
+    private URL m_testEndpoint;
+	private WsdmClient m_wsdmServer;
+	private WsdmResource m_resourceDisk;
+    private WsdmResource m_resourceRegistry;
+    
+	/*
+	 * @see TestCase#setUp()
+	 */
+	protected void setUp() throws Exception {
+		super.setUp();
+		m_testEndpoint=new URL(getAxisBaseUrl().toExternalForm());
+		WsdmClientFactory.clearGeneratedClassCache();
+		m_wsdmServer=WsdmClientFactory.create(WsdmClientFactory.AXIS_CLIENT_TYPE,m_testEndpoint.getHost()+":"+m_testEndpoint.getPort(),"axis");
+	    RegistrationManagerFactory.discoverResources(  );
+	    m_resourceDisk=m_wsdmServer.getResources()[0];
+	    m_resourceRegistry=m_wsdmServer.getResources()[1];
+	}
+
+	/*
+	 * @see TestCase#tearDown()
+	 */
+	protected void tearDown() throws Exception {
+		super.tearDown();
+	    RegistrationManagerFactory.shutdown(  );
+	}
+
+	
+	public void testGetName(){
+	    Assert.assertNotNull(m_resourceDisk.getName());
+	    Assert.assertEquals("disk",m_resourceDisk.getName());
+	    Assert.assertNotNull(m_resourceRegistry.getName());
+	    Assert.assertEquals("registry",m_resourceRegistry.getName());
+	}
+	
+	public void testGetInstances() throws Exception{
+	    WsdmInstance[] instancesDisk = m_resourceDisk.getInstances();
+	    Assert.assertNotNull(instancesDisk);
+	    Assert.assertEquals(4,instancesDisk.length);
+	    Assert.assertEquals("1234",instancesDisk[0].getName());
+	    Assert.assertEquals("8765",instancesDisk[1].getName());
+	    Assert.assertEquals("4321",instancesDisk[2].getName());
+	    Assert.assertEquals("5678",instancesDisk[3].getName());
+
+	    WsdmInstance[] instancesRegistrySingleton = m_resourceRegistry.getInstances();
+	    Assert.assertNotNull(instancesRegistrySingleton);
+	    Assert.assertEquals(1,instancesRegistrySingleton.length);
+	    Assert.assertEquals("Singleton",instancesRegistrySingleton[0].getName());
+	}
+	
+}

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/util/SubscriberTest.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/util/SubscriberTest.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/util/SubscriberTest.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/client/util/SubscriberTest.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,110 @@
+/*=============================================================================*
+ *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
+ *=============================================================================*/
+package org.apache.ws.client.util;
+
+import junit.framework.TestCase;
+import org.apache.ws.client.model.WsdmInstance;
+import org.apache.ws.client.model.impl.WsdmInstanceImpl;
+import com.ibm.xmlns.stdwip.webServices.wsBaseNotification.TopicExpressionType;
+
+import java.net.URL;
+
+/**
+ * Tests the Subscriber utility.
+ */
+public class SubscriberTest
+   extends TestCase
+{
+   /** the subscriber object to test */
+   private Subscriber m_subscriber;
+
+   /** some dummy WSDM instances */
+   private WsdmInstance m_wsdm1 = new WsdmInstanceImpl( "one", null );
+   private WsdmInstance m_wsdm2 = new WsdmInstanceImpl( "two", null );
+
+   /** some dummy topic expressions */
+   private TopicExpressionType m_topic1;
+   private TopicExpressionType m_topic2;
+
+   /**
+    * Creates a new {@link SubscriberTest} object.
+    */
+   public SubscriberTest(  )
+   {
+      m_topic1    = TopicExpressionType.Factory.newInstance(  );
+      m_topic2    = TopicExpressionType.Factory.newInstance(  );
+
+      m_topic1.setDialect( "topic1dialect" );
+      m_topic2.setDialect( "topic2dialect" );
+   }
+
+   /**
+    * Tests getting existing subscriptions.
+    *
+    * @throws Exception
+    */
+   public void testGetSubscriptions(  )
+   throws Exception
+   {
+   	//TODO wire This feature is not done and this test is disabled
+   	
+//      assertEquals( 0, m_subscriber.getSubscriptions(  ).length );
+//
+//      m_subscriber.subscribe( m_wsdm1, m_topic1 );
+//      assertEquals( 1, m_subscriber.getSubscriptions(  ).length );
+//      assertEquals( 1, m_subscriber.getSubscriptions( m_wsdm1 ).length );
+//
+//      m_subscriber.subscribe( m_wsdm2, m_topic2 );
+//      assertEquals( 2, m_subscriber.getSubscriptions(  ).length );
+//      assertEquals( 1, m_subscriber.getSubscriptions( m_wsdm2 ).length );
+//
+//      m_subscriber.subscribe( m_wsdm1, m_topic2 );
+//      assertEquals( 3, m_subscriber.getSubscriptions(  ).length );
+//      assertEquals( 2, m_subscriber.getSubscriptions( m_wsdm1 ).length );
+//
+//      m_subscriber.subscribe( m_wsdm2, m_topic1 );
+//      assertEquals( 4, m_subscriber.getSubscriptions(  ).length );
+//      assertEquals( 2, m_subscriber.getSubscriptions( m_wsdm2 ).length );
+//
+//      assertNotNull( m_subscriber.getSubscription( m_wsdm1, m_topic1 ) );
+//      assertNotNull( m_subscriber.getSubscription( m_wsdm2, m_topic2 ) );
+//      assertNotNull( m_subscriber.getSubscription( m_wsdm1, m_topic2 ) );
+//      assertNotNull( m_subscriber.getSubscription( m_wsdm2, m_topic1 ) );
+//
+//      m_subscriber.unsubscribe( m_wsdm1, m_topic1 );
+//      assertNull( m_subscriber.getSubscription( m_wsdm1, m_topic1 ) );
+//      assertEquals( 3, m_subscriber.getSubscriptions(  ).length );
+//
+//      m_subscriber.unsubscribe( m_wsdm2 );
+//      assertNull( m_subscriber.getSubscription( m_wsdm2, m_topic1 ) );
+//      assertNull( m_subscriber.getSubscription( m_wsdm2, m_topic2 ) );
+//      assertEquals( 1, m_subscriber.getSubscriptions(  ).length );
+//
+//      m_subscriber.unsubscribe(  );
+//      assertNull( m_subscriber.getSubscription( m_wsdm1, m_topic1 ) );
+//      assertNull( m_subscriber.getSubscription( m_wsdm2, m_topic2 ) );
+//      assertNull( m_subscriber.getSubscription( m_wsdm1, m_topic2 ) );
+//      assertNull( m_subscriber.getSubscription( m_wsdm2, m_topic1 ) );
+//      assertEquals( 0, m_subscriber.getSubscriptions(  ).length );
+   }
+
+   /**
+    * @see junit.framework.TestCase#setUp()
+    */
+   protected void setUp(  )
+   throws Exception
+   {
+      m_subscriber = new Subscriber( new URL( "http://consumer" ) );
+   }
+
+   /**
+    * @see junit.framework.TestCase#tearDown()
+    */
+   protected void tearDown(  )
+   throws Exception
+   {
+      m_subscriber.unsubscribe(  );
+      m_subscriber = null;
+   }
+}
\ No newline at end of file

Added: webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/http/NotSoSimpleAxisServer.java
URL: http://svn.apache.org/viewcvs/webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/http/NotSoSimpleAxisServer.java?rev=232376&view=auto
==============================================================================
--- webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/http/NotSoSimpleAxisServer.java (added)
+++ webservices/muse/trunk/src/examples/client/target/wsdmclient-1.0/src/wsdmclient-1.0/src/test/org/apache/ws/http/NotSoSimpleAxisServer.java Fri Aug 12 13:38:04 2005
@@ -0,0 +1,468 @@
+/*
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.ws.http;
+
+import org.apache.axis.EngineConfiguration;
+import org.apache.axis.collections.LRUMap;
+import org.apache.axis.components.logger.LogFactory;
+import org.apache.axis.components.threadpool.ThreadPool;
+import org.apache.axis.configuration.EngineConfigurationFactoryFinder;
+import org.apache.axis.management.ServiceAdmin;
+import org.apache.axis.server.AxisServer;
+import org.apache.axis.session.Session;
+import org.apache.axis.session.SimpleSession;
+import org.apache.axis.transport.http.SimpleAxisWorker;
+import org.apache.axis.transport.http.SimpleAxisServer;
+import org.apache.axis.utils.Messages;
+import org.apache.axis.utils.NetworkUtils;
+import org.apache.axis.utils.Options;
+import org.apache.commons.logging.Log;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Map;
+
+/**
+ * This is a simple implementation of an HTTP server for processing SOAP requests via Apache's xml-axis.  This is not
+ * intended for production use.  Its intended uses are for demos, debugging, and performance profiling.
+ * <p/>
+ * Note this classes uses static objects to provide a thread pool, so you should not use multiple instances of this
+ * class in the same JVM/classloader unless you want bad things to happen at shutdown.
+ *
+ * TODO: delete any methods that can be safely inherited from superclass
+ *
+ * @author Ian Springer
+ */
+public class NotSoSimpleAxisServer extends SimpleAxisServer implements Runnable
+{
+
+    public static final File DEFAULT_DOC_ROOT_DIR = new File( "./src/wsdl" );
+    public static final int DEFAULT_MAX_THREADS = 200;
+    public static final int DEFAULT_MAX_SESSIONS = 100;
+
+    protected static final Log LOG = LogFactory.getLog( NotSoSimpleAxisServer.class.getName() );
+
+    // session state.
+    // This table maps session keys (random numbers) to SimpleAxisSession objects.
+    //
+    // There is a simple LRU based session cleanup mechanism, but if clients are not
+    // passing cookies, then a new session will be created for *every* request.
+    private Map m_sessions;
+    //Maximum capacity of the LRU Map used for session cleanup
+    private int m_maxSessions;
+
+    private File m_docRootDir;
+
+    /**
+     * get the thread pool
+     *
+     * @return
+     */
+    public static ThreadPool getPool()
+    {
+        return m_pool;
+    }
+
+    /*
+     * pool of threads
+     */
+    private static ThreadPool m_pool;
+
+    /*
+     * Are we doing threads?
+     */
+    private static boolean s_doThreads = true;
+
+    /*
+     * Are we doing sessions? Set this to false if you don't want any session overhead.
+     */
+    private static boolean s_doSessions = true;
+
+    /**
+     * Create a server with default options.
+     */
+    public NotSoSimpleAxisServer()
+    {
+        this( DEFAULT_DOC_ROOT_DIR );
+    }
+
+    /**
+     * Create a server with the specified docRoot.
+     */
+    public NotSoSimpleAxisServer( File docRootDir )
+    {
+        this( docRootDir, DEFAULT_MAX_THREADS );
+    }
+
+    /**
+     * Create a server with the specified docRoot and max threads.
+     */
+    public NotSoSimpleAxisServer( File docRootDir, int maxPoolSize )
+    {
+        this( docRootDir, maxPoolSize, DEFAULT_MAX_SESSIONS );
+    }
+
+    /**
+     * Create a server with the specified docRoot, max threads, and max sessions.
+     */
+    public NotSoSimpleAxisServer( File docRootDir, int maxPoolSize, int maxSessions )
+    {
+        m_docRootDir = docRootDir;
+        m_pool = new ThreadPool( maxPoolSize );
+        m_sessions = new LRUMap( maxSessions );
+    }
+
+    /**
+     * stop the server if not already told to.
+     *
+     * @throws Throwable
+     */
+    protected void finalize() throws Throwable
+    {
+        stop();
+        super.finalize();
+    }
+
+    /**
+     * get max session count
+     *
+     * @return
+     */
+    public int getMaxSessions()
+    {
+        return m_maxSessions;
+    }
+
+    /**
+     * Resize the session map
+     *
+     * @param maxSessions maximum sessions
+     */
+    public void setMaxSessions( int maxSessions )
+    {
+        this.m_maxSessions = maxSessions;
+        ( (LRUMap) m_sessions ).setMaximumSize( maxSessions );
+    }
+    //---------------------------------------------------
+
+    protected boolean isSessionUsed()
+    {
+        return s_doSessions;
+    }
+
+    /**
+     * turn threading on or off. This sets a static value
+     *
+     * @param value
+     */
+    public void setDoThreads( boolean value )
+    {
+        s_doThreads = value;
+    }
+
+    public boolean getDoThreads()
+    {
+        return s_doThreads;
+    }
+
+    public EngineConfiguration getMyConfig()
+    {
+        return m_myConfig;
+    }
+
+    public void setMyConfig( EngineConfiguration myConfig )
+    {
+        m_myConfig = myConfig;
+    }
+
+    /**
+     * demand create a session if there is not already one for the string
+     *
+     * @param cooky
+     *
+     * @return a session.
+     */
+    protected Session createSession( String cooky )
+    {
+
+        // is there a session already?
+        Session session = null;
+        if ( m_sessions.containsKey( cooky ) )
+        {
+            session = (Session) m_sessions.get( cooky );
+        }
+        else
+        {
+            // no session for this cooky, bummer
+            session = new SimpleSession();
+
+            // ADD CLEANUP LOGIC HERE if needed
+            m_sessions.put( cooky, session );
+        }
+        return session;
+    }
+
+    // What is our current session index?
+    // This is a monotonically increasing, non-thread-safe integer
+    // (thread safety not considered crucial here)
+    public static int sessionIndex = 0;
+
+    // Axis server (shared between instances)
+    private static AxisServer myAxisServer = null;
+
+    private EngineConfiguration m_myConfig = null;
+
+    /**
+     * demand create an axis server; return an existing one if one exists. The configuration for the axis server is
+     * derived from #myConfig if not null, the default config otherwise.
+     *
+     * @return
+     */
+    public synchronized AxisServer getAxisServer()
+    {
+        if ( myAxisServer == null )
+        {
+            if ( m_myConfig == null )
+            {
+                m_myConfig = EngineConfigurationFactoryFinder.newFactory().getServerEngineConfig();
+            }
+            myAxisServer = new AxisServer( m_myConfig );
+            ServiceAdmin.setEngine( myAxisServer, NetworkUtils.getLocalHostname() + "@" + m_serverSocket.getLocalPort() );
+        }
+        return myAxisServer;
+    }
+
+    /**
+     * are we stopped? latch to true if stop() is called
+     */
+    private boolean stopped = false;
+
+    /**
+     * Accept requests from a given TCP port and send them through the Axis engine for processing.
+     */
+    public void run()
+    {
+        LOG.info( Messages.getMessage( "start01", "SimpleAxisServer",
+                new Integer( getServerSocket().getLocalPort() ).toString(), getCurrentDirectory() ) );
+
+        // Accept and process requests from the socket
+        while ( !stopped )
+        {
+            Socket socket = null;
+            try
+            {
+                socket = m_serverSocket.accept();
+            }
+            catch ( java.io.InterruptedIOException iie )
+            {
+            }
+            catch ( Exception e )
+            {
+                LOG.debug( Messages.getMessage( "exception00" ), e );
+                break;
+            }
+            if ( socket != null )
+            {
+                SimpleAxisWorker worker = new NotSoSimpleAxisWorker( this, socket, m_docRootDir );
+                if ( s_doThreads )
+                {
+                    m_pool.addWorker( worker );
+                }
+                else
+                {
+                    worker.run();
+                }
+            }
+        }
+        LOG.info( Messages.getMessage( "quit00", "SimpleAxisServer" ) );
+    }
+
+    /**
+     * Gets the current directory
+     *
+     * @return current directory
+     */
+    private String getCurrentDirectory()
+    {
+        return System.getProperty( "user.dir" );
+    }
+
+    // per thread socket information
+    private ServerSocket m_serverSocket;
+
+    /**
+     * Obtain the serverSocket that that SimpleAxisServer is listening on.
+     */
+    public ServerSocket getServerSocket()
+    {
+        return m_serverSocket;
+    }
+
+    /**
+     * Set the serverSocket this server should listen on. (note : changing this will not affect a running server, but if
+     * you stop() and then start() the server, the new socket will be used).
+     */
+    public void setServerSocket( ServerSocket serverSocket )
+    {
+        m_serverSocket = serverSocket;
+    }
+
+    /**
+     * Start this server.
+     * <p/>
+     * Spawns a worker thread to listen for HTTP requests.
+     *
+     * @param daemon a boolean indicating if the thread should be a daemon.
+     */
+    public void start( boolean daemon ) throws Exception
+    {
+        stopped = false;
+        if ( s_doThreads )
+        {
+            Thread thread = new Thread( this );
+            thread.setDaemon( daemon );
+            thread.start();
+        }
+        else
+        {
+            run();
+        }
+    }
+
+    /**
+     * Start this server as a NON-daemon.
+     */
+    public void start() throws Exception
+    {
+        start( false );
+    }
+
+    /**
+     * Stop this server. Can be called safely if the system is already stopped, or if it was never started.
+     * <p/>
+     * This will interrupt any pending accept().
+     */
+    public void stop()
+    {
+        //recognise use before we are live
+        if ( stopped )
+        {
+            return;
+        }
+        /*
+         * Close the server socket cleanly, but avoid fresh accepts while
+         * the socket is closing.
+         */
+        stopped = true;
+
+        try
+        {
+            if ( m_serverSocket != null )
+            {
+                m_serverSocket.close();
+            }
+        }
+        catch ( IOException e )
+        {
+            LOG.info( Messages.getMessage( "exception00" ), e );
+        }
+        finally
+        {
+            m_serverSocket = null;
+        }
+
+        LOG.info( Messages.getMessage( "quit00", "SimpleAxisServer" ) );
+
+        //shut down the pool
+        m_pool.shutdown();
+    }
+
+    /**
+     * Server process.
+     */
+    public static void main( String args[] )
+    {
+
+        Options opts = null;
+        try
+        {
+            opts = new Options( args );
+        }
+        catch ( MalformedURLException e )
+        {
+            LOG.error( Messages.getMessage( "malformedURLException00" ), e );
+            return;
+        }
+
+        String maxPoolSize = opts.isValueSet( 't' );
+        if ( maxPoolSize == null )
+        {
+            maxPoolSize = ThreadPool.DEFAULT_MAX_THREADS + "";
+        }
+
+        String maxSessions = opts.isValueSet( 'm' );
+        if ( maxSessions == null )
+        {
+            maxSessions = DEFAULT_MAX_SESSIONS + "";
+        }
+
+        String[] nonOptionArgs = opts.getRemainingArgs();
+        NotSoSimpleAxisServer server = new NotSoSimpleAxisServer( new File( nonOptionArgs[0] ), Integer.parseInt( maxPoolSize ),
+                Integer.parseInt( maxSessions ) );
+
+        try
+        {
+            s_doThreads = ( opts.isFlagSet( 't' ) > 0 );
+
+            int port = opts.getPort();
+            ServerSocket ss = null;
+            // Try five times
+            final int retries = 5;
+            for ( int i = 0; i < retries; i++ )
+            {
+                try
+                {
+                    ss = new ServerSocket( port );
+                    break;
+                }
+                catch ( java.net.BindException be )
+                {
+                    LOG.debug( Messages.getMessage( "exception00" ), be );
+                    if ( i < ( retries - 1 ) )
+                    {
+                        // At 3 second intervals.
+                        Thread.sleep( 3000 );
+                    }
+                    else
+                    {
+                        throw new Exception( Messages.getMessage( "unableToStartServer00",
+                                Integer.toString( port ) ) );
+                    }
+                }
+            }
+            server.setServerSocket( ss );
+            server.start();
+        }
+        catch ( Exception e )
+        {
+            LOG.error( Messages.getMessage( "exception00" ), e );
+            return;
+        }
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: muse-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: muse-dev-help@ws.apache.org