/*
 * JBoss, the OpenSource J2EE webOS
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package org.jboss.test.aop.annotated.declare;

import java.util.ArrayList;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;


/**
 *
 * @author <a href="mailto:kabir.khan@jboss.org">Kabir Khan</a>
 * @version $Revision: 1.1.8.2 $
 */
public class AnnotatedDeclareTestCase extends TestCase
{
   public static void main(String[] args)
   {
      TestRunner.run(suite());
   }

   public static Test suite()
   {
      TestSuite suite = new TestSuite("AnnotatedDeclareTestCase");
      suite.addTestSuite(AnnotatedDeclareTestCase.class);
      return suite;
   }

   public AnnotatedDeclareTestCase(String name)
   {
      super(name);
   }

   protected void setUp() throws Exception
   {
   }
   
   public void testLoadtimeAnnotatedDeclare()throws Exception
   {
      System.out.println("*** testLoadtimeAnnotatedDeclare");
      SystemOutDecorator out = null;
      try
      {
         out = SystemOutDecorator.initialise();
         POJO pojo = new POJO();
         pojo.someMethod();
         ArrayList actual = out.getWarnings();
         assertEquals("Wrong number of warnings generated", 1, actual.size());
         String s = (String)actual.get(0);
         assertTrue("Warning does not end with the expected \"Expected annotated warning\"", s.endsWith("Expected annotated warning\n"));
      } 
      finally
      {
         out.kill();         
      }
   }

}
