1   /****************************************************************
2    * Licensed to the Apache Software Foundation (ASF) under one   *
3    * or more contributor license agreements.  See the NOTICE file *
4    * distributed with this work for additional information        *
5    * regarding copyright ownership.  The ASF licenses this file   *
6    * to you under the Apache License, Version 2.0 (the            *
7    * "License"); you may not use this file except in compliance   *
8    * with the License.  You may obtain a copy of the License at   *
9    *                                                              *
10   *   http://www.apache.org/licenses/LICENSE-2.0                 *
11   *                                                              *
12   * Unless required by applicable law or agreed to in writing,   *
13   * software distributed under the License is distributed on an  *
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
15   * KIND, either express or implied.  See the License for the    *
16   * specific language governing permissions and limitations      *
17   * under the License.                                           *
18   ****************************************************************/
19  
20  package org.apache.jsieve;
21  
22  import junit.framework.TestCase;
23  
24  import org.apache.jsieve.exception.SieveException;
25  import org.apache.jsieve.parser.generated.ParseException;
26  import org.apache.jsieve.utils.JUnitUtils;
27  
28  /**
29   * Class LogTest
30   */
31  public class LogTest extends TestCase {
32  
33      /**
34       * Test for Command 'log'.
35       */
36      public void testLogDebug() {
37          boolean isTestPassed = false;
38          String script = "log :debug \"Log a debug message.\";";
39  
40          try {
41              JUnitUtils.interpret(JUnitUtils.createMail(), script);
42              isTestPassed = true;
43          } catch (ParseException e) {
44          } catch (SieveException e) {
45          }
46          assertTrue(isTestPassed);
47      }
48  
49      /**
50       * Test for Command 'log'.
51       */
52      public void testLogError() {
53          boolean isTestPassed = false;
54          String script = "log :error \"Log an error message.\";";
55  
56          try {
57              JUnitUtils.interpret(JUnitUtils.createMail(), script);
58              isTestPassed = true;
59          } catch (ParseException e) {
60          } catch (SieveException e) {
61          }
62          assertTrue(isTestPassed);
63      }
64  
65      /**
66       * Test for Command 'log'.
67       */
68      public void testLogFatal() {
69          boolean isTestPassed = false;
70          String script = "log :fatal \"Log a fatal message.\";";
71  
72          try {
73              JUnitUtils.interpret(JUnitUtils.createMail(), script);
74              isTestPassed = true;
75          } catch (ParseException e) {
76          } catch (SieveException e) {
77          }
78          assertTrue(isTestPassed);
79      }
80  
81      /**
82       * Test for Command 'log'.
83       */
84      public void testLogInfo() {
85          boolean isTestPassed = false;
86          String script = "log :info \"Log an info message.\";";
87  
88          try {
89              JUnitUtils.interpret(JUnitUtils.createMail(), script);
90              isTestPassed = true;
91          } catch (ParseException e) {
92          } catch (SieveException e) {
93          }
94          assertTrue(isTestPassed);
95      }
96  
97      /**
98       * Test for Command 'log'.
99       */
100     public void testLogTrace() {
101         boolean isTestPassed = false;
102         String script = "log :trace \"Log a trace message.\";";
103 
104         try {
105             JUnitUtils.interpret(JUnitUtils.createMail(), script);
106             isTestPassed = true;
107         } catch (ParseException e) {
108         } catch (SieveException e) {
109         }
110         assertTrue(isTestPassed);
111     }
112 
113     /**
114      * Test for Command 'log'.
115      */
116     public void testLogWarn() {
117         boolean isTestPassed = false;
118         String script = "log :warn \"Log a warning message.\";";
119 
120         try {
121             JUnitUtils.interpret(JUnitUtils.createMail(), script);
122             isTestPassed = true;
123         } catch (ParseException e) {
124         } catch (SieveException e) {
125         }
126         assertTrue(isTestPassed);
127     }
128 
129     /**
130      * Test for Command 'log'.
131      */
132     public void testLogDefault() {
133         boolean isTestPassed = false;
134         String script = "log \"Log a default message.\";";
135 
136         try {
137             JUnitUtils.interpret(JUnitUtils.createMail(), script);
138             isTestPassed = true;
139         } catch (ParseException e) {
140         } catch (SieveException e) {
141         }
142         assertTrue(isTestPassed);
143     }
144 
145 }