You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by al...@apache.org on 2014/01/06 03:18:39 UTC

svn commit: r1555648 [9/13] - in /juddi/trunk: ./ docs/examples/auth/ juddi-client/src/main/java/org/apache/juddi/v3/client/config/ juddi-core-openjpa/ juddi-core/src/main/java/org/apache/juddi/api/impl/ juddi-core/src/main/java/org/apache/juddi/subscr...

Added: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerExternalTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerExternalTest.java?rev=1555648&view=auto
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerExternalTest.java (added)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerExternalTest.java Mon Jan  6 02:18:37 2014
@@ -0,0 +1,627 @@
+package org.apache.juddi.v3.tck;
+
+/*
+ * Copyright 2001-2009 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.
+ */
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Random;
+
+import javax.xml.ws.Endpoint;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.juddi.v3.client.config.UDDIClient;
+import org.apache.juddi.v3.client.transport.Transport;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+import org.uddi.v3_service.UDDISubscriptionPortType;
+
+import java.net.InetAddress;
+import java.util.Locale;
+import javax.xml.ws.BindingProvider;
+import org.apache.commons.net.PrintCommandListener;
+import org.apache.commons.net.pop3.POP3Client;
+import org.apache.commons.net.pop3.POP3MessageInfo;
+import org.apache.commons.net.pop3.POP3SClient;
+import static org.apache.juddi.v3.tck.TckBusiness.MARY_BUSINESS_XML;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Used only when running the TCK against a running UDDI server (could be something other than jUDDI)
+ * from the juddi-tck-runner application. The 'external' part is really managing about managing
+ * hostnames for callbacks, and for using an external smtp server for smtp based notifications
+ * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
+ */
+public class UDDI_090_SubscriptionListenerExternalTest {
+
+        private static Log logger = LogFactory.getLog(UDDI_090_SubscriptionListenerExternalTest.class);
+        private static UDDISubscriptionPortType subscriptionMary = null;
+        private static UDDIInquiryPortType inquiryMary = null;
+        private static TckTModel tckTModelMary = null;
+        private static TckBusiness tckBusinessMary = null;
+        private static TckBusinessService tckBusinessServiceMary = null;
+        private static TckSubscriptionListener tckSubscriptionListenerMary = null;
+        private static String hostname = null;
+        private static UDDISubscriptionPortType subscriptionJoe = null;
+        private static UDDIInquiryPortType inquiryJoe = null;
+        private static TckTModel tckTModelJoe = null;
+        private static TckBusiness tckBusinessJoe = null;
+        private static TckBusinessService tckBusinessServiceJoe = null;
+        private static TckSubscriptionListener tckSubscriptionListenerJoe = null;
+        private static Endpoint endPoint;
+        private static String authInfoJoe = null;
+        private static String authInfoMary = null;
+        private static UDDIClient manager;
+        private static String email = null;
+        private static Integer httpPort = 80;
+
+        @AfterClass
+        public static void stopManager() throws ConfigurationException {
+                tckTModelJoe.deleteCreatedTModels(authInfoJoe);
+                tckTModelMary.deleteCreatedTModels(authInfoMary);
+                manager.stop();
+                //shutting down the TCK SubscriptionListener
+                endPoint.stop();
+                endPoint = null;
+        }
+
+        @BeforeClass
+        public static void startManager() throws ConfigurationException {
+                try {
+                        httpPort = 9600 + new Random().nextInt(99);
+
+                        hostname = TckPublisher.getProperties().getProperty("bindaddress");
+                        if (hostname == null) {
+                                hostname = InetAddress.getLocalHost().getHostName();
+                        }
+
+                        //bring up the TCK SubscriptionListener
+                        String httpEndpoint = "http://" + hostname + ":" + httpPort + "/tcksubscriptionlistener";
+                        System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
+                        endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
+
+                        manager = new UDDIClient();
+                        manager.start();
+
+                        logger.debug("Getting auth tokens..");
+
+
+                        Transport transport = manager.getTransport();
+                        UDDISecurityPortType security = transport.getUDDISecurityService();
+                        authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                        authInfoMary = TckSecurity.getAuthToken(security, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
+                        Assert.assertNotNull(authInfoJoe);
+
+
+
+                        UDDIPublicationPortType publication = transport.getUDDIPublishService();
+                        inquiryJoe = transport.getUDDIInquiryService();
+                        subscriptionJoe = transport.getUDDISubscriptionService();
+                        if (!TckPublisher.isUDDIAuthMode()) {
+                                TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                                TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                                TckSecurity.setCredentials((BindingProvider) subscriptionJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                        }
+
+
+                        tckTModelJoe = new TckTModel(publication, inquiryJoe);
+                        tckBusinessJoe = new TckBusiness(publication, inquiryJoe);
+                        tckBusinessServiceJoe = new TckBusinessService(publication, inquiryJoe);
+                        tckSubscriptionListenerJoe = new TckSubscriptionListener(subscriptionJoe, publication);
+
+
+
+
+                        transport = manager.getTransport();
+                        publication = transport.getUDDIPublishService();
+                        inquiryMary = transport.getUDDIInquiryService();
+                        subscriptionMary = transport.getUDDISubscriptionService();
+                        if (!TckPublisher.isUDDIAuthMode()) {
+                                TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
+                                TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
+                                TckSecurity.setCredentials((BindingProvider) subscriptionJoe, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
+                        }
+
+
+                        tckTModelMary = new TckTModel(publication, inquiryMary);
+                        tckBusinessMary = new TckBusiness(publication, inquiryMary);
+                        tckBusinessServiceMary = new TckBusinessService(publication, inquiryMary);
+                        tckSubscriptionListenerMary = new TckSubscriptionListener(subscriptionMary, publication);
+
+                        email = TckPublisher.getProperties().getProperty("mail.to");
+
+                } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
+                        Assert.fail("Could not obtain authInfo token.");
+                }
+        }
+
+        @Test
+        public void joePublisherUpdate_HTTP_FIND_SERVICE() {
+                logger.info("joePublisherUpdate_HTTP_FIND_SERVICE");
+                try {
+                        TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                        String before = TckCommon.DumpAllServices(authInfoJoe, inquiryJoe);
+                        UDDISubscriptionListenerImpl.notifcationMap.clear();
+                        UDDISubscriptionListenerImpl.notificationCount = 0;
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        //Saving the binding template that will be called by the server for a subscription event
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the HTTP Listener Service
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, "uddi_data/subscriptionnotifier/listenerService.xml", httpPort, hostname);
+                        //Saving the HTTP Subscription
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, "uddi_data/subscriptionnotifier/subscription1.xml");
+                        //Changing the service we subscribed to "JoePublisherService"
+                        Thread.sleep(1000);
+                        logger.info("Updating Service ********** ");
+                        tckBusinessServiceJoe.updateJoePublisherService(authInfoJoe, "foo");
+                        logger.info("Waiting " + TckPublisher.getSubscriptionTimeout() + " seconds for delivery");
+                        //waiting up to 100 seconds for the listener to notice the change.
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                        }
+                        if (UDDISubscriptionListenerImpl.notificationCount == 0) {
+                                Assert.fail("No HttpNotification was sent");
+                        }
+                        Iterator<String> iterator = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
+                        boolean found = false;
+                        while (iterator.hasNext()) {
+                                String test = iterator.next();
+                                if (test.toLowerCase().contains("service one")) {
+                                        found = true;
+                                }
+                        }
+                        if (!found) {
+                                logger.warn("Test failed, dumping service list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllServices(authInfoJoe, inquiryJoe));
+                                //if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("<name xml:lang=\"en\">Service One</name>")) {
+                                Assert.fail("Notification does not contain the correct service");
+                        }
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, "uddi:uddi.joepublisher.com:subscriptionone");
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
+                }
+        }
+
+        /**
+         * gets all current messages from the mail server and returns return
+         * String is the body of each message
+         */
+        private static int fetchMail(String contains) {
+                /*if (args.length < 3)
+                 {
+                 System.err.println(
+                 "Usage: POP3Mail <pop3 server hostname> <username> <password> [TLS [true=implicit]]");
+                 System.exit(1);
+                 }*/
+                Properties properties = TckPublisher.getProperties();
+
+                String server = properties.getProperty("mail.host");
+                String username = properties.getProperty("mail.username");
+                String password = properties.getProperty("mail.password");
+
+                String proto = properties.getProperty("mail.secureProtocol");
+                boolean implicit = false;
+                try {
+                        implicit = Boolean.parseBoolean(properties.getProperty("mail.secureProtocol"));
+                } catch (Exception ex) {
+                }
+                POP3Client pop3;
+
+                if (proto != null) {
+                        logger.debug("Using secure protocol: " + proto);
+                        pop3 = new POP3SClient(proto, implicit);
+                } else {
+                        pop3 = new POP3Client();
+                }
+                logger.debug("Connecting to server " + server + " on " + pop3.getDefaultPort());
+
+                // We want to timeout if a response takes longer than 60 seconds
+                pop3.setDefaultTimeout(60000);
+
+                // suppress login details
+                pop3.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));
+
+                try {
+                        pop3.connect(server);
+                } catch (IOException e) {
+                        logger.error(e);
+                        Assert.fail("Could not connect to mail server." + e.getMessage());
+                }
+
+                try {
+                        if (!pop3.login(username, password)) {
+                                logger.error("Could not login to server.  Check password.");
+                                pop3.disconnect();
+
+                                Assert.fail("Could not connect to mail server. check password");
+                        }
+
+                        POP3MessageInfo[] messages = pop3.listMessages();
+
+                        if (messages == null) {
+                                logger.warn("Could not retrieve message list.");
+                                pop3.disconnect();
+                                return 0;
+                        } else if (messages.length == 0) {
+                                logger.info("No messages");
+                                pop3.logout();
+                                pop3.disconnect();
+                                return 0;
+                        }
+
+                        int ret = 0;
+                        for (POP3MessageInfo msginfo : messages) {
+                                /*BufferedReader reader = (BufferedReader) pop3.retrieveMessageTop(msginfo.number, 0);
+
+                                 if (reader == null) {
+                                 logger.error("Could not retrieve message header.");
+                                 pop3.disconnect();
+                                 return 0;
+                                 }*/
+                                //printMessageInfo(reader, msginfo.number);
+                                BufferedReader reader = (BufferedReader) pop3.retrieveMessage(msginfo.number);
+                                String line = "";
+                                StringBuilder sb = new StringBuilder();
+                                while ((line = reader.readLine()) != null) {
+                                        String lower = line.toLowerCase(Locale.ENGLISH);
+                                        sb.append(lower);
+                                }
+
+
+                                if (TckCommon.isDebug()) {
+                                        logger.info("Email contents: " + sb.toString());
+                                }
+                                if (sb.toString().contains(contains.toLowerCase())) {
+                                        ret++;
+                                        pop3.deleteMessage(msginfo.number);
+                                }
+                        }
+
+                        pop3.logout();
+                        pop3.disconnect();
+                        return ret;
+                } catch (IOException e) {
+                        logger.error(e);
+                        return 0;
+                }
+        }
+
+        @Test
+        public void joePublisher_SMTP_FIND_SERVICE() {
+                Assume.assumeNotNull(email);
+                logger.info("joePublisher_SMTP_FIND_SERVICE");
+                try {
+                        TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+
+                        String before = TckCommon.DumpAllServices(authInfoJoe, inquiryJoe);
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the SMTP Listener Service
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_SMTP_SERVICE_EXTERNAL_XML, 0, email);
+                        //Saving the SMTP Subscription
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_SMTP_XML);
+                        //Changing the service we subscribed to "JoePublisherService"
+                        Thread.sleep(1000);
+                        logger.info("Updating Service ********** ");
+
+                        tckBusinessServiceJoe.updateJoePublisherService(authInfoJoe, "foo");
+
+                        logger.info("Waiting " + TckPublisher.getSubscriptionTimeout() + " seconds for delivery");
+                        //waiting up to 100 seconds for the listener to notice the change.
+                        boolean received = false;
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                                System.out.print(".");
+                                if (fetchMail("Service One") > 0) {
+                                        logger.info("Received Email Notification");
+                                        received = true;
+                                        break;
+                                }
+                        }
+                        if (!received) {
+                                logger.warn("Test failed, dumping service list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllServices(authInfoJoe, inquiryJoe));
+                        }
+                        Assert.assertTrue("No email was received", received);
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_SMTP_KEY);
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
+                }
+        }
+
+        @Test
+        public void joePublisherUpdate_HTTP_FIND_BUSINESS() {
+                logger.info("joePublisherUpdate_HTTP_FIND_BUSINESS");
+                try {
+                        TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                        String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
+                        UDDISubscriptionListenerImpl.notifcationMap.clear();
+                        UDDISubscriptionListenerImpl.notificationCount = 0;
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the Listener Service
+                        logger.info("Saving Joe's callback endpoint ********** ");
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, "uddi_data/subscriptionnotifier/listenerService.xml", httpPort, hostname);
+                        //Saving the Subscription
+                        logger.info("Saving Joe's subscription********** ");
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, "uddi_data/subscriptionnotifier/subscription2.xml");
+
+                        logger.info("Clearing the WS inbox********** ");
+                        UDDISubscriptionListenerImpl.notifcationMap.clear();
+                        UDDISubscriptionListenerImpl.notificationCount = 0;
+                        Thread.sleep(1000);
+                        logger.info("Saving Mary's Business ********** ");
+                        tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
+                        logger.info("Waiting " + TckPublisher.getSubscriptionTimeout() + " seconds for delivery");
+                        //waiting up to 10 seconds for the listener to notice the change.
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                                System.out.print(".");
+                                if (UDDISubscriptionListenerImpl.notificationCount > 0) {
+                                }
+                        }
+                        logger.info("RX " + UDDISubscriptionListenerImpl.notificationCount + " notifications");
+                        Iterator<String> it = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
+                        boolean found = false;
+
+                        while (it.hasNext()) {
+                                String test = it.next();
+                                if (TckCommon.isDebug()) {
+                                        logger.info("Notification: " + test);
+                                }
+                                if (test.toLowerCase().contains("marybusinessone")) {
+                                        found = true;
+                                }
+                        }
+
+                        if (UDDISubscriptionListenerImpl.notificationCount == 0) {
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
+                                Assert.fail("No Notification was sent");
+                        }
+                        if (!found) {
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
+                                Assert.fail("Notification does not contain the correct service");
+                        }
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, "uddi:uddi.joepublisher.com:subscriptionone");
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
+                        tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
+                }
+        }
+
+        @Test
+        public void joePublisherUpdate_SMTP_FIND_BUSINESS() {
+                Assume.assumeNotNull(email);
+                logger.info("joePublisherUpdate_SMTP_FIND_BUSINESS");
+                try {
+                        TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                        String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the Listener Service
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_SMTP_SERVICE_EXTERNAL_XML, 0, email);
+
+                        //Saving the Subscription
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION2_SMTP_XML);
+
+
+                        Thread.sleep(3000);
+                        logger.info("Saving Mary's Business ********** ");
+                        tckBusinessMary.saveBusiness(authInfoMary, MARY_BUSINESS_XML, "uddi:uddi.marypublisher.com:marybusinessone");
+
+                        logger.info("Waiting " + TckPublisher.getSubscriptionTimeout() + " seconds for delivery");
+                        boolean received = false;
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                                if (fetchMail("marybusinessone") > 0) {
+                                        logger.info("Received Email Notification");
+                                        received = true;
+                                        break;
+                                }
+                        }
+                        if (!received) {
+                                logger.warn("Test failed, dumping before and after business list");
+                                logger.warn("Before " + before);
+                                logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
+                                Assert.fail("No email was received");
+                        }
+
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_SMTP_KEY);
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
+                        //      tckTModel.deleteJoePublisherTmodel(authInfoJoe);
+                        tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
+                }
+        }
+
+        //tmodel tests
+        @Test
+        public void joePublisherUpdate_HTTP_FIND_TMODEL() {
+                logger.info("joePublisherUpdate_HTTP_FIND_TMODEL");
+                TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                try {
+                        UDDISubscriptionListenerImpl.notifcationMap.clear();
+                        UDDISubscriptionListenerImpl.notificationCount = 0;
+                        String before = TckCommon.DumpAllTModels(authInfoJoe, inquiryJoe);
+
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the Listener Service
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML, httpPort, hostname);
+                        //Saving the Subscription
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
+                        //Changing the service we subscribed to "JoePublisherService"
+                        Thread.sleep(1000);
+                        logger.info("Deleting tModel ********** ");
+                        
+                        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, true);
+
+                        logger.info("Waiting " + TckPublisher.getSubscriptionTimeout() + " seconds for delivery");
+                        //waiting up to 100 seconds for the listener to notice the change.
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                                System.out.print(".");
+                                if (UDDISubscriptionListenerImpl.notificationCount > 0) {
+                                        logger.info("Received Notification");
+                                        break;
+                                }
+                        }
+                        if (UDDISubscriptionListenerImpl.notificationCount == 0) {
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllTModels(authInfoJoe, inquiryJoe));
+                                Assert.fail("No Notification was sent");
+                        }
+                        Iterator<String> it = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
+                        boolean found = false;
+                        while (it.hasNext()) {
+                                String test = it.next();
+                                if (test.contains("tModel One")) {
+                                        found = true;
+                                        break;
+                                }
+                        }
+                        if (!found) {
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllTModels(authInfoJoe, inquiryJoe));
+                                Assert.fail("Notification does not contain the correct service");
+                        }
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
+                        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
+                }
+        }
+
+        @Test
+        public void joePublisherUpdate_SMTP_FIND_TMODEL() {
+                Assume.assumeNotNull(email);
+                logger.info("joePublisherUpdate_SMTP_FIND_TMODEL");
+                TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                try {
+
+                        String before = TckCommon.DumpAllTModels(authInfoJoe, inquiryJoe);
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the Listener Service
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_SMTP_SERVICE_EXTERNAL_XML, 0, email);
+                        //Saving the Subscription
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_SMTP_XML);
+                        //Changing the service we subscribed to "JoePublisherService"
+                        Thread.sleep(1000);
+                        logger.info("Deleting tModel ********** ");
+                        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, true);
+
+                        logger.info("Waiting " + TckPublisher.getSubscriptionTimeout() + " seconds for delivery");
+                        boolean received = false;
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                                System.out.print(".");
+                                if (fetchMail("tModel One") > 0) {
+                                        logger.info("Received Email Notification");
+                                        received = true;
+                                        break;
+                                }
+                        }
+                        if (!received){
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllTModels(authInfoJoe, inquiryJoe));
+                                Assert.fail("No email was received");
+                        }
+                        
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_SMTP_KEY);
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
+                        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
+                }
+        }
+        //TODO If a subscriber specifies a maximum number of entries to be returned with a subscription and the amount of data to be returned exceeds this limit, or if the node determines based on its policy that there are too many entries to be returned in a single group, then the node SHOULD provide a chunkToken with results.  
+        //TODO  If no more results are pending, the value of the chunkToken MUST be "0".
+}

Modified: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java?rev=1555648&r1=1555647&r2=1555648&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java (original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java Mon Jan  6 02:18:37 2014
@@ -14,8 +14,10 @@ package org.apache.juddi.v3.tck;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+import java.io.File;
+import java.io.FileOutputStream;
 import java.util.Iterator;
-import java.util.List;
+import java.util.Properties;
 import java.util.Random;
 
 import javax.xml.ws.Endpoint;
@@ -23,299 +25,363 @@ import javax.xml.ws.Endpoint;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.juddi.v3.client.UDDIConstants;
+import org.apache.juddi.v3.client.Release;
 import org.apache.juddi.v3.client.config.UDDIClient;
 import org.apache.juddi.v3.client.transport.Transport;
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.uddi.api_v3.FindQualifiers;
-import org.uddi.api_v3.FindService;
-import org.uddi.api_v3.Name;
-import org.uddi.api_v3.ServiceList;
-import org.uddi.sub_v3.DeleteSubscription;
-import org.uddi.sub_v3.Subscription;
 import org.uddi.v3_service.UDDIInquiryPortType;
 import org.uddi.v3_service.UDDIPublicationPortType;
 import org.uddi.v3_service.UDDISecurityPortType;
 import org.uddi.v3_service.UDDISubscriptionPortType;
 
+import com.dumbster.smtp.SimpleSmtpServer;
+import com.dumbster.smtp.SmtpMessage;
+import java.net.InetAddress;
+import javax.xml.ws.BindingProvider;
+
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
 /**
+ * Used during the Maven build process for testing against jUDDI
+ *
  * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
+ * @see UDDI_090_SubscriptionListenerExternalTest
  */
 public class UDDI_090_SubscriptionListenerIntegrationTest {
 
-    private static Log logger = LogFactory.getLog(UDDI_090_SubscriptionListenerIntegrationTest.class);
-    private static TckTModel tckTModel = null;
-    private static TckBusiness tckBusiness = null;
-    private static TckBusinessService tckBusinessService = null;
-    private static TckSubscriptionListener tckSubscriptionListener = null;
-    private static Endpoint endPoint;
-    private static String authInfoJoe = null;
-    private static String authInfoMary = null;
-    private static UDDIClient manager;
-    private static Integer httpPort = 80;
-    private static UDDISubscriptionPortType subscription = null;
-    private static UDDIInquiryPortType inquiry=null;
-
-    @AfterClass
-    public static void stopManager() throws ConfigurationException {
-        manager.stop();
-        //shutting down the TCK SubscriptionListener
-        endPoint.stop();
-        endPoint = null;
-    }
-
-    @BeforeClass
-    public static void startManager() throws ConfigurationException {
-        try {
-            httpPort = 9600 + new Random().nextInt(99);
-
-            //bring up the TCK SubscriptionListener
-            String httpEndpoint = "http://localhost:" + httpPort + "/tcksubscriptionlistener";
-            System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
-            endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
-
-            manager = new UDDIClient();
-            manager.start();
-
-            logger.debug("Getting auth tokens..");
-
-
-            Transport transport = manager.getTransport();
-            UDDISecurityPortType security = transport.getUDDISecurityService();
-            authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
-            authInfoMary = TckSecurity.getAuthToken(security, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
-            Assert.assertNotNull(authInfoJoe);
-            subscription = transport.getUDDISubscriptionService();
-
-            UDDIPublicationPortType publication = transport.getUDDIPublishService();
-             inquiry = transport.getUDDIInquiryService();
-            tckTModel = new TckTModel(publication, inquiry);
-            tckBusiness = new TckBusiness(publication, inquiry);
-            tckBusinessService = new TckBusinessService(publication, inquiry);
-            tckSubscriptionListener = new TckSubscriptionListener(subscription, publication);
-
-        } catch (Exception e) {
-            logger.error(e.getMessage(), e);
-            Assert.fail("Could not obtain authInfo token.");
-        }
-    }
-
-    private void removeAllExistingSubscriptions(String authinfo) {
-        List<Subscription> subscriptions;
-        try {
-            subscriptions = subscription.getSubscriptions(authinfo);
-
-            DeleteSubscription ds = new DeleteSubscription();
-            ds.setAuthInfo(authinfo);
-            for (int i = 0; i < subscriptions.size(); i++) {
-                ds.getSubscriptionKey().add(subscriptions.get(i).getSubscriptionKey());
-            }
-            if (!subscriptions.isEmpty()) {
-                logger.info("Purging " + subscriptions.size() + " old subscriptions");
-                subscription.deleteSubscription(ds);
-            }
-        } catch (Exception ex) {
-            logger.warn("error clearing subscriptions", ex);
+        private static Log logger = LogFactory.getLog(UDDI_090_SubscriptionListenerIntegrationTest.class);
+        private static UDDISubscriptionPortType subscriptionMary = null;
+        private static UDDIInquiryPortType inquiryMary = null;
+        private static TckTModel tckTModelMary = null;
+        private static TckBusiness tckBusinessMary = null;
+        private static TckBusinessService tckBusinessServiceMary = null;
+        private static TckSubscriptionListener tckSubscriptionListenerMary = null;
+        private static String hostname = null;
+        private static UDDISubscriptionPortType subscriptionJoe = null;
+        private static UDDIInquiryPortType inquiryJoe = null;
+        private static UDDIPublicationPortType publicationMary = null;
+        private static UDDIPublicationPortType publicationJoe = null;
+        private static TckTModel tckTModelJoe = null;
+        private static TckBusiness tckBusinessJoe = null;
+        private static TckBusinessService tckBusinessServiceJoe = null;
+        private static TckSubscriptionListener tckSubscriptionListenerJoe = null;
+        private static Endpoint endPoint;
+        private static String authInfoJoe = null;
+        private static String authInfoMary = null;
+        private static UDDIClient manager;
+        private static SimpleSmtpServer mailServer;
+        private static Integer smtpPort = 25;
+        private static Integer httpPort = 80;
+
+        @AfterClass
+        public static void stopManager() throws ConfigurationException {
+                tckTModelJoe.deleteCreatedTModels(authInfoJoe);
+                tckTModelMary.deleteCreatedTModels(authInfoMary);
+                manager.stop();
+                //shutting down the TCK SubscriptionListener
+                endPoint.stop();
+                endPoint = null;
         }
-    }
 
-    @Test
-    public void joePublisherUpdateService_HTTP_FIND_SERVICE() {
-        logger.info("joePublisherUpdateService_HTTP_FIND_SERVICE");
-        try {
-            removeAllExistingSubscriptions(authInfoJoe);
-            UDDISubscriptionListenerImpl.notifcationMap.clear();
-            UDDISubscriptionListenerImpl.notificationCount = 0;
-            tckTModel.saveJoePublisherTmodel(authInfoJoe);
-            tckBusiness.saveJoePublisherBusiness(authInfoJoe);
-            //Saving the binding template that will be called by the server for a subscription event
-            tckBusinessService.saveJoePublisherService(authInfoJoe);
-            //Saving the HTTP Listener Service
-            tckSubscriptionListener.saveService(authInfoJoe, "uddi_data/subscriptionnotifier/listenerService.xml", httpPort);
-            //Saving the HTTP Subscription
-            tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, "uddi_data/subscriptionnotifier/subscription1.xml");
-            //Changing the service we subscribed to "JoePublisherService"
-            Thread.sleep(1000);
-            logger.info("Updating Service ********** ");
-            tckBusinessService.updateJoePublisherService(authInfoJoe, "foo");
-
-            //waiting up to 100 seconds for the listener to notice the change.
-            for (int i = 0; i < 200; i++) {
-                Thread.sleep(500);
-                System.out.print(".");
-                if (UDDISubscriptionListenerImpl.notificationCount > 0) {
-                    logger.info("Received HTTP Notification");
-                    break;
+        @BeforeClass
+        public static void startManager() throws ConfigurationException {
+                try {
+                        smtpPort = 9700 + new Random().nextInt(99);
+                        httpPort = 9600 + new Random().nextInt(99);
+                        Properties properties = new Properties();
+                        properties.setProperty("juddi.mail.smtp.host", "localhost");
+                        properties.setProperty("juddi.mail.smtp.port", String.valueOf(smtpPort));
+                        properties.setProperty("juddi.mail.smtp.from", "jUDDI@example.org");
+                        String version = Release.getRegistryVersion().replaceAll(".SNAPSHOT", "-SNAPSHOT");
+                        String curDir = System.getProperty("user.dir");
+                        if (!curDir.endsWith("uddi-tck")) {
+                                curDir += "/uddi-tck";
+                        }
+                        String path = curDir + "/target/juddi-tomcat-" + version + "/temp/";
+                        System.out.println("Saving jUDDI email properties to " + path);
+                        File tmpDir = new File(path);
+                        File tmpFile = new File(tmpDir + "/juddi-mail.properties");
+                        if (!tmpFile.createNewFile()) {
+                                tmpFile.delete();
+                                tmpFile.createNewFile();
+                        }
+                        properties.store(new FileOutputStream(tmpFile), "tmp email settings");
+
+                        hostname = InetAddress.getLocalHost().getHostName();
+                        //bring up the TCK SubscriptionListener
+                        String httpEndpoint = "http://" + hostname + ":" + httpPort + "/tcksubscriptionlistener";
+                        System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
+                        endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
+                        int count = 0;
+                        while (!endPoint.isPublished()) {
+                                httpPort = 9600 + new Random().nextInt(99);
+                                httpEndpoint = "http://" + hostname + ":" + httpPort + "/tcksubscriptionlistener";
+                                System.out.println("Bringing up SubscriptionListener endpoint at " + httpEndpoint);
+                                endPoint = Endpoint.publish(httpEndpoint, new UDDISubscriptionListenerImpl());
+                                count++;
+                                if (count > 10) {
+                                        Assert.fail("unable to bring up endpoint");
+                                }
+                        }
+
+                        manager = new UDDIClient();
+                        manager.start();
+
+                        logger.debug("Getting auth tokens..");
+
+
+                        Transport transport = manager.getTransport();
+                        UDDISecurityPortType security = transport.getUDDISecurityService();
+                        authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                        authInfoMary = TckSecurity.getAuthToken(security, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
+                        //Assert.assertNotNull(authInfoJoe);
+
+
+
+                        publicationJoe = transport.getUDDIPublishService();
+                        inquiryJoe = transport.getUDDIInquiryService();
+                        subscriptionJoe = transport.getUDDISubscriptionService();
+                        if (!TckPublisher.isUDDIAuthMode()) {
+                                TckSecurity.setCredentials((BindingProvider) publicationJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                                TckSecurity.setCredentials((BindingProvider) inquiryJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                                TckSecurity.setCredentials((BindingProvider) subscriptionJoe, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                        }
+
+
+                        tckTModelJoe = new TckTModel(publicationJoe, inquiryJoe);
+                        tckBusinessJoe = new TckBusiness(publicationJoe, inquiryJoe);
+                        tckBusinessServiceJoe = new TckBusinessService(publicationJoe, inquiryJoe);
+                        tckSubscriptionListenerJoe = new TckSubscriptionListener(subscriptionJoe, publicationJoe);
+
+
+
+
+                        transport = manager.getTransport();
+                        publicationMary = transport.getUDDIPublishService();
+                        inquiryMary = transport.getUDDIInquiryService();
+                        subscriptionMary = transport.getUDDISubscriptionService();
+                        if (!TckPublisher.isUDDIAuthMode()) {
+                                TckSecurity.setCredentials((BindingProvider) publicationMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
+                                TckSecurity.setCredentials((BindingProvider) inquiryMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
+                                TckSecurity.setCredentials((BindingProvider) subscriptionMary, TckPublisher.getMaryPublisherId(), TckPublisher.getMaryPassword());
+                        }
+
+
+                        tckTModelMary = new TckTModel(publicationMary, inquiryMary);
+                        tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
+
+                        tckBusinessMary = new TckBusiness(publicationMary, inquiryMary);
+                        tckBusinessServiceMary = new TckBusinessService(publicationMary, inquiryMary);
+                        tckSubscriptionListenerMary = new TckSubscriptionListener(subscriptionMary, publicationMary);
+
+                } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
+                        Assert.fail("Could not obtain authInfo token.");
                 }
-            }
-            if (UDDISubscriptionListenerImpl.notificationCount == 0) {
-                Assert.fail("No HttpNotification was sent");
-            }
-            if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("<name xml:lang=\"en\">Service One</name>")) {
-                Assert.fail("Notification does not contain the correct service");
-            }
-
-        } catch (Exception e) {
-            logger.error("No exceptions please.");
-            e.printStackTrace();
-
-            Assert.fail();
-        } finally {
-            tckSubscriptionListener.deleteNotifierSubscription(authInfoJoe, "uddi:uddi.joepublisher.com:subscriptionone");
-            tckBusinessService.deleteJoePublisherService(authInfoJoe);
-            tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
-            tckTModel.deleteJoePublisherTmodel(authInfoJoe);
         }
-    }
 
- //   @Test
-    public void joePublisherUpdateBusiness_HTTP_FIND_BUSINESS() {
-        logger.info("joePublisherUpdateBusiness_HTTP_FIND_BUSINESS");
-        try {
-            removeAllExistingSubscriptions(authInfoJoe);
-            DumpAllBusinesses();
-            Thread.sleep(5000);
-            UDDISubscriptionListenerImpl.notifcationMap.clear();
-            UDDISubscriptionListenerImpl.notificationCount = 0;
-            tckTModel.saveJoePublisherTmodel(authInfoJoe);
-            tckBusiness.saveJoePublisherBusiness(authInfoJoe);
-            tckBusinessService.saveJoePublisherService(authInfoJoe);
-            //Saving the Listener Service
-            logger.info("Saving Joe's callback endpoint ********** ");
-            tckSubscriptionListener.saveService(authInfoJoe, "uddi_data/subscriptionnotifier/listenerService.xml", httpPort);
-            //Saving the Subscription
-            logger.info("Saving Joe's subscription********** ");
-            tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, "uddi_data/subscriptionnotifier/subscription2.xml");
-            //Changing the service we subscribed to "JoePublisherService"
-            DumpAllBusinesses();
-            logger.info("Clearing the inbox********** ");
-            UDDISubscriptionListenerImpl.notifcationMap.clear();
-            UDDISubscriptionListenerImpl.notificationCount = 0;
-            Thread.sleep(2000);
-            logger.info("Saving Mary's Business ********** ");
-            tckBusiness.saveMaryPublisherBusiness(authInfoMary);
-            DumpAllBusinesses();
-            //waiting up to 10 seconds for the listener to notice the change.
-            String test = "";
-            for (int i = 0; i < 20; i++) {
-                Thread.sleep(500);
-                System.out.print(".");
-                if (UDDISubscriptionListenerImpl.notificationCount > 0) {
-                    //logger.info("Received Notification");
-                    //break;
-                } else {
-                    System.out.print(test);
+        @Test
+        public void joePublisherUpdate_HTTP_FIND_SERVICE() {
+                logger.info("joePublisherUpdate_HTTP_FIND_SERVICE");
+                try {
+                        TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                        String before = TckCommon.DumpAllServices(authInfoJoe, inquiryJoe);
+                        UDDISubscriptionListenerImpl.notifcationMap.clear();
+                        UDDISubscriptionListenerImpl.notificationCount = 0;
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        //Saving the binding template that will be called by the server for a subscription event
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the HTTP Listener Service
+                        logger.info("sanity check, this shouldn't be the rmi file " + TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML);
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML, httpPort, hostname);
+                        //Saving the HTTP Subscription
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, "uddi_data/subscriptionnotifier/subscription1.xml");
+                        //Changing the service we subscribed to "JoePublisherService"
+                        Thread.sleep(1000);
+                        logger.info("Updating Service ********** ");
+                        tckBusinessServiceJoe.updateJoePublisherService(authInfoJoe, "foo");
+
+                        //waiting up to 100 seconds for the listener to notice the change.
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                                System.out.print(".");
+                                if (UDDISubscriptionListenerImpl.notificationCount > 0) {
+                                        logger.info("Received HTTP Notification");
+                                        break;
+                                }
+                        }
+                        Iterator<String> iterator = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
+                        boolean found = false;
+                        while (iterator.hasNext()) {
+                                String test = iterator.next();
+                                if (test.toLowerCase().contains("service one")) {
+                                        found = true;
+                                }
+                        }
+                        if (!found) {
+                                logger.warn("Test failed, dumping service list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllServices(authInfoJoe, inquiryJoe));
+                                //if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("<name xml:lang=\"en\">Service One</name>")) {
+                                Assert.fail("Notification does not contain the correct service");
+                        }
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, "uddi:uddi.joepublisher.com:subscriptionone");
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
                 }
-            }
-            logger.info("RX " + UDDISubscriptionListenerImpl.notificationCount + " notifications");
-            Iterator<String> it = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
-            while (it.hasNext())
-            {
-                logger.info("Notification: " + it.next());
-            }
-            DumpAllBusinesses();
-            if (UDDISubscriptionListenerImpl.notificationCount == 0) {
-                Assert.fail("No Notification was sent");
-            }
-            if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("uddi:uddi.marypublisher.com:marybusinessone")) {
-                Assert.fail("Notification does not contain the correct service");
-            }
-
-        } catch (Exception e) {
-            logger.error("No exceptions please.");
-            e.printStackTrace();
-
-            Assert.fail();
-        } finally {
-            tckSubscriptionListener.deleteNotifierSubscription(authInfoJoe, "uddi:uddi.joepublisher.com:subscriptionone");
-            tckBusinessService.deleteJoePublisherService(authInfoJoe);
-            tckTModel.deleteJoePublisherTmodel(authInfoJoe);
-            tckBusiness.deleteMaryPublisherBusiness(authInfoMary);
         }
-    }
 
-    private static void DumpAllBusinesses() {
-        logger.warn("Dumping the business/service list for debugging");
-        FindService fs = new FindService();
-        fs.setFindQualifiers(new FindQualifiers());
-        fs.getFindQualifiers().getFindQualifier().add(UDDIConstants.APPROXIMATE_MATCH);
-        fs.getName().add(new Name("%", null));
-        try {
-            ServiceList findService = inquiry.findService(fs);
-            if (findService.getServiceInfos() == null) {
-                logger.warn("NO SERVICES RETURNED!");
-            } else {
-                for (int i = 0; i < findService.getServiceInfos().getServiceInfo().size(); i++) {
-                    logger.warn(findService.getServiceInfos().getServiceInfo().get(i).getName().get(0).getValue() + " lang="
-                            + findService.getServiceInfos().getServiceInfo().get(i).getName().get(0).getLang() + " "
-                            + findService.getServiceInfos().getServiceInfo().get(i).getServiceKey() + " "
-                            + findService.getServiceInfos().getServiceInfo().get(i).getBusinessKey());
+        
+        @Test
+        public void joePublisherUpdate_HTTP_FIND_BUSINESS() {
+                logger.info("joePublisherUpdate_HTTP_FIND_BUSINESS");
+                try {
+                        TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                        TckCommon.DeleteBusiness(TckBusiness.MARY_BUSINESS_KEY, authInfoMary, publicationMary);
+                        String before = TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe);
+                        Thread.sleep(5000);
+                        UDDISubscriptionListenerImpl.notifcationMap.clear();
+                        UDDISubscriptionListenerImpl.notificationCount = 0;
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the Listener Service
+                        logger.info("sanity check, this shouldn't be the rmi file " + TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML);
+                        logger.info("Saving Joe's callback endpoint ********** ");
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML, httpPort, hostname);
+                        //Saving the Subscription
+                        logger.info("Saving Joe's subscription********** ");
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, "uddi_data/subscriptionnotifier/subscription2.xml");
+                        //Changing the service we subscribed to "JoePublisherService"
+
+                        logger.info("Clearing the inbox********** ");
+                        UDDISubscriptionListenerImpl.notifcationMap.clear();
+                        UDDISubscriptionListenerImpl.notificationCount = 0;
+                        Thread.sleep(2000);
+                        logger.info("Saving Mary's Business ********** ");
+                        tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
+
+                        //waiting up to 10 seconds for the listener to notice the change.
+
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                                System.out.print(".");
+                                //if (UDDISubscriptionListenerImpl.notificationCount > 0) {
+
+                                //}
+                        }
+                        logger.info("RX " + UDDISubscriptionListenerImpl.notificationCount + " notifications");
+                        Iterator<String> it = UDDISubscriptionListenerImpl.notifcationMap.values().iterator();
+                        boolean found = false;
+                        while (it.hasNext()) {
+                                String msg = it.next();
+                                if (TckCommon.isDebug()) {
+                                        logger.info("Notification: " + msg);
+                                }
+                                if (msg.toLowerCase().contains("mary")) {
+                                        found = true;
+                                }
+
+                        }
+                        if (UDDISubscriptionListenerImpl.notificationCount == 0) {
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
+                                Assert.fail("No Notification was sent");
+                        }
+                        if (!found) {
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe, inquiryJoe));
+                                Assert.fail("Notification does not contain the correct service");
+                        }
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, "uddi:uddi.joepublisher.com:subscriptionone");
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
+                        TckCommon.DeleteBusiness(TckBusiness.MARY_BUSINESS_KEY, authInfoMary, publicationMary);
+                        //tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
                 }
-            }
-        } catch (Exception ex) {
-            ex.printStackTrace();
         }
-    }
 
-    //tmodel tests
-    //@Test
-    public void joePublisherUpdateBusiness_HTTP_FIND_TMODEL() {
-        logger.info("joePublisherUpdateBusiness_HTTP_FIND_TMODEL");
-        removeAllExistingSubscriptions(authInfoJoe);
-        try {
-            UDDISubscriptionListenerImpl.notifcationMap.clear();
-            UDDISubscriptionListenerImpl.notificationCount = 0;
-            tckTModel.saveJoePublisherTmodel(authInfoJoe);
-            tckTModel.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
-            tckBusiness.saveJoePublisherBusiness(authInfoJoe);
-            tckBusinessService.saveJoePublisherService(authInfoJoe);
-            //Saving the Listener Service
-            tckSubscriptionListener.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML, httpPort);
-            //Saving the Subscription
-            tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
-            //Changing the service we subscribed to "JoePublisherService"
-            Thread.sleep(1000);
-            logger.info("Deleting tModel ********** ");
-            tckTModel.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY);
-
-            //waiting up to 100 seconds for the listener to notice the change.
-            String test = "";
-            for (int i = 0; i < 200; i++) {
-                Thread.sleep(500);
-                System.out.print(".");
-                if (UDDISubscriptionListenerImpl.notificationCount > 0) {
-                    logger.info("Received Notification");
-                    break;
-                } else {
-                    System.out.print(test);
+        
+        //tmodel tests
+        @Test
+        public void joePublisherUpdate_HTTP_FIND_TMODEL() {
+                logger.info("joePublisherUpdate_HTTP_FIND_TMODEL");
+                TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                try {
+                        UDDISubscriptionListenerImpl.notifcationMap.clear();
+                        UDDISubscriptionListenerImpl.notificationCount = 0;
+                        String before=TckCommon.DumpAllTModels(authInfoJoe, inquiryJoe);
+                        tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
+                        tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the Listener Service
+                        logger.info("sanity check, this shouldn't be the rmi file " + TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML);
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML, httpPort, hostname);
+                        //Saving the Subscription
+                        tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_XML);
+                        //Changing the service we subscribed to "JoePublisherService"
+                        Thread.sleep(1000);
+                        logger.info("Deleting tModel ********** ");
+                        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY);
+
+                        //waiting up to 100 seconds for the listener to notice the change.
+
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++) {
+                                Thread.sleep(1000);
+                                System.out.print(".");
+                                if (UDDISubscriptionListenerImpl.notificationCount > 0) {
+                                        logger.info("Received Notification");
+                                        break;
+                                }
+                        }
+                        
+                        if (UDDISubscriptionListenerImpl.notificationCount == 0) {
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllTModels(authInfoJoe, inquiryJoe));
+                                Assert.fail("No Notification was sent");
+                        }
+                        if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("<name xml:lang=\"en\">tModel One</name>")) {
+                                Assert.fail("Notification does not contain the correct service");
+                        }
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
+                        tckBusinessServiceJoe.deleteJoePublisherService(authInfoJoe);
+                        tckBusinessJoe.deleteJoePublisherBusiness(authInfoJoe);
+                        tckTModelJoe.deleteJoePublisherTmodel(authInfoJoe);
+                        tckTModelJoe.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
                 }
-            }
-            if (UDDISubscriptionListenerImpl.notificationCount == 0) {
-                Assert.fail("No Notification was sent");
-            }
-            if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("<name xml:lang=\"en\">tModel One</name>")) {
-                Assert.fail("Notification does not contain the correct service");
-            }
-
-        } catch (Exception e) {
-            logger.error("No exceptions please.");
-            e.printStackTrace();
-
-            Assert.fail();
-        } finally {
-            tckSubscriptionListener.deleteNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_KEY);
-            tckBusinessService.deleteJoePublisherService(authInfoJoe);
-            tckBusiness.deleteJoePublisherBusiness(authInfoJoe);
-            tckTModel.deleteJoePublisherTmodel(authInfoJoe);
-            tckTModel.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
         }
-    }
 
-    //TODO If a subscriber specifies a maximum number of entries to be returned with a subscription and the amount of data to be returned exceeds this limit, or if the node determines based on its policy that there are too many entries to be returned in a single group, then the node SHOULD provide a chunkToken with results.  
-    
-    
-    //TODO  If no more results are pending, the value of the chunkToken MUST be "0".
+        
+        //TODO If a subscriber specifies a maximum number of entries to be returned with a subscription and the amount of data to be returned exceeds 
+//this limit, or if the node determines based on its policy that there are too many entries to be returned in a single group, 
+        //then the node SHOULD provide a chunkToken with results.  
+        //TODO  If no more results are pending, the value of the chunkToken MUST be "0".
 }

Modified: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java?rev=1555648&r1=1555647&r2=1555648&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java (original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_110_FindBusinessIntegrationTest.java Mon Jan  6 02:18:37 2014
@@ -14,8 +14,8 @@ package org.apache.juddi.v3.tck;
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 import java.util.List;
+import javax.xml.ws.BindingProvider;
 
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
@@ -37,115 +37,115 @@ import org.uddi.v3_service.UDDISecurityP
 
 /**
  * Test to verify JUDDI-398
- * 
+ *
  * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
+ * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
  */
-public class UDDI_110_FindBusinessIntegrationTest 
-{
-	final static String TOM_PUBLISHER_TMODEL_XML      = "uddi_data/tompublisher/tModelKeyGen.xml";
-	final static String TOM_PUBLISHER_TMODEL01_XML 	  = "uddi_data/tompublisher/tModel01.xml";
-	final static String TOM_PUBLISHER_TMODEL02_XML 	  = "uddi_data/tompublisher/tModel02.xml";
-
-	final static String TOM_PUBLISHER_TMODEL_KEY      = "uddi:uddi.tompublisher.com:keygenerator";
-	final static String TOM_PUBLISHER_TMODEL01_KEY      = "uddi:uddi.tompublisher.com:tmodeltest01";
-	final static String TOM_PUBLISHER_TMODEL01_NAME 	= "tmodeltest01";
-	final static String TOM_PUBLISHER_TMODEL02_KEY      = "uddi:uddi.tompublisher.com:tmodeltest02";
-
-	final static String TOM_BUSINESS_XML        = "uddi_data/tompublisher/businessEntity.xml";
-    final static String TOM_BUSINESS_KEY        = "uddi:uddi.tompublisher.com:businesstest01";
-	
-    final static String TOM_PUBLISHER_SERVICEINFO_NAME = "servicetest01";
-    
-    private static Log logger = LogFactory.getLog(UDDI_040_BusinessServiceIntegrationTest.class);
-	
-	protected static TckTModel tckTModel               = null;
-	protected static TckTModel tckTModel01             = null;
-	protected static TckTModel tckTModel02             = null;	
-	
-	protected static TckBusiness tckBusiness           = null;
-	
-	protected static String authInfoJoe               = null;
-	
-	private static UDDIInquiryPortType inquiry = null;
-	private static UDDIClient manager;
-
-	@AfterClass
-	public static void stopManager() throws ConfigurationException {
-		manager.stop();
-	}
-	
-	@BeforeClass
-	public static void startManager() throws ConfigurationException {
-		manager  = new UDDIClient();
-		manager.start();
-		
-		logger.debug("Getting auth tokens..");
-		try {
-			 Transport transport = manager.getTransport();
-        	 UDDISecurityPortType security = transport.getUDDISecurityService();
-        	 authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(),  TckPublisher.getJoePassword());
-        	 Assert.assertNotNull(authInfoJoe);
-        	 UDDIPublicationPortType publication = transport.getUDDIPublishService();
-        	 inquiry = transport.getUDDIInquiryService();
-        	 
-        	 tckTModel  = new TckTModel(publication, inquiry);
-        	 tckTModel01 = new TckTModel(publication, inquiry);
-        	 tckTModel02 = new TckTModel(publication, inquiry);
-        	 tckBusiness = new TckBusiness(publication, inquiry);
-        	  
-	     } catch (Exception e) {
-	    	 logger.error(e.getMessage(), e);
-				Assert.fail("Could not obtain authInfo token.");
-	     } 
-	}
-	
-	@Test
-	public void findBusinessByTModelBag() {
-		try {
-			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
-			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
-			tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
-			
-			tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS_XML, TOM_BUSINESS_KEY, 1);
-			
-			try {
-				int size = 0;
-				BusinessList bl = null;
-	
-				FindBusiness fbb = new FindBusiness();
-				TModelBag tmb = new TModelBag();
-				tmb.getTModelKey().add(TOM_PUBLISHER_TMODEL01_KEY);
-				fbb.setTModelBag(tmb);
-				bl = inquiry.findBusiness(fbb);
-				size = bl.getBusinessInfos().getBusinessInfo().size();
-				if (size != 1) {
-					Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
-							+ "found " + size);
-				} else {
-					List<BusinessInfo> biList = bl.getBusinessInfos().getBusinessInfo();
-					if (biList.get(0).getServiceInfos().getServiceInfo().size() != 2) {
-						Assert.fail("Should have found two ServiceInfos");
-					} else {
-							List<ServiceInfo> siList = biList.get(0).getServiceInfos().getServiceInfo();
-							ServiceInfo si = siList.get(0);
-							if (!TOM_PUBLISHER_SERVICEINFO_NAME.equals(si.getName().get(0).getValue())) {
-								Assert.fail("Should have found " + TOM_PUBLISHER_TMODEL01_NAME + " as the "
-										+ "ServiceInfo name, found " + si.getName().get(0).getValue());
-							}
-					}
-				}
-			} catch (Exception e) {
-				e.printStackTrace();
-				Assert.fail(e.getMessage());
-			}
-		} finally {
-			tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS_XML, TOM_BUSINESS_KEY, 1);
-			
-			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
-			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
-			tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
-
-		}
-	}
-	
+public class UDDI_110_FindBusinessIntegrationTest {
+
+        final static String TOM_PUBLISHER_TMODEL_XML = "uddi_data/tompublisher/tModelKeyGen.xml";
+        final static String TOM_PUBLISHER_TMODEL01_XML = "uddi_data/tompublisher/tModel01.xml";
+        final static String TOM_PUBLISHER_TMODEL02_XML = "uddi_data/tompublisher/tModel02.xml";
+        final static String TOM_PUBLISHER_TMODEL_KEY = "uddi:uddi.tompublisher.com:keygenerator";
+        final static String TOM_PUBLISHER_TMODEL01_KEY = "uddi:uddi.tompublisher.com:tmodeltest01";
+        final static String TOM_PUBLISHER_TMODEL01_NAME = "tmodeltest01";
+        final static String TOM_PUBLISHER_TMODEL02_KEY = "uddi:uddi.tompublisher.com:tmodeltest02";
+        final static String TOM_BUSINESS_XML = "uddi_data/tompublisher/businessEntity.xml";
+        final static String TOM_BUSINESS_KEY = "uddi:uddi.tompublisher.com:businesstest01";
+        final static String TOM_PUBLISHER_SERVICEINFO_NAME = "servicetest01";
+        private static Log logger = LogFactory.getLog(UDDI_040_BusinessServiceIntegrationTest.class);
+        protected static TckTModel tckTModel = null;
+        protected static TckTModel tckTModel01 = null;
+        protected static TckTModel tckTModel02 = null;
+        protected static TckBusiness tckBusiness = null;
+        protected static String authInfoJoe = null;
+        private static UDDIInquiryPortType inquiry = null;
+        private static UDDIClient manager;
+
+        @AfterClass
+        public static void stopManager() throws ConfigurationException {
+                tckTModel.deleteCreatedTModels(authInfoJoe);
+                tckTModel01.deleteCreatedTModels(authInfoJoe);
+                tckTModel02.deleteCreatedTModels(authInfoJoe);
+                manager.stop();
+        }
+
+        @BeforeClass
+        public static void startManager() throws ConfigurationException {
+                manager = new UDDIClient();
+                manager.start();
+
+                logger.debug("Getting auth tokens..");
+                try {
+                        Transport transport = manager.getTransport();
+                        UDDISecurityPortType security = transport.getUDDISecurityService();
+                        authInfoJoe = TckSecurity.getAuthToken(security, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                        //Assert.assertNotNull(authInfoJoe);
+                        
+                        UDDIPublicationPortType publication = transport.getUDDIPublishService();
+                        inquiry = transport.getUDDIInquiryService();
+                        if (!TckPublisher.isUDDIAuthMode()){
+                                TckSecurity.setCredentials((BindingProvider) publication, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                                TckSecurity.setCredentials((BindingProvider) inquiry, TckPublisher.getJoePublisherId(), TckPublisher.getJoePassword());
+                        }
+
+                        tckTModel = new TckTModel(publication, inquiry);
+                        tckTModel01 = new TckTModel(publication, inquiry);
+                        tckTModel02 = new TckTModel(publication, inquiry);
+                        tckBusiness = new TckBusiness(publication, inquiry);
+
+                } catch (Exception e) {
+                        logger.error(e.getMessage(), e);
+                        Assert.fail("Could not obtain authInfo token.");
+                }
+        }
+
+        @Test
+        public void findBusinessByTModelBag() {
+                try {
+                        tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+                        tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+                        tckTModel.saveTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+                        tckBusiness.saveBusinesses(authInfoJoe, TOM_BUSINESS_XML, TOM_BUSINESS_KEY, 1);
+
+                        try {
+                                int size = 0;
+                                BusinessList bl = null;
+
+                                FindBusiness fbb = new FindBusiness();
+                                TModelBag tmb = new TModelBag();
+                                tmb.getTModelKey().add(TOM_PUBLISHER_TMODEL01_KEY);
+                                fbb.setTModelBag(tmb);
+                                bl = inquiry.findBusiness(fbb);
+                                size = bl.getBusinessInfos().getBusinessInfo().size();
+                                if (size != 1) {
+                                        Assert.fail("Should have found one entry on FindBusiness with TModelBag, "
+                                                + "found " + size);
+                                } else {
+                                        List<BusinessInfo> biList = bl.getBusinessInfos().getBusinessInfo();
+                                        if (biList.get(0).getServiceInfos().getServiceInfo().size() != 2) {
+                                                Assert.fail("Should have found two ServiceInfos");
+                                        } else {
+                                                List<ServiceInfo> siList = biList.get(0).getServiceInfos().getServiceInfo();
+                                                ServiceInfo si = siList.get(0);
+                                                if (!TOM_PUBLISHER_SERVICEINFO_NAME.equals(si.getName().get(0).getValue())) {
+                                                        Assert.fail("Should have found " + TOM_PUBLISHER_TMODEL01_NAME + " as the "
+                                                                + "ServiceInfo name, found " + si.getName().get(0).getValue());
+                                                }
+                                        }
+                                }
+                        } catch (Exception e) {
+                                e.printStackTrace();
+                                Assert.fail(e.getMessage());
+                        }
+                } finally {
+                        tckBusiness.deleteBusinesses(authInfoJoe, TOM_BUSINESS_XML, TOM_BUSINESS_KEY, 1);
+
+                        tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL_XML, TOM_PUBLISHER_TMODEL_KEY);
+                        tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL01_XML, TOM_PUBLISHER_TMODEL01_KEY);
+                        tckTModel.deleteTModel(authInfoJoe, TOM_PUBLISHER_TMODEL02_XML, TOM_PUBLISHER_TMODEL02_KEY);
+
+                }
+        }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org
For additional commands, e-mail: commits-help@juddi.apache.org