Return-Path: X-Original-To: apmail-juddi-commits-archive@www.apache.org Delivered-To: apmail-juddi-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9C45410037 for ; Fri, 30 Aug 2013 02:23:43 +0000 (UTC) Received: (qmail 14568 invoked by uid 500); 30 Aug 2013 02:23:42 -0000 Delivered-To: apmail-juddi-commits-archive@juddi.apache.org Received: (qmail 14528 invoked by uid 500); 30 Aug 2013 02:23:42 -0000 Mailing-List: contact commits-help@juddi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@juddi.apache.org Received: (qmail 14520 invoked by uid 99); 30 Aug 2013 02:23:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Aug 2013 02:23:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 30 Aug 2013 02:23:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 2B47223889BF; Fri, 30 Aug 2013 02:23:13 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1518882 [2/2] - in /juddi/trunk: ./ juddi-client.net/juddi-client.net/Properties/ juddi-client/src/main/java/org/apache/juddi/v3/client/ juddi-client/src/main/java/org/apache/juddi/v3/client/config/ juddi-core-openjpa/src/test/resources/ j... Date: Fri, 30 Aug 2013 02:23:12 -0000 To: commits@juddi.apache.org From: alexoree@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20130830022313.2B47223889BF@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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=1518882&r1=1518881&r2=1518882&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 Fri Aug 30 02:23:11 2013 @@ -39,393 +39,473 @@ import org.uddi.v3_service.UDDISubscript import com.dumbster.smtp.SimpleSmtpServer; import com.dumbster.smtp.SmtpMessage; +import java.rmi.RemoteException; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.apache.juddi.v3.client.UDDIConstants; +import static org.apache.juddi.v3.tck.TckBusiness.MARY_BUSINESS_XML; +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.DispositionReportFaultMessage; /** * @author Tom Cunningham */ -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 UDDIClient manager; - private static SimpleSmtpServer mailServer; - private static Integer smtpPort = 25; - private static Integer httpPort = 80; - - @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 { - 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"); - - //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()); - Assert.assertNotNull(authInfoJoe); - UDDISubscriptionPortType subscription = transport.getUDDISubscriptionService(); - - UDDIPublicationPortType publication = transport.getUDDIPublishService(); - UDDIInquiryPortType 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."); - } - } - - @Test - public void joePublisherUpdateService_HTTP_FIND_SERVICE() { - try { - - 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, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML, httpPort); - //Saving the HTTP Subscription - tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_XML); +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 SimpleSmtpServer mailServer; + private static Integer smtpPort = 25; + 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 { + 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"); + + //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 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); + } + } + + @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"); - + 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; - } - } - if (UDDISubscriptionListenerImpl.notificationCount == 0) { - Assert.fail("No HttpNotification was sent"); - } - if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("Service One")) { - 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); - } - } - - @Test - public void joePublisherUpdateService_SMTP_FIND_SERVICE() { - try { - mailServer = SimpleSmtpServer.start(smtpPort); - - 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 SMTP Listener Service - tckSubscriptionListener.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_SMTP_SERVICE_XML, 0); - //Saving the SMTP Subscription - tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_SMTP_XML); + for (int i = 0; i < 200; i++) { + Thread.sleep(500); + System.out.print("."); + if (UDDISubscriptionListenerImpl.notificationCount > 0) { + logger.info("Received HTTP Notification"); + break; + } + } + if (UDDISubscriptionListenerImpl.notificationCount == 0) { + Assert.fail("No HttpNotification was sent"); + } + if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("Service One")) { + 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 joePublisherUpdateService_SMTP_FIND_SERVICE() { + logger.info("joePublisherUpdateService_SMTP_FIND_SERVICE"); + try { + removeAllExistingSubscriptions(authInfoJoe); + // if (mailServer != null && !mailServer.isStopped()) { + // mailServer.stop(); + // } + mailServer = SimpleSmtpServer.start(smtpPort); + + 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 SMTP Listener Service + tckSubscriptionListener.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_SMTP_SERVICE_XML, 0); + //Saving the SMTP Subscription + tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_SMTP_XML); //Changing the service we subscribed to "JoePublisherService" - Thread.sleep(1000); - logger.info("Updating Service ********** "); - tckBusinessService.updateJoePublisherService(authInfoJoe, "foo"); - + 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 (mailServer.getReceivedEmailSize() > 0) { - logger.info("Received Email Notification"); - break; - } - } - if (mailServer.getReceivedEmailSize() == 0) { - Assert.fail("No SmtpNotification was sent"); - } - @SuppressWarnings("rawtypes") - Iterator emailIter = mailServer.getReceivedEmail(); - SmtpMessage email = (SmtpMessage)emailIter.next(); - System.out.println("Subject:" + email.getHeaderValue("Subject")); - System.out.println("Body:" + email.getBody()); - if (!email.getBody().contains("Service One")) { - 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_SMTP_KEY); - tckBusinessService.deleteJoePublisherService(authInfoJoe); - tckBusiness.deleteJoePublisherBusiness(authInfoJoe); - tckTModel.deleteJoePublisherTmodel(authInfoJoe); - mailServer.stop(); - } - } - - - - //@Test - public void joePublisherUpdateBusiness_HTTP_FIND_BUSINESS() { - try { - tckTModel.saveJoePublisherTmodel(authInfoJoe); - 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.SUBSCRIPTION2_XML); - //Changing the service we subscribed to "JoePublisherService" - Thread.sleep(1000); - logger.info("Deleting Business ********** "); - tckBusiness.deleteJoePublisherBusiness(authInfoJoe); - + for (int i = 0; i < 200; i++) { + Thread.sleep(500); + System.out.print("."); + if (mailServer.getReceivedEmailSize() > 0) { + logger.info("Received Email Notification"); + break; + } + } + if (mailServer.getReceivedEmailSize() == 0) { + Assert.fail("No SmtpNotification was sent"); + } + @SuppressWarnings("rawtypes") + Iterator emailIter = mailServer.getReceivedEmail(); + SmtpMessage email = (SmtpMessage) emailIter.next(); + System.out.println("Subject:" + email.getHeaderValue("Subject")); + System.out.println("Body:" + email.getBody()); + if (!email.getBody().replace("=", "").contains("Service One")) { + 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_SMTP_KEY); + tckBusinessService.deleteJoePublisherService(authInfoJoe); + tckBusiness.deleteJoePublisherBusiness(authInfoJoe); + tckTModel.deleteJoePublisherTmodel(authInfoJoe); + mailServer.stop(); + } + } + + @Test + public void joePublisherUpdateBusiness_HTTP_FIND_BUSINESS() { + logger.info("joePublisherUpdateBusiness_HTTP_FIND_BUSINESS"); + try { + removeAllExistingSubscriptions(authInfoJoe); + UDDISubscriptionListenerImpl.notifcationMap.clear(); + UDDISubscriptionListenerImpl.notificationCount = 0; + tckTModel.saveJoePublisherTmodel(authInfoJoe); + tckBusiness.saveJoePublisherBusiness(authInfoJoe); + tckBusinessService.saveJoePublisherService(authInfoJoe); + //Saving the Listener Service + tckSubscriptionListener.saveService(authInfoJoe, "uddi_data/subscriptionnotifier/listenerService.xml", httpPort); + //Saving the Subscription + tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, "uddi_data/subscriptionnotifier/subscription2.xml"); + //Changing the service we subscribed to "JoePublisherService" + Thread.sleep(1000); + logger.info("Saving Mary's Business ********** "); + tckBusiness.saveMaryPublisherBusiness(authInfoMary); + //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); - } - } - if (UDDISubscriptionListenerImpl.notificationCount == 0) { - Assert.fail("No Notification was sent"); - } - if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("Service One")) { - 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); - tckTModel.deleteJoePublisherTmodel(authInfoJoe); - } - } - - //@Test - public void joePublisherUpdateBusiness_SMTP_FIND_BUSINESS() { - try { - mailServer = SimpleSmtpServer.start(smtpPort); - tckTModel.saveJoePublisherTmodel(authInfoJoe); - tckBusiness.saveJoePublisherBusiness(authInfoJoe); - tckBusinessService.saveJoePublisherService(authInfoJoe); - //Saving the Listener Service - tckSubscriptionListener.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_SMTP_SERVICE_XML, 0); - //tckSubscriptionListener.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML, httpPort); - //Saving the Subscription - tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION2_SMTP_XML); - //tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_XML); - //Changing the service we subscribed to "JoePublisherService" - Thread.sleep(1000); - logger.info("Deleting Business ********** "); - tckBusiness.deleteJoePublisherBusiness(authInfoJoe); - - for (int i=0; i<200; i++) { - Thread.sleep(500); - System.out.print("."); - if (mailServer.getReceivedEmailSize() > 0) { - logger.info("Received Email Notification"); - break; - } - } - if (mailServer.getReceivedEmailSize() == 0) { - Assert.fail("No SmtpNotification was sent"); - } - @SuppressWarnings("rawtypes") - Iterator emailIter = mailServer.getReceivedEmail(); - SmtpMessage email = (SmtpMessage)emailIter.next(); - System.out.println("Subject:" + email.getHeaderValue("Subject")); - System.out.println("Body:" + email.getBody()); - if (!email.getBody().contains("Service One")) { - 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_SMTP_KEY); - tckBusinessService.deleteJoePublisherService(authInfoJoe); - tckBusiness.deleteJoePublisherBusiness(authInfoJoe); - tckTModel.deleteJoePublisherTmodel(authInfoJoe); - tckTModel.deleteJoePublisherTmodel(authInfoJoe); - mailServer.stop(); - } - } - - - - - - //tmodel tests - //@Test - public void joePublisherUpdateBusiness_HTTP_FIND_TMODEL() { - try { - 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); - + 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); + } + } + if (UDDISubscriptionListenerImpl.notificationCount == 0) { + Assert.fail("No Notification was sent"); + } + if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("uddi:uddi.marypublisher.com:marybusinessone")) { + DumpAllBusinesses(); + 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() { + + 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() + " " + + findService.getServiceInfos().getServiceInfo().get(i).getServiceKey() + " " + + findService.getServiceInfos().getServiceInfo().get(i).getBusinessKey()); + } + } + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + @Test + public void joePublisherUpdateBusiness_SMTP_FIND_BUSINESS() { + logger.info("joePublisherUpdateBusiness_SMTP_FIND_BUSINESS"); + try { + removeAllExistingSubscriptions(authInfoJoe); + // if (mailServer != null && !mailServer.isStopped()) { + // mailServer.stop(); + // } + mailServer = SimpleSmtpServer.start(smtpPort); + tckTModel.saveJoePublisherTmodel(authInfoJoe); + tckBusiness.saveJoePublisherBusiness(authInfoJoe); + tckBusinessService.saveJoePublisherService(authInfoJoe); + //Saving the Listener Service + tckSubscriptionListener.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_SMTP_SERVICE_XML, 0); + //tckSubscriptionListener.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML, httpPort); + //Saving the Subscription + tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION2_SMTP_XML); + //tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION_XML); + + Thread.sleep(3000); + logger.info("Saving Mary's Business ********** "); + tckBusiness.saveBusiness(authInfoMary, MARY_BUSINESS_XML, "uddi:uddi.marypublisher.com:marybusinessone"); + + for (int i = 0; i < 200; i++) { + Thread.sleep(500); + System.out.print("."); + if (mailServer.getReceivedEmailSize() > 0) { + logger.info("Received Email Notification"); + break; + } + } + if (mailServer.getReceivedEmailSize() == 0) { + Assert.fail("No SmtpNotification was sent"); + } + @SuppressWarnings("rawtypes") + Iterator emailIter = mailServer.getReceivedEmail(); + SmtpMessage email = (SmtpMessage) emailIter.next(); + System.out.println("Subject:" + email.getHeaderValue("Subject")); + System.out.println("Body:" + email.getBody()); + if (!email.getBody().replaceAll("=", "").contains("uddi:uddi.marypublisher.com:marybusinessone")) { + DumpAllBusinesses(); + 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_SMTP_KEY); + tckBusinessService.deleteJoePublisherService(authInfoJoe); + tckBusiness.deleteJoePublisherBusiness(authInfoJoe); + tckTModel.deleteJoePublisherTmodel(authInfoJoe); + // tckTModel.deleteJoePublisherTmodel(authInfoJoe); + tckBusiness.deleteMaryPublisherBusiness(authInfoMary); + mailServer.stop(); + } + } + + //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); - } - } - if (UDDISubscriptionListenerImpl.notificationCount == 0) { - Assert.fail("No Notification was sent"); - } - if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("tModel One")) { - 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); - } - } - - //@Test - public void joePublisherUpdateBusiness_SMTP_FIND_TMODEL() { - try { - mailServer = SimpleSmtpServer.start(smtpPort); - - 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_SMTP_SERVICE_XML, 0); - //Saving the Subscription - tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_SMTP_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); - - - for (int i=0; i<200; i++) { - Thread.sleep(500); - System.out.print("."); - if (mailServer.getReceivedEmailSize() > 0) { - logger.info("Received Email Notification"); - break; - } - } - if (mailServer.getReceivedEmailSize() == 0) { - Assert.fail("No SmtpNotification was sent"); - } - @SuppressWarnings("rawtypes") - Iterator emailIter = mailServer.getReceivedEmail(); - SmtpMessage email = (SmtpMessage)emailIter.next(); - System.out.println("Subject:" + email.getHeaderValue("Subject")); - System.out.println("Body:" + email.getBody()); - if (!email.getBody().contains("tModel One")) { - 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_SMTP_KEY); - tckBusinessService.deleteJoePublisherService(authInfoJoe); - tckBusiness.deleteJoePublisherBusiness(authInfoJoe); - tckTModel.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3); - tckTModel.deleteJoePublisherTmodel(authInfoJoe); - mailServer.stop(); - } - } - - + 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); + } + } + if (UDDISubscriptionListenerImpl.notificationCount == 0) { + Assert.fail("No Notification was sent"); + } + if (!UDDISubscriptionListenerImpl.notifcationMap.get(0).contains("tModel One")) { + 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); + } + } + + //@Test + public void joePublisherUpdateBusiness_SMTP_FIND_TMODEL() { + logger.info("joePublisherUpdateBusiness_SMTP_FIND_TMODEL"); + removeAllExistingSubscriptions(authInfoJoe); + try { + if (mailServer != null && !mailServer.isStopped()) { + mailServer.stop(); + } + mailServer = SimpleSmtpServer.start(smtpPort); + + 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_SMTP_SERVICE_XML, 0); + //Saving the Subscription + tckSubscriptionListener.saveNotifierSubscription(authInfoJoe, TckSubscriptionListener.SUBSCRIPTION3_SMTP_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); + + + for (int i = 0; i < 200; i++) { + Thread.sleep(500); + System.out.print("."); + if (mailServer.getReceivedEmailSize() > 0) { + logger.info("Received Email Notification"); + break; + } + } + if (mailServer.getReceivedEmailSize() == 0) { + Assert.fail("No SmtpNotification was sent"); + } + @SuppressWarnings("rawtypes") + Iterator emailIter = mailServer.getReceivedEmail(); + SmtpMessage email = (SmtpMessage) emailIter.next(); + System.out.println("Subject:" + email.getHeaderValue("Subject")); + System.out.println("Body:" + email.getBody()); + if (!email.getBody().contains("tModel One")) { + 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_SMTP_KEY); + tckBusinessService.deleteJoePublisherService(authInfoJoe); + tckBusiness.deleteJoePublisherBusiness(authInfoJoe); + tckTModel.deleteTModel(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_SUBSCRIPTION3_TMODEL_KEY, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3); + tckTModel.deleteJoePublisherTmodel(authInfoJoe); + mailServer.stop(); + } + } } Modified: juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_141_JIRAIntegrationTest.java URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_141_JIRAIntegrationTest.java?rev=1518882&r1=1518881&r2=1518882&view=diff ============================================================================== --- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_141_JIRAIntegrationTest.java (original) +++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_141_JIRAIntegrationTest.java Fri Aug 30 02:23:11 2013 @@ -14,8 +14,6 @@ */ package org.apache.juddi.v3.tck; -import java.net.Inet4Address; -import java.util.AbstractList; import java.util.ArrayList; import java.util.Calendar; import java.util.GregorianCalendar; @@ -37,6 +35,7 @@ import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.uddi.api_v3.*; +import org.uddi.sub_v3.DeleteSubscription; import org.uddi.sub_v3.Subscription; import org.uddi.sub_v3.SubscriptionFilter; import org.uddi.v3_service.UDDIInquiryPortType; @@ -770,6 +769,28 @@ public class UDDI_141_JIRAIntegrationTes } + + + + private void removeAllExistingSubscriptions(String authinfo) { + List 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); + } + } + /** * //testing upper case subscription callbacks * @@ -777,10 +798,13 @@ public class UDDI_141_JIRAIntegrationTes */ @Test public void JIRA_597() throws Exception { + System.out.println("JIRA_597"); + int port = 4444; String localhostname = java.net.InetAddress.getLocalHost().getHostName(); UDDISubscriptionListenerImpl impl = new UDDISubscriptionListenerImpl(); + removeAllExistingSubscriptions(authInfoJoe); UDDISubscriptionListenerImpl.notifcationMap.clear(); UDDISubscriptionListenerImpl.notificationCount = 0; Endpoint ep = null; @@ -864,6 +888,8 @@ public class UDDI_141_JIRAIntegrationTes Thread.sleep(1000); maxwait = maxwait - 1000; } + removeAllExistingSubscriptions(authInfoJoe); + ep.stop(); if (UDDISubscriptionListenerImpl.notifcationMap.isEmpty()) { Assert.fail("no callbacks were recieved."); } @@ -872,7 +898,9 @@ public class UDDI_141_JIRAIntegrationTes } /** - * testing callbacks with underfined transport type + * testing callbacks with undefined transport type with a uppercase path + * this also tests the case of one user subscribing to a specific entity + * via GetBusinessDetail subscription filter * * @throws Exception */ @@ -880,10 +908,12 @@ public class UDDI_141_JIRAIntegrationTes public void JIRA_596() throws Exception { System.out.println("JIRA_596"); int port = 4444; - String localhostname = java.net.InetAddress.getLocalHost().getHostName(); + String localhostname = "localhost";//java.net.InetAddress.getLocalHost().getHostName(); + removeAllExistingSubscriptions(authInfoJoe); UDDISubscriptionListenerImpl impl = new UDDISubscriptionListenerImpl(); UDDISubscriptionListenerImpl.notifcationMap.clear(); UDDISubscriptionListenerImpl.notificationCount = 0; + Endpoint ep = null; boolean ok = false; do { @@ -908,17 +938,16 @@ public class UDDI_141_JIRAIntegrationTes bt.setAccessPoint(new AccessPoint()); bt.getAccessPoint().setValue("http://" + localhostname + ":" + port + "/UDDI_CALLBACK"); bt.getAccessPoint().setUseType("endPoint"); - //Added per Kurt + //obmitted as part of the jira test case /*TModelInstanceInfo instanceInfo = new TModelInstanceInfo(); instanceInfo.setTModelKey("uddi:uddi.org:transport:http"); bt.setTModelInstanceDetails(new TModelInstanceDetails()); bt.getTModelInstanceDetails().getTModelInstanceInfo().add(instanceInfo); */ bs.getBindingTemplates().getBindingTemplate().add(bt); - - bs.getBindingTemplates().getBindingTemplate().add(bt); be.getBusinessServices().getBusinessService().add(bs); sb.getBusinessEntity().add(be); + logger.info("setting up joe's callback business"); BusinessDetail saveBusiness = publication.saveBusiness(sb); //ok Joe's callback is setup @@ -930,6 +959,7 @@ public class UDDI_141_JIRAIntegrationTes be.getName().add(new Name()); be.getName().get(0).setValue("Sam's business"); sb.getBusinessEntity().add(be); + logger.info("saving sam's business"); BusinessDetail saveBusiness1 = publication.saveBusiness(sb); //ok Joe now needs to subscribe for Sam's business @@ -948,6 +978,7 @@ public class UDDI_141_JIRAIntegrationTes s.setNotificationInterval(df.newDuration(5000)); list.value.add(s); + logger.info("subscribing joe's to updates for sam's business"); subscription.saveSubscription(authInfoJoe, list); //ok have sam change his business around. @@ -956,7 +987,9 @@ public class UDDI_141_JIRAIntegrationTes be = saveBusiness1.getBusinessEntity().get(0); be.getName().get(0).setLang("en"); sb.getBusinessEntity().add(be); + logger.info("altering sam's business"); publication.saveBusiness(sb); + logger.info("Waiting..."); int maxwait = 30000; while (maxwait > 0) { if (UDDISubscriptionListenerImpl.notifcationMap.size() > 0) { @@ -965,10 +998,14 @@ public class UDDI_141_JIRAIntegrationTes Thread.sleep(1000); maxwait = maxwait - 1000; } + removeAllExistingSubscriptions(authInfoJoe); + ep.stop(); if (UDDISubscriptionListenerImpl.notifcationMap.isEmpty()) { + logger.error("no callbacks were recieved"); Assert.fail("no callbacks were recieved."); } - + logger.info("callback response was " + UDDISubscriptionListenerImpl.notifcationMap.get(0)); + logger.info("PASS"); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@juddi.apache.org For additional commands, e-mail: commits-help@juddi.apache.org