Author: bago Date: Sun Oct 1 13:55:19 2006 New Revision: 451809 URL: http://svn.apache.org/viewvc?view=rev&rev=451809 Log: Binary parts now use full random bytes for binary parts (not only letters)
Fix to the MailMatchingUtils size calculator (uses getContent and not part.getSize) Added a debug helper: exception nesting. Modified: james/postage/trunk/pom.xml james/postage/trunk/src/main/java/org/apache/james/postage/PostageRunner.java james/postage/trunk/src/main/java/org/apache/james/postage/mail/AbstractMailFactory.java james/postage/trunk/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java Modified: james/postage/trunk/pom.xml URL: http://svn.apache.org/viewvc/james/postage/trunk/pom.xml?view=diff&rev=451809&r1=451808&r2=451809 ============================================================================== --- james/postage/trunk/pom.xml (original) +++ james/postage/trunk/pom.xml Sun Oct 1 13:55:19 2006 @@ -231,7 +231,7 @@ <dependency> <groupId>org.apache.james</groupId> <artifactId>james-server</artifactId> - <version>3.0-SNAPSHOT</version> + <version>2.3.0-SNAPSHOT</version> <exclusions> <exclusion> <groupId>org.bouncycastle</groupId> @@ -353,7 +353,7 @@ <distributionManagement> <site> <id>postage-website</id> - <url>scp://minotaur.apache.org/www/james.apache.org/postage/</url> + <url>scp://people.apache.org/www/james.apache.org/postage/</url> </site> </distributionManagement> Modified: james/postage/trunk/src/main/java/org/apache/james/postage/PostageRunner.java URL: http://svn.apache.org/viewvc/james/postage/trunk/src/main/java/org/apache/james/postage/PostageRunner.java?view=diff&rev=451809&r1=451808&r2=451809 ============================================================================== --- james/postage/trunk/src/main/java/org/apache/james/postage/PostageRunner.java (original) +++ james/postage/trunk/src/main/java/org/apache/james/postage/PostageRunner.java Sun Oct 1 13:55:19 2006 @@ -20,26 +20,26 @@ package org.apache.james.postage; -import org.apache.james.postage.configuration.PostageConfiguration; -import org.apache.james.postage.configuration.SendProfile; -import org.apache.james.postage.configuration.MailSender; -import org.apache.james.postage.result.PostageRunnerResultImpl; -import org.apache.james.postage.result.PostageRunnerResult; -import org.apache.james.postage.client.RemoteManagerClient; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.apache.james.postage.client.POP3Client; +import org.apache.james.postage.client.RemoteManagerClient; import org.apache.james.postage.client.SMTPClient; +import org.apache.james.postage.configuration.MailSender; +import org.apache.james.postage.configuration.PostageConfiguration; +import org.apache.james.postage.configuration.SendProfile; import org.apache.james.postage.execution.SampleController; -import org.apache.james.postage.smtpserver.SMTPMailSink; import org.apache.james.postage.jmx.JVMResourceSampler; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; +import org.apache.james.postage.result.PostageRunnerResult; +import org.apache.james.postage.result.PostageRunnerResultImpl; +import org.apache.james.postage.smtpserver.SMTPMailSink; +import java.io.File; import java.util.ArrayList; -import java.util.List; import java.util.Iterator; import java.util.LinkedHashSet; +import java.util.List; import java.util.Set; -import java.io.File; /** * central controlling class for the testing process. starts all workers, collects data and stops when time is out.<br/> @@ -384,7 +384,7 @@ Set existingUsers = getExistingUsers(host, remoteManagerPort, remoteManagerUsername, remoteManagerPassword); RemoteManagerClient remoteManagerClient = new RemoteManagerClient(host, remoteManagerPort, remoteManagerUsername, remoteManagerPassword); - boolean loginSuccess = remoteManagerClient.login(); + remoteManagerClient.login(); ArrayList internalUsers = new ArrayList(); for (int i = 1; i <= internalUserCount; i++) { String username = internalUsernamePrefix + i; @@ -392,13 +392,13 @@ log.info("user already exists: " + username); if (!m_postageConfiguration.isInternalReuseExisting()) { remoteManagerClient.executeCommand("deluser " + username); - List answers = remoteManagerClient.readAnswer(); + remoteManagerClient.readAnswer(); addUser(remoteManagerClient, username, internalPassword); - answers = remoteManagerClient.readAnswer(); + remoteManagerClient.readAnswer(); log.info("user deleted and re-created: " + username); } remoteManagerClient.executeCommand("setpassword " + username + " " + internalPassword); - List answers = remoteManagerClient.readAnswer(); + remoteManagerClient.readAnswer(); } else { addUser(remoteManagerClient, username, internalPassword); } @@ -418,7 +418,7 @@ try { smtpMailSink.initialize(); } catch (Exception e) { - throw new StartupException("failed to setup"); + throw new StartupException("failed to setup",e); } m_smtpMailSink = smtpMailSink; log.info("forwarded mail interceptor is set up."); @@ -443,7 +443,7 @@ private void addUser(RemoteManagerClient remoteManagerClient, String username, String internalPassword) { remoteManagerClient.executeCommand("adduser " + username + " " + internalPassword); - List answers = remoteManagerClient.readAnswer(); + remoteManagerClient.readAnswer(); log.info("user created: " + username); } Modified: james/postage/trunk/src/main/java/org/apache/james/postage/mail/AbstractMailFactory.java URL: http://svn.apache.org/viewvc/james/postage/trunk/src/main/java/org/apache/james/postage/mail/AbstractMailFactory.java?view=diff&rev=451809&r1=451808&r2=451809 ============================================================================== --- james/postage/trunk/src/main/java/org/apache/james/postage/mail/AbstractMailFactory.java (original) +++ james/postage/trunk/src/main/java/org/apache/james/postage/mail/AbstractMailFactory.java Sun Oct 1 13:55:19 2006 @@ -54,7 +54,7 @@ } public static byte getRandomByte() { - return (byte)CHARSET[getRandomInt()]; + return (byte)(Math.random() * 255); } public AbstractMailFactory() { Modified: james/postage/trunk/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java URL: http://svn.apache.org/viewvc/james/postage/trunk/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java?view=diff&rev=451809&r1=451808&r2=451809 ============================================================================== --- james/postage/trunk/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java (original) +++ james/postage/trunk/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java Sun Oct 1 13:55:19 2006 @@ -22,6 +22,7 @@ import org.apache.james.postage.PostageRuntimeException; import org.apache.james.postage.classloading.CachedInstanceFactory; import org.apache.james.postage.result.MailProcessingRecord; +import org.apache.james.util.io.IOUtil; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -30,6 +31,9 @@ import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.regex.Pattern; /** @@ -138,7 +142,20 @@ for (int i = 0; i < parts.getCount(); i++) { BodyPart bodyPart = parts.getBodyPart(i); if (bodyPart.getContentType().startsWith(mimeType)) { - return bodyPart.getSize(); + try { + Object content = bodyPart.getContent(); + if (content instanceof InputStream) { + ByteArrayOutputStream os = new ByteArrayOutputStream(); + IOUtil.copy(((InputStream) content), os); + return os.size(); + } else if (content instanceof String) { + return ((String) content).length(); + } else { + throw new IllegalStateException("Unsupported content: "+content.getClass().toString()); + } + } catch (IOException e) { + throw new IllegalStateException("Unexpected IOException in getContent()"); + } } } } catch (MessagingException e) { --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]