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

svn commit: r1555270 - in /juddi/trunk: juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.java

Author: kstam
Date: Fri Jan  3 22:43:28 2014
New Revision: 1555270

URL: http://svn.apache.org/r1555270
Log:
JUDDI-746 removing test code from the SMTPNotifier. Removing the SMTP tests from the TCK test bc this smtp test will never work with other UDDI implementations anyway.

Modified:
    juddi/trunk/juddi-core/src/main/java/org/apache/juddi/subscription/notify/SMTPNotifier.java
    juddi/trunk/uddi-tck/src/test/java/org/apache/juddi/v3/tck/UDDI_090_SubscriptionListenerIntegrationTest.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=1555270&r1=1555269&r2=1555270&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 Fri Jan  3 22:43:28 2014
@@ -1,13 +1,12 @@
 package org.apache.juddi.subscription.notify;
 
-import java.io.File;
-import java.io.FileInputStream;
 import java.net.URISyntaxException;
 import java.rmi.RemoteException;
 import java.security.InvalidAlgorithmParameterException;
 import java.security.InvalidKeyException;
 import java.security.NoSuchAlgorithmException;
 import java.util.Properties;
+
 import javax.crypto.BadPaddingException;
 import javax.crypto.IllegalBlockSizeException;
 import javax.crypto.NoSuchPaddingException;
@@ -18,6 +17,7 @@ import javax.mail.Session;
 import javax.mail.Transport;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
+
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -27,7 +27,6 @@ import org.apache.juddi.config.Property;
 import org.apache.juddi.cryptor.CryptorFactory;
 import org.apache.juddi.jaxb.JAXBMarshaller;
 import org.apache.juddi.model.BindingTemplate;
-import org.apache.juddi.v3.client.Release;
 import org.uddi.api_v3.DispositionReport;
 import org.uddi.api_v3.Result;
 import org.uddi.subr_v3.NotifySubscriptionListener;
@@ -38,17 +37,17 @@ import org.uddi.v3_service.DispositionRe
  * @author probably Kurt Stam
  */
 public class SMTPNotifier implements Notifier {
-	
+
 	Log log = LogFactory.getLog(this.getClass());
 	String notificationEmailAddress = null;
 	//String from = null;
 	Session session = null;
 	Properties properties = null;
-	
+
 	private final static String[] mailProps = {"mail.smtp.from", "mail.smtp.host", "mail.smtp.port", 
 		"mail.smtp.socketFactory.class", "mail.smtp.socketFactory.fallback", "mail.smtp.starttls.enable",
 		"mail.smtp.socketFactory.port","mail.smtp.auth","mail.smtp.user","mail.smtp.password"};
-	
+
 	protected Properties getEMailProperties() throws ConfigurationException {
 		if (properties==null) {
 			properties = new Properties();
@@ -61,43 +60,10 @@ public class SMTPNotifier implements Not
 					properties.put(key, System.getProperty(mailPrefix + key));
 				}
 			}
-			// only read from file during testing
-			if (properties.size()==0 || "jUDDI@example.org".equals(properties.getProperty("mail.smtp.from"))) {
-				String curDir = System.getProperty("user.dir");
-				if (! curDir.endsWith("uddi-tck")) curDir += "/uddi-tck";
-				String version = Release.getRegistryVersion().replaceAll(".SNAPSHOT", "-SNAPSHOT");
-				String path = curDir + "/target/juddi-tomcat-" + version + "/temp/";
-				log.info("Path="+ path);
-				File tmpFile = new File(path + "/juddi-mail.properties");
-				if (tmpFile.exists()) {
-                                    FileInputStream fis = null;
-					try {
-						Properties fileProperties = new Properties();
-                                                fis = new FileInputStream(tmpFile);
-						fileProperties.load(fis);
-						for (String key: mailProps) {
-							if (fileProperties.containsKey(mailPrefix + key)) {
-								properties.put(key, fileProperties.get(mailPrefix + key));
-							}
-						}
-					} catch (Exception e) {
-						// TODO Auto-generated catch block
-						log.warn("Unable to load mail properties",e);
-					}
-                                        finally{
-                                            if (fis!=null)
-                                                try {
-                                                fis.close();
-                                                } catch (Exception ex) {
-                                                }
-                                        }
-					log.info("TEST only: Reading properties from " + tmpFile.getAbsolutePath() + ":" + properties);
-				}
-			}
 		}
 		return properties;
 	}
-	
+
 	public SMTPNotifier(BindingTemplate bindingTemplate) throws URISyntaxException, Exception {
 		super();
 		if (!AccessPointType.END_POINT.toString().equalsIgnoreCase(bindingTemplate.getAccessPointType())) {
@@ -112,26 +78,26 @@ public class SMTPNotifier implements Not
 			notificationEmailAddress = accessPointUrl.substring(accessPointUrl.indexOf(":")+1);
 			if (Boolean.getBoolean(getEMailProperties().getProperty("mail.smtp.starttls.enable"))) {
 				final String username = getEMailProperties().getProperty("mail.smtp.username");
-                                String pwd = getEMailProperties().getProperty("mail.smtp.password");
-                                if (getEMailProperties().getProperty("mail.smtp.password" + Property.ENCRYPTED_ATTRIBUTE, "false").equalsIgnoreCase("true"))
-                                {
-                                    try {
-                                        pwd = CryptorFactory.getCryptor().decrypt(pwd);
-                                    } catch (NoSuchPaddingException ex) {
-                                        log.error("Unable to decrypt settings",ex);
-                                    } catch (NoSuchAlgorithmException ex) {
-                                        log.error("Unable to decrypt settings",ex);
-                                    } catch (InvalidAlgorithmParameterException ex) {
-                                        log.error("Unable to decrypt settings",ex);
-                                    } catch (InvalidKeyException ex) {
-                                        log.error("Unable to decrypt settings",ex);
-                                    } catch (IllegalBlockSizeException ex) {
-                                        log.error("Unable to decrypt settings",ex);
-                                    } catch (BadPaddingException ex) {
-                                        log.error("Unable to decrypt settings",ex);
-                                    }
-                                }
-                                final String password = pwd;
+				String pwd = getEMailProperties().getProperty("mail.smtp.password");
+				if (getEMailProperties().getProperty("mail.smtp.password" + Property.ENCRYPTED_ATTRIBUTE, "false").equalsIgnoreCase("true"))
+				{
+					try {
+						pwd = CryptorFactory.getCryptor().decrypt(pwd);
+					} catch (NoSuchPaddingException ex) {
+						log.error("Unable to decrypt settings",ex);
+					} catch (NoSuchAlgorithmException ex) {
+						log.error("Unable to decrypt settings",ex);
+					} catch (InvalidAlgorithmParameterException ex) {
+						log.error("Unable to decrypt settings",ex);
+					} catch (InvalidKeyException ex) {
+						log.error("Unable to decrypt settings",ex);
+					} catch (IllegalBlockSizeException ex) {
+						log.error("Unable to decrypt settings",ex);
+					} catch (BadPaddingException ex) {
+						log.error("Unable to decrypt settings",ex);
+					}
+				}
+				final String password = pwd;
 				session = Session.getInstance(getEMailProperties(), new javax.mail.Authenticator() {
 					protected PasswordAuthentication getPasswordAuthentication() {
 						return new PasswordAuthentication(username, password);
@@ -144,9 +110,9 @@ public class SMTPNotifier implements Not
 	}
 
 	public DispositionReport notifySubscriptionListener(NotifySubscriptionListener body) throws DispositionReportFaultMessage, RemoteException {
-		
+
 		log.info("Sending notification email to " + notificationEmailAddress);
-		
+
 		try {
 			if (session !=null && notificationEmailAddress != null) {
 				MimeMessage message = new MimeMessage(session);
@@ -165,11 +131,11 @@ public class SMTPNotifier implements Not
 			log.error(e.getMessage(),e);
 			throw new DispositionReportFaultMessage(e.getMessage(), null);
 		}
-		
+
 		DispositionReport dr = new DispositionReport();
 		Result res = new Result();
 		dr.getResult().add(res);
-		
+
 		return dr;
 	}
 }

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=1555270&r1=1555269&r2=1555270&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 Jan  3 22:43:28 2014
@@ -14,10 +14,8 @@ 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.Properties;
+import java.util.List;
 import java.util.Random;
 
 import javax.xml.ws.Endpoint;
@@ -25,33 +23,23 @@ 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.Release;
+import org.apache.juddi.v3.client.UDDIConstants;
 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.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.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;
+import org.uddi.v3_service.UDDIInquiryPortType;
+import org.uddi.v3_service.UDDIPublicationPortType;
+import org.uddi.v3_service.UDDISecurityPortType;
+import org.uddi.v3_service.UDDISubscriptionPortType;
 
 /**
  * @author <a href="mailto:tcunning@apache.org">Tom Cunningham</a>
@@ -67,8 +55,6 @@ public class UDDI_090_SubscriptionListen
     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;
@@ -84,26 +70,7 @@ public class UDDI_090_SubscriptionListen
     @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";
@@ -204,64 +171,6 @@ public class UDDI_090_SubscriptionListen
         }
     }
 
-    @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");
-
-            //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().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");
@@ -351,66 +260,6 @@ public class UDDI_090_SubscriptionListen
         }
     }
 
-    //@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() {
@@ -465,66 +314,6 @@ public class UDDI_090_SubscriptionListen
         }
     }
 
-    //@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();
-        }
-    }
-    
-    
     //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.  
     
     



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