[jboss-svn-commits] JBL Code SVN: r6982 - in labs/jbossesb/trunk/product: core/rosetta/src/org/jboss/soa/esb/common core/services/src/org/jboss/soa/esb/services/registry core/services/tests/src/org/jboss/soa/esb/services/registry etc/test/resources install/conf

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Oct 20 16:48:18 EDT 2006


Author: kurt.stam at jboss.com
Date: 2006-10-20 16:48:14 -0400 (Fri, 20 Oct 2006)
New Revision: 6982

Added:
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryException.java
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java
Modified:
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Configuration.java
   labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Environment.java
   labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java
   labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java
   labs/jbossesb/trunk/product/etc/test/resources/jbossesb-unittest-properties.xml
   labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
Log:
Working on Registry

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Configuration.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Configuration.java	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Configuration.java	2006-10-20 20:48:14 UTC (rev 6982)
@@ -38,6 +38,7 @@
 			new KeyValuePair(Environment.JNDI_SERVER_URL, 				getJndiServerURL()),
 			new KeyValuePair(Environment.REGISTRY_QUERY_MANAGER_URI, 	getRegistryQueryManageURI()),
 			new KeyValuePair(Environment.REGISTRY_LIFECYCLE_MANAGER_URI,getRegistryLifecycleManagerURI()),
+			new KeyValuePair(Environment.REGISTRY_IMPEMENTATION_CLASS,  getRegistryImplementationClass()),
 			new KeyValuePair(Environment.REGISTRY_FACTORY_CLASS, 		getRegistryFactoryClass()),
 			new KeyValuePair(Environment.REGISTRY_USER, 				getRegistryUser()),
 			new KeyValuePair(Environment.REGISTRY_PASSWORD, 			getRegistryPassword()),
@@ -137,6 +138,14 @@
 		return ModulePropertyManager.getPropertyManager(ModulePropertyManager.REGISTRY_MODULE).getProperty(Environment.REGISTRY_FACTORY_CLASS);
 	}
 	/**
+	 * The Registry Implememtation Class defines wrapper class
+	 * @return Registry Implementation Class String
+	 */
+	public static String getRegistryImplementationClass()
+	{
+		return ModulePropertyManager.getPropertyManager(ModulePropertyManager.REGISTRY_MODULE).getProperty(Environment.REGISTRY_IMPEMENTATION_CLASS);
+	}
+	/**
 	 * The Registry Scout Transport Class defines which communication protocol Scout should use to communicate
 	 * with the UDDI registry. Note that this parameter is Scout specific.
 	 * @return Registry Scout Transport Class String

Modified: labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Environment.java
===================================================================
--- labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Environment.java	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/core/rosetta/src/org/jboss/soa/esb/common/Environment.java	2006-10-20 20:48:14 UTC (rev 6982)
@@ -53,6 +53,10 @@
 	 * The Registry Lifecycle Manager URI defines the endPoint where service information can be published to.
 	 */
 	public static final String REGISTRY_LIFECYCLE_MANAGER_URI = "org.jboss.soa.esb.registry.lifeCycleManagerURI";
+    /**
+     * The Registry Implementation class, a light wrapper class.
+     */
+	public static final String REGISTRY_IMPEMENTATION_CLASS = "org.jboss.soa.esb.registry.implementationClass";
 	/** 
 	 * The Registry Factory Class setting specifies which JAXR implementation should be used.
 	 */

Modified: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/JAXRRegistryImpl.java	2006-10-20 20:48:14 UTC (rev 6982)
@@ -31,7 +31,6 @@
 import javax.xml.registry.Connection;
 import javax.xml.registry.ConnectionFactory;
 import javax.xml.registry.JAXRException;
-import javax.xml.registry.infomodel.Service;
 
 import org.apache.log4j.Logger;
 import org.apache.log4j.Priority;
@@ -44,7 +43,7 @@
  *
  * @author Kurt Stam
  */
-public class JAXRRegistryImpl 
+public class JAXRRegistryImpl implements Registry
 {
 	private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
 	public static Set<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
@@ -69,7 +68,7 @@
 	 * 
 	 * @return Connection to a Registry using JAXR. 
 	 */
-	protected static Connection getConnection() 
+	protected static  Connection getConnection() 
 	{
 		Connection connection = null;
 		init();
@@ -101,7 +100,7 @@
 	 * Publish an EPR to the Registry
 	 */
 	public void publish(String serviceName, EPR epr) {
-		
+		return;
 	}
 	/** 
 	 * Remove an EPR from the Registry
@@ -113,9 +112,9 @@
 	 * Find all ESB Services
 	 * @return collection services
 	 */
-	public Collection<Service> findServices() 
+	public Collection<String> findServices() 
 	{
-		Collection<Service> services = new ArrayList<Service>();
+		Collection<String> services = new ArrayList<String>();
 		return services;
 	}
 	/**
@@ -124,8 +123,8 @@
 	 * @param serviceType
 	 * @return collection services
 	 */
-	public Collection<Service> findServices(String serviceType){
-		Collection<Service> services = new ArrayList<Service>();
+	public Collection<String> findServices(String serviceType){
+		Collection<String> services = new ArrayList<String>();
 		return services;
 	}
 	/**
@@ -133,7 +132,7 @@
 	 * @param service
 	 * @return
 	 */
-	Collection<EPR> findEPR(Service service){
+	public Collection<EPR> findEPR(String serviceName){
 		Collection<EPR> eprs = new ArrayList<EPR>();
 		return eprs;
 	}

Added: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/Registry.java	2006-10-20 20:48:14 UTC (rev 6982)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.services.registry;
+
+import java.util.Collection;
+
+import org.jboss.soa.esb.addressing.EPR;
+/**
+ * Registry interface for the ESB.
+ *
+ * @author Kurt Stam
+ */
+interface Registry 
+{
+	public void publish(String serviceName, EPR epr);
+	/** 
+	 * Remove an EPR from the Registry
+	 */
+	public void unPublish(EPR epr);
+	/** 
+	 * Find all ESB Services
+	 * @return collection services
+	 */
+	public Collection<String> findServices();
+	/**
+	 * Find Services based on a type ("transformation"
+	 * 
+	 * @param serviceType
+	 * @return collection services
+	 */
+	public Collection<String> findServices(String serviceType);
+	/**
+	 * 
+	 * @param service
+	 * @return
+	 */
+	public Collection<EPR> findEPR(String serviceName);
+}

Added: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryException.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryException.java	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryException.java	2006-10-20 20:48:14 UTC (rev 6982)
@@ -0,0 +1,29 @@
+/*
+ * Created on Jul 15, 2004
+ *
+ */
+package org.jboss.soa.esb.services.registry;
+
+/**
+ * @author gerry
+ * 
+ * <p>Created:  Jul 15, 2004</p>
+ */
+public class RegistryException extends Exception {
+    private static final long serialVersionUID = 1L;
+	public final static String STORE = "Failed to store.  ";
+    public final static String DELETE = "Failed to delete.  ";
+    public final static String FETCH = "Failed to fetch.  ";
+    
+    public RegistryException(){
+        super();
+    }
+    
+    public RegistryException (String msg){
+        super(msg);
+    }
+    
+    public RegistryException (String msg, Throwable cause){
+        super (msg, cause);
+    }
+}

Added: labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/core/services/src/org/jboss/soa/esb/services/registry/RegistryFactory.java	2006-10-20 20:48:14 UTC (rev 6982)
@@ -0,0 +1,75 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.services.registry;
+
+import org.apache.log4j.Logger;
+import org.apache.log4j.Priority;
+import org.jboss.soa.esb.common.Configuration;
+/**
+ * Returns an Instance of the Registry.
+ * @author kstam
+ *
+ */
+public class RegistryFactory 
+{
+	private static Logger logger = Logger.getLogger(RegistryFactory.class);
+	
+	public static Registry getRegistry() {
+		Registry registry = null;
+		String className = Configuration.getRegistryImplementationClass();
+		try {
+			// instruct class loader to load the TransportFactory
+			Class registryClass = getClassForName(className);
+			// Try to instance the Registry
+			registry = (Registry) registryClass.newInstance();
+		} catch (ClassNotFoundException cnfex) {
+			cnfex.printStackTrace();	
+		} catch (java.lang.Exception ex) {
+			ex.printStackTrace();
+		}
+		return registry;
+	}
+	
+	/**
+	 * Loads the class with the given name.
+	 * @param className - the className to be found
+	 * @return - the class
+	 * @throws ClassNotFoundException
+	 */
+	private static Class getClassForName(String className) throws ClassNotFoundException
+	{
+		Class clazz = null;
+		try {
+			logger.log(Priority.DEBUG, "Using the Context ClassLoader");
+			ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
+			clazz = Class.forName(className, true, contextClassLoader);
+		} catch (ClassNotFoundException classNotFound) {
+			if (logger.isDebugEnabled()) {
+				logger.log(Priority.WARN, "The Contect ClassLoader could not find the class.");
+				logger.log(Priority.WARN, "Using the System ClassLoader");
+			}
+			ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
+			clazz = Class.forName(className, true, systemClassLoader);
+		}
+		return clazz;
+	}
+}

Added: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/JAXRRegistryUnitTest.java	2006-10-20 20:48:14 UTC (rev 6982)
@@ -0,0 +1,432 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.services.registry;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.io.InputStream;
+import java.sql.DriverManager;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+
+import javax.xml.registry.BulkResponse;
+import javax.xml.registry.BusinessLifeCycleManager;
+import javax.xml.registry.BusinessQueryManager;
+import javax.xml.registry.Connection;
+import javax.xml.registry.FindQualifier;
+import javax.xml.registry.JAXRException;
+import javax.xml.registry.JAXRResponse;
+import javax.xml.registry.RegistryService;
+import javax.xml.registry.infomodel.Classification;
+import javax.xml.registry.infomodel.ClassificationScheme;
+import javax.xml.registry.infomodel.EmailAddress;
+import javax.xml.registry.infomodel.ExternalIdentifier;
+import javax.xml.registry.infomodel.Key;
+import javax.xml.registry.infomodel.Organization;
+import javax.xml.registry.infomodel.PersonName;
+import javax.xml.registry.infomodel.PostalAddress;
+import javax.xml.registry.infomodel.Service;
+import javax.xml.registry.infomodel.ServiceBinding;
+import javax.xml.registry.infomodel.TelephoneNumber;
+import javax.xml.registry.infomodel.User;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.common.tests.HsqldbUtil;
+import org.jboss.soa.esb.common.tests.TestUtil;
+import org.jboss.soa.esb.services.util.FileUtil;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+/**
+ * Testing the registry.
+ * 
+ * @author kstam
+ *
+ */
+public class JAXRRegistryUnitTest
+{
+    private static String mDbDriver;
+	private static String mDbUrl;
+	private static String mDbUsername;
+	private static String mDbPassword;
+	
+	@SuppressWarnings("unchecked")
+	@Test
+	public void publishOrganization() 
+	{
+		//Getting the connection to the Registry (reading config)
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			//Logging in
+			connection.setCredentials(JAXRRegistryImpl.creds);
+			RegistryService rs = connection.getRegistryService();
+			//Building organization
+			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+			Collection<Organization> orgs = new ArrayList<Organization>();
+			Organization org = createOrganization(blm);
+			orgs.add(org);
+			//Saving the organization (this make the actual calls)
+			BulkResponse br = blm.saveOrganizations(orgs);
+//			Verify the return
+			if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+				System.out.println("Organization Saved");
+				Collection coll = br.getCollection();
+				Iterator iter = coll.iterator();
+				while (iter.hasNext()) {
+					Key key = (Key) iter.next();
+					org.setKey(key);
+					System.out.println("Saved Key=" + key.getId());
+				}
+			} else {
+				System.out.println("JAXRExceptions " + "occurred during save:");
+				Collection exceptions = br.getExceptions();
+				Iterator iter = exceptions.iterator();
+				while (iter.hasNext()) {
+					Exception e = (Exception) iter.next();
+					e.printStackTrace();
+				}
+				assertTrue(false);
+			}
+			
+			//Add a Service
+			Service service = blm.createService(blm.createInternationalString("JBossESB TEST Service"));
+			service.setDescription(blm.createInternationalString("Services of the ESB UDDI Registry"));
+			org.addService(service);
+			Collection services = new ArrayList();
+			services.add(service);
+			br=blm.saveServices(services);
+//			Verify the return
+			if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+				System.out.println("Service Saved");
+				Collection coll = br.getCollection();
+				Iterator iter = coll.iterator();
+				while (iter.hasNext()) {
+					Key key = (Key) iter.next();
+					System.out.println("Saved Key=" + key.getId());
+					service.setKey(key);
+				}
+			} else {
+				System.out.println("JAXRExceptions " + "occurred during save:");
+				Collection exceptions = br.getExceptions();
+				Iterator iter = exceptions.iterator();
+				while (iter.hasNext()) {
+					Exception e = (Exception) iter.next();
+					e.printStackTrace();
+				}
+				assertTrue(false);
+			}
+			
+			//Add a serviceBinding
+			ServiceBinding serviceBinding = blm.createServiceBinding();
+			serviceBinding.setName(blm.createInternationalString("JBossESB Test ServiceBinding"));
+			serviceBinding.setDescription(blm.createInternationalString("Binding Description"));
+			serviceBinding.setAccessURI("http://www.jboss.com/services/TestService");
+		    ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+		    serviceBindings.add(serviceBinding);
+		    service.addServiceBindings(serviceBindings);
+			br=blm.saveServiceBindings(serviceBindings);
+			
+//			Verify the return
+			if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+				System.out.println("Service Binding Saved");
+				Collection coll = br.getCollection();
+				Iterator iter = coll.iterator();
+				while (iter.hasNext()) {
+					Key key = (Key) iter.next();
+					System.out.println("Saved Key=" + key.getId());
+					serviceBinding.setKey(key);
+				}
+			} else {
+				System.out.println("JAXRExceptions " + "occurred during save:");
+				Collection exceptions = br.getExceptions();
+				Iterator iter = exceptions.iterator();
+				while (iter.hasNext()) {
+					Exception e = (Exception) iter.next();
+					e.printStackTrace();
+				}
+				assertTrue(false);
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			assertTrue(false);
+		} finally {
+			JAXRRegistryImpl.closeConnection(connection);
+		}
+	}
+	/**
+	 * Queries the newly added information
+	 * @throws Exception
+	 */
+	@Test
+	public void findOrganizations()
+    {
+		String queryString = "JBOSS"; //All organization with JBOSS in the name.
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			// Get registry service and business query manager
+			RegistryService rs = connection.getRegistryService();
+			BusinessQueryManager bqm = rs.getBusinessQueryManager();
+			// Define find qualifiers and name patterns
+			Collection<String> findQualifiers = new ArrayList<String>();
+			findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+			Collection<String> namePatterns = new ArrayList<String>();
+			namePatterns.add("%" + queryString + "%");
+//			 Find based upon qualifier type and values
+			System.out.println("Going to query the registry for name pattern " + namePatterns);
+			BulkResponse response = bqm.findOrganizations(findQualifiers,
+					namePatterns, null, null, null, null);
+
+			System.out.println("Found " + response.getCollection().size() + " organization.");
+			for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();) 
+			{
+				Organization org = (Organization) orgIter.next();
+				System.out.println("Organization name: " + org.getName().getValue());
+				System.out.println("Description: " + org.getDescription().getValue());
+				System.out.println("Key id: " + org.getKey().getId());
+				User primaryContact = org.getPrimaryContact();
+				System.out.println("Primary Contact: " + primaryContact.getPersonName().getFullName());
+				Collection services = org.getServices();
+				for (Iterator serviceIter = services.iterator();serviceIter.hasNext();) {
+					Service service = (Service) serviceIter.next();
+					System.out.println("Service Name: " + service.getName().getValue());
+					Collection serviceBindings = service.getServiceBindings();
+					for (Iterator serviceBindingIter = serviceBindings.iterator();serviceBindingIter.hasNext();){
+						ServiceBinding serviceBinding = (ServiceBinding) serviceBindingIter.next();
+						System.out.println("ServiceBinding Description: " + serviceBinding.getDescription().getValue());
+						System.out.println("ServiceBinding URI: " + serviceBinding.getAccessURI());
+						assertEquals("http://www.jboss.com/services/TestService",serviceBinding.getAccessURI());
+					}
+				}
+			}
+			
+		} catch (JAXRException e) {
+			e.printStackTrace();
+			assertTrue(false);
+		} finally {
+			JAXRRegistryImpl.closeConnection(connection);
+		}
+    }
+	/**
+	 * 
+	 */
+	@SuppressWarnings("unchecked")
+	@Test
+	public void publishAnEPR() {
+//		String EPR_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+//			+ "<EPR>"
+//			+ "	<wsa:Address>jms://queue</wsa:Address>"
+//			+ "	<wsa:ReferenceProperties>"
+//	        + "		<wsarjaddr:specification-version xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">1.1</wsarjaddr:specification-version>"
+//	        + "		<wsarjaddr:destination-name xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">queue/A</wsarjaddr:destination-name>"
+//	        + "		<wsarjaddr:connection-factory xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">ConnectionFactory</wsarjaddr:connection-factory>"
+//	        + "		<wsarjaddr:jndi-type xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">jboss</wsarjaddr:jndi-type>"
+//	        + "		<wsarjaddr:jndi-URL xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">localhost</wsarjaddr:jndi-URL>"
+//	        + "		<wsarjaddr:message-selector xmlns:wsarjaddr=\"http://schemas.arjuna.com/ws/2004/06/wsarjaddr\">listener='maradona'</wsarjaddr:message-selector>"
+//	        + "	</wsa:ReferenceProperties>"
+//	        + "</EPR>";
+//		String serviceName="Kurt's Travel Agency";
+//		String serviceURI="epr:jbossesb:version:1.0:logicalname:KurtsTravelAgency";
+		
+		Connection connection = JAXRRegistryImpl.getConnection();
+		try {
+			//Logging in
+			connection.setCredentials(JAXRRegistryImpl.creds);
+			RegistryService rs = connection.getRegistryService();
+			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+			BusinessQueryManager bqm = rs.getBusinessQueryManager();
+			// Define find qualifiers and name patterns
+			Collection<String> findQualifiers = new ArrayList<String>();
+			findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
+			Collection<String> namePatterns = new ArrayList<String>();
+			namePatterns.add("%JBOSS%");
+//			 Find based upon qualifier type and values
+			System.out.println("Going to query the registry for name pattern " + namePatterns);
+			BulkResponse response = bqm.findOrganizations(findQualifiers,
+					namePatterns, null, null, null, null);
+
+			System.out.println("Found " + response.getCollection().size() + " organization.");
+			for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();) 
+			{
+				Organization org = (Organization) orgIter.next();
+				Service service = blm.createService(blm.createInternationalString("JBossESB TEST Service"));
+				service.setDescription(blm.createInternationalString("Services of the ESB UDDI Registry"));
+				org.addService(service);
+				Collection services = new ArrayList();
+				services.add(service);
+				BulkResponse br=blm.saveServices(services);
+				if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
+					br.getCollection();
+					//ServiceBinding serviceBinding = 
+					//service.addServiceBinding(serviceBinding);
+				}
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+			assertTrue(false);
+		} finally {
+			JAXRRegistryImpl.closeConnection(connection);
+		}
+		
+		
+		
+	}
+	/**
+	 * Creates a Jaxr Organization with 1 or more services
+	 * 
+	 * @return
+	 * @throws JAXRException
+	 */
+	@SuppressWarnings("unused")
+	private Organization createOrganization(BusinessLifeCycleManager blm)
+			throws JAXRException {
+		Organization org = blm.createOrganization(blm.createInternationalString("USA -- JBOSS ORG"));
+		org.setDescription(blm.createInternationalString("JBoss Professional Open Source"));
+		
+		User user = blm.createUser();
+		org.setPrimaryContact(user);
+		PersonName personName = blm.createPersonName("Kurt Stam");
+		TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
+		telephoneNumber.setNumber("404 467-8555");
+		telephoneNumber.setType(null);
+		PostalAddress address = blm.createPostalAddress("3340",
+				"Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
+				"30326", "");
+		Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
+		postalAddresses.add(address);
+		Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
+		EmailAddress emailAddress = blm
+				.createEmailAddress("kurt.stam at jboss.org");
+		emailAddresses.add(emailAddress);
+
+		Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
+		numbers.add(telephoneNumber);
+		user.setPersonName(personName);
+		user.setPostalAddresses(postalAddresses);
+		user.setEmailAddresses(emailAddresses);
+		user.setTelephoneNumbers(numbers);
+
+		ClassificationScheme cScheme = getClassificationScheme(blm,
+				"ntis-gov:naics", "");
+		Key cKey = blm.createKey("uuid:C0B9FE13-324F-413D-5A5B-2004DB8E5CC2");
+		cScheme.setKey(cKey);
+		Classification classification = blm.createClassification(cScheme,
+				"Professional Open Source", "5415");
+		org.addClassification(classification);
+		ClassificationScheme cScheme1 = getClassificationScheme(blm, "D-U-N-S",
+				"");
+		Key cKey1 = blm.createKey("uuid:3367C81E-FF1F-4D5A-B202-3EB13AD02423");
+		cScheme1.setKey(cKey1);
+		ExternalIdentifier ei = blm.createExternalIdentifier(cScheme1,
+				"D-U-N-S number", "08-146-6849");
+		org.addExternalIdentifier(ei);
+		return org;
+	}
+
+	private ClassificationScheme getClassificationScheme(
+			BusinessLifeCycleManager blm, String str1, String str2)
+			throws JAXRException {
+		ClassificationScheme cs = blm.createClassificationScheme(blm
+				.createInternationalString(str1), blm
+				.createInternationalString(str2));
+		return cs;
+	}
+
+	
+	/**
+	 * Setup the database.
+	 * @throws Exception
+	 */
+	@BeforeClass
+	public static void runBeforeAllTests() throws Exception {
+		try {
+			TestUtil.setESBPropertiesFileToUse();
+			//Set the juddi properties file in System so juddi will pick it up later and use the test values.
+			String juddiPropertiesFile = "/org/jboss/soa/esb/services/registry/juddi-unittest.properties";
+			System.setProperty("juddi.propertiesFile", juddiPropertiesFile);
+			//Read this properties file to get the db connection string
+			Properties props = new Properties();
+			InputStream inStream = Class.class.getResourceAsStream(juddiPropertiesFile);
+			props.load(inStream);
+			mDbDriver    = props.getProperty("juddi.jdbcDriver");
+			mDbUrl       = props.getProperty("juddi.jdbcUrl");
+			mDbUsername  = props.getProperty("juddi.jdbcUsername");
+			mDbPassword  = props.getProperty("juddi.jdbcPassword");
+			
+			String database="not tested yet";
+			if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
+				database = "hsqldb";
+				//Bring up hsql on default port 9001
+				HsqldbUtil.startHsqldb(TestUtil.getPrefix() + "build/hsqltestdb", "juddi");
+			} else if ("com.mysql.jdbc.Driver".equals(mDbDriver)) {
+				database = "mysql";
+			} //add and test your own database..
+			
+			//Get the registry-schema create scripts
+			String sqlDir = TestUtil.getPrefix() + "install/jUDDI-registry/sql/" + database + "/";
+			//Drop what is there now, if exists. We want to start fresh.
+			String sqlDropCmd      = FileUtil.readTextFile(new File(sqlDir + "drop_database.sql"));
+			String sqlCreateCmd    = FileUtil.readTextFile(new File(sqlDir + "create_database.sql"));
+			String sqlInsertPubCmd = FileUtil.readTextFile(new File(sqlDir + "insert_publishers.sql"));
+			
+			try {
+				Class.forName(mDbDriver);
+			} catch (Exception e) {
+				System.out.println("ERROR: failed to load " + database + " JDBC driver.");
+				e.printStackTrace();
+				return;
+			}
+			java.sql.Connection con = DriverManager.getConnection(mDbUrl, mDbUsername, mDbPassword);
+			Statement stmnt = con.createStatement();
+			System.out.println("Dropping the schema if exist");
+			stmnt.execute(sqlDropCmd);
+			System.out.println("Creating the juddi-schema");
+			stmnt.execute(sqlCreateCmd);
+			System.out.println("Adding the jbossesb publisher");
+			stmnt.execute(sqlInsertPubCmd);
+		} catch (Exception e) {
+			e.printStackTrace();
+			System.out.println("We should stop testing, since we don't have a db.");
+			assertTrue(false);
+		}
+	}
+	/**
+	 * Shutdown the database
+	 * @throws Exception
+	 */
+	@AfterClass
+	public static void runAfterAllTests() throws Exception {
+		if ("org.hsqldb.jdbcDriver".equals(mDbDriver)) {
+			HsqldbUtil.stopHsqldb(mDbUrl, mDbUsername, mDbPassword);
+		}
+	}
+
+	public static junit.framework.Test suite() {
+		return new JUnit4TestAdapter(JAXRRegistryUnitTest.class);
+	}
+
+}

Modified: labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/core/services/tests/src/org/jboss/soa/esb/services/registry/RegistryUnitTest.java	2006-10-20 20:48:14 UTC (rev 6982)
@@ -21,7 +21,6 @@
 */
 package org.jboss.soa.esb.services.registry;
 
-import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
@@ -38,21 +37,10 @@
 import javax.xml.registry.BusinessQueryManager;
 import javax.xml.registry.Connection;
 import javax.xml.registry.FindQualifier;
-import javax.xml.registry.JAXRException;
 import javax.xml.registry.JAXRResponse;
 import javax.xml.registry.RegistryService;
-import javax.xml.registry.infomodel.Classification;
-import javax.xml.registry.infomodel.ClassificationScheme;
-import javax.xml.registry.infomodel.EmailAddress;
-import javax.xml.registry.infomodel.ExternalIdentifier;
-import javax.xml.registry.infomodel.Key;
 import javax.xml.registry.infomodel.Organization;
-import javax.xml.registry.infomodel.PersonName;
-import javax.xml.registry.infomodel.PostalAddress;
 import javax.xml.registry.infomodel.Service;
-import javax.xml.registry.infomodel.ServiceBinding;
-import javax.xml.registry.infomodel.TelephoneNumber;
-import javax.xml.registry.infomodel.User;
 
 import junit.framework.JUnit4TestAdapter;
 
@@ -75,164 +63,7 @@
 	private static String mDbUsername;
 	private static String mDbPassword;
 	
-	@SuppressWarnings("unchecked")
-	@Test
-	public void publishOrganization() 
-	{
-		//Getting the connection to the Registry (reading config)
-		Connection connection = JAXRRegistryImpl.getConnection();
-		try {
-			//Logging in
-			connection.setCredentials(JAXRRegistryImpl.creds);
-			RegistryService rs = connection.getRegistryService();
-			//Building organization
-			BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-			Collection<Organization> orgs = new ArrayList<Organization>();
-			Organization org = createOrganization(blm);
-			orgs.add(org);
-			//Saving the organization (this make the actual calls)
-			BulkResponse br = blm.saveOrganizations(orgs);
-//			Verify the return
-			if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
-				System.out.println("Organization Saved");
-				Collection coll = br.getCollection();
-				Iterator iter = coll.iterator();
-				while (iter.hasNext()) {
-					Key key = (Key) iter.next();
-					org.setKey(key);
-					System.out.println("Saved Key=" + key.getId());
-				}
-			} else {
-				System.out.println("JAXRExceptions " + "occurred during save:");
-				Collection exceptions = br.getExceptions();
-				Iterator iter = exceptions.iterator();
-				while (iter.hasNext()) {
-					Exception e = (Exception) iter.next();
-					e.printStackTrace();
-				}
-				assertTrue(false);
-			}
-			
-			//Add a Service
-			Service service = blm.createService(blm.createInternationalString("JBossESB TEST Service"));
-			service.setDescription(blm.createInternationalString("Services of the ESB UDDI Registry"));
-			org.addService(service);
-			Collection services = new ArrayList();
-			services.add(service);
-			br=blm.saveServices(services);
-//			Verify the return
-			if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
-				System.out.println("Service Saved");
-				Collection coll = br.getCollection();
-				Iterator iter = coll.iterator();
-				while (iter.hasNext()) {
-					Key key = (Key) iter.next();
-					System.out.println("Saved Key=" + key.getId());
-					service.setKey(key);
-				}
-			} else {
-				System.out.println("JAXRExceptions " + "occurred during save:");
-				Collection exceptions = br.getExceptions();
-				Iterator iter = exceptions.iterator();
-				while (iter.hasNext()) {
-					Exception e = (Exception) iter.next();
-					e.printStackTrace();
-				}
-				assertTrue(false);
-			}
-			
-			//Add a serviceBinding
-			ServiceBinding serviceBinding = blm.createServiceBinding();
-			serviceBinding.setName(blm.createInternationalString("JBossESB Test ServiceBinding"));
-			serviceBinding.setDescription(blm.createInternationalString("Binding Description"));
-			serviceBinding.setAccessURI("http://www.jboss.com/services/TestService");
-		    ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
-		    serviceBindings.add(serviceBinding);
-		    service.addServiceBindings(serviceBindings);
-			br=blm.saveServiceBindings(serviceBindings);
-			
-//			Verify the return
-			if (br.getStatus() == JAXRResponse.STATUS_SUCCESS) {
-				System.out.println("Service Binding Saved");
-				Collection coll = br.getCollection();
-				Iterator iter = coll.iterator();
-				while (iter.hasNext()) {
-					Key key = (Key) iter.next();
-					System.out.println("Saved Key=" + key.getId());
-					serviceBinding.setKey(key);
-				}
-			} else {
-				System.out.println("JAXRExceptions " + "occurred during save:");
-				Collection exceptions = br.getExceptions();
-				Iterator iter = exceptions.iterator();
-				while (iter.hasNext()) {
-					Exception e = (Exception) iter.next();
-					e.printStackTrace();
-				}
-				assertTrue(false);
-			}
-		} catch (Exception e) {
-			e.printStackTrace();
-			assertTrue(false);
-		} finally {
-			JAXRRegistryImpl.closeConnection(connection);
-		}
-	}
 	/**
-	 * Queries the newly added information
-	 * @throws Exception
-	 */
-	@Test
-	public void queryForOrganizations()
-    {
-		String queryString = "JBOSS"; //All organization with JBOSS in the name.
-		Connection connection = JAXRRegistryImpl.getConnection();
-		try {
-			// Get registry service and business query manager
-			RegistryService rs = connection.getRegistryService();
-			BusinessQueryManager bqm = rs.getBusinessQueryManager();
-			// Define find qualifiers and name patterns
-			Collection<String> findQualifiers = new ArrayList<String>();
-			findQualifiers.add(FindQualifier.SORT_BY_NAME_ASC);
-			Collection<String> namePatterns = new ArrayList<String>();
-			namePatterns.add("%" + queryString + "%");
-//			 Find based upon qualifier type and values
-			System.out.println("Going to query the registry for name pattern " + namePatterns);
-			BulkResponse response = bqm.findOrganizations(findQualifiers,
-					namePatterns, null, null, null, null);
-
-			System.out.println("Found " + response.getCollection().size() + " organization.");
-			for (Iterator orgIter = response.getCollection().iterator(); orgIter.hasNext();) 
-			{
-				Organization org = (Organization) orgIter.next();
-				System.out.println("Orginazation name: " + org.getName().getValue());
-				System.out.println("Description: " + org.getDescription().getValue());
-				System.out.println("Key id: " + org.getKey().getId());
-				User primaryContact = org.getPrimaryContact();
-				System.out.println("Primary Contact: " + primaryContact.getPersonName().getFullName());
-				Collection services = org.getServices();
-				for (Iterator serviceIter = services.iterator();serviceIter.hasNext();) {
-					Service service = (Service) serviceIter.next();
-					System.out.println("Service Name: " + service.getName().getValue());
-					Collection serviceBindings = service.getServiceBindings();
-					for (Iterator serviceBindingIter = serviceBindings.iterator();serviceBindingIter.hasNext();){
-						ServiceBinding serviceBinding = (ServiceBinding) serviceBindingIter.next();
-						System.out.println("ServiceBinding Name: " + serviceBinding.getName().getValue());
-						System.out.println("ServiceBinding Description: " + serviceBinding.getDescription().getValue());
-						System.out.println("ServiceBinding URI: " + serviceBinding.getAccessURI());
-						assertEquals("http://www.jboss.com/services/TestService",serviceBinding.getAccessURI());
-					}
-				}
-			}
-			
-		} catch (JAXRException e) {
-			e.printStackTrace();
-			assertTrue(false);
-		} finally {
-			JAXRRegistryImpl.closeConnection(connection);
-		}
-    }
-	/**
 	 * 
 	 */
 	@SuppressWarnings("unchecked")
@@ -296,67 +127,6 @@
 		
 		
 	}
-	/**
-	 * Creates a Jaxr Organization with 1 or more services
-	 * 
-	 * @return
-	 * @throws JAXRException
-	 */
-	@SuppressWarnings("unused")
-	private Organization createOrganization(BusinessLifeCycleManager blm)
-			throws JAXRException {
-		Organization org = blm.createOrganization(blm.createInternationalString("USA -- JBOSS ORG"));
-		org.setDescription(blm.createInternationalString("JBoss Professional Open Source"));
-		
-		User user = blm.createUser();
-		org.setPrimaryContact(user);
-		PersonName personName = blm.createPersonName("Kurt Stam");
-		TelephoneNumber telephoneNumber = blm.createTelephoneNumber();
-		telephoneNumber.setNumber("404 467-8555");
-		telephoneNumber.setType(null);
-		PostalAddress address = blm.createPostalAddress("3340",
-				"Peachtree Road, NE, Suite 1200", "Atlanta", "GA", "USA",
-				"30326", "");
-		Collection<PostalAddress> postalAddresses = new ArrayList<PostalAddress>();
-		postalAddresses.add(address);
-		Collection<EmailAddress> emailAddresses = new ArrayList<EmailAddress>();
-		EmailAddress emailAddress = blm
-				.createEmailAddress("kurt.stam at jboss.org");
-		emailAddresses.add(emailAddress);
-
-		Collection<TelephoneNumber> numbers = new ArrayList<TelephoneNumber>();
-		numbers.add(telephoneNumber);
-		user.setPersonName(personName);
-		user.setPostalAddresses(postalAddresses);
-		user.setEmailAddresses(emailAddresses);
-		user.setTelephoneNumbers(numbers);
-
-		ClassificationScheme cScheme = getClassificationScheme(blm,
-				"ntis-gov:naics", "");
-		Key cKey = blm.createKey("uuid:C0B9FE13-324F-413D-5A5B-2004DB8E5CC2");
-		cScheme.setKey(cKey);
-		Classification classification = blm.createClassification(cScheme,
-				"Professional Open Source", "5415");
-		org.addClassification(classification);
-		ClassificationScheme cScheme1 = getClassificationScheme(blm, "D-U-N-S",
-				"");
-		Key cKey1 = blm.createKey("uuid:3367C81E-FF1F-4D5A-B202-3EB13AD02423");
-		cScheme1.setKey(cKey1);
-		ExternalIdentifier ei = blm.createExternalIdentifier(cScheme1,
-				"D-U-N-S number", "08-146-6849");
-		org.addExternalIdentifier(ei);
-		return org;
-	}
-
-	private ClassificationScheme getClassificationScheme(
-			BusinessLifeCycleManager blm, String str1, String str2)
-			throws JAXRException {
-		ClassificationScheme cs = blm.createClassificationScheme(blm
-				.createInternationalString(str1), blm
-				.createInternationalString(str2));
-		return cs;
-	}
-
 	
 	/**
 	 * Setup the database.

Modified: labs/jbossesb/trunk/product/etc/test/resources/jbossesb-unittest-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/etc/test/resources/jbossesb-unittest-properties.xml	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/etc/test/resources/jbossesb-unittest-properties.xml	2006-10-20 20:48:14 UTC (rev 6982)
@@ -37,6 +37,7 @@
     <properties name="registry">
     	<property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/>
     	<property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/>
+    	<property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.soa.esb.services.registry.JAXRRegistryImpl"/>
     	<property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
     	<property name="org.jboss.soa.esb.registry.user" value="jbossesb"/>
     	<property name="org.jboss.soa.esb.registry.password" value="password"/>

Modified: labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml	2006-10-20 20:02:47 UTC (rev 6981)
+++ labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml	2006-10-20 20:48:14 UTC (rev 6982)
@@ -37,6 +37,7 @@
     <properties name="registry">
     	<property name="org.jboss.soa.esb.registry.queryManagerURI" value="org.apache.juddi.registry.local.InquiryService#inquire"/>
     	<property name="org.jboss.soa.esb.registry.lifeCycleManagerURI" value="org.apache.juddi.registry.local.PublishService#publish"/>
+    	<property name="org.jboss.soa.esb.registry.implementationClass" value="org.jboss.soa.esb.services.registry.JAXRRegistryImpl"/>
     	<property name="org.jboss.soa.esb.registry.factoryClass" value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
     	<property name="org.jboss.soa.esb.registry.user" value="jbossesb"/>
     	<property name="org.jboss.soa.esb.registry.password" value="password"/>




More information about the jboss-svn-commits mailing list