1   package org.apache.maven.cvslib;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  import junit.framework.TestCase;
22  
23  import org.netbeans.lib.cvsclient.event.MessageEvent;
24  
25  
26  /**
27   * Test cases for {@link CvsLogListener}
28   * @author <a href="mailto:epugh@upstate.com">Eric Pugh</a>
29   * @version $Id: CvsLogListenerTest.java 532339 2007-04-25 12:28:56Z ltheussl $
30   */
31  public class CvsLogListenerTest extends TestCase
32  {
33  
34  
35      /**
36       * Create a test with the given name
37       * @param testName the name of the test
38       */
39      public CvsLogListenerTest(String testName)
40      {
41          super(testName);
42      }
43  
44      /**
45       * Test of listening to a regular output
46       * @throws Exception when there is an unexpected problem
47       */
48      public void testNormalEvent() throws Exception
49      {
50          String MESSAGE = "I am a message";
51          CvsLogListener listener = new CvsLogListener();
52  		MessageEvent me = new MessageEvent("souce",MESSAGE,false);
53          listener.messageSent(me);
54          assertTrue(listener.getStdout().toString().indexOf(MESSAGE)>-1);
55  
56      }
57      
58  	/**
59  	 * Test of listening to an error
60  	 * @throws Exception when there is an unexpected problem
61  	 */
62  	public void testErrorEvent() throws Exception
63  	{
64  		String MESSAGE = "I am a message";
65  		CvsLogListener listener = new CvsLogListener();
66  		MessageEvent me = new MessageEvent("souce",MESSAGE,true);
67  		listener.messageSent(me);
68  		assertTrue(listener.getStdout().toString().indexOf(MESSAGE)==-1);
69  
70  	}    
71  
72     
73  
74  }