Package org.apache.jsieve.junit.utils

Examples of org.apache.jsieve.junit.utils.SieveMailAdapter


public class QuotingTest extends TestCase {

    public void testQuoteInQuotedString() throws Exception {
        String script = "if header :is \"X-Test\" \"Before\\\"After\" {throwTestException;}";
       
        final SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
        mail.getMessage().addHeader("X-Test", "Before\"After");
        try {
            JUnitUtils.interpret(mail, script);
            fail("Expected header to be matched");
        } catch (ThrowTestException.TestException e) {
            // expected
View Full Code Here


    /**
     * Test for Test 'size'
     */
    public void testSizeIsOverTrue() {
        boolean isTestPassed = false;
        SieveMailAdapter mail = null;
        int size = 0;
        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!)
            mail = (SieveMailAdapter) JUnitUtils.copyMail(mail);
            size = mail.getSize();
        } catch (SieveMailException e) {
        } catch (MessagingException e) {
        }

        String script = "if size :over " + new Integer(size - 1).toString()
View Full Code Here

    /**
     * Test for Test 'size'
     */
    public void testSizeIsOverFalse() {
        boolean isTestPassed = false;
        SieveMailAdapter mail = null;
        int size = 0;
        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!)
            mail = (SieveMailAdapter) JUnitUtils.copyMail(mail);
            size = mail.getSize();
        } catch (SieveMailException e) {
        } catch (MessagingException e) {
        }

        String script = "if size :over " + new Integer(size).toString()
View Full Code Here

    /**
     * Test for Test 'size'
     */
    public void testSizeIsUnderTrue() {
        boolean isTestPassed = false;
        SieveMailAdapter mail = null;
        int size = 0;
        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!)
            mail = (SieveMailAdapter) JUnitUtils.copyMail(mail);
            size = mail.getSize();
        } catch (SieveMailException e) {
        } catch (MessagingException e) {
        }

        String script = "if size :under " + new Integer(size + 1).toString()
View Full Code Here

    /**
     * Test for Test 'size'
     */
    public void testSizeIsUnderFalse() {
        boolean isTestPassed = false;
        SieveMailAdapter mail = null;
        int size = 0;
        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!)
            mail = (SieveMailAdapter) JUnitUtils.copyMail(mail);
            size = mail.getSize();
        } catch (SieveMailException e) {
        } catch (MessagingException e) {
        }

        String script = "if size :over " + new Integer(size).toString()
View Full Code Here

     */
    public void testIfAddressAllIsTrue() {
        boolean isTestPassed = false;
        String script = "if address :all :is \"From\" \"user@domain\" {throwTestException;}";
        try {
            SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
            mail.getMessage().addHeader("From", "user@domain");
            JUnitUtils.interpret(mail, script);
        } catch (MessagingException e) {
        } catch (ThrowTestException.TestException e) {
            isTestPassed = true;
        } catch (ParseException e) {
View Full Code Here

     */
    public void testCaseInsensitiveHeaderName() {
        boolean isTestPassed = false;
        String script = "if address :all :is \"from\" \"user@domain\" {throwTestException;}";
        try {
            SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
            mail.getMessage().addHeader("From", "user@domain");
            JUnitUtils.interpret(mail, script);
        } catch (MessagingException e) {
        } catch (ThrowTestException.TestException e) {
            isTestPassed = true;
        } catch (ParseException e) {
View Full Code Here

     */
    public void testTreatmentOfEmbededSpacesInHeaderName() {
        boolean isTestPassed = false;
        String script = "if address :all :is \"From\" \"user@domain\" {throwTestException;}";
        try {
            SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
            mail.getMessage().addHeader("From ", "user@domain");
            JUnitUtils.interpret(mail, script);
        } catch (MessagingException e) {
        } catch (ThrowTestException.TestException e) {
            isTestPassed = true;
        } catch (ParseException e) {
View Full Code Here

     */
    public void testOctetComparatorTrue() {
        boolean isTestPassed = false;
        String script = "if address :comparator \"i;octet\" :all :is \"From\" \"uSeR@dOmAiN\" {throwTestException;}";
        try {
            SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
            mail.getMessage().addHeader("From ", "uSeR@dOmAiN");
            JUnitUtils.interpret(mail, script);
        } catch (MessagingException e) {
        } catch (ThrowTestException.TestException e) {
            isTestPassed = true;
        } catch (ParseException e) {
View Full Code Here

     */
    public void testOctetComparatorFalse() {
        boolean isTestPassed = false;
        String script = "if address :comparator \"i;octet\" :all :is \"From\" \"uSeR@dOmAiN\" {throwTestException;}";
        try {
            SieveMailAdapter mail = (SieveMailAdapter) JUnitUtils.createMail();
            mail.getMessage().addHeader("From ", "user@domain");
            JUnitUtils.interpret(mail, script);
            isTestPassed = true;
        } catch (MessagingException e) {
        } catch (ThrowTestException.TestException e) {
        } catch (ParseException e) {
View Full Code Here

TOP

Related Classes of org.apache.jsieve.junit.utils.SieveMailAdapter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.