juddi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexo...@apache.org
Subject svn commit: r1564123 - in /juddi/trunk: juddi-core/src/main/java/org/apache/juddi/subscription/notify/ uddi-tck-runner/ uddi-tck/ uddi-tck/src/test/java/org/apache/juddi/v3/tck/
Date Mon, 03 Feb 2014 23:12:33 GMT
Author: alexoree
Date: Mon Feb  3 23:12:33 2014
New Revision: 1564123

URL: http://svn.apache.org/r1564123
Log:
JUDDI-242 adding smtp and http delivery test for getTModelDetails (tck runner). smtp tests
should be more reliable now with proper decoding

Modified:
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
    juddi/trunk/uddi-tck-runner/tck.properties
    juddi/trunk/uddi-tck/pom.xml
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerExternalTest.java

Modified: juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
URL: http://svn.apache.org/viewvc/juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java?rev=1564123&r1=1564122&r2=1564123&view=diff
==============================================================================
--- juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
(original)
+++ juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
Mon Feb  3 23:12:33 2014
@@ -140,7 +140,8 @@ public class SMTPNotifier implements Not
 				message.setFrom(new InternetAddress(getEMailProperties().getProperty("mail.smtp.from",
"jUDDI")));
 				//maybe nice to use a template rather then sending raw xml.
 				String subscriptionResultXML = JAXBMarshaller.marshallToString(body, JAXBMarshaller.PACKAGE_SUBSCR_RES);
-				message.setText(subscriptionResultXML, "UTF-8");
+				//message.setText(subscriptionResultXML, "UTF-8");
+                                message.setContent(subscriptionResultXML, "text/xml; charset=UTF-8;");
 				message.setSubject("UDDI Subscription Notification for subscription " 
 						+ body.getSubscriptionResultsList().getSubscription().getSubscriptionKey());
 				Transport.send(message);

Modified: juddi/trunk/uddi-tck-runner/tck.properties
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck-runner/tck.properties?rev=1564123&r1=1564122&r2=1564123&view=diff
==============================================================================
--- juddi/trunk/uddi-tck-runner/tck.properties (original)
+++ juddi/trunk/uddi-tck-runner/tck.properties Mon Feb  3 23:12:33 2014
@@ -35,7 +35,7 @@ vsv.enabled = false
 sub.enabled=true
 
 #subscription callback timeouts, in seconds
-sub.timeout=60
+sub.timeout=15
 
 #does the UDDI server support the Custody Transfer API?
 transfer.enabled=true
@@ -49,14 +49,15 @@ smtp.notify.enabled=true
 
 
 #if true, use these settings to verify message delivery/notification
-mail.host=localhost
-mail.port=110
-#this can be TLS
-#mail.secureProtocol=TLS
-#mail.implicit=false
-mail.username=juddi@local.domain
-mail.password=da_password1
-mail.to=juddi@local.domain
+mail.pop3.host=localhost
+mail.pop3.port=110
+#mail.pop3.socketFactory.class
+#mail.pop3.socketFactory.fallback
+#mail.pop3.socketFactory.port
+mail.pop3.username=juddi@local.domain
+mail.pop3.password=da_password1
+#tell UDDI to send alerts to this address
+mail.pop3.to=juddi@local.domain
 
 # for UDDI server callbacks (subscription api, value set validation)
 # use this to override the bind to address, by default it's the hostname of the computer
running the tests from

Modified: juddi/trunk/uddi-tck/pom.xml
URL: http://svn.apache.org/viewvc/juddi/trunk/uddi-tck/pom.xml?rev=1564123&r1=1564122&r2=1564123&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/pom.xml (original)
+++ juddi/trunk/uddi-tck/pom.xml Mon Feb  3 23:12:33 2014
@@ -92,6 +92,22 @@
 			<artifactId>commons-net</artifactId>
 			<version>3.3</version>
 		</dependency>
+		<dependency>
+			<groupId>javax.mail</groupId>
+			<artifactId>mail</artifactId>
+			<version>1.4.7</version>
+		</dependency>
+		<dependency>
+			<groupId>commons-codec</groupId>
+			<artifactId>commons-codec</artifactId>
+			<version>1.9</version>
+		</dependency>
+   		<dependency>
+			<groupId>org.apache.commons</groupId>
+			<artifactId>commons-email</artifactId>
+			<version>1.3.2</version>
+		</dependency>
+					
 	</dependencies>
 	<build>
 		<plugins>

Modified: 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=1564123&r1=1564122&r2=1564123&view=diff
==============================================================================
--- juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerExternalTest.java
(original)
+++ juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerExternalTest.java
Mon Feb  3 23:12:33 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.BufferedInputStream;
 import java.io.BufferedReader;
 import java.io.IOException;
+import java.io.InputStream;
 import java.io.PrintWriter;
 import java.util.Iterator;
 import java.util.Properties;
@@ -35,11 +37,23 @@ import org.uddi.v3_service.UDDISubscript
 
 import java.net.InetAddress;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.List;
 import java.util.Locale;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.mail.Flags;
+import javax.mail.Folder;
+import javax.mail.Message;
+import javax.mail.Session;
+import javax.mail.Store;
+import javax.mail.internet.MimeMessage;
 import javax.xml.datatype.DatatypeFactory;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Holder;
+import org.apache.commons.codec.net.QuotedPrintableCodec;
+import org.apache.commons.mail.util.MimeMessageParser;
+//import org.apache.commons.io.IOUtils;
 import org.apache.commons.net.PrintCommandListener;
 import org.apache.commons.net.pop3.POP3Client;
 import org.apache.commons.net.pop3.POP3MessageInfo;
@@ -49,23 +63,28 @@ import org.junit.AfterClass;
 import org.junit.Assert;
 import org.junit.Assume;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.uddi.api_v3.BusinessEntity;
+import org.uddi.api_v3.Description;
 import org.uddi.api_v3.GetBusinessDetail;
+import org.uddi.api_v3.GetTModelDetail;
 import org.uddi.api_v3.Name;
 import org.uddi.api_v3.SaveBusiness;
+import org.uddi.api_v3.SaveTModel;
+import org.uddi.api_v3.TModel;
 import org.uddi.sub_v3.DeleteSubscription;
 import org.uddi.sub_v3.Subscription;
 import org.uddi.sub_v3.SubscriptionFilter;
 
 /**
- * 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 
- * hostnames for callbacks, and for using an external smtp server for smtp based notifications.<br><br>
- * WARNING, when adding changes to this class, you MUST always add the corresponding functions.<br><br>
+ * 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 hostnames for callbacks, and for using an
+ * external smtp server for smtp based notifications.<br><br>
+ * WARNING, when adding changes to this class, you MUST always add the
+ * corresponding functions.<br><br>
  * to UDDI_090_SubscriptionListenerIntegrationTest
- * 
+ *
  * @see UDDI_090_SubscriptionListenerIntegrationTest
  * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
  * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
@@ -124,13 +143,11 @@ public class UDDI_090_SubscriptionListen
 
                         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());
 
-                        
                         UDDIPublicationPortType publication = transport.getUDDIPublishService();
                         inquiryJoe = transport.getUDDIInquiryService();
                         subscriptionJoe = transport.getUDDISubscriptionService();
@@ -140,15 +157,11 @@ public class UDDI_090_SubscriptionListen
                                 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();
                         publicationMary = publication;
@@ -160,13 +173,12 @@ public class UDDI_090_SubscriptionListen
                                 TckSecurity.setCredentials((BindingProvider) subscriptionMary,
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");
+                        email = TckPublisher.getProperties().getProperty("mail.pop3.to");
 
                 } catch (Exception e) {
                         logger.error(e.getMessage(), e);
@@ -232,109 +244,96 @@ public class UDDI_090_SubscriptionListen
         }
 
         /**
-         * gets all current messages from the mail server and returns return
+         * gets all current messages from the mail server and returns the number
+         * of messages containing the string, messages containing the string are deleted
from the mail server
          * String is the body of each message
+         * @return number of matching and deleted messages
+         * @param contains a string to search for
          */
         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);
+                //final String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory";
 
-                // 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);
+                /* Set the mail properties */
+                Properties properties = TckPublisher.getProperties();
+                // Set manual Properties
 
-                                 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);
+                int found = 0;
+                Session session = Session.getDefaultInstance(properties, null);
+                Store store = null;
+                try {
+                        store = session.getStore("pop3");
+
+                        store.connect(properties.getProperty("mail.pop3.host"), Integer.parseInt(properties.getProperty("mail.pop3.port",
"110")), properties.getProperty("mail.pop3.username"), properties.getProperty("mail.pop3.password"));
+                        /* Mention the folder name which you want to read. */
+                        // inbox = store.getDefaultFolder();
+                        // inbox = inbox.getFolder("INBOX");
+                        Folder inbox = store.getFolder("INBOX");
+
+                        /* Open the inbox using store. */
+                        inbox.open(Folder.READ_WRITE);
+
+                        Message messages[] = inbox.getMessages();
+
+                        for (int i = 0; i < messages.length; i++) {
+
+                                MimeMessageParser p = new MimeMessageParser(new MimeMessage(session,
messages[i].getInputStream()));
+                                Enumeration allHeaders = p.getMimeMessage().getAllHeaders();
+                                while (allHeaders.hasMoreElements()) {
+                                        Object j = allHeaders.nextElement();
+                                        if (j instanceof javax.mail.Header) {
+                                                javax.mail.Header msg = (javax.mail.Header)
j;
+                                                logger.info("XML as message header is " +
msg.getValue());
+                                                if (msg.getValue().contains(contains)) {
+                                                        //found it
+                                                        messages[i].setFlag(Flags.Flag.DELETED,
true);
+                                                        found++;
+                                                }
+                                        }
+                                }
+                                for (int k = 0; k < p.getAttachmentList().size(); k++)
{
+                                        InputStream is = p.getAttachmentList().get((k)).getInputStream();
+                                        QuotedPrintableCodec qp = new QuotedPrintableCodec();
+                                        // If "is" is not already buffered, wrap a BufferedInputStream
+                                        // around it.
+                                        if (!(is instanceof BufferedInputStream)) {
+                                                is = new BufferedInputStream(is);
+                                        }
+                                        int c;
+                                        StringBuilder sb = new StringBuilder();
+                                        System.out.println("Message : ");
+                                        while ((c = is.read()) != -1) {
+                                                sb.append(c);
+                                                System.out.write(c);
+                                        }
+                                        is.close();
+                                        String decoded = qp.decode(sb.toString());
+                                        logger.info("decode message is " + decoded);
+                                        if (decoded.contains(contains)) {
+                                                //found it
+                                                messages[i].setFlag(Flags.Flag.DELETED, true);
+                                                found++;
+                                        }
                                 }
 
+                        }
+                        inbox.close(true);
 
-                                if (TckCommon.isDebug()) {
-                                        logger.info("Email contents: " + sb.toString());
-                                }
-                                if (sb.toString().contains(contains.toLowerCase())) {
-                                        ret++;
-                                        pop3.deleteMessage(msginfo.number);
+                } catch (Exception ex) {
+                        ex.printStackTrace();
+                } finally {
+                        if (store != null) {
+                                try {
+                                        store.close();
+                                } catch (Exception ex) {
                                 }
                         }
-
-                        pop3.logout();
-                        pop3.disconnect();
-                        return ret;
-                } catch (IOException e) {
-                        logger.error(e);
-                        return 0;
                 }
+                return found;
         }
 
+        
+  
         @Test
         public void joePublisher_SMTP_FIND_SERVICE() {
                 Assume.assumeNotNull(email);
@@ -480,7 +479,6 @@ public class UDDI_090_SubscriptionListen
                         //Saving the Subscription
                         tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe,
TckSubscriptionListener.SUBSCRIPTION2_SMTP_XML);
 
-
                         Thread.sleep(3000);
                         logger.info("Saving Mary's tModel ********** ");
                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
@@ -504,7 +502,6 @@ public class UDDI_090_SubscriptionListen
                                 Assert.fail("No email was received");
                         }
 
-
                 } catch (Exception e) {
                         logger.error("No exceptions please.");
                         e.printStackTrace();
@@ -541,7 +538,7 @@ public class UDDI_090_SubscriptionListen
                         //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");
@@ -622,13 +619,12 @@ public class UDDI_090_SubscriptionListen
                                         break;
                                 }
                         }
-                        if (!received){
+                        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.");
@@ -645,21 +641,18 @@ public class UDDI_090_SubscriptionListen
         }
         //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".
-        
-        
-        
-        
+
         /**
-         * getBusiness tests
-         * joe want's updates on mary's business
-         * @throws Exception 
+         * getBusiness tests joe want's updates on mary's business
+         *
+         * @throws Exception
          */
         @Test
         //@Ignore
-        public void joePublisherUpdate_HTTP_GET_BUSINESS_DETAIL() throws Exception{
+        public void joePublisherUpdate_HTTP_GET_BUSINESS_DETAIL() throws Exception {
                 logger.info("joePublisherUpdate_HTTP_GET_BUSINESS_DETAIL");
                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
-                Holder<List<Subscription>> holder=null;
+                Holder<List<Subscription>> holder = null;
                 try {
                         UDDISubscriptionListenerImpl.notifcationMap.clear();
                         UDDISubscriptionListenerImpl.notificationCount = 0;
@@ -667,10 +660,10 @@ public class UDDI_090_SubscriptionListen
 
                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
-                        
+
                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
-                        
+
                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
                         //Saving the Listener Service
@@ -684,22 +677,22 @@ public class UDDI_090_SubscriptionListen
                         sub.setSubscriptionFilter(new SubscriptionFilter());
                         sub.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail());
                         sub.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey().add(TckBusiness.MARY_BUSINESS_KEY);
-                        
+
                         holder.value.add(sub);
                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe,
TckSubscriptionListener.SUBSCRIPTION3_XML);
                         //Changing the service we subscribed to "JoePublisherService"
                         Thread.sleep(1000);
                         logger.info("updating Mary's business ********** ");
-                        updatePublisherBusiness(authInfoMary,saveMaryPublisherBusiness, publicationMary);
-                        
+                        updatePublisherBusiness(authInfoMary, saveMaryPublisherBusiness,
publicationMary);
+
                         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.warn("Test failed, dumping business list");
                                 logger.warn("BEFORE " + before);
@@ -737,28 +730,26 @@ public class UDDI_090_SubscriptionListen
                         subscriptionJoe.deleteSubscription(ds);
                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
-                        
+
                         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);
-                        
+
                 }
         }
 
-       
-        
-                /**
-         * getBusiness tests
-         * joe want's updates on mary's business
-         * @throws Exception 
+        /**
+         * getBusiness tests joe want's updates on mary's business
+         *
+         * @throws Exception
          */
         @Test
         //@Ignore
-        public void joePublisherUpdate_SMTP_GET_BUSINESS_DETAIL() throws Exception{
+        public void joePublisherUpdate_SMTP_GET_BUSINESS_DETAIL() throws Exception {
                 logger.info("joePublisherUpdate_SMTP_GET_BUSINESS_DETAIL");
                 TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
-                Holder<List<Subscription>> holder=null;
+                Holder<List<Subscription>> holder = null;
                 try {
                         UDDISubscriptionListenerImpl.notifcationMap.clear();
                         UDDISubscriptionListenerImpl.notificationCount = 0;
@@ -766,10 +757,10 @@ public class UDDI_090_SubscriptionListen
 
                         tckTModelJoe.saveJoePublisherTmodel(authInfoJoe);
                         tckTModelJoe.saveTModels(authInfoJoe, TckTModel.JOE_PUBLISHER_TMODEL_XML_SUBSCRIPTION3);
-                        
+
                         tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
                         BusinessEntity saveMaryPublisherBusiness = tckBusinessMary.saveMaryPublisherBusiness(authInfoMary);
-                        
+
                         tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
                         tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
                         //Saving the Listener Service
@@ -783,28 +774,28 @@ public class UDDI_090_SubscriptionListen
                         sub.setSubscriptionFilter(new SubscriptionFilter());
                         sub.getSubscriptionFilter().setGetBusinessDetail(new GetBusinessDetail());
                         sub.getSubscriptionFilter().getGetBusinessDetail().getBusinessKey().add(TckBusiness.MARY_BUSINESS_KEY);
-                        
+
                         holder.value.add(sub);
                         subscriptionJoe.saveSubscription(authInfoJoe, holder);
                         //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe,
TckSubscriptionListener.SUBSCRIPTION3_XML);
                         //Changing the service we subscribed to "JoePublisherService"
                         Thread.sleep(1000);
                         logger.info("updating Mary's business ********** ");
-                        updatePublisherBusiness(authInfoMary,saveMaryPublisherBusiness, publicationMary);
-                        
+                        updatePublisherBusiness(authInfoMary, saveMaryPublisherBusiness,
publicationMary);
+
                         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("tModel One") > 0) {
+                                if (fetchMail("Updated Name") > 0) {
                                         logger.info("Received Email Notification");
                                         received = true;
                                         break;
                                 }
                         }
-                        
+
                         if (!received) {
                                 logger.warn("Test failed, dumping business list");
                                 logger.warn("BEFORE " + before);
@@ -825,28 +816,221 @@ public class UDDI_090_SubscriptionListen
                         subscriptionJoe.deleteSubscription(ds);
                         tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
                         tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
-                        
+
                         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);
-                        
+
                 }
         }
 
-
-
         /**
          * adds a new name to the business, then resaves it
+         *
          * @param auth
          * @param biz
-         * @param pub 
+         * @param pub
          */
-        public static void updatePublisherBusiness(String auth, BusinessEntity biz, UDDIPublicationPortType
pub) throws Exception{
+        public static void updatePublisherBusiness(String auth, BusinessEntity biz, UDDIPublicationPortType
pub) throws Exception {
                 biz.getName().add(new Name("Updated Name", "en"));
                 SaveBusiness sb = new SaveBusiness();
                 sb.setAuthInfo(auth);
                 sb.getBusinessEntity().add(biz);
                 pub.saveBusiness(sb);
         }
+
+        /**
+         * getBusiness tests joe want's updates on mary's business
+         *
+         * @throws Exception
+         */
+        @Test
+        public void joePublisherUpdate_HTTP_GET_TMODEL_DETAIL() throws Exception {
+                logger.info("joePublisherUpdate_HTTP_GET_TMODEL_DETAIL");
+                TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                Holder<List<Subscription>> holder = null;
+                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);
+                        TModel saveMaryPublisherTmodel = tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
+
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the Listener Service
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_HTTP_SERVICE_XML,
httpPort, hostname);
+
+                        //Saving the Subscription
+                        holder = new Holder<List<Subscription>>();
+                        holder.value = new ArrayList<Subscription>();
+                        Subscription sub = new Subscription();
+                        sub.setBindingKey("uddi:uddi.joepublisher.com:bindinglistener");
+                        sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
+                        sub.setSubscriptionFilter(new SubscriptionFilter());
+                        sub.getSubscriptionFilter().setGetTModelDetail(new GetTModelDetail());
+                        sub.getSubscriptionFilter().getGetTModelDetail().getTModelKey().add(TckTModel.MARY_PUBLISHER_TMODEL_KEY);
+
+                        holder.value.add(sub);
+                        subscriptionJoe.saveSubscription(authInfoJoe, holder);
+                        //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe,
TckSubscriptionListener.SUBSCRIPTION3_XML);
+                        //Changing the service we subscribed to "JoePublisherService"
+                        Thread.sleep(1000);
+                        logger.info("updating Mary's tModel ********** ");
+                        updateTModel(authInfoMary, saveMaryPublisherTmodel, publicationMary);
+
+                        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();
+                        StringBuilder sb = new StringBuilder();
+                        boolean found = false;
+                        while (it.hasNext()) {
+                                String test = it.next();
+                                sb.append("Message: " + test + System.getProperty("line.separator"));
+                                if (test.contains("a new description")) {
+                                        found = true;
+                                        break;
+                                }
+                        }
+                        if (!found) {
+                                logger.warn("Test failed, dumping business list");
+                                logger.warn("BEFORE " + before);
+                                logger.warn("After " + TckCommon.DumpAllBusinesses(authInfoJoe,
inquiryJoe));
+                                logger.warn("Messages RX " + sb.toString());
+                                Assert.fail("Notification does not contain the correct service.
Messages received: " + sb.toString());
+                        }
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe,
TckSubscriptionListener.SUBSCRIPTION_KEY);
+                        DeleteSubscription ds = new DeleteSubscription();
+                        ds.setAuthInfo(authInfoJoe);
+                        ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
+                        subscriptionJoe.deleteSubscription(ds);
+                        //tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
+                        tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
+
+                        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);
+
+                }
+        }
+
+        /**
+         * getBusiness tests joe want's updates on mary's business
+         *
+         * @throws Exception
+         */
+        @Test
+        public void joePublisherUpdate_SMTP_GET_TMODEL_DETAIL() throws Exception {
+                logger.info("joePublisherUpdate_SMTP_GET_TMODEL_DETAIL");
+                TckCommon.removeAllExistingSubscriptions(authInfoJoe, subscriptionJoe);
+                Holder<List<Subscription>> holder = null;
+                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);
+                        TModel saveMaryPublisherTmodel = tckTModelMary.saveMaryPublisherTmodel(authInfoMary);
+
+                        tckBusinessJoe.saveJoePublisherBusiness(authInfoJoe);
+                        tckBusinessServiceJoe.saveJoePublisherService(authInfoJoe);
+                        //Saving the Listener Service
+                        tckSubscriptionListenerJoe.saveService(authInfoJoe, TckSubscriptionListener.LISTENER_SMTP_SERVICE_EXTERNAL_XML,
0, email);
+                        //Saving the Subscription
+                        holder = new Holder<List<Subscription>>();
+                        holder.value = new ArrayList<Subscription>();
+                        Subscription sub = new Subscription();
+                        sub.setBindingKey("uddi:uddi.joepublisher.com:bindinglistenersmtp");
+                        sub.setNotificationInterval(DatatypeFactory.newInstance().newDuration(5000));
+                        sub.setSubscriptionFilter(new SubscriptionFilter());
+                        sub.getSubscriptionFilter().setGetTModelDetail(new GetTModelDetail());
+                        sub.getSubscriptionFilter().getGetTModelDetail().getTModelKey().add(TckTModel.MARY_PUBLISHER_TMODEL_KEY);
+
+                        holder.value.add(sub);
+                        subscriptionJoe.saveSubscription(authInfoJoe, holder);
+                        //tckSubscriptionListenerJoe.saveNotifierSubscription(authInfoJoe,
TckSubscriptionListener.SUBSCRIPTION3_XML);
+                        //Changing the service we subscribed to "JoePublisherService"
+                        Thread.sleep(1000);
+                        logger.info("updating Mary's tModel ********** ");
+                        updateTModel(authInfoMary, saveMaryPublisherTmodel, publicationMary);
+
+                        logger.info("Waiting " + TckPublisher.getSubscriptionTimeout() +
" seconds for delivery");
+                        //waiting up to 100 seconds for the listener to notice the change.
+                        boolean found = false;
+                        for (int i = 0; i < TckPublisher.getSubscriptionTimeout(); i++)
{
+                                Thread.sleep(1000);
+                                System.out.print(".");
+                                if (fetchMail("a new description") > 0) {
+                                        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("No Notification was sent");
+                        }
+
+                } catch (Exception e) {
+                        logger.error("No exceptions please.");
+                        e.printStackTrace();
+
+                        Assert.fail();
+                } finally {
+                        //tckSubscriptionListenerJoe.deleteNotifierSubscription(authInfoJoe,
TckSubscriptionListener.SUBSCRIPTION_KEY);
+                        DeleteSubscription ds = new DeleteSubscription();
+                        ds.setAuthInfo(authInfoJoe);
+                        ds.getSubscriptionKey().add(holder.value.get(0).getSubscriptionKey());
+                        subscriptionJoe.deleteSubscription(ds);
+                        //tckBusinessMary.deleteMaryPublisherBusiness(authInfoMary);
+                        tckTModelMary.deleteMaryPublisherTmodel(authInfoMary);
+
+                        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);
+
+                }
+        }
+
+        //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".
+        public static void updateTModel(String authInfoMary, TModel saveMaryPublisherTmodel,
UDDIPublicationPortType publicationMary) throws Exception {
+                saveMaryPublisherTmodel.getDescription().add(new Description("a new description",
null));
+                SaveTModel stm = new SaveTModel();
+                stm.setAuthInfo(authInfoMary);
+                stm.getTModel().add(saveMaryPublisherTmodel);
+                publicationMary.saveTModel(stm);
+        }
 }



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


Mime
View raw message