Remove m_ prefixes from class fields (POSTAGE-24)
git-svn-id: https://svn.apache.org/repos/asf/james/postage/trunk@1350156 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/james/postage/Main.java b/src/main/java/org/apache/james/postage/Main.java
index 9758526..4d868fd 100644
--- a/src/main/java/org/apache/james/postage/Main.java
+++ b/src/main/java/org/apache/james/postage/Main.java
@@ -18,23 +18,23 @@
****************************************************************/
package org.apache.james.postage;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.XMLConfiguration;
import org.apache.james.postage.configuration.ConfigurationLoader;
import org.apache.james.postage.configuration.PostageConfiguration;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* bootstrapping the application
*/
public class Main {
- private static PostageRunner m_currentPostageRunner = null;
+ private static PostageRunner currentPostageRunner = null;
- public static void main(String[] args) {
+ public static void main(String... args) {
if (args == null || args.length == 0) {
System.out.println("Please provide the configuration file");
return;
@@ -43,8 +43,7 @@
String filename = args[0];
List<String> scenariosToRun = new ArrayList<String>();
- for (int i = 1; i < args.length; i++)
- {
+ for (int i = 1; i < args.length; i++) {
scenariosToRun.add(args[i]);
}
@@ -80,10 +79,10 @@
playedScenarioCounter++;
PostageConfiguration postageConfiguration = configurations.get(id);
- m_currentPostageRunner = new PostageRunner(postageConfiguration);
- m_currentPostageRunner.run(); // TODO maybe we want to run this Runnable in its own thread, but maybe not
+ currentPostageRunner = new PostageRunner(postageConfiguration);
+ currentPostageRunner.run(); // TODO maybe we want to run this Runnable in its own thread, but maybe not
}
- m_currentPostageRunner = null;
+ currentPostageRunner = null;
if (playedScenarioCounter == 0) {
System.out.println("No scenario has been executed. ");
System.out.println("Either those on the command line where not matching those in the file.");
@@ -92,7 +91,7 @@
}
private static void shutdown() {
- if (m_currentPostageRunner != null) m_currentPostageRunner.terminate();
+ if (currentPostageRunner != null) currentPostageRunner.terminate();
}
}
diff --git a/src/main/java/org/apache/james/postage/PostageException.java b/src/main/java/org/apache/james/postage/PostageException.java
index 7554fbe..2ed36c2 100644
--- a/src/main/java/org/apache/james/postage/PostageException.java
+++ b/src/main/java/org/apache/james/postage/PostageException.java
@@ -16,14 +16,16 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-
-
package org.apache.james.postage;
/**
- * base exception for Postage
+ * <p>
+ * Base exception for Postage
+ * </p>
*/
public class PostageException extends Exception {
+ private static final long serialVersionUID = 6272996357773871487L;
+
public PostageException() {
super();
}
@@ -39,4 +41,5 @@
public PostageException(String message, Throwable cause) {
super(message, cause);
}
+
}
diff --git a/src/main/java/org/apache/james/postage/PostageRunner.java b/src/main/java/org/apache/james/postage/PostageRunner.java
index e022327..61ef051 100644
--- a/src/main/java/org/apache/james/postage/PostageRunner.java
+++ b/src/main/java/org/apache/james/postage/PostageRunner.java
@@ -16,14 +16,21 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-
-
package org.apache.james.postage;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.james.cli.probe.ServerProbe;
+import org.apache.james.cli.probe.impl.JmxServerProbe;
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;
@@ -34,15 +41,8 @@
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.Iterator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
-
/**
- * central controlling class for the testing process. starts all workers, collects data and stops when time is out.<br/>
+ * Central controlling class for the testing process. starts all workers, collects data and stops when time is out.<br/>
* relates to one and only one Scenario section from the configuration file.
*/
public class PostageRunner implements Runnable {
@@ -55,33 +55,33 @@
public static final int PHASE_ABORTED = 3;
public static final int PHASE_COMPLETED = 4;
- private int m_currentPhase = PHASE_CREATED;
+ private int currentPhase = PHASE_CREATED;
- private final PostageConfiguration m_postageConfiguration;
- private final PostageRunnerResult m_results = new PostageRunnerResultImpl();
+ private final PostageConfiguration postageConfiguration;
+ private final PostageRunnerResult results = new PostageRunnerResultImpl();
- private POP3Client m_inboundMailingChecker;
- private SampleController m_inboundMailingController;
+ private POP3Client inboundMailingChecker;
+ private SampleController inboundMailingController;
- private SMTPMailSink m_smtpMailSink;
- private SampleController m_outboundMailingInterceptorController;
+ private SMTPMailSink smtpMailSink;
+ private SampleController outboundMailingInterceptorController;
- private List<SampleController> m_sendControllers = new ArrayList<SampleController>();
+ private List<SampleController> sendControllers = new ArrayList<SampleController>();
- private JVMResourceSampler m_jvmResourceSampler = null;
- private SampleController m_jvmResourceController = null;
+ private JVMResourceSampler jvmResourceSampler = null;
+ private SampleController jvmResourceController = null;
- private int m_minutesRunning = 0;
+ private int minutesRunning = 0;
/**
* defines the prefix for every mail id generated by the current runner, so they can be distinguished from
* next runs. the runner instance is responsable to initializing this value!
* NOTE: this construct becomes a problem when two runners are running in parallel
*/
- private static String m_messageIdPrefix = null;
+ private static String messageIdPrefix = null;
public static String getMessageIdPrefix() {
- return m_messageIdPrefix + "-";
+ return messageIdPrefix + "-";
}
/**
@@ -96,22 +96,22 @@
* @param postageConfiguration
*/
public PostageRunner(PostageConfiguration postageConfiguration) {
- m_messageIdPrefix = "" + System.currentTimeMillis();
+ this.messageIdPrefix = "" + System.currentTimeMillis();
- m_postageConfiguration = postageConfiguration;
+ this.postageConfiguration = postageConfiguration;
- int totalMailsPerMin = m_postageConfiguration.getTotalMailsPerMin();
- int durationMinutes = m_postageConfiguration.getDurationMinutes();
+ int totalMailsPerMin = this.postageConfiguration.getTotalMailsPerMin();
+ int durationMinutes = this.postageConfiguration.getDurationMinutes();
- m_postageConfiguration.addDescriptionItem("mails_per_min", "" + totalMailsPerMin);
- m_postageConfiguration.addDescriptionItem("totally_running_min", "" + durationMinutes);
- m_postageConfiguration.addDescriptionItem("totally_mails_target", "" + totalMailsPerMin * durationMinutes);
+ this.postageConfiguration.addDescriptionItem("mails_per_min", "" + totalMailsPerMin);
+ this.postageConfiguration.addDescriptionItem("totally_running_min", "" + durationMinutes);
+ this.postageConfiguration.addDescriptionItem("totally_mails_target", "" + totalMailsPerMin * durationMinutes);
- m_results.setEnvironmentDescription(m_postageConfiguration.getDescriptionItems());
+ this.results.setEnvironmentDescription(this.postageConfiguration.getDescriptionItems());
}
private void execute() {
- if (m_postageConfiguration != null) m_currentPhase = PHASE_STARTING;
+ if (this.postageConfiguration != null) this.currentPhase = PHASE_STARTING;
// do initialisation, check if all services can be connected
try {
@@ -130,9 +130,9 @@
}
- m_currentPhase = PHASE_RUNNING;
+ this.currentPhase = PHASE_RUNNING;
- log.info("starting scenario " + m_postageConfiguration.getId());
+ log.info("starting scenario " + this.postageConfiguration.getId());
// fork the timeout controller thread. it issues the oneMinute checkpoint event, too.
startTimer();
@@ -145,10 +145,10 @@
}
// has to be set by method stopRecording()
- // m_currentPhase = PHASE_COMPLETED;
+ // this.currentPhase = PHASE_COMPLETED;
// writeMatchedMailResults (remaining) collected data
- log.info("completing by writing data for scenario " + m_postageConfiguration.getId());
+ log.info("completing by writing data for scenario " + this.postageConfiguration.getId());
writeData(false);
}
@@ -166,7 +166,7 @@
* @return one of the values PHASE_CREATED (0), PHASE_STARTING (1), PHASE_RUNNING (2), PHASE_ABORTED (3), PHASE_COMPLETED (4)
*/
public int getCurrentPhase() {
- return m_currentPhase;
+ return this.currentPhase;
}
public void run() {
@@ -174,7 +174,7 @@
}
public PostageRunnerResult getResult() {
- return m_results;
+ return this.results;
}
/**
@@ -185,7 +185,7 @@
new Runnable() {
public void run() {
try {
- int durationMinutes = m_postageConfiguration.getDurationMinutes();
+ int durationMinutes = postageConfiguration.getDurationMinutes();
log.info("running for " + durationMinutes + " minute(s)");
for (int i = 0; i < durationMinutes; i++) {
Thread.sleep(60*1000);
@@ -205,9 +205,9 @@
* called after each fully completed minute in the running phase
*/
private void oneMinuteCheckpoint() {
- m_minutesRunning++;
- log.info("reached checkpoint after " + m_minutesRunning + " of "
- + m_postageConfiguration.getDurationMinutes() + " minute(s) running.");
+ this.minutesRunning++;
+ log.info("reached checkpoint after " + this.minutesRunning + " of "
+ + this.postageConfiguration.getDurationMinutes() + " minute(s) running.");
//TODO do this in a separate thread?
writeData(true);
@@ -215,17 +215,17 @@
private void stopRecording() {
log.info("stopping");
- if (m_sendControllers != null) {
- Iterator<SampleController> iterator = m_sendControllers.iterator();
+ if (this.sendControllers != null) {
+ Iterator<SampleController> iterator = this.sendControllers.iterator();
while (iterator.hasNext()) {
SampleController sendController = iterator.next();
sendController.stop();
}
}
- if (m_inboundMailingController != null) m_inboundMailingController.stop();
+ if (this.inboundMailingController != null) this.inboundMailingController.stop();
- if (m_outboundMailingInterceptorController != null) m_outboundMailingInterceptorController.stop();
- m_currentPhase = PHASE_COMPLETED;
+ if (this.outboundMailingInterceptorController != null) this.outboundMailingInterceptorController.stop();
+ this.currentPhase = PHASE_COMPLETED;
}
/**
@@ -233,7 +233,7 @@
*/
public void terminate() {
stopRecording();
- m_currentPhase = PHASE_ABORTED;
+ this.currentPhase = PHASE_ABORTED;
writeData(false);
}
@@ -243,48 +243,48 @@
String filenameMailResult = getCanonicalMailResultFileName();
String filenameJVMStatistics = getCanonicalJVMStatisticsFileName();
String filenameErrors = getCanonicalErrorsFileName();
- m_results.writeResults(filenameMailResult, filenameJVMStatistics, filenameErrors, flushMatchedMailOnly);
+ this.results.writeResults(filenameMailResult, filenameJVMStatistics, filenameErrors, flushMatchedMailOnly);
}
public String getCanonicalMailResultFileName() {
- return "postage_mailResults." + m_postageConfiguration.getId() + ".csv";
+ return "postage_mailResults." + this.postageConfiguration.getId() + ".csv";
}
public String getCanonicalJVMStatisticsFileName() {
- return "postage_jvmStatistics." + m_postageConfiguration.getId() + ".csv";
+ return "postage_jvmStatistics." + this.postageConfiguration.getId() + ".csv";
}
public String getCanonicalErrorsFileName() {
- return "postage_errors." + m_postageConfiguration.getId() + ".csv";
+ return "postage_errors." + this.postageConfiguration.getId() + ".csv";
}
private void logElapsedData() {
- log.info("unmatched messages: " + m_results.getUnmatchedMails());
- log.info("matched messages: " + m_results.getMatchedMails());
- log.info("valid matches: " + m_results.getValidMails());
- log.info("recorded errors: " + m_results.getErrorCount());
+ log.info("unmatched messages: " + this.results.getUnmatchedMails());
+ log.info("matched messages: " + this.results.getMatchedMails());
+ log.info("valid matches: " + this.results.getValidMails());
+ log.info("recorded errors: " + this.results.getErrorCount());
}
private void recordData() {
- Iterator<SampleController> iterator = m_sendControllers.iterator();
+ Iterator<SampleController> iterator = this.sendControllers.iterator();
while (iterator.hasNext()) {
SampleController sendController = iterator.next();
sendController.runThreaded();
}
- m_inboundMailingController = new SampleController(m_inboundMailingChecker, m_postageConfiguration.getTestserverPOP3FetchesPerMinute());
- m_inboundMailingController.runThreaded();
+ this.inboundMailingController = new SampleController(this.inboundMailingChecker, this.postageConfiguration.getTestserverPOP3FetchesPerMinute());
+ this.inboundMailingController.runThreaded();
- m_outboundMailingInterceptorController = new SampleController(m_smtpMailSink, 10, m_postageConfiguration.getTestserverSMTPForwardingWaitSeconds());
- m_outboundMailingInterceptorController.runThreaded();
+ this.outboundMailingInterceptorController = new SampleController(this.smtpMailSink, 10, this.postageConfiguration.getTestserverSMTPForwardingWaitSeconds());
+ this.outboundMailingInterceptorController.runThreaded();
- if (m_jvmResourceSampler != null) {
- m_jvmResourceController = new SampleController(m_jvmResourceSampler, 4);
- m_jvmResourceController.runThreaded();
+ if (this.jvmResourceSampler != null) {
+ this.jvmResourceController = new SampleController(this.jvmResourceSampler, 4);
+ this.jvmResourceController.runThreaded();
}
- while(m_currentPhase == PHASE_RUNNING) {
+ while(this.currentPhase == PHASE_RUNNING) {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
@@ -292,10 +292,10 @@
}
}
- if (m_currentPhase == PHASE_COMPLETED) {
+ if (this.currentPhase == PHASE_COMPLETED) {
// walk through all internal users and check for un-matched mails
log.info("checking all internal accounts for unmatched mail...");
- m_inboundMailingChecker.doMatchMailForAllUsers();
+ this.inboundMailingChecker.doMatchMailForAllUsers();
log.info("...done checking internal accounts");
} else {
// if we didn't COMPLETE, we'd better skip this
@@ -304,15 +304,15 @@
}
private void setupExternalUserAccounts() {
- int externalUserCount = m_postageConfiguration.getExternalUsers().getCount();
- String externalUsernamePrefix = m_postageConfiguration.getExternalUsers().getNamePrefix();
+ int externalUserCount = this.postageConfiguration.getExternalUsers().getCount();
+ String externalUsernamePrefix = this.postageConfiguration.getExternalUsers().getNamePrefix();
ArrayList<String> externalUsers = new ArrayList<String>();
for (int i = 1; i <= externalUserCount; i++) {
String username = externalUsernamePrefix + i;
externalUsers.add(username);
}
- m_postageConfiguration.getExternalUsers().setExistingUsers(externalUsers);
+ this.postageConfiguration.getExternalUsers().setExistingUsers(externalUsers);
}
/**
@@ -320,9 +320,9 @@
* @throws StartupException
*/
private void setupInboundMailing() throws StartupException {
- if (m_postageConfiguration.getTestserverPortSMTPInbound() <= 0) return;
+ if (this.postageConfiguration.getTestserverPortSMTPInbound() <= 0) return;
- Iterator<SendProfile> profileIterator = m_postageConfiguration.getProfiles().iterator();
+ Iterator<SendProfile> profileIterator = this.postageConfiguration.getProfiles().iterator();
while (profileIterator.hasNext()) {
SendProfile sendProfile = profileIterator.next();
Iterator<MailSender> mailSenderIterator = sendProfile.mailSenderIterator();
@@ -332,11 +332,11 @@
if (sendPerMinute < 1) continue;
- SMTPClient smtpClient = new SMTPClient(m_postageConfiguration.getTestserverHost(),
- m_postageConfiguration.getTestserverPortSMTPInbound(),
- m_postageConfiguration.getInternalUsers(),
- m_postageConfiguration.getExternalUsers(),
- m_results,
+ SMTPClient smtpClient = new SMTPClient(this.postageConfiguration.getTestserverHost(),
+ this.postageConfiguration.getTestserverPortSMTPInbound(),
+ this.postageConfiguration.getInternalUsers(),
+ this.postageConfiguration.getExternalUsers(),
+ this.results,
mailSender
);
@@ -345,7 +345,7 @@
if (!available) continue;
SampleController sendController = new SampleController(smtpClient, sendPerMinute);
- m_sendControllers.add(sendController);
+ this.sendControllers.add(sendController);
}
}
@@ -357,115 +357,107 @@
* @throws StartupException
*/
private void setupInboundMailingChecker() throws StartupException {
- if (m_postageConfiguration.getTestserverPortPOP3() <= 0) return;
+ if (this.postageConfiguration.getTestserverPortPOP3() <= 0) return;
- m_inboundMailingChecker = new POP3Client(m_postageConfiguration.getTestserverHost(),
- m_postageConfiguration.getTestserverPortPOP3(),
- m_postageConfiguration.getInternalUsers(),
- m_results
+ this.inboundMailingChecker = new POP3Client(this.postageConfiguration.getTestserverHost(),
+ this.postageConfiguration.getTestserverPortPOP3(),
+ this.postageConfiguration.getInternalUsers(),
+ this.results
);
- m_inboundMailingChecker.checkAvailability();
- boolean available = m_inboundMailingChecker.checkAvailability();
+ this.inboundMailingChecker.checkAvailability();
+ boolean available = this.inboundMailingChecker.checkAvailability();
if (available) {
log.info("availability of checking for inbound mailing (POP3) verified");
}
}
+ /**
+ * This method makes sure the test accounts exist in the target James Server.
+ * If the account does not already exist then the account is created;
+ * if the account does exist, the method checks configuration
+ * to see if the account should be re-used or removed and re-added.
+ *
+ * @throws StartupException
+ */
private void setupInternalUserAccounts() throws StartupException {
+
try {
- String host = m_postageConfiguration.getTestserverHost();
- int remoteManagerPort = m_postageConfiguration.getTestserverRemoteManagerPort();
- String remoteManagerUsername = m_postageConfiguration.getTestserverRemoteManagerUsername();
- String remoteManagerPassword = m_postageConfiguration.getTestserverRemoteManagerPassword();
- int internalUserCount = m_postageConfiguration.getInternalUsers().getCount();
- String internalUsernamePrefix = m_postageConfiguration.getInternalUsers().getNamePrefix();
- String internalPassword = m_postageConfiguration.getInternalUsers().getPassword();
-
- Set<String> existingUsers = getExistingUsers(host, remoteManagerPort, remoteManagerUsername, remoteManagerPassword);
-
- RemoteManagerClient remoteManagerClient = new RemoteManagerClient(host, remoteManagerPort, remoteManagerUsername, remoteManagerPassword);
- remoteManagerClient.login();
- ArrayList<String> internalUsers = new ArrayList<String>();
- for (int i = 1; i <= internalUserCount; i++) {
- String username = internalUsernamePrefix + i;
- if (existingUsers.contains(username)) {
- log.info("user already exists: " + username);
- if (!m_postageConfiguration.isInternalReuseExisting()) {
- remoteManagerClient.executeCommand("deluser " + username);
- remoteManagerClient.readAnswer();
- addUser(remoteManagerClient, username, internalPassword);
- remoteManagerClient.readAnswer();
- log.info("user deleted and re-created: " + username);
- }
- remoteManagerClient.executeCommand("setpassword " + username + " " + internalPassword);
- remoteManagerClient.readAnswer();
- } else {
- addUser(remoteManagerClient, username, internalPassword);
- }
- internalUsers.add(username);
+
+ String host = this.postageConfiguration.getTestserverHost();
+ int jmxPort = this.postageConfiguration.getTestserverPortJMXRemoting();
+ int internalUserCount = this.postageConfiguration.getInternalUsers().getCount();
+ String internalUsernamePrefix = this.postageConfiguration.getInternalUsers().getNamePrefix();
+ String internalDomain = this.postageConfiguration.getInternalUsers().getDomain();
+ String internalPassword = this.postageConfiguration.getInternalUsers().getPassword();
+
+ // Make connection to the James server via JMX
+ log.info("Connecting to host: " + host + ":" + jmxPort);
+ ServerProbe serverManager = new JmxServerProbe(host, jmxPort);
+
+ if (! serverManager.containsDomain(internalDomain)) {
+ serverManager.addDomain(internalDomain);
}
- m_postageConfiguration.getInternalUsers().setExistingUsers(internalUsers);
- remoteManagerClient.disconnect();
+
+ // Collect the set of users already provisioned
+ Set<String> existingUsers = new LinkedHashSet<String>(Arrays.asList(serverManager.listUsers()));
+ log.info("Existing users: " + existingUsers.toString());
+
+ // Check all the test accounts we need; if they don't exist then
+ // create them; if they do exist then check if we should reuse or recreate
+ ArrayList<String> internalUsers = new ArrayList<String>();
+ for (int i = 1; i <= internalUserCount; i++) {
+ String username = internalUsernamePrefix + i;
+ String useremail = username + "@" + internalDomain;
+ if (existingUsers.contains(useremail)) {
+ log.info("user already exists: " + useremail);
+ if (!this.postageConfiguration.isInternalReuseExisting()) {
+ serverManager.removeUser(useremail);
+ serverManager.addUser(useremail, internalPassword);
+ log.info("user deleted and re-created: " + useremail);
+ }
+ serverManager.setPassword(useremail, internalPassword);
+ } else {
+ log.info("Adding user: " + useremail);
+ serverManager.addUser(useremail, internalPassword);
+ }
+ internalUsers.add(username);
+ }
+
+ this.postageConfiguration.getInternalUsers().setExistingUsers(internalUsers);
+
} catch (Exception e) {
- throw new StartupException("error setting up internal user accounts", e);
- }
+ throw new StartupException("error setting up internal user accounts", e);
+ }
+
}
private void setupForwardedMailInterceptor() throws StartupException {
SMTPMailSink smtpMailSink = new SMTPMailSink();
- smtpMailSink.setSmtpListenerPort(m_postageConfiguration.getTestserverPortSMTPForwarding());
- smtpMailSink.setResults(m_results);
+ smtpMailSink.setSmtpListenerPort(this.postageConfiguration.getTestserverPortSMTPForwarding());
+ smtpMailSink.setResults(this.results);
try {
smtpMailSink.initialize();
} catch (Exception e) {
throw new StartupException("failed to setup",e);
}
- m_smtpMailSink = smtpMailSink;
+ this.smtpMailSink = smtpMailSink;
log.info("forwarded mail interceptor is set up.");
}
private void setupJMXRemoting() throws StartupException {
- int jmxPort = m_postageConfiguration.getTestserverPortJMXRemoting();
+ int jmxPort = this.postageConfiguration.getTestserverPortJMXRemoting();
if (jmxPort <= 0) {
return;
}
- JVMResourceSampler jvmResourceSampler = new JVMResourceSampler("localhost", jmxPort, m_results);
+ JVMResourceSampler jvmResourceSampler = new JVMResourceSampler("localhost", jmxPort, this.results);
try {
jvmResourceSampler.connectRemoteJamesJMXServer();
log.info("connected to remote JMX");
- m_jvmResourceSampler = jvmResourceSampler;
+ this.jvmResourceSampler = jvmResourceSampler;
} catch (Exception e) {
throw new StartupException("failed to setup JMX remoting for JVM resource sampling", e);
}
}
- private void addUser(RemoteManagerClient remoteManagerClient, String username, String internalPassword) {
- remoteManagerClient.executeCommand("adduser " + username + " " + internalPassword);
- remoteManagerClient.readAnswer();
- log.info("user created: " + username);
- }
-
- /**
- * aquire a list of all existing internal James accounts
- * @return Set<String>, each String a username
- */
- private Set<String> getExistingUsers(String host, int remoteManagerPort, String remoteManagerUsername, String remoteManagerPassword) {
- RemoteManagerClient remoteManagerClient = new RemoteManagerClient(host, remoteManagerPort, remoteManagerUsername, remoteManagerPassword);
- boolean loginSuccess = remoteManagerClient.login();
- if (!loginSuccess) throw new Error("failed to login to remote manager");
- List<String> rawUserList = remoteManagerClient.executeCommand("listusers");
- remoteManagerClient.disconnect();
-
- Set<String> existingUsers = new LinkedHashSet<String>();
- Iterator<String> iterator = rawUserList.iterator();
- while (iterator.hasNext()) {
- String line = iterator.next();
- if (!line.startsWith("user: ")) continue;
-
- existingUsers.add(line.substring(6));
- }
- return existingUsers;
- }
-
}
diff --git a/src/main/java/org/apache/james/postage/classloading/CachedInstanceFactory.java b/src/main/java/org/apache/james/postage/classloading/CachedInstanceFactory.java
index 9f74066..f56e83e 100644
--- a/src/main/java/org/apache/james/postage/classloading/CachedInstanceFactory.java
+++ b/src/main/java/org/apache/james/postage/classloading/CachedInstanceFactory.java
@@ -31,14 +31,14 @@
private static Log log = LogFactory.getLog(CachedInstanceFactory.class);
- private final static Map<String, Class<?>> m_classes = new HashMap<String, Class<?>>();
+ private final static Map<String, Class<?>> classes = new HashMap<String, Class<?>>();
public static Object createInstance(String classname) {
Object object = null;
Class<?> clazz = null;
// class is configured, but not yet loaded
- if (classname != null && m_classes.get(classname) == null) {
+ if (classname != null && classes.get(classname) == null) {
try {
clazz = Class.forName(classname);
} catch (ClassNotFoundException e) {
diff --git a/src/main/java/org/apache/james/postage/configuration/MailSender.java b/src/main/java/org/apache/james/postage/configuration/MailSender.java
index 33a1214..443c01e 100644
--- a/src/main/java/org/apache/james/postage/configuration/MailSender.java
+++ b/src/main/java/org/apache/james/postage/configuration/MailSender.java
@@ -20,14 +20,14 @@
package org.apache.james.postage.configuration;
-import org.apache.james.postage.mail.MailFactory;
-import org.apache.james.postage.mail.DefaultMailFactory;
-import org.apache.james.postage.result.MailProcessingRecord;
+import javax.mail.Message;
+import javax.mail.Session;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-
-import javax.mail.Session;
-import javax.mail.Message;
+import org.apache.james.postage.mail.DefaultMailFactory;
+import org.apache.james.postage.mail.MailFactory;
+import org.apache.james.postage.result.MailProcessingRecord;
/**
* specifies, how mail is to be generated and sent, as coming from the configuration (<send> element)<br/>
@@ -47,13 +47,13 @@
private int sizeMaxText = 1000;
private int sizeMinBinary = -1;
private int sizeMaxBinary = -1;
- private SendProfile m_parentProfile;
+ private SendProfile parentProfile;
- private String m_mailFactoryClassname = null;
- private Class<? extends MailFactory> m_mailFactoryClass = null;
+ private String mailFactoryClassname = null;
+ private Class<? extends MailFactory> mailFactoryClass = null;
public MailSender(SendProfile parent) {
- m_parentProfile = parent;
+ this.parentProfile = parent;
}
public int getSendPerMinute() {
@@ -135,15 +135,15 @@
}
public SendProfile getParentProfile() {
- return m_parentProfile;
+ return this.parentProfile;
}
public String getMailFactoryClassname() {
- return m_mailFactoryClassname;
+ return this.mailFactoryClassname;
}
public void setMailFactoryClassname(String mailFactoryClassname) {
- this.m_mailFactoryClassname = mailFactoryClassname;
+ this.mailFactoryClassname = mailFactoryClassname;
}
public boolean sendTextPart() {
@@ -163,20 +163,20 @@
MailFactory mailFactory = null;
// class is configured, but not yet loaded
- if (m_mailFactoryClassname != null && m_mailFactoryClass == null) {
+ if (this.mailFactoryClassname != null && this.mailFactoryClass == null) {
try {
- m_mailFactoryClass = (Class<? extends MailFactory>) Class.forName(m_mailFactoryClassname);
+ this.mailFactoryClass = (Class<? extends MailFactory>) Class.forName(this.mailFactoryClassname);
} catch (ClassNotFoundException e) {
- log.error("failed to load MailFactory class " + m_mailFactoryClassname, e);
+ log.error("failed to load MailFactory class " + this.mailFactoryClassname, e);
}
}
// create instance, if custom class is given
- if (m_mailFactoryClass != null) {
+ if (this.mailFactoryClass != null) {
try {
- mailFactory = m_mailFactoryClass.newInstance();
+ mailFactory = this.mailFactoryClass.newInstance();
} catch (Exception e) {
- log.error("failed to create instance if MailFactory class " + m_mailFactoryClassname, e);
+ log.error("failed to create instance if MailFactory class " + this.mailFactoryClassname, e);
}
}
diff --git a/src/main/java/org/apache/james/postage/configuration/PostageConfiguration.java b/src/main/java/org/apache/james/postage/configuration/PostageConfiguration.java
index 198111d..79d0f6e 100644
--- a/src/main/java/org/apache/james/postage/configuration/PostageConfiguration.java
+++ b/src/main/java/org/apache/james/postage/configuration/PostageConfiguration.java
@@ -17,214 +17,221 @@
* under the License. *
****************************************************************/
-
package org.apache.james.postage.configuration;
-import org.apache.james.postage.user.UserList;
-
import java.util.ArrayList;
-import java.util.List;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
+import org.apache.james.postage.user.UserList;
+
public class PostageConfiguration {
- private String m_id;
+ private String id;
- private int m_durationMinutes = 10;
+ private int durationMinutes = 10;
- private boolean m_internalReuseExisting = true;
+ private boolean internalReuseExisting = true;
- private Map<String, String> m_descriptionItems = new LinkedHashMap<String, String>();
+ private Map<String, String> descriptionItems = new LinkedHashMap<String, String>();
- private UserList m_externalUsers = null;
+ private UserList externalUsers = null;
- private UserList m_internalUsers = null;
+ private UserList internalUsers = null;
- private String m_testserverHost = null;
+ private String testserverHost = null;
- private int m_testserverPortSMTPForwarding = -1;
+ private int testserverPortSMTPForwarding = -1;
- private int m_testserverSMTPForwardingWaitSeconds = 0;
+ private int testserverSMTPForwardingWaitSeconds = 0;
- private int m_testserverPortSMTPInbound = -1;
+ private int testserverPortSMTPInbound = -1;
- private int m_testserverPortPOP3 = -1;
+ private int testserverPortPOP3 = -1;
- private int m_testserverPOP3FetchesPerMinute = 1;
+ private int testserverPOP3FetchesPerMinute = 1;
- private int m_testserverRemoteManagerPort = -1;
+ private int testserverRemoteManagerPort = -1;
- private String m_testserverRemoteManagerUsername = null;
+ private String testserverRemoteManagerUsername = null;
- private String m_testserverRemoteManagerPassword = null;
+ private String testserverRemoteManagerPassword = null;
- private String m_testserverSpamAccountUsername = null;
+ private String testserverSpamAccountUsername = null;
- private String m_testserverSpamAccountPassword = null;
+ private String testserverSpamAccountPassword = null;
- private int m_testserverJMXRemotingPort = -1;
+ private int testserverJMXRemotingPort = -1;
- private List<SendProfile> m_profiles = new ArrayList<SendProfile>();
+ private List<SendProfile> profiles = new ArrayList<SendProfile>();
public PostageConfiguration(String id) {
- m_id = id;
+ this.id = id;
}
public String getId() {
- return m_id;
+ return this.id;
}
public int getDurationMinutes() {
- return m_durationMinutes;
+ return this.durationMinutes;
}
public void setDurationMinutes(int durationMinutes) {
- m_durationMinutes = durationMinutes;
+ this.durationMinutes = durationMinutes;
}
public boolean isInternalReuseExisting() {
- return m_internalReuseExisting;
+ return this.internalReuseExisting;
}
public void addDescriptionItem(String name, String value) {
- m_descriptionItems.put(name, value);
+ this.descriptionItems.put(name, value);
}
public Map<String, String> getDescriptionItems() {
- return Collections.unmodifiableMap(m_descriptionItems);
+ return Collections.unmodifiableMap(this.descriptionItems);
}
public void setInternalReuseExisting(boolean internalReuseExisting) {
- m_internalReuseExisting = internalReuseExisting;
+ this.internalReuseExisting = internalReuseExisting;
}
public UserList getExternalUsers() {
- return m_externalUsers;
+ return this.externalUsers;
}
public void setExternalUsers(UserList externalUsers) {
- m_externalUsers = externalUsers;
+ this.externalUsers = externalUsers;
}
public UserList getInternalUsers() {
- return m_internalUsers;
+ return this.internalUsers;
}
public void setInternalUsers(UserList internalUsers) {
- m_internalUsers = internalUsers;
+ this.internalUsers = internalUsers;
}
public String getTestserverHost() {
- return m_testserverHost;
+ return this.testserverHost;
}
public void setTestserverHost(String testserverHost) {
- m_testserverHost = testserverHost;
+ this.testserverHost = testserverHost;
}
public int getTestserverPortSMTPForwarding() {
- return m_testserverPortSMTPForwarding;
+ return this.testserverPortSMTPForwarding;
}
public void setTestserverPortSMTPForwarding(int testserverPortSMTPForwarding) {
- m_testserverPortSMTPForwarding = testserverPortSMTPForwarding;
+ this.testserverPortSMTPForwarding = testserverPortSMTPForwarding;
}
public int getTestserverSMTPForwardingWaitSeconds() {
- return m_testserverSMTPForwardingWaitSeconds;
+ return this.testserverSMTPForwardingWaitSeconds;
}
- public void setTestserverSMTPForwardingWaitSeconds(int testserverSMTPForwardingWaitSeconds) {
- m_testserverSMTPForwardingWaitSeconds = testserverSMTPForwardingWaitSeconds;
+ public void setTestserverSMTPForwardingWaitSeconds(
+ int testserverSMTPForwardingWaitSeconds) {
+ this.testserverSMTPForwardingWaitSeconds = testserverSMTPForwardingWaitSeconds;
}
public int getTestserverPortSMTPInbound() {
- return m_testserverPortSMTPInbound;
+ return this.testserverPortSMTPInbound;
}
public void setTestserverPortSMTPInbound(int testserverPortSMTPInbound) {
- m_testserverPortSMTPInbound = testserverPortSMTPInbound;
+ this.testserverPortSMTPInbound = testserverPortSMTPInbound;
}
public int getTestserverPortPOP3() {
- return m_testserverPortPOP3;
+ return this.testserverPortPOP3;
}
public void setTestserverPortPOP3(int testserverPortPOP3) {
- m_testserverPortPOP3 = testserverPortPOP3;
+ this.testserverPortPOP3 = testserverPortPOP3;
}
public int getTestserverPOP3FetchesPerMinute() {
- return m_testserverPOP3FetchesPerMinute;
+ return this.testserverPOP3FetchesPerMinute;
}
- public void setTestserverPOP3FetchesPerMinute(int testserverPOP3FetchesPerMinute) {
- m_testserverPOP3FetchesPerMinute = testserverPOP3FetchesPerMinute;
+ public void setTestserverPOP3FetchesPerMinute(
+ int testserverPOP3FetchesPerMinute) {
+ this.testserverPOP3FetchesPerMinute = testserverPOP3FetchesPerMinute;
}
public int getTestserverRemoteManagerPort() {
- return m_testserverRemoteManagerPort;
+ return this.testserverRemoteManagerPort;
}
public void setTestserverRemoteManagerPort(int testserverRemoteManagerPort) {
- m_testserverRemoteManagerPort = testserverRemoteManagerPort;
+ this.testserverRemoteManagerPort = testserverRemoteManagerPort;
}
public String getTestserverRemoteManagerUsername() {
- return m_testserverRemoteManagerUsername;
+ return this.testserverRemoteManagerUsername;
}
- public void setTestserverRemoteManagerUsername(String testserverRemoteManagerUsername) {
- m_testserverRemoteManagerUsername = testserverRemoteManagerUsername;
+ public void setTestserverRemoteManagerUsername(
+ String testserverRemoteManagerUsername) {
+ this.testserverRemoteManagerUsername = testserverRemoteManagerUsername;
}
public String getTestserverRemoteManagerPassword() {
- return m_testserverRemoteManagerPassword;
+ return this.testserverRemoteManagerPassword;
}
- public void setTestserverRemoteManagerPassword(String testserverRemoteManagerPassword) {
- m_testserverRemoteManagerPassword = testserverRemoteManagerPassword;
+ public void setTestserverRemoteManagerPassword(
+ String testserverRemoteManagerPassword) {
+ this.testserverRemoteManagerPassword = testserverRemoteManagerPassword;
}
public String getTestserverSpamAccountUsername() {
- return m_testserverSpamAccountUsername;
+ return this.testserverSpamAccountUsername;
}
- public void setTestserverSpamAccountUsername(String testserverSpamAccountUsername) {
- m_testserverSpamAccountUsername = testserverSpamAccountUsername;
+ public void setTestserverSpamAccountUsername(
+ String testserverSpamAccountUsername) {
+ this.testserverSpamAccountUsername = testserverSpamAccountUsername;
}
public String getTestserverSpamAccountPassword() {
- return m_testserverSpamAccountPassword;
+ return this.testserverSpamAccountPassword;
}
- public void setTestserverSpamAccountPassword(String testserverSpamAccountPassword) {
- m_testserverSpamAccountPassword = testserverSpamAccountPassword;
+ public void setTestserverSpamAccountPassword(
+ String testserverSpamAccountPassword) {
+ this.testserverSpamAccountPassword = testserverSpamAccountPassword;
}
public int getTestserverPortJMXRemoting() {
- return m_testserverJMXRemotingPort;
+ return this.testserverJMXRemotingPort;
}
public void setTestserverPortJMXRemoting(int testserverJMXRemotingPort) {
- m_testserverJMXRemotingPort = testserverJMXRemotingPort;
+ this.testserverJMXRemotingPort = testserverJMXRemotingPort;
}
public void addProfile(SendProfile profile) {
- m_profiles.add(profile);
+ this.profiles.add(profile);
}
public List<SendProfile> getProfiles() {
- return Collections.unmodifiableList(m_profiles);
+ return Collections.unmodifiableList(this.profiles);
}
- public SendProfile findProfile(boolean sourceInternal, boolean targetInternal) {
- Iterator<SendProfile> iterator = m_profiles.iterator();
+ public SendProfile findProfile(boolean sourceInternal,
+ boolean targetInternal) {
+ Iterator<SendProfile> iterator = this.profiles.iterator();
while (iterator.hasNext()) {
SendProfile sendProfile = iterator.next();
- if (sendProfile.isSourceInternal() == sourceInternal && sendProfile.isTargetInternal() == targetInternal) {
+ if (sendProfile.isSourceInternal() == sourceInternal
+ && sendProfile.isTargetInternal() == targetInternal) {
return sendProfile;
}
}
@@ -232,7 +239,7 @@
}
public int getTotalMailsPerMin() {
- Iterator<SendProfile> iterator = m_profiles.iterator();
+ Iterator<SendProfile> iterator = this.profiles.iterator();
int total = 0;
while (iterator.hasNext()) {
SendProfile sendProfile = iterator.next();
diff --git a/src/main/java/org/apache/james/postage/configuration/SendProfile.java b/src/main/java/org/apache/james/postage/configuration/SendProfile.java
index 2026431..1a652be 100644
--- a/src/main/java/org/apache/james/postage/configuration/SendProfile.java
+++ b/src/main/java/org/apache/james/postage/configuration/SendProfile.java
@@ -21,53 +21,53 @@
package org.apache.james.postage.configuration;
import java.util.ArrayList;
-import java.util.List;
import java.util.Iterator;
+import java.util.List;
/**
* specifies for the contained MailSenders, what are source and target of each mail they generate
*/
public class SendProfile {
- private String m_profileName;
- private boolean m_sourceInternal = true;
- private boolean m_targetInternal = true;
+ private String profileName;
+ private boolean sourceInternal = true;
+ private boolean targetInternal = true;
- private final List<MailSender> m_mailSenders = new ArrayList<MailSender>();
+ private final List<MailSender> mailSenders = new ArrayList<MailSender>();
public SendProfile(String profileName) {
- m_profileName = profileName;
+ this.profileName = profileName;
}
public String getName() {
- return m_profileName;
+ return this.profileName;
}
public void setSourceInternal(boolean internal) {
- m_sourceInternal = internal;
+ this.sourceInternal = internal;
}
public boolean isSourceInternal() {
- return m_sourceInternal;
+ return this.sourceInternal;
}
public void setTargetInternal(boolean internal) {
- m_targetInternal = internal;
+ this.targetInternal = internal;
}
public boolean isTargetInternal() {
- return m_targetInternal;
+ return this.targetInternal;
}
public void addMailSender(MailSender mailSender) {
- m_mailSenders.add(mailSender);
+ this.mailSenders.add(mailSender);
}
public Iterator<MailSender> mailSenderIterator() {
- return m_mailSenders.iterator();
+ return this.mailSenders.iterator();
}
public int getTotalMailsPerMin() {
- Iterator<MailSender> iterator = m_mailSenders.iterator();
+ Iterator<MailSender> iterator = this.mailSenders.iterator();
int total = 0;
while (iterator.hasNext()) {
MailSender mailSender = iterator.next();
diff --git a/src/main/java/org/apache/james/postage/execution/SampleController.java b/src/main/java/org/apache/james/postage/execution/SampleController.java
index c5755e2..8e0f133 100644
--- a/src/main/java/org/apache/james/postage/execution/SampleController.java
+++ b/src/main/java/org/apache/james/postage/execution/SampleController.java
@@ -34,37 +34,37 @@
private static Log log = LogFactory.getLog(SampleController.class);
- private Sampler m_sampler;
- private int m_samplesPerMinute;
- private Timer m_timer;
- private int m_secondsDelayOnStop = 0;
+ private Sampler sampler;
+ private int samplesPerMinute;
+ private Timer timer;
+ private int secondsDelayOnStop = 0;
public SampleController(Sampler sampler, int samplesPerMinute) {
- m_sampler = sampler;
- m_samplesPerMinute = samplesPerMinute;
+ this.sampler = sampler;
+ this.samplesPerMinute = samplesPerMinute;
}
public SampleController(Sampler sampler, int samplesPerMinute, int secondsDelayOnStop) {
this(sampler, samplesPerMinute);
- m_secondsDelayOnStop = secondsDelayOnStop;
+ this.secondsDelayOnStop = secondsDelayOnStop;
}
public void runThreaded() {
- if (m_samplesPerMinute < 1) {
- log.warn("sample controller effectivly disabled with sample-per-minute value = " + m_samplesPerMinute);
+ if (this.samplesPerMinute < 1) {
+ log.warn("sample controller effectivly disabled with sample-per-minute value = " + this.samplesPerMinute);
return;
}
- m_timer = new Timer(true);
- m_timer.schedule(this, 5, 60*1000/m_samplesPerMinute);
+ this.timer = new Timer(true);
+ this.timer.schedule(this, 5, 60*1000/this.samplesPerMinute);
}
public void stop() {
- if (m_timer != null) m_timer.cancel();
+ if (this.timer != null) this.timer.cancel();
- if (m_secondsDelayOnStop > 0) {
+ if (this.secondsDelayOnStop > 0) {
try {
- log.warn("sampler is waiting additional seconds: " + m_secondsDelayOnStop + " (type = " + m_sampler.getClass().getName() + ")");
- Thread.sleep(m_secondsDelayOnStop * 1000);
+ log.warn("sampler is waiting additional seconds: " + this.secondsDelayOnStop + " (type = " + this.sampler.getClass().getName() + ")");
+ Thread.sleep(this.secondsDelayOnStop * 1000);
log.warn("sampler delay passed.");
} catch (InterruptedException e) {
; // fall thru
@@ -74,7 +74,7 @@
public void run() {
try {
- m_sampler.doSample();
+ this.sampler.doSample();
} catch (SamplingException e) {
log.warn("taking sample failed", e);
}
diff --git a/src/main/java/org/apache/james/postage/jmx/JVMResourceSampler.java b/src/main/java/org/apache/james/postage/jmx/JVMResourceSampler.java
index 8641358..eb4957e 100644
--- a/src/main/java/org/apache/james/postage/jmx/JVMResourceSampler.java
+++ b/src/main/java/org/apache/james/postage/jmx/JVMResourceSampler.java
@@ -20,21 +20,22 @@
package org.apache.james.postage.jmx;
-import org.apache.james.postage.execution.Sampler;
-import org.apache.james.postage.result.PostageRunnerResult;
-import org.apache.james.postage.result.JVMResourcesRecord;
-import org.apache.james.postage.SamplingException;
+import java.io.IOException;
+import java.util.Iterator;
-import javax.management.remote.JMXConnector;
-import javax.management.remote.JMXServiceURL;
-import javax.management.remote.JMXConnectorFactory;
-import javax.management.openmbean.CompositeDataSupport;
+import javax.management.Attribute;
import javax.management.AttributeList;
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
-import javax.management.Attribute;
-import java.io.IOException;
-import java.util.Iterator;
+import javax.management.openmbean.CompositeDataSupport;
+import javax.management.remote.JMXConnector;
+import javax.management.remote.JMXConnectorFactory;
+import javax.management.remote.JMXServiceURL;
+
+import org.apache.james.postage.SamplingException;
+import org.apache.james.postage.execution.Sampler;
+import org.apache.james.postage.result.JVMResourcesRecord;
+import org.apache.james.postage.result.PostageRunnerResult;
/**
* the peek into the James JVM is done using the build-in management (JMX) of J2SE 5 (and probably later)
@@ -52,25 +53,23 @@
* this class does not even compile on Java versions before JSE 5.<br/>
*/
public class JVMResourceSampler implements Sampler {
-
- private String m_host;
- private int m_port;
- private PostageRunnerResult m_results;
-
- private MBeanServerConnection m_mBeanServerConnection;
+ private String host;
+ private int port;
+ private PostageRunnerResult results;
+ private MBeanServerConnection mBeanServerConnection;
public JVMResourceSampler(String host, int port, PostageRunnerResult results) {
- m_host = host;
- m_port = port;
- m_results = results;
+ this.host = host;
+ this.port = port;
+ this.results = results;
}
public void connectRemoteJamesJMXServer() throws SamplingException {
- String serviceURL = "service:jmx:rmi:///jndi/rmi://" + m_host + ":" + m_port + "/jmxrmi";
+ String serviceURL = "service:jmx:rmi:///jndi/rmi://" + this.host + ":" + this.port + "/jmxrmi";
try {
JMXServiceURL jmxServiceURL = new JMXServiceURL(serviceURL);
JMXConnector jmxConnector = JMXConnectorFactory.connect(jmxServiceURL, null);
- m_mBeanServerConnection = jmxConnector.getMBeanServerConnection();
+ this.mBeanServerConnection = jmxConnector.getMBeanServerConnection();
} catch (IOException e) {
throw new SamplingException("could not connect to " + serviceURL, e);
}
@@ -96,7 +95,7 @@
CompositeDataSupport data;
try {
ObjectName name = new ObjectName(jmxObjectName);
- data = (CompositeDataSupport)m_mBeanServerConnection.getAttribute(name, attributeName);
+ data = (CompositeDataSupport)this.mBeanServerConnection.getAttribute(name, attributeName);
} catch (IOException e) {
throw new SamplingException("lost connection to JMX server", e);
} catch (Exception e) {
@@ -109,7 +108,7 @@
try {
ObjectName name = new ObjectName("java.lang:type=Threading");
String[] attributeNames = new String[] {"PeakThreadCount", "ThreadCount", "TotalStartedThreadCount"};
- AttributeList attributes = m_mBeanServerConnection.getAttributes(name, attributeNames);
+ AttributeList attributes = this.mBeanServerConnection.getAttributes(name, attributeNames);
return attributes;
} catch (IOException e) {
throw new SamplingException("lost connection to JMX server", e);
@@ -130,6 +129,6 @@
JVMResourcesRecord jvmResourcesRecord = new JVMResourcesRecord();
takeMemorySample(jvmResourcesRecord);
takeThreadingSample(jvmResourcesRecord);
- m_results.addJVMResult(jvmResourcesRecord);
+ this.results.addJVMResult(jvmResourcesRecord);
}
}
diff --git a/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java b/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java
index 270e340..97239d0 100644
--- a/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java
+++ b/src/main/java/org/apache/james/postage/mail/MailMatchingUtils.java
@@ -18,23 +18,23 @@
****************************************************************/
package org.apache.james.postage.mail;
-import org.apache.james.postage.PostageRunner;
-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;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.regex.Pattern;
import javax.mail.BodyPart;
import javax.mail.MessagingException;
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;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.james.postage.PostageRunner;
+import org.apache.james.postage.PostageRuntimeException;
+import org.apache.james.postage.classloading.CachedInstanceFactory;
+import org.apache.james.postage.result.MailProcessingRecord;
/**
* helps matching, analysing and validating result mails and sent test mails
@@ -146,7 +146,7 @@
Object content = bodyPart.getContent();
if (content instanceof InputStream) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
- IOUtil.copy(((InputStream) content), os);
+ IOUtils.copy(((InputStream) content), os);
return os.size();
} else if (content instanceof String) {
return ((String) content).length();
diff --git a/src/main/java/org/apache/james/postage/result/JVMResourcesRecord.java b/src/main/java/org/apache/james/postage/result/JVMResourcesRecord.java
index a24ee53..edc2b14 100644
--- a/src/main/java/org/apache/james/postage/result/JVMResourcesRecord.java
+++ b/src/main/java/org/apache/james/postage/result/JVMResourcesRecord.java
@@ -26,79 +26,79 @@
public class JVMResourcesRecord {
private static String SEPARATOR = ",";
- private final long m_timestamp = System.currentTimeMillis();
- private String m_errorMessage = null;
+ private final long timestamp = System.currentTimeMillis();
+ private String errorMessage = null;
- private long m_memoryCommitted = -1;
- private long m_memoryInit = -1;
- private long m_memoryMax = -1;
- private long m_memoryUsed = -1;
- private long m_threadCountPeak = -1;
- private long m_threadCountCurrent = -1;
- private long m_threadCountTotalStarted = -1;
+ private long memoryCommitted = -1;
+ private long memoryInit = -1;
+ private long memoryMax = -1;
+ private long memoryUsed = -1;
+ private long threadCountPeak = -1;
+ private long threadCountCurrent = -1;
+ private long threadCountTotalStarted = -1;
public String getErrorMessage() {
- return m_errorMessage;
+ return this.errorMessage;
}
public void setErrorMessage(String errorMessage) {
- m_errorMessage = errorMessage;
+ this.errorMessage = errorMessage;
}
public long getMemoryCommitted() {
- return m_memoryCommitted;
+ return this.memoryCommitted;
}
public void setMemoryCommitted(long memoryCommitted) {
- this.m_memoryCommitted = memoryCommitted;
+ this.memoryCommitted = memoryCommitted;
}
public long getMemoryInit() {
- return m_memoryInit;
+ return this.memoryInit;
}
public void setMemoryInit(long memoryInit) {
- this.m_memoryInit = memoryInit;
+ this.memoryInit = memoryInit;
}
public long getMemoryMax() {
- return m_memoryMax;
+ return this.memoryMax;
}
public void setMemoryMax(long memoryMax) {
- this.m_memoryMax = memoryMax;
+ this.memoryMax = memoryMax;
}
public long getMemoryUsed() {
- return m_memoryUsed;
+ return this.memoryUsed;
}
public void setMemoryUsed(long memoryUsed) {
- this.m_memoryUsed = memoryUsed;
+ this.memoryUsed = memoryUsed;
}
public long getThreadCountPeak() {
- return m_threadCountPeak;
+ return this.threadCountPeak;
}
public void setThreadCountPeak(long threadCountPeak) {
- this.m_threadCountPeak = threadCountPeak;
+ this.threadCountPeak = threadCountPeak;
}
public long getThreadCountCurrent() {
- return m_threadCountCurrent;
+ return this.threadCountCurrent;
}
public void setThreadCountCurrent(long threadCountCurrent) {
- this.m_threadCountCurrent = threadCountCurrent;
+ this.threadCountCurrent = threadCountCurrent;
}
public long getThreadCountTotalStarted() {
- return m_threadCountTotalStarted;
+ return this.threadCountTotalStarted;
}
public void setThreadCountTotalStarted(long threadCountTotalStarted) {
- this.m_threadCountTotalStarted = threadCountTotalStarted;
+ this.threadCountTotalStarted = threadCountTotalStarted;
}
public static StringBuffer writeHeader() {
@@ -119,15 +119,15 @@
public StringBuffer writeData() {
StringBuffer stringBuffer = new StringBuffer();
- stringBuffer.append(m_timestamp).append(SEPARATOR);
- stringBuffer.append(m_errorMessage).append(SEPARATOR);
- stringBuffer.append(m_memoryInit).append(SEPARATOR);
- stringBuffer.append(m_memoryMax).append(SEPARATOR);
- stringBuffer.append(m_memoryCommitted).append(SEPARATOR);
- stringBuffer.append(m_memoryUsed).append(SEPARATOR);
- stringBuffer.append(m_threadCountPeak).append(SEPARATOR);
- stringBuffer.append(m_threadCountCurrent).append(SEPARATOR);
- stringBuffer.append(m_threadCountTotalStarted).append(SEPARATOR);
+ stringBuffer.append(this.timestamp).append(SEPARATOR);
+ stringBuffer.append(this.errorMessage).append(SEPARATOR);
+ stringBuffer.append(this.memoryInit).append(SEPARATOR);
+ stringBuffer.append(this.memoryMax).append(SEPARATOR);
+ stringBuffer.append(this.memoryCommitted).append(SEPARATOR);
+ stringBuffer.append(this.memoryUsed).append(SEPARATOR);
+ stringBuffer.append(this.threadCountPeak).append(SEPARATOR);
+ stringBuffer.append(this.threadCountCurrent).append(SEPARATOR);
+ stringBuffer.append(this.threadCountTotalStarted).append(SEPARATOR);
stringBuffer.append("\r\n");
return stringBuffer;
diff --git a/src/main/java/org/apache/james/postage/result/MailProcessingRecord.java b/src/main/java/org/apache/james/postage/result/MailProcessingRecord.java
index 79597ee..3e2774b 100644
--- a/src/main/java/org/apache/james/postage/result/MailProcessingRecord.java
+++ b/src/main/java/org/apache/james/postage/result/MailProcessingRecord.java
@@ -28,7 +28,7 @@
public class MailProcessingRecord {
private static String SEPARATOR = ",";
- private static int m_messageId = 1;
+ private static int messageId = 1;
boolean matchedSentAndReceived = false;
boolean isReceivedValid = false;
@@ -57,7 +57,7 @@
String receivingQueue;
public synchronized static String getNextId() {
- return PostageRunner.getMessageIdPrefix() + (m_messageId++);
+ return PostageRunner.getMessageIdPrefix() + (messageId++);
}
public boolean isMatchedSentAndReceived() {
diff --git a/src/main/java/org/apache/james/postage/result/PostageRunnerResultImpl.java b/src/main/java/org/apache/james/postage/result/PostageRunnerResultImpl.java
index 2d35b4f..b02fd93 100644
--- a/src/main/java/org/apache/james/postage/result/PostageRunnerResultImpl.java
+++ b/src/main/java/org/apache/james/postage/result/PostageRunnerResultImpl.java
@@ -20,49 +20,50 @@
package org.apache.james.postage.result;
-import org.apache.commons.collections.map.HashedMap;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
+import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.io.File;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.LinkedHashMap;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
public class PostageRunnerResultImpl implements PostageRunnerResult {
private static Log log = LogFactory.getLog(PostageRunnerResultImpl.class);
- private Map<String, MailProcessingRecord> m_matchedMailResults = initMatchedMailResultContainer();
+ private Map<String, MailProcessingRecord> matchedMailResults = initMatchedMailResultContainer();
- private final Map<String, MailProcessingRecord> m_unmatchedMailResults = new HashedMap();
+ private final Map<String, MailProcessingRecord> unmatchedMailResults = new HashMap<String, MailProcessingRecord>();
- private List<ErrorRecord> m_errors = initErrorResultContainer();
+ private List<ErrorRecord> errors = initErrorResultContainer();
- private List<JVMResourcesRecord> m_jvmStatistics = initMatchedJVMStatisticsResultContainer();
+ private List<JVMResourcesRecord> jvmStatistics = initMatchedJVMStatisticsResultContainer();
- private long m_TimestampFirstResult = -1;
+ private long TimestampFirstResult = -1;
- private long m_TimestampLastResult = -1;
+ private long TimestampLastResult = -1;
- private long m_matchedMailCounter = 0;
+ private long matchedMailCounter = 0;
- private long m_validMailCounter = 0;
+ private long validMailCounter = 0;
- private Map<String, String> m_environmentInfo = new LinkedHashMap<String, String>();
+ private Map<String, String> environmentInfo = new LinkedHashMap<String, String>();
public void addNewMailRecord(MailProcessingRecord mailProcessingRecord) {
- if (m_TimestampFirstResult <= 0) m_TimestampFirstResult = System.currentTimeMillis();
- m_TimestampLastResult = System.currentTimeMillis();
+ if (this.TimestampFirstResult <= 0) this.TimestampFirstResult = System.currentTimeMillis();
+ this.TimestampLastResult = System.currentTimeMillis();
- MailProcessingRecord prevMailProcessingRecord = m_unmatchedMailResults.put(mailProcessingRecord.getMailId(), mailProcessingRecord);
+ MailProcessingRecord prevMailProcessingRecord = this.unmatchedMailResults.put(mailProcessingRecord.getMailId(), mailProcessingRecord);
if (prevMailProcessingRecord != null) {
log.error("mail result already contained in unmatched list!");
}
@@ -73,17 +74,17 @@
String mailId = mailProcessingRecord.getMailId();
if (mailId == null) return null;
- if (m_unmatchedMailResults.containsKey(mailId)) {
+ if (this.unmatchedMailResults.containsKey(mailId)) {
// merge both mail result objects into one and move it to matched list
- MailProcessingRecord match = m_unmatchedMailResults.remove(mailId);
+ MailProcessingRecord match = this.unmatchedMailResults.remove(mailId);
log.info("matched test mail having id = " + mailId + " received by queue = " + mailProcessingRecord.getReceivingQueue());
match.merge(mailProcessingRecord); // copy new data to saved record
- m_matchedMailResults.put(mailId, match);
- m_matchedMailCounter++;
+ this.matchedMailResults.put(mailId, match);
+ this.matchedMailCounter++;
return match;
- } else if (m_matchedMailResults.containsKey(mailId)) {
+ } else if (this.matchedMailResults.containsKey(mailId)) {
log.warn("mail already matched for mailId = " + mailId);
} else {
log.warn("mail match candidate has unknown (purged?) mailId = " + mailId);
@@ -93,33 +94,33 @@
}
public void recordValidatedMatch(MailProcessingRecord matchedAndMergedRecord) {
- if (!m_matchedMailResults.values().contains(matchedAndMergedRecord)) {
+ if (!this.matchedMailResults.values().contains(matchedAndMergedRecord)) {
log.error("cannot record validation result for (already written?) result having id "
+ matchedAndMergedRecord.getMailId());
return;
}
- if (matchedAndMergedRecord.isReceivedValid()) m_validMailCounter++;
+ if (matchedAndMergedRecord.isReceivedValid()) this.validMailCounter++;
}
public void addJVMResult(JVMResourcesRecord jvmResourcesRecord) {
- m_jvmStatistics.add(jvmResourcesRecord);
+ this.jvmStatistics.add(jvmResourcesRecord);
}
public void setEnvironmentDescription(Map<String, String> descriptionItems) {
- m_environmentInfo.putAll(descriptionItems);
+ this.environmentInfo.putAll(descriptionItems);
}
public long getUnmatchedMails() {
- return m_unmatchedMailResults.size();
+ return this.unmatchedMailResults.size();
}
public long getMatchedMails() {
- return m_matchedMailCounter;
+ return this.matchedMailCounter;
}
public long getValidMails() {
- return m_validMailCounter;
+ return this.validMailCounter;
}
public void writeMailResults(OutputStreamWriter outputStreamWriter, boolean flushOnlyMatched) throws IOException {
@@ -131,44 +132,44 @@
}
private void writeUnmatchedMailResults(OutputStreamWriter outputStreamWriter) throws IOException {
- writeMailResults(m_unmatchedMailResults, outputStreamWriter);
+ writeMailResults(this.unmatchedMailResults, outputStreamWriter);
outputStreamWriter.flush();
}
private void writeMatchedMailResults(OutputStreamWriter outputStreamWriter) throws IOException {
- Map<String, MailProcessingRecord> writeResults = m_matchedMailResults; // keep current results for writing
- m_matchedMailResults = initMatchedMailResultContainer(); // establish new map for further unwritten results
+ Map<String, MailProcessingRecord> writeResults = this.matchedMailResults; // keep current results for writing
+ this.matchedMailResults = initMatchedMailResultContainer(); // establish new map for further unwritten results
writeMailResults(writeResults, outputStreamWriter);
outputStreamWriter.flush();
}
private void writeGeneralData(OutputStreamWriter outputStreamWriter) throws IOException {
- outputStreamWriter.write("start," + m_TimestampFirstResult + "," + new Date(m_TimestampFirstResult) + "\r\n");
- outputStreamWriter.write("end," + m_TimestampLastResult + "," + new Date(m_TimestampLastResult) + "\r\n");
+ outputStreamWriter.write("start," + this.TimestampFirstResult + "," + new Date(this.TimestampFirstResult) + "\r\n");
+ outputStreamWriter.write("end," + this.TimestampLastResult + "," + new Date(this.TimestampLastResult) + "\r\n");
outputStreamWriter.write("current," + System.currentTimeMillis() + "," + new Date() + "\r\n");
- Iterator<String> iterator = m_environmentInfo.keySet().iterator();
+ Iterator<String> iterator = this.environmentInfo.keySet().iterator();
while (iterator.hasNext()) {
String elementName = iterator.next();
- String elementValue = m_environmentInfo.get(elementName);
+ String elementValue = this.environmentInfo.get(elementName);
outputStreamWriter.write(elementName + "," + elementValue + "\r\n");
}
}
public long getTimestampFirstResult() {
- return m_TimestampFirstResult;
+ return this.TimestampFirstResult;
}
public long getTimestampLastResult() {
- return m_TimestampLastResult;
+ return this.TimestampLastResult;
}
public void addError(int errorNumber, String errorMessage) {
- m_errors.add(new ErrorRecord(errorNumber, errorMessage));
+ this.errors.add(new ErrorRecord(errorNumber, errorMessage));
}
public long getErrorCount() {
- return m_errors.size();
+ return this.errors.size();
}
private void writeMailResults(Map<String, MailProcessingRecord> mailResults, OutputStreamWriter outputStreamWriter) throws IOException {
@@ -241,8 +242,8 @@
}
private void writeJVMStatisticsResults(OutputStreamWriter outputStreamWriter) throws IOException {
- List<JVMResourcesRecord> unwrittenResults = m_jvmStatistics;
- m_jvmStatistics = initMatchedJVMStatisticsResultContainer();
+ List<JVMResourcesRecord> unwrittenResults = this.jvmStatistics;
+ this.jvmStatistics = initMatchedJVMStatisticsResultContainer();
Iterator<JVMResourcesRecord> iterator = unwrittenResults.iterator();
while (iterator.hasNext()) {
JVMResourcesRecord record = iterator.next();
@@ -262,16 +263,16 @@
outputStreamWriter.write("timestamp,number,message\r\n");
}
- List<ErrorRecord> unwrittenResults = m_errors;
- m_errors = initErrorResultContainer();
+ List<ErrorRecord> unwrittenResults = this.errors;
+ this.errors = initErrorResultContainer();
Iterator<ErrorRecord> iterator = unwrittenResults.iterator();
while (iterator.hasNext()) {
ErrorRecord record = iterator.next();
StringBuffer resultString = new StringBuffer();
- resultString.append(record.m_timestamp).append(",");
- resultString.append(record.m_number).append(",");
- resultString.append(record.m_message).append(",");
+ resultString.append(record.timestamp).append(",");
+ resultString.append(record.number).append(",");
+ resultString.append(record.message).append(",");
resultString.append("\r\n");
outputStreamWriter.write(resultString.toString());
@@ -292,13 +293,13 @@
}
class ErrorRecord {
- long m_timestamp = -1;
- int m_number = -1;
- String m_message = null;
+ long timestamp = -1;
+ int number = -1;
+ String message = null;
- public ErrorRecord(int m_number, String m_message) {
- this.m_timestamp = System.currentTimeMillis();
- this.m_number = m_number;
- this.m_message = m_message;
+ public ErrorRecord(int number, String message) {
+ this.timestamp = System.currentTimeMillis();
+ this.number = number;
+ this.message = message;
}
}
diff --git a/src/main/java/org/apache/james/postage/user/UserList.java b/src/main/java/org/apache/james/postage/user/UserList.java
index 3951aac..db5e865 100644
--- a/src/main/java/org/apache/james/postage/user/UserList.java
+++ b/src/main/java/org/apache/james/postage/user/UserList.java
@@ -16,68 +16,65 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/
-
-
package org.apache.james.postage.user;
-import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
/**
- * collection of all users used for one Postage scenario
+ * Collection of all users used for one Postage scenario
*/
public class UserList {
-
- int m_count = 0;
- String m_namePrefix = null;
-
- List<String> m_users = new ArrayList<String>();
- String m_password = null; // common to all users, if set
- String m_domain = null; // domain, common to all users
+ int count = 0;
+ String namePrefix = null;
+ List<String> users = new ArrayList<String>();
+ String password = null; // common to all users, if set
+ String domain = null; // domain, common to all users
public UserList(int count, String namePrefix, String domain) {
- m_count = count;
- m_namePrefix = namePrefix;
- m_domain = domain;
+ this.count = count;
+ this.namePrefix = namePrefix;
+ this.domain = domain;
}
public UserList(int count, String namePrefix, String domain, String password) {
this(count, namePrefix, domain);
- m_password = password;
+ this.password = password;
}
public int getCount() {
- return m_count;
+ return this.count;
}
public String getNamePrefix() {
- return m_namePrefix;
+ return this.namePrefix;
}
public Iterator<String> getUsernames() {
- return m_users.iterator();
+ return this.users.iterator();
}
public void setExistingUsers(List<String> existingUsers) {
- m_users.clear();
- m_users.addAll(existingUsers);
+ this.users.clear();
+ this.users.addAll(existingUsers);
}
public String getPassword() {
- return m_password;
+ return this.password;
}
public String getDomain() {
- return m_domain;
+ return this.domain;
}
public String getRandomUsername() {
- if (m_users.isEmpty()) return null;
- return m_users.get((int)(Math.random() * (m_users.size() - 1)));
+ if (this.users.isEmpty()) return null;
+ return this.users.get((int)(Math.random() * (this.users.size() - 1)));
}
public String getEmailAddress(String username) {
- return username + "@" + m_domain;
+ return username + "@" + this.domain;
}
+
}