Class SieveEnvelopeMailAdapter extends class SieveMailAdapter, a mock implementation of a MailAdapter, to add support for EnvelopeAccessors.
As the Envelope Test is an optional Sieve test, MailAdapter support for the interface is optional too.
221222223224225226227228229230231232
*/ public void testIfEnvelopeAllMatchesTrue() { boolean isTestPassed = false; String script = "if envelope :all :matches \"From\" \"*@domain\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("user@domain"); JUnitUtils.interpret(mail, script); } catch (ThrowTestException.TestException e) { isTestPassed = true; } catch (ParseException e) { } catch (SieveException e) {
239240241242243244245246247248249250
*/ public void testIfEnvelopeAllContainsTrue() { boolean isTestPassed = false; String script = "if envelope :all :contains \"From\" \"r@dom\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("user@domain"); JUnitUtils.interpret(mail, script); } catch (ThrowTestException.TestException e) { isTestPassed = true; } catch (ParseException e) { } catch (SieveException e) {
257258259260261262263264265266267268
*/ public void testIfEnvelopeLocalpartIsTrue() { boolean isTestPassed = false; String script = "if envelope :localpart :is \"From\" \"user\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("user@domain"); JUnitUtils.interpret(mail, script); } catch (ThrowTestException.TestException e) { isTestPassed = true; } catch (ParseException e) { } catch (SieveException e) {
275276277278279280281282283284285286
*/ public void testIfEnvelopeLocalpartMatchesTrue() { boolean isTestPassed = false; String script = "if envelope :localpart :matches \"From\" \"*er\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("user@domain"); JUnitUtils.interpret(mail, script); } catch (ThrowTestException.TestException e) { isTestPassed = true; } catch (ParseException e) { } catch (SieveException e) {
293294295296297298299300301302303304
*/ public void testIfEnvelopeLocalpartContainsTrue() { boolean isTestPassed = false; String script = "if envelope :localpart :contains \"From\" \"r\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("user@domain"); JUnitUtils.interpret(mail, script); } catch (ThrowTestException.TestException e) { isTestPassed = true; } catch (ParseException e) { } catch (SieveException e) {
312313314315316317318319320321322323
public void testIfEnvelopeDomainIsTrue() { boolean isTestPassed = false; String script = "if envelope :domain :is \"From\" \"domain\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("user@domain"); JUnitUtils.interpret(mail, script); } catch (ThrowTestException.TestException e) { isTestPassed = true; } catch (ParseException e) { } catch (SieveException e) {
330331332333334335336337338339340341
*/ public void testIfEnvelopeDomainMatchesTrue() { boolean isTestPassed = false; String script = "if envelope :domain :matches \"From\" \"*main\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("user@domain"); JUnitUtils.interpret(mail, script); } catch (ThrowTestException.TestException e) { isTestPassed = true; } catch (ParseException e) { } catch (SieveException e) {
348349350351352353354355356357358359
*/ public void testIfEnvelopeDomainContainsTrue() { boolean isTestPassed = false; String script = "if envelope :domain :contains \"From\" \"dom\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("user@domain"); JUnitUtils.interpret(mail, script); } catch (ThrowTestException.TestException e) { isTestPassed = true; } catch (ParseException e) { } catch (SieveException e) {
366367368369370371372373374375376377
*/ public void testIfEnvelopeAllIsFalse() { boolean isTestPassed = false; String script = "if envelope :all :is \"From\" \"user@domain\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("tweety@pie"); JUnitUtils.interpret(mail, script); isTestPassed = true; } catch (ThrowTestException.TestException e) { } catch (ParseException e) { } catch (SieveException e) {
384385386387388389390391392393394395
*/ public void testIfEnvelopeAllMatchesFalse() { boolean isTestPassed = false; String script = "if envelope :all :matches \"From\" \"(.*)@domain\" {throwTestException;}"; try { SieveEnvelopeMailAdapter mail = JUnitUtils.createEnvelopeMail(); mail.setEnvelopeFrom("bugs@bunny"); JUnitUtils.interpret(mail, script); isTestPassed = true; } catch (ThrowTestException.TestException e) { } catch (ParseException e) { } catch (SieveException e) {