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 ba...@apache.org on 2007/09/21 11:22:32 UTC
svn commit: r578031 [3/4] - in
/james/jsieve/trunk/src/test/java/org/apache/jsieve: javaxmail/ junit/
parser/address/ samples/james/junit/ util/check/
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/HeaderTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import javax.mail.MessagingException;
@@ -30,458 +29,306 @@
import org.apache.jsieve.junit.utils.*;
import org.apache.jsieve.parser.generated.ParseException;
-
/**
* Class HeaderTest
*/
-public class HeaderTest extends TestCase
-{
+public class HeaderTest extends TestCase {
/**
* Constructor for HeaderTest.
+ *
* @param arg0
*/
- public HeaderTest(String arg0)
- {
+ public HeaderTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(HeaderTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
- }
-
-
-
+ TestManager.resetInstance();
+ }
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Test 'header'
*/
- public void testHeaderIsTrue()
- {
+ public void testHeaderIsTrue() {
boolean isTestPassed = false;
String script = "if header :is \"X-Caffeine\" \"C8H10N4O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
+ mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
JUnitUtils.interpret(mail, script);
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'header'
*/
- public void testHeaderCaseInsensitivity()
- {
+ public void testHeaderCaseInsensitivity() {
boolean isTestPassed = false;
String script = "if header :is \"X-Caffeine\" \"C8H10N4O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("x-caffeine", "C8H10N4O2");
+ mail.getMessage().addHeader("x-caffeine", "C8H10N4O2");
JUnitUtils.interpret(mail, script);
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Test 'header'
*/
- public void testHeaderIsTrueMulti1()
- {
+ public void testHeaderIsTrueMulti1() {
boolean isTestPassed = false;
String script = "if header :is [\"X-Decaf\", \"X-Caffeine\"] \"C8H10N4O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
+ mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
JUnitUtils.interpret(mail, script);
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'header'
*/
- public void testHeaderIsFalseMulti1()
- {
+ public void testHeaderIsFalseMulti1() {
boolean isTestPassed = false;
String script = "if header :is [\"X-Decaf\", \"X-Caffeine\"] \"C8H10N4O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
mail.getMessage().addHeader("X-Caffeine", "stuff");
- mail.getMessage().addHeader("X-Decaf", "more stuff");
+ mail.getMessage().addHeader("X-Decaf", "more stuff");
JUnitUtils.interpret(mail, script);
- isTestPassed = true;
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Test 'header'
*/
- public void testHeaderIsTrueMulti2()
- {
+ public void testHeaderIsTrueMulti2() {
boolean isTestPassed = false;
String script = "if header :is \"X-Caffeine\" [\"absent\", \"C8H10N4O2\"] {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
+ mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
JUnitUtils.interpret(mail, script);
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
-
+ }
+
/**
* Test for Test 'header'
*/
- public void testHeaderIsTrueMulti3()
- {
+ public void testHeaderIsTrueMulti3() {
boolean isTestPassed = false;
String script = "if header :is [\"X-Decaf\", \"X-Caffeine\"] [\"absent\", \"C8H10N4O2\"] {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "stuff");
- mail.getMessage().addHeader("X-Decaf", "C8H10N4O2");
+ mail.getMessage().addHeader("X-Caffeine", "stuff");
+ mail.getMessage().addHeader("X-Decaf", "C8H10N4O2");
JUnitUtils.interpret(mail, script);
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Test 'header'
*/
- public void testHeaderIsFalseValue()
- {
+ public void testHeaderIsFalseValue() {
boolean isTestPassed = false;
String script = "if header :is \"X-Caffeine\" \"C8H10N4O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "C8H10N4O");
+ mail.getMessage().addHeader("X-Caffeine", "C8H10N4O");
JUnitUtils.interpret(mail, script);
- isTestPassed = true;
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'header'
*/
- public void testHeaderIsFalseHeader()
- {
+ public void testHeaderIsFalseHeader() {
boolean isTestPassed = false;
String script = "if header :is \"X-Caffeine\" \"C8H10N4O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffein", "C8H10N4O2");
+ mail.getMessage().addHeader("X-Caffein", "C8H10N4O2");
JUnitUtils.interpret(mail, script);
- isTestPassed = true;
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Test 'header'
*/
- public void testHeaderContainsTrue()
- {
+ public void testHeaderContainsTrue() {
boolean isTestPassed = false;
String script = "if header :contains \"X-Caffeine\" \"C8H10\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
+ mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
JUnitUtils.interpret(mail, script);
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'header'
*/
- public void testHeaderContainsFalse()
- {
+ public void testHeaderContainsFalse() {
boolean isTestPassed = false;
String script = "if header :is \"X-Caffeine\" \"C8H10N4O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "izzy");
+ mail.getMessage().addHeader("X-Caffeine", "izzy");
JUnitUtils.interpret(mail, script);
- isTestPassed = true;
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'header'
*/
- public void testHeaderContainsNullTrue()
- {
+ public void testHeaderContainsNullTrue() {
boolean isTestPassed = false;
String script = "if header :contains \"X-Caffeine\" \"\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", null);
+ mail.getMessage().addHeader("X-Caffeine", null);
JUnitUtils.interpret(mail, script);
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'header'
*/
- public void testHeaderIsNullFalse()
- {
+ public void testHeaderIsNullFalse() {
boolean isTestPassed = false;
String script = "if header :is \"X-Caffeine\" \"\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", null);
+ mail.getMessage().addHeader("X-Caffeine", null);
JUnitUtils.interpret(mail, script);
- isTestPassed = true;
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Test 'header'
*/
- public void testHeaderMatchesTrue()
- {
+ public void testHeaderMatchesTrue() {
boolean isTestPassed = false;
String script = "if header :matches \"X-Caffeine\" \"*10N?O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
+ mail.getMessage().addHeader("X-Caffeine", "C8H10N4O2");
JUnitUtils.interpret(mail, script);
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'header'
*/
- public void testHeaderMatchesFalse()
- {
+ public void testHeaderMatchesFalse() {
boolean isTestPassed = false;
String script = "if header :matches \"X-Caffeine\" \"*10N?O2\" {throwTestException;}";
- try
- {
+ try {
SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().addHeader("X-Caffeine", "C8H10N4O3");
+ mail.getMessage().addHeader("X-Caffeine", "C8H10N4O3");
JUnitUtils.interpret(mail, script);
- isTestPassed = true;
- }
- catch (MessagingException e)
- {
- }
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (MessagingException e) {
+ } catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
-
-
+ }
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/KeepTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/KeepTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/KeepTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/KeepTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import org.apache.jsieve.CommandManager;
@@ -34,119 +33,88 @@
/**
* Class KeepTest
*/
-public class KeepTest extends TestCase
-{
+public class KeepTest extends TestCase {
/**
* Constructor for KeepTest.
+ *
* @param arg0
*/
- public KeepTest(String arg0)
- {
+ public KeepTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(KeepTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
+ TestManager.resetInstance();
}
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Command 'keep' with invalid arguments
*/
- public void testInvalidArguments()
- {
+ public void testInvalidArguments() {
boolean isTestPassed = false;
String script = "keep 1 ;";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
+ } catch (SyntaxException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
/**
* Test for Command 'keep' with an invalid block
*/
- public void testInvalidBlock()
- {
+ public void testInvalidBlock() {
boolean isTestPassed = false;
String script = "keep 1 {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
+ } catch (SyntaxException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
/**
* Test for Command 'keep'
*/
- public void testKeep()
- {
+ public void testKeep() {
boolean isTestPassed = false;
String script = "keep;";
- try
- {
+ try {
MailAdapter mail = JUnitUtils.createMail();
JUnitUtils.interpret(mail, script);
assertTrue(mail.getActions().size() == 1);
assertTrue(mail.getActions().get(0) instanceof ActionKeep);
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
-
-
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/LogTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/LogTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/LogTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/LogTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import org.apache.jsieve.CommandManager;
@@ -31,205 +30,147 @@
/**
* Class LogTest
*/
-public class LogTest extends TestCase
-{
+public class LogTest extends TestCase {
/**
* Constructor for LogTest.
+ *
* @param arg0
*/
- public LogTest(String arg0)
- {
+ public LogTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(LogTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
+ TestManager.resetInstance();
}
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Command 'log'.
*/
- public void testLogDebug()
- {
+ public void testLogDebug() {
boolean isTestPassed = false;
String script = "log :debug \"Log a debug message.\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- isTestPassed = true;
- }
- catch (ParseException e)
- {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
- catch (SieveException e)
- {
- }
- assertTrue(isTestPassed);
- }
-
+ assertTrue(isTestPassed);
+ }
+
/**
* Test for Command 'log'.
*/
- public void testLogError()
- {
+ public void testLogError() {
boolean isTestPassed = false;
String script = "log :error \"Log an error message.\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
- assertTrue(isTestPassed);
+ assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'log'.
*/
- public void testLogFatal()
- {
+ public void testLogFatal() {
boolean isTestPassed = false;
String script = "log :fatal \"Log a fatal message.\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- isTestPassed = true;
- }
- catch (ParseException e)
- {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
- catch (SieveException e)
- {
- }
- assertTrue(isTestPassed);
+ assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'log'.
*/
- public void testLogInfo()
- {
+ public void testLogInfo() {
boolean isTestPassed = false;
String script = "log :info \"Log an info message.\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
- assertTrue(isTestPassed);
+ assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'log'.
*/
- public void testLogTrace()
- {
+ public void testLogTrace() {
boolean isTestPassed = false;
String script = "log :trace \"Log a trace message.\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
- assertTrue(isTestPassed);
+ assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'log'.
*/
- public void testLogWarn()
- {
+ public void testLogWarn() {
boolean isTestPassed = false;
String script = "log :warn \"Log a warning message.\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- isTestPassed = true;
- }
- catch (ParseException e)
- {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
- catch (SieveException e)
- {
- }
- assertTrue(isTestPassed);
+ assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'log'.
*/
- public void testLogDefault()
- {
+ public void testLogDefault() {
boolean isTestPassed = false;
String script = "log \"Log a default message.\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
- assertTrue(isTestPassed);
- }
-
-
-
-
-
-
-
-
-
-
-
-
+ assertTrue(isTestPassed);
+ }
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/MultipleRequireTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/MultipleRequireTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/MultipleRequireTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/MultipleRequireTest.java Fri Sep 21 02:22:30 2007
@@ -25,7 +25,7 @@
import junit.framework.TestCase;
public class MultipleRequireTest extends TestCase {
-
+
private static final String MINIMAL_SIEVE = "require [\"fileinto\", \"reject\"];\n";
private static final String MULTIPLE_REQUIRED_SIEVE = "# \n" +
@@ -41,7 +41,7 @@
"\n";
MailAdapter mail;
-
+
protected void setUp() throws Exception {
super.setUp();
mail = JUnitUtils.createMail();
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/MultipleToTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/MultipleToTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/MultipleToTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/MultipleToTest.java Fri Sep 21 02:22:30 2007
@@ -21,8 +21,6 @@
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-import java.io.StringBufferInputStream;
-import java.io.StringReader;
import java.util.List;
import junit.framework.TestCase;
@@ -30,37 +28,36 @@
import org.apache.jsieve.util.check.ScriptChecker;
public class MultipleToTest extends TestCase {
-
- private static final String SOLO_TO_EMAIL =
- "Date: Sun, 1 Apr 2007 1100:00:00 +0100 (BST)\r\f" +
- "From: roadrunner@acme.example.com\r\f" +
- "To: coyote@desert.example.org\r\f" +
- "Subject: Who's The Fool?\r\f" +
- "\r\f" +
- "Beep-Beep\r\f";
-
- private static final String MULTIPLE_TO_EMAIL =
- "Date: Sun, 1 Apr 2007 1100:00:00 +0100 (BST)\r\f" +
- "From: roadrunner@acme.example.com\r\f" +
- "To: coyote@desert.example.org, bugs@example.org, " +
- " elmer@hunters.example.org,\r\f" +
- "Subject: Who's The Fool?\r\f" +
- "\r\f" +
- "Beep-Beep\r\f";
-
- private static final String FILTER_SCRIPT = "require \"fileinto\";\r\f" +
- "if address :is :all \"to\" \"coyote@desert.example.org\" {\r\f" +
- " fileinto \"coyote\";\r\f}\r\f" +
- "if address :is :all \"to\" \"bugs@example.org\" {\r\f" +
- " fileinto \"bugs\";\r\f}\r\f" +
- "if address :is :all \"to\" \"roadrunneracme.@example.org\" {\r\f" +
- " fileinto \"rr\";\r\f}\r\f" +
- "if address :is :all \"to\" \"elmer@hunters.example.org\" {\r\f" +
- " fileinto \"elmer\";\r\f}\r\f";
-
+
+ private static final String SOLO_TO_EMAIL = "Date: Sun, 1 Apr 2007 1100:00:00 +0100 (BST)\r\f"
+ + "From: roadrunner@acme.example.com\r\f"
+ + "To: coyote@desert.example.org\r\f"
+ + "Subject: Who's The Fool?\r\f"
+ + "\r\f"
+ + "Beep-Beep\r\f";
+
+ private static final String MULTIPLE_TO_EMAIL = "Date: Sun, 1 Apr 2007 1100:00:00 +0100 (BST)\r\f"
+ + "From: roadrunner@acme.example.com\r\f"
+ + "To: coyote@desert.example.org, bugs@example.org, "
+ + " elmer@hunters.example.org,\r\f"
+ + "Subject: Who's The Fool?\r\f"
+ + "\r\f"
+ + "Beep-Beep\r\f";
+
+ private static final String FILTER_SCRIPT = "require \"fileinto\";\r\f"
+ + "if address :is :all \"to\" \"coyote@desert.example.org\" {\r\f"
+ + " fileinto \"coyote\";\r\f}\r\f"
+ + "if address :is :all \"to\" \"bugs@example.org\" {\r\f"
+ + " fileinto \"bugs\";\r\f}\r\f"
+ + "if address :is :all \"to\" \"roadrunneracme.@example.org\" {\r\f"
+ + " fileinto \"rr\";\r\f}\r\f"
+ + "if address :is :all \"to\" \"elmer@hunters.example.org\" {\r\f"
+ + " fileinto \"elmer\";\r\f}\r\f";
+
public void testSingleTo() throws Exception {
ScriptChecker checker = new ScriptChecker();
- ScriptChecker.Results results = checker.check(toStream(SOLO_TO_EMAIL), toStream(FILTER_SCRIPT));
+ ScriptChecker.Results results = checker.check(toStream(SOLO_TO_EMAIL),
+ toStream(FILTER_SCRIPT));
if (results.getException() != null) {
fail(results.getException().toString());
}
@@ -68,10 +65,11 @@
assertEquals(1, actionsExecuted.size());
assertTrue(results.isActionFileInto("coyote", 0));
}
-
+
public void testMultipleTo() throws Exception {
ScriptChecker checker = new ScriptChecker();
- ScriptChecker.Results results = checker.check(toStream(MULTIPLE_TO_EMAIL), toStream(FILTER_SCRIPT));
+ ScriptChecker.Results results = checker.check(
+ toStream(MULTIPLE_TO_EMAIL), toStream(FILTER_SCRIPT));
if (results.getException() != null) {
fail(results.getException().toString());
}
@@ -81,7 +79,7 @@
assertTrue(results.isActionFileInto("bugs", 1));
assertTrue(results.isActionFileInto("elmer", 2));
}
-
+
private InputStream toStream(String in) throws Exception {
byte[] bytes = in.getBytes("US-ASCII");
ByteArrayInputStream result = new ByteArrayInputStream(bytes);
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/NotTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/NotTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/NotTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/NotTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import org.apache.jsieve.CommandManager;
@@ -33,89 +32,69 @@
/**
* Class NotTest
*/
-public class NotTest extends TestCase
-{
+public class NotTest extends TestCase {
/**
* Constructor for NotTest.
+ *
* @param arg0
*/
- public NotTest(String arg0)
- {
+ public NotTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(NotTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
- }
+ TestManager.resetInstance();
+ }
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Test 'not'
*/
- public void testIfNotFalse()
- {
+ public void testIfNotFalse() {
boolean isTestPassed = false;
String script = "if not false {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'true' with invalid argument
*/
- public void testInvalidArgument()
- {
+ public void testInvalidArgument() {
boolean isTestPassed = false;
String script = "if not 1 {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
+ } catch (SyntaxException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
+ }
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/OpenedAddress.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/OpenedAddress.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/OpenedAddress.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/OpenedAddress.java Fri Sep 21 02:22:30 2007
@@ -25,8 +25,11 @@
final class OpenedAddress extends Address {
- protected boolean match(MailAdapter mail, String addressPart, String comparator, String matchType, String headerName, String key) throws SieveException {
- return super.match(mail, addressPart, comparator, matchType, headerName, key);
+ protected boolean match(MailAdapter mail, String addressPart,
+ String comparator, String matchType, String headerName, String key)
+ throws SieveException {
+ return super.match(mail, addressPart, comparator, matchType,
+ headerName, key);
}
-
+
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/RejectTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/RejectTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/RejectTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/RejectTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import junit.framework.TestCase;
@@ -35,222 +34,161 @@
/**
* Class RejectTest
*/
-public class RejectTest extends TestCase
-{
+public class RejectTest extends TestCase {
/**
* Constructor for RejectTest.
+ *
* @param arg0
*/
- public RejectTest(String arg0)
- {
+ public RejectTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(RejectTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
+ TestManager.resetInstance();
}
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Command 'reject' with invalid arguments
*/
- public void testInvalidArguments()
- {
+ public void testInvalidArguments() {
boolean isTestPassed = false;
String script = "reject 1 ;";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
+ } catch (SyntaxException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
/**
* Test for Command 'reject' with an invalid block
*/
- public void testInvalidBlock()
- {
+ public void testInvalidBlock() {
boolean isTestPassed = false;
String script = "reject \"Spam not consumed here!\" {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
+ } catch (SyntaxException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
/**
* Test for Command 'reject'
*/
- public void testReject()
- {
+ public void testReject() {
boolean isTestPassed = false;
String script = "reject \"Spam not consumed here!\";";
- try
- {
+ try {
MailAdapter mail = JUnitUtils.createMail();
JUnitUtils.interpret(mail, script);
assertTrue(mail.getActions().size() == 1);
assertTrue(mail.getActions().get(0) instanceof ActionReject);
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'reject'
*/
- public void testRejectMissingMessage()
- {
+ public void testRejectMissingMessage() {
boolean isTestPassed = false;
String script = "reject;";
- try
- {
+ try {
MailAdapter mail = JUnitUtils.createMail();
JUnitUtils.interpret(mail, script);
assertTrue(mail.getActions().size() == 1);
assertTrue(mail.getActions().get(0) instanceof ActionReject);
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
- isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
+ isTestPassed = true;
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for duplicate Command 'reject'
*/
- public void testDuplicateReject()
- {
+ public void testDuplicateReject() {
boolean isTestPassed = false;
String script = "reject \"Spam not consumed here!\"; reject \"Spam not consumed here!\";";
- try
- {
+ try {
MailAdapter mail = JUnitUtils.createMail();
JUnitUtils.interpret(mail, script);
- }
- catch (CommandException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (CommandException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'reject' preceded by another command
*/
- public void testRejectAndAPrecedingCommand()
- {
+ public void testRejectAndAPrecedingCommand() {
boolean isTestPassed = false;
String script = "keep; reject \"Spam not consumed here!\";";
- try
- {
+ try {
MailAdapter mail = JUnitUtils.createMail();
JUnitUtils.interpret(mail, script);
- }
- catch (CommandException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (CommandException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Command 'reject' followed by another command
*/
- public void testRejectAndAFollowingCommand()
- {
+ public void testRejectAndAFollowingCommand() {
boolean isTestPassed = false;
String script = "reject \"Spam not consumed here!\"; keep;";
- try
- {
+ try {
MailAdapter mail = JUnitUtils.createMail();
JUnitUtils.interpret(mail, script);
- }
- catch (CommandException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (CommandException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
-
-
+ }
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/RequireTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/RequireTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/RequireTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/RequireTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import junit.framework.TestCase;
@@ -34,352 +33,253 @@
/**
* Class RequireTest
*/
-public class RequireTest extends TestCase
-{
+public class RequireTest extends TestCase {
/**
* Constructor for RequireTest.
+ *
* @param arg0
*/
- public RequireTest(String arg0)
- {
+ public RequireTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(RequireTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
+ TestManager.resetInstance();
}
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Command 'require' with a single command that is present
*/
- public void testSingleCommandSatisfied()
- {
+ public void testSingleCommandSatisfied() {
boolean isTestPassed = false;
String script = "require \"if\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'require' with a single test that is present
*/
- public void testSingleTestSatisfied()
- {
+ public void testSingleTestSatisfied() {
boolean isTestPassed = false;
String script = "require \"true\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Command 'require' with multiple commands that are present
*/
- public void testMultipleCommandSatisfied()
- {
+ public void testMultipleCommandSatisfied() {
boolean isTestPassed = false;
String script = "require [\"if\", \"elsif\", \"else\"];";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'require' with multiple tests that are present
*/
- public void testMultipleTestSatisfied()
- {
+ public void testMultipleTestSatisfied() {
boolean isTestPassed = false;
String script = "require [\"true\", \"false\", \"not\"];";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Command 'require' with a single command that is absent
*/
- public void testSingleCommandUnsatisfied()
- {
+ public void testSingleCommandUnsatisfied() {
boolean isTestPassed = false;
String script = "require \"absent\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (FeatureException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (FeatureException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'require' with a single test that is absent
*/
- public void testSingleTestUnsatisfied()
- {
+ public void testSingleTestUnsatisfied() {
boolean isTestPassed = false;
String script = "require \"absent\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (FeatureException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (FeatureException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'require' for missing argument
*/
- public void testMissingArgument()
- {
+ public void testMissingArgument() {
boolean isTestPassed = false;
String script = "require;";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (SyntaxException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'require' for extra argument
*/
- public void testExtraArgument()
- {
+ public void testExtraArgument() {
boolean isTestPassed = false;
String script = "require \"if\" 1;";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (SyntaxException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'require' rejecting Blocks
*/
- public void testRejectBlock()
- {
+ public void testRejectBlock() {
boolean isTestPassed = false;
String script = "require \"if\" {stop;}";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (SyntaxException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'require' after a Command
*/
- public void testInterveningCommand()
- {
+ public void testInterveningCommand() {
boolean isTestPassed = false;
String script = "fileinto \"someplace\"; require \"fileinto\";";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (CommandException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (CommandException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Command 'require' rejecting invalid arguments
*/
- public void testRejectInvalidArgument()
- {
+ public void testRejectInvalidArgument() {
boolean isTestPassed = false;
String script = "require 1 ;";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (SyntaxException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
- * Test for Command 'require' with a multiple commands of which one is absent
+ * Test for Command 'require' with a multiple commands of which one is
+ * absent
*/
- public void testMultipleCommandsUnsatisfied()
- {
+ public void testMultipleCommandsUnsatisfied() {
boolean isTestPassed = false;
String script = "require [\"if\", \"elsif\", \"absent\"];";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (FeatureException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (FeatureException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'require' with a multiple tests of which one is absent
*/
- public void testMultipleTestsUnsatisfied()
- {
+ public void testMultipleTestsUnsatisfied() {
boolean isTestPassed = false;
String script = "require [\"true\", \"false\", \"absent\"];";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (FeatureException e)
- {
- isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (FeatureException e) {
+ isTestPassed = true;
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
+ }
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/SizeTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/SizeTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/SizeTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/SizeTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import javax.mail.MessagingException;
@@ -36,230 +35,171 @@
/**
* Class SizeTest
*/
-public class SizeTest extends TestCase
-{
+public class SizeTest extends TestCase {
/**
* Constructor for SizeTest.
+ *
* @param arg0
*/
- public SizeTest(String arg0)
- {
+ public SizeTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(SizeTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
+ TestManager.resetInstance();
}
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Test 'size'
*/
- public void testSizeIsOverTrue()
- {
+ public void testSizeIsOverTrue() {
boolean isTestPassed = false;
SieveMailAdapter mail = null;
int size = 0;
- try
- {
+ try {
mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().setText("Hi!");
+ mail.getMessage().setText("Hi!");
mail.getMessage().saveChanges();
// Need to copy the mail to get JavaMail to report the message size
- // correctly (saveChanges() only saves the headers!)
+ // correctly (saveChanges() only saves the headers!)
mail = (SieveMailAdapter) JUnitUtils.copyMail(mail);
size = mail.getSize();
- }
- catch (SieveMailException e)
- {
- }
- catch (MessagingException e)
- {
+ } catch (SieveMailException e) {
+ } catch (MessagingException e) {
}
- String script =
- "if size :over "
- + new Integer(size - 1).toString()
+ String script = "if size :over " + new Integer(size - 1).toString()
+ " {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(mail, script);
}
- catch (ThrowTestException.TestException e)
- {
+ catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'size'
*/
- public void testSizeIsOverFalse()
- {
+ public void testSizeIsOverFalse() {
boolean isTestPassed = false;
SieveMailAdapter mail = null;
int size = 0;
- try
- {
+ try {
mail = (SieveMailAdapter) JUnitUtils.createMail();
- mail.getMessage().setText("Hi!");
+ mail.getMessage().setText("Hi!");
mail.getMessage().saveChanges();
// Need to copy the mail to get JavaMail to report the message size
- // correctly (saveChanges() only saves the headers!)
+ // correctly (saveChanges() only saves the headers!)
mail = (SieveMailAdapter) JUnitUtils.copyMail(mail);
size = mail.getSize();
- }
- catch (SieveMailException e)
- {
- }
- catch (MessagingException e)
- {
+ } catch (SieveMailException e) {
+ } catch (MessagingException e) {
}
- String script =
- "if size :over "
- + new Integer(size).toString()
+ String script = "if size :over " + new Integer(size).toString()
+ " {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(mail, script);
- isTestPassed = true;
+ isTestPassed = true;
}
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
-
+ }
+
/**
* Test for Test 'size'
*/
- public void testSizeIsUnderTrue()
- {
+ public void testSizeIsUnderTrue() {
boolean isTestPassed = false;
SieveMailAdapter mail = null;
int size = 0;
- try
- {
+ try {
mail = (SieveMailAdapter) JUnitUtils.createMail();
mail.getMessage().setText("Hi!");
mail.getMessage().saveChanges();
// Need to copy the mail to get JavaMail to report the message size
- // correctly (saveChanges() only saves the headers!)
+ // correctly (saveChanges() only saves the headers!)
mail = (SieveMailAdapter) JUnitUtils.copyMail(mail);
size = mail.getSize();
- }
- catch (SieveMailException e)
- {
- }
- catch (MessagingException e)
- {
+ } catch (SieveMailException e) {
+ } catch (MessagingException e) {
}
- String script =
- "if size :under "
- + new Integer(size + 1).toString()
+ String script = "if size :under " + new Integer(size + 1).toString()
+ " {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(mail, script);
}
- catch (ThrowTestException.TestException e)
- {
+ catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
+
/**
* Test for Test 'size'
*/
- public void testSizeIsUnderFalse()
- {
+ public void testSizeIsUnderFalse() {
boolean isTestPassed = false;
SieveMailAdapter mail = null;
int size = 0;
- try
- {
+ try {
mail = (SieveMailAdapter) JUnitUtils.createMail();
mail.getMessage().setText("Hi!");
mail.getMessage().saveChanges();
// Need to copy the mail to get JavaMail to report the message size
- // correctly (saveChanges() only saves the headers!)
+ // correctly (saveChanges() only saves the headers!)
mail = (SieveMailAdapter) JUnitUtils.copyMail(mail);
size = mail.getSize();
- }
- catch (SieveMailException e)
- {
- }
- catch (MessagingException e)
- {
+ } catch (SieveMailException e) {
+ } catch (MessagingException e) {
}
- String script =
- "if size :over "
- + new Integer(size).toString()
+ String script = "if size :over " + new Integer(size).toString()
+ " {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(mail, script);
isTestPassed = true;
}
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
+ }
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/StopTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/StopTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/StopTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/StopTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import junit.framework.TestCase;
@@ -35,117 +34,89 @@
/**
* Class StopTest
*/
-public class StopTest extends TestCase
-{
+public class StopTest extends TestCase {
/**
* Constructor for StopTest.
+ *
* @param arg0
*/
- public StopTest(String arg0)
- {
+ public StopTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(StopTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
+ TestManager.resetInstance();
}
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Command 'stop'. This has an implicit Keep.
*/
- public void testStop()
- {
+ public void testStop() {
boolean isTestPassed = false;
String script = "stop; throwTestException;";
- try
- {
+ try {
MailAdapter mail = JUnitUtils.createMail();
JUnitUtils.interpret(mail, script);
assertTrue(mail.getActions().size() == 1);
assertTrue(mail.getActions().get(0) instanceof ActionKeep);
- isTestPassed = true;
- }
- catch (ThrowTestException.TestException e)
- {
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ isTestPassed = true;
+ } catch (ThrowTestException.TestException e) {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'stop' with invalid arguments
*/
- public void testInvalidArguments()
- {
+ public void testInvalidArguments() {
boolean isTestPassed = false;
String script = "stop 1 ;";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
+ } catch (SyntaxException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Command 'stop' with an invalid block
*/
- public void testInvalidBlock()
- {
+ public void testInvalidBlock() {
boolean isTestPassed = false;
String script = "stop 1 {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
+ } catch (SyntaxException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
+ }
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/TrueTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/TrueTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/TrueTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/junit/TrueTest.java Fri Sep 21 02:22:30 2007
@@ -17,7 +17,6 @@
* under the License. *
****************************************************************/
-
package org.apache.jsieve.junit;
import org.apache.jsieve.CommandManager;
@@ -33,89 +32,69 @@
/**
* Class TrueTest
*/
-public class TrueTest extends TestCase
-{
+public class TrueTest extends TestCase {
/**
* Constructor for TrueTest.
+ *
* @param arg0
*/
- public TrueTest(String arg0)
- {
+ public TrueTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(TrueTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
CommandManager.resetInstance();
- TestManager.resetInstance();
- }
+ TestManager.resetInstance();
+ }
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
-
+
/**
* Test for Test 'true'
*/
- public void testIfTrue()
- {
+ public void testIfTrue() {
boolean isTestPassed = false;
String script = "if true {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (ThrowTestException.TestException e)
- {
+ } catch (ThrowTestException.TestException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
}
-
+
/**
* Test for Test 'true' with invalid argument
*/
- public void testInvalidArgument()
- {
+ public void testInvalidArgument() {
boolean isTestPassed = false;
String script = "if true 1 {throwTestException;}";
- try
- {
+ try {
JUnitUtils.interpret(JUnitUtils.createMail(), script);
- }
- catch (SyntaxException e)
- {
+ } catch (SyntaxException e) {
isTestPassed = true;
- }
- catch (ParseException e)
- {
- }
- catch (SieveException e)
- {
+ } catch (ParseException e) {
+ } catch (SieveException e) {
}
assertTrue(isTestPassed);
- }
+ }
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/parser/address/SieveAddressBuilderTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/parser/address/SieveAddressBuilderTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/parser/address/SieveAddressBuilderTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/parser/address/SieveAddressBuilderTest.java Fri Sep 21 02:22:30 2007
@@ -26,16 +26,24 @@
public class SieveAddressBuilderTest extends TestCase {
public static final String DOMAIN = "example.org";
+
public static final String COYOTE = "coyote";
+
public static final String COYOTE_ADDRESS = COYOTE + "@" + DOMAIN;
+
public static final String ROADRUNNER = "roadrunner";
+
public static final String ROADRUNNER_ADDRESS = ROADRUNNER + "@" + DOMAIN;
+
public static final String BUGS = "bugs";
+
public static final String BUGS_ADDRESS = BUGS + "@" + DOMAIN;
- public static final String HEROS = ROADRUNNER_ADDRESS + " , " + BUGS_ADDRESS;
-
+
+ public static final String HEROS = ROADRUNNER_ADDRESS + " , "
+ + BUGS_ADDRESS;
+
SieveAddressBuilder builder;
-
+
protected void setUp() throws Exception {
super.setUp();
builder = new SieveAddressBuilder();
@@ -44,10 +52,11 @@
protected void tearDown() throws Exception {
super.tearDown();
}
-
+
public void testNotAddress() throws Exception {
try {
- builder.addAddresses("What a load of rubbish - not an address in sight!");
+ builder
+ .addAddresses("What a load of rubbish - not an address in sight!");
fail("Parsing should fail when the input is not an address");
} catch (ParseException e) {
// expected
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/samples/james/junit/ActionDispatcherTest.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/samples/james/junit/ActionDispatcherTest.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/samples/james/junit/ActionDispatcherTest.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/samples/james/junit/ActionDispatcherTest.java Fri Sep 21 02:22:30 2007
@@ -26,7 +26,6 @@
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.internet.MimeMessage;
-import javax.mail.internet.ParseException;
import junit.framework.TestCase;
@@ -43,29 +42,25 @@
/**
* Class <code>ActionDispatcherTest</code>.
*/
-public class ActionDispatcherTest extends TestCase
-{
+public class ActionDispatcherTest extends TestCase {
/**
* Constructor for ActionDispatcherTest.
*
* @param arg0
*/
- public ActionDispatcherTest(String arg0)
- {
+ public ActionDispatcherTest(String arg0) {
super(arg0);
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(ActionDispatcherTest.class);
}
/**
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception
- {
+ protected void setUp() throws Exception {
super.setUp();
ActionDispatcher.resetInstance();
}
@@ -73,42 +68,34 @@
/**
* @see TestCase#tearDown()
*/
- protected void tearDown() throws Exception
- {
+ protected void tearDown() throws Exception {
super.tearDown();
}
/**
* Test execute of ActionKeep
- * @throws MessagingException
+ *
+ * @throws MessagingException
*/
- public void testExecuteActionKeep() throws MessagingException
- {
+ public void testExecuteActionKeep() throws MessagingException {
boolean isTestPassed = false;
Mail aMail = new MailImpl();
- aMail.setRecipients(Arrays.asList(new MailAddress[] { new MailAddress("a","a.com")}));
- MimeMessage mimeMessage = new MimeMessage(Session.getDefaultInstance(new Properties()));
+ aMail.setRecipients(Arrays.asList(new MailAddress[] { new MailAddress(
+ "a", "a.com") }));
+ MimeMessage mimeMessage = new MimeMessage(Session
+ .getDefaultInstance(new Properties()));
mimeMessage.setText("TEST");
- aMail.setMessage(mimeMessage);
+ aMail.setMessage(mimeMessage);
MailetContext aMailetContext = new MockMailetContext();
Action action = new ActionKeep();
- try
- {
+ try {
ActionDispatcher.getInstance().execute(action, aMail,
aMailetContext);
isTestPassed = true;
- }
- catch (NoSuchMethodException e)
- {
- }
- catch (IllegalAccessException e)
- {
- }
- catch (InvocationTargetException e)
- {
- }
- catch (MessagingException e)
- {
+ } catch (NoSuchMethodException e) {
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
+ } catch (MessagingException e) {
}
assertTrue(isTestPassed);
@@ -117,29 +104,19 @@
/**
* Test execute of ActionAbsent. Should throw a NoSuchMethodException.
*/
- public void testExecuteActionAbsent()
- {
+ public void testExecuteActionAbsent() {
boolean isTestPassed = false;
Mail aMail = new MailImpl();
MailetContext aMailetContext = new MockMailetContext();
Action action = new ActionAbsent();
- try
- {
+ try {
ActionDispatcher.getInstance().execute(action, aMail,
aMailetContext);
- }
- catch (NoSuchMethodException e)
- {
+ } catch (NoSuchMethodException e) {
isTestPassed = true;
- }
- catch (IllegalAccessException e)
- {
- }
- catch (InvocationTargetException e)
- {
- }
- catch (MessagingException e)
- {
+ } catch (IllegalAccessException e) {
+ } catch (InvocationTargetException e) {
+ } catch (MessagingException e) {
}
assertTrue(isTestPassed);
}
Modified: james/jsieve/trunk/src/test/java/org/apache/jsieve/samples/james/junit/AllTests.java
URL: http://svn.apache.org/viewvc/james/jsieve/trunk/src/test/java/org/apache/jsieve/samples/james/junit/AllTests.java?rev=578031&r1=578030&r2=578031&view=diff
==============================================================================
--- james/jsieve/trunk/src/test/java/org/apache/jsieve/samples/james/junit/AllTests.java (original)
+++ james/jsieve/trunk/src/test/java/org/apache/jsieve/samples/james/junit/AllTests.java Fri Sep 21 02:22:30 2007
@@ -25,21 +25,18 @@
/**
* Class <code>AllTests</code>.
*/
-public class AllTests
-{
+public class AllTests {
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
junit.swingui.TestRunner.run(AllTests.class);
}
- public static Test suite()
- {
- TestSuite suite =
- new TestSuite("Test for org.apache.jsieve.samples.james.junit");
- //$JUnit-BEGIN$
- suite.addTest(new TestSuite(ActionDispatcherTest.class));
- //$JUnit-END$
+ public static Test suite() {
+ TestSuite suite = new TestSuite(
+ "Test for org.apache.jsieve.samples.james.junit");
+ // $JUnit-BEGIN$
+ suite.addTest(new TestSuite(ActionDispatcherTest.class));
+ // $JUnit-END$
return suite;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org