示例#1
0
  /** Test for nested Command 'elsif' with an argument of 'true' */
  public void testElsifFalseElsifTrue() {
    boolean isTestPassed = false;
    String script = "if false {stop;} elsif false {stop;} elsif true {throwTestException;}";

    try {
      JUnitUtils.interpret(JUnitUtils.createMail(), script);
    } catch (ThrowTestException.TestException e) {
      isTestPassed = true;
    } catch (ParseException e) {
    } catch (SieveException e) {
    }
    assertTrue(isTestPassed);
  }
示例#2
0
  /** Test for Command 'elsif' out of sequence nested in a block */
  public void testNestedOutOfSequenceElsif() {
    boolean isTestPassed = false;
    String script = "if true {elsif true {stop;}}";

    try {
      JUnitUtils.interpret(JUnitUtils.createMail(), script);
    } catch (CommandException e) {
      isTestPassed = true;
    } catch (ParseException e) {
    } catch (SieveException e) {
    }
    assertTrue(isTestPassed);
  }
示例#3
0
  /** Test for Command 'else' without a corresponding Block */
  public void testElseMissingBlock() {
    boolean isTestPassed = false;
    String script = "if false {stop;} else stop;";

    try {
      JUnitUtils.interpret(JUnitUtils.createMail(), script);
    } catch (SyntaxException e) {
      isTestPassed = true;
    } catch (ParseException e) {
    } catch (SieveException e) {
    }
    assertTrue(isTestPassed);
  }
示例#4
0
  /** Test for Command 'fileinto' with an invalid argument number */
  @Test
  public void testInvalidArgumentNumber() {
    boolean isTestPassed = false;
    String script = "fileinto [\"INBOX.test\", \"elsewhere\"];";

    try {
      JUnitUtils.interpret(JUnitUtils.createMail(), script);
    } catch (SyntaxException e) {
      isTestPassed = true;
    } catch (ParseException e) {
    } catch (SieveException e) {
    }
    Assert.assertTrue(isTestPassed);
  }
示例#5
0
  /** Test for Command 'fileinto' with an invalid block */
  @Test
  public void testInvalidBlock() {
    boolean isTestPassed = false;
    String script = "fileinto 1 {throwTestException;}";

    try {
      JUnitUtils.interpret(JUnitUtils.createMail(), script);
    } catch (SyntaxException e) {
      isTestPassed = true;
    } catch (ParseException e) {
    } catch (SieveException e) {
    }
    Assert.assertTrue(isTestPassed);
  }
示例#6
0
  /**
   * Test for Command 'fileinto' with duplicate destinations. Only one ActionFileInto should result.
   */
  @Test
  public void testDuplicateFileInto() {
    boolean isTestPassed = false;
    String script = "fileinto \"INBOX.test1\"; fileinto \"INBOX.test1\";";

    try {
      MailAdapter mail = JUnitUtils.createMail();
      JUnitUtils.interpret(mail, script);
      Assert.assertTrue(mail.getActions().size() == 1);
      Assert.assertTrue(mail.getActions().get(0) instanceof ActionFileInto);
      Assert.assertTrue(
          ((ActionFileInto) mail.getActions().get(0)).getDestination().equals("INBOX.test1"));
      isTestPassed = true;
    } catch (ParseException e) {
    } catch (SieveException e) {
    }
    Assert.assertTrue(isTestPassed);
  }