You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2009/12/02 08:02:10 UTC
svn commit: r886063 - in /james/mpt/trunk/mavenplugin: pom.xml
src/main/java/org/apache/james/mpt/maven/MailProtocolTestMojo.java
Author: norman
Date: Wed Dec 2 07:02:09 2009
New Revision: 886063
URL: http://svn.apache.org/viewvc?rev=886063&view=rev
Log:
more work on the maven2 plugin (MPT-2)
Modified:
james/mpt/trunk/mavenplugin/pom.xml
james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTestMojo.java
Modified: james/mpt/trunk/mavenplugin/pom.xml
URL: http://svn.apache.org/viewvc/james/mpt/trunk/mavenplugin/pom.xml?rev=886063&r1=886062&r2=886063&view=diff
==============================================================================
--- james/mpt/trunk/mavenplugin/pom.xml (original)
+++ james/mpt/trunk/mavenplugin/pom.xml Wed Dec 2 07:02:09 2009
@@ -33,7 +33,7 @@
<description>Apache JAMES Mail Protocol Tester (MPT) is a library providing a framework for the
scritable functional testing of ASCII based line protocols. This Maven2 Plugin is an easy interface
to the library requiring no extra coding.</description>
- <url>http://james.apache.org/mpt/antlib</url>
+ <url>http://james.apache.org/mpt/mavenplugin</url>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
@@ -99,7 +99,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Export-Package>org.apache.james.mpt.ant</Export-Package>
+ <Export-Package>org.apache.james.mpt.maven</Export-Package>
<Embed-Dependency>*;scope=runtime</Embed-Dependency>
</instructions>
</configuration>
@@ -122,9 +122,9 @@
</build>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/james/mpt/trunk/antlib</connection>
- <developerConnection>scm:svn:https://rdonkin@svn.apache.org/repos/asf/james/mpt/trunk/antlib</developerConnection>
- <url>http://svn.apache.org/viewcvs.cgi/james/mpt/trunk/antlib?root=Apache-SVN</url>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/james/mpt/trunk/maven</connection>
+ <developerConnection>scm:svn:https://rdonkin@svn.apache.org/repos/asf/james/mpt/trunk/maven</developerConnection>
+ <url>http://svn.apache.org/viewcvs.cgi/james/mpt/trunk/maven?root=Apache-SVN</url>
</scm>
</project>
Modified: james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTestMojo.java
URL: http://svn.apache.org/viewvc/james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTestMojo.java?rev=886063&r1=886062&r2=886063&view=diff
==============================================================================
--- james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTestMojo.java (original)
+++ james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTestMojo.java Wed Dec 2 07:02:09 2009
@@ -23,50 +23,75 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
import org.apache.james.mpt.ExternalHostSystem;
import org.apache.james.mpt.Monitor;
import org.apache.james.mpt.ProtocolSessionBuilder;
import org.apache.james.mpt.Runner;
+import org.apache.james.mpt.ScriptedUserAdder;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+/**
+ * @goal mpt
+ */
public class MailProtocolTestMojo extends AbstractMojo implements Monitor{
/**
*
- * @parameter default-value="0"
+ * @parameter
+ * @required
*/
private Integer port;
/**
*
* @parameter
+ * @required
*/
private File scriptFile;
/**
+ * @required
* @parameter
*/
private String host;
-
+ /**
+ * @parameter
+ */
+ private String user;
+ /**
+ * @parameter
+ */
+ private String pass;
/**
* @parameter
*/
private String shabang;
+ /*
+ * (non-Javadoc)
+ * @see org.apache.maven.plugin.AbstractMojo#execute()
+ */
public void execute() throws MojoExecutionException, MojoFailureException {
validate();
- final ExternalHostSystem hostSystem = new ExternalHostSystem(host, port, this, shabang, null);
- final ProtocolSessionBuilder builder = new ProtocolSessionBuilder();
-
+
final Runner runner = new Runner();
InputStream inputStream;
try {
inputStream = new FileInputStream(scriptFile);
+
+ final ScriptedUserAdder adder = new ScriptedUserAdder(host, port,this);
+
+ if (user != null) adder.addUser(user, pass, new InputStreamReader(inputStream));
+
+ final ExternalHostSystem hostSystem = new ExternalHostSystem(host, port, this, shabang, adder);
+ final ProtocolSessionBuilder builder = new ProtocolSessionBuilder();
+
builder.addProtocolLines(scriptFile.getName(), inputStream, runner.getTestElements());
runner.runSessions(hostSystem);
@@ -78,32 +103,42 @@
}
+ /**
+ * Validate if the configured parameters are valid
+ *
+ * @throws MojoFailureException
+ */
private void validate() throws MojoFailureException {
if (port <= 0) {
throw new MojoFailureException("'port' configuration must be set.");
}
- if (host == null) {
- throw new MojoFailureException("'host' configuration must be set.");
- }
-
- if (scriptFile == null ) {
- throw new MojoFailureException("'scriptFile' configuration must be set.");
- }
-
if (scriptFile.exists() == false ) {
throw new MojoFailureException("'scriptFile' not exists");
}
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mpt.Monitor#debug(char)
+ */
public void debug(char character) {
getLog().debug("'" + character + "'");
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mpt.Monitor#debug(java.lang.String)
+ */
public void debug(String message) {
getLog().debug(message);
}
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mpt.Monitor#note(java.lang.String)
+ */
public void note(String message) {
getLog().debug(message);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org