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 2010/01/07 20:36:07 UTC
svn commit: r896976 - in /james/mpt/trunk/mavenplugin: ./ pom.xml
src/main/java/org/apache/james/mpt/maven/AddUser.java
src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java
src/main/java/org/apache/james/mpt/maven/MailProtocolTestMojo.java
Author: norman
Date: Thu Jan 7 19:36:06 2010
New Revision: 896976
URL: http://svn.apache.org/viewvc?rev=896976&view=rev
Log:
Rename jar to work with maven and allow to configure more smoke tests then one (MPT-2)
Added:
james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java
james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java
Modified:
james/mpt/trunk/mavenplugin/ (props changed)
james/mpt/trunk/mavenplugin/pom.xml
james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTestMojo.java
Propchange: james/mpt/trunk/mavenplugin/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Thu Jan 7 19:36:06 2010
@@ -0,0 +1 @@
+target
Modified: james/mpt/trunk/mavenplugin/pom.xml
URL: http://svn.apache.org/viewvc/james/mpt/trunk/mavenplugin/pom.xml?rev=896976&r1=896975&r2=896976&view=diff
==============================================================================
--- james/mpt/trunk/mavenplugin/pom.xml (original)
+++ james/mpt/trunk/mavenplugin/pom.xml Thu Jan 7 19:36:06 2010
@@ -28,7 +28,7 @@
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.james</groupId>
- <artifactId>apache-james-mpt-mavenplugin</artifactId>
+ <artifactId>maven-mpt-plugin</artifactId>
<name>Apache JAMES MPT Maven2 Plugin</name>
<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
Added: james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java
URL: http://svn.apache.org/viewvc/james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java?rev=896976&view=auto
==============================================================================
--- james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java (added)
+++ james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/AddUser.java Thu Jan 7 19:36:06 2010
@@ -0,0 +1,122 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mpt.maven;
+
+import java.io.File;
+
+
+/**
+ * Adds a user.
+ */
+public class AddUser {
+
+ private int port;
+ private String user;
+ private String passwd;
+ private String scriptText;
+ private String host;
+ private File scriptFile;
+
+ /**
+ * Gets the host (either name or number) against which this
+ * test will run.
+ * @return host, not null
+ */
+ public String getHost() {
+ return host;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ /**
+ * Gets the port against which the user addition
+ * script should be executed.
+ * @return port number
+ */
+ public int getPort() {
+ return port;
+ }
+
+ /**
+ * Sets the port against which the user addition
+ * script should be executed.
+ * @param port port number
+ */
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ /**
+ * Gets the password for the user.
+ * @return password not null
+ */
+ public String getPasswd() {
+ return passwd;
+ }
+
+ /**
+ * Sets the password for the user.
+ * This will be passed in the user creation script.
+ * @param passwd not null
+ */
+ public void setPasswd(String passwd) {
+ this.passwd = passwd;
+ }
+
+ /**
+ * Gets the name of the user to be created.
+ * @return user name, not null
+ */
+ public String getUser() {
+ return user;
+ }
+
+ /**
+ * Sets the name of the user to be created.
+ * @param user not null
+ */
+ public void setUser(String user) {
+ this.user = user;
+ }
+
+ /**
+ * Sets user addition script.
+ * @param scriptText not null
+ */
+ public void setScriptText(String scriptText) {
+ this.scriptText = scriptText;
+ }
+
+
+ public String getScriptText() {
+ return scriptText;
+ }
+
+ public File getScriptFile() {
+ return scriptFile;
+ }
+
+ public void setScriptFile(File scriptFile) {
+ this.scriptFile = scriptFile;
+ }
+
+}
\ No newline at end of file
Added: james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java
URL: http://svn.apache.org/viewvc/james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java?rev=896976&view=auto
==============================================================================
--- james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java (added)
+++ james/mpt/trunk/mavenplugin/src/main/java/org/apache/james/mpt/maven/MailProtocolTest.java Thu Jan 7 19:36:06 2010
@@ -0,0 +1,194 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mpt.maven;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.StringReader;
+
+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.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+
+public class MailProtocolTest implements Monitor{
+
+ private Integer port;
+
+ private File scriptFile;
+
+ private String host;
+
+ private String shabang;
+
+ private AddUser[] addUsers;
+
+ public void setScriptFile(File scriptFile) {
+ this.scriptFile = scriptFile;
+ }
+
+ public void setPort(Integer port) {
+ this.port = port;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+
+ public void setShabang(String shabang) {
+ this.shabang = shabang;
+ }
+
+ public void setAddUser(AddUser[] addUsers) {
+ this.addUsers = addUsers;
+ }
+
+
+ /**
+ * Gets the host (either name or number) against which this
+ * test will run.
+ * @return host, not null
+ */
+ public String getHost() {
+ return host;
+ }
+
+
+ /**
+ * Gets the port against which this test will run.
+ * @return port number
+ */
+ public int getPort() {
+ return port;
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.maven.plugin.AbstractMojo#execute()
+ */
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ validate();
+
+
+ for (int i = 0; i < addUsers.length; i++) {
+ AddUser addUser = (AddUser) addUsers[i];
+ try {
+
+ final Reader reader;
+ if (addUser.getScriptText() != null) {
+ reader = new StringReader(addUser.getScriptText());
+ } else {
+ reader = new FileReader(addUser.getScriptFile());
+ }
+ final ScriptedUserAdder adder = new ScriptedUserAdder(addUser.getHost(), addUser.getPort(), this);
+ adder.addUser(addUser.getUser(), addUser.getPasswd(), reader);
+ } catch (Exception e) {
+ //getLog().error("Unable to add user", e);
+ throw new MojoFailureException("User addition failed: \n" + e.getMessage());
+ }
+ }
+ final Runner runner = new Runner();
+ InputStream inputStream;
+ try {
+ inputStream = new FileInputStream(scriptFile);
+
+ final ExternalHostSystem hostSystem = new ExternalHostSystem(host, port, this, shabang, null);
+ final ProtocolSessionBuilder builder = new ProtocolSessionBuilder();
+
+ builder.addProtocolLines(scriptFile.getName(), inputStream, runner.getTestElements());
+ runner.runSessions(hostSystem);
+
+ } catch (IOException e1) {
+ throw new MojoExecutionException("Cannot load script " + scriptFile.getName(), e1);
+ } catch (Exception e) {
+ throw new MojoExecutionException("[FAILURE] in script " + scriptFile.getName() + "\n" + e.getMessage(), e);
+ }
+
+ }
+
+ /**
+ * 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 (scriptFile.exists() == false ) {
+ throw new MojoFailureException("'scriptFile' not exists");
+ }
+
+ for (int i = 0; i < addUsers.length; i++) {
+ AddUser addUser = (AddUser)addUsers[i];
+
+ if (addUser.getScriptText() == null && addUser.getScriptFile() == null) {
+ throw new MojoFailureException("AddUser must contain the text of the script or a scriptFile");
+ }
+
+ if (addUser.getPort() <= 0) {
+ throw new MojoFailureException("'port' attribute must be set on AddUser to the port against which the script should run.");
+ }
+
+ if (addUser.getHost() == null) {
+ throw new MojoFailureException("'host' attribute must be set on AddUser to the host against which the script should run.");
+ }
+ }
+
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mpt.Monitor#debug(char)
+ */
+ public void debug(char character) {
+ //getLog().debug("'" + character + "'");
+ // do nothing by default
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mpt.Monitor#debug(java.lang.String)
+ */
+ public void debug(String message) {
+ //getLog().debug(message);
+ // do nothing by default
+
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.mpt.Monitor#note(java.lang.String)
+ */
+ public void note(String message) {
+ //getLog().debug(message);
+ System.out.println(message);
+ }
+}
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=896976&r1=896975&r2=896976&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 Thu Jan 7 19:36:06 2010
@@ -19,19 +19,6 @@
package org.apache.james.mpt.maven;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-
-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;
@@ -39,258 +26,21 @@
/**
* @goal run
*/
-public class MailProtocolTestMojo extends AbstractMojo implements Monitor{
-
- /**
- *
- * @parameter
- * @required
- */
- private Integer port;
-
- /**
- *
- * @parameter
- * @required
- */
- private File scriptFile;
-
- /**
- * @required
- * @parameter
- */
- private String host;
-
- /**
- * @parameter
- */
- private String shabang;
-
- /**
- * @parameter
- */
- private AddUser[] addUsers;
-
-
- /**
- * Gets the host (either name or number) against which this
- * test will run.
- * @return host, not null
- */
- public String getHost() {
- return host;
- }
-
-
- /**
- * Gets the port against which this test will run.
- * @return port number
- */
- public int getPort() {
- return port;
- }
-
-
- /*
- * (non-Javadoc)
- * @see org.apache.maven.plugin.AbstractMojo#execute()
- */
- public void execute() throws MojoExecutionException, MojoFailureException {
- validate();
-
-
- for (int i = 0; i < addUsers.length; i++) {
- AddUser addUser = (AddUser) addUsers[i];
- try {
-
- final Reader reader;
- if (addUser.getScriptText() != null) {
- reader = new StringReader(addUser.getScriptText());
- } else {
- reader = new FileReader(addUser.getScriptFile());
- }
- final ScriptedUserAdder adder = new ScriptedUserAdder(addUser.getHost(), addUser.getPort(), MailProtocolTestMojo.this);
- adder.addUser(addUser.getUser(), addUser.getPasswd(), reader);
- } catch (Exception e) {
- getLog().error("Unable to add user", e);
- throw new MojoFailureException("User addition failed: \n" + e.getMessage());
- }
- }
- final Runner runner = new Runner();
- InputStream inputStream;
- try {
- inputStream = new FileInputStream(scriptFile);
-
- final ExternalHostSystem hostSystem = new ExternalHostSystem(host, port, this, shabang, null);
- final ProtocolSessionBuilder builder = new ProtocolSessionBuilder();
-
- builder.addProtocolLines(scriptFile.getName(), inputStream, runner.getTestElements());
- runner.runSessions(hostSystem);
-
- } catch (IOException e1) {
- throw new MojoExecutionException("Cannot load script " + scriptFile.getName(), e1);
- } catch (Exception e) {
- throw new MojoExecutionException("[FAILURE] in script " + scriptFile.getName() + "\n" + e.getMessage(), e);
- }
-
- }
+public class MailProtocolTestMojo extends AbstractMojo{
/**
- * Validate if the configured parameters are valid
- *
- * @throws MojoFailureException
+ * @parameter
+ * @required
*/
- private void validate() throws MojoFailureException {
- if (port <= 0) {
- throw new MojoFailureException("'port' configuration must be set.");
- }
-
- if (scriptFile.exists() == false ) {
- throw new MojoFailureException("'scriptFile' not exists");
- }
-
- for (int i = 0; i < addUsers.length; i++) {
- AddUser addUser = (AddUser)addUsers[i];
-
- if (addUser.getScriptText() == null && addUser.getScriptFile() == null) {
- throw new MojoFailureException("AddUser must contain the text of the script or a scriptFile");
- }
-
- if (addUser.getPort() <= 0) {
- throw new MojoFailureException("'port' attribute must be set on AddUser to the port against which the script should run.");
- }
-
- if (addUser.getHost() == null) {
- throw new MojoFailureException("'host' attribute must be set on AddUser to the host against which the script should run.");
- }
- }
-
- }
-
-
- /*
- * (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);
- }
+ private MailProtocolTest[] mailProtocolTests;
- /*
- * (non-Javadoc)
- * @see org.apache.james.mpt.Monitor#note(java.lang.String)
- */
- public void note(String message) {
- getLog().debug(message);
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ for (int i = 0; i < mailProtocolTests.length; i++) {
+ MailProtocolTest test = mailProtocolTests[i];
+ test.execute();
+ }
}
-
-
-
- /**
- * Adds a user.
- */
- public class AddUser {
-
- private int port;
- private String user;
- private String passwd;
- private String scriptText;
- private String host;
- private File scriptFile;
-
- /**
- * Gets the host (either name or number) against which this
- * test will run.
- * @return host, not null
- */
- public String getHost() {
- return host;
- }
-
- public void setHost(String host) {
- this.host = host;
- }
-
- /**
- * Gets the port against which the user addition
- * script should be executed.
- * @return port number
- */
- public int getPort() {
- return port;
- }
-
- /**
- * Sets the port against which the user addition
- * script should be executed.
- * @param port port number
- */
- public void setPort(int port) {
- this.port = port;
- }
-
- /**
- * Gets the password for the user.
- * @return password not null
- */
- public String getPasswd() {
- return passwd;
- }
-
- /**
- * Sets the password for the user.
- * This will be passed in the user creation script.
- * @param passwd not null
- */
- public void setPasswd(String passwd) {
- this.passwd = passwd;
- }
-
- /**
- * Gets the name of the user to be created.
- * @return user name, not null
- */
- public String getUser() {
- return user;
- }
-
- /**
- * Sets the name of the user to be created.
- * @param user not null
- */
- public void setUser(String user) {
- this.user = user;
- }
-
- /**
- * Sets user addition script.
- * @param scriptText not null
- */
- public void setScriptText(String scriptText) {
- this.scriptText = scriptText;
- }
-
-
- public String getScriptText() {
- return scriptText;
- }
-
- public File getScriptFile() {
- return scriptFile;
- }
-
- public void setScriptFile(File scriptFile) {
- this.scriptFile = scriptFile;
- }
-
- }
+
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org