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.
252253254255256257258259260261262263
*/ 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) {
270271272273274275276277278279280281
*/ 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) {
288289290291292293294295296297298299
*/ 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) {
306307308309310311312313314315316317
*/ 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) {
324325326327328329330331332333334335
*/ 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) {
343344345346347348349350351352353354
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) {
361362363364365366367368369370371372
*/ 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) {
379380381382383384385386387388389390
*/ 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) {
397398399400401402403404405406407408
*/ 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) {
415416417418419420421422423424425426
*/ 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) {