View Javadoc

1   /*
2    *  jDTAUS Core Messages
3    *  Copyright (C) 2005 Christian Schulte
4    *  <cs@schulte.it>
5    *
6    *  This library is free software; you can redistribute it and/or
7    *  modify it under the terms of the GNU Lesser General Public
8    *  License as published by the Free Software Foundation; either
9    *  version 2.1 of the License, or any later version.
10   *
11   *  This library is distributed in the hope that it will be useful,
12   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14   *  Lesser General Public License for more details.
15   *
16   *  You should have received a copy of the GNU Lesser General Public
17   *  License along with this library; if not, write to the Free Software
18   *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19   *
20   */
21  package org.jdtaus.core.messages.test;
22  
23  import java.io.File;
24  import java.net.URL;
25  import java.util.Locale;
26  import junit.framework.Assert;
27  import junit.framework.TestCase;
28  import org.jdtaus.core.messages.BugReportMessage;
29  import org.jdtaus.core.messages.DeletesBlocksMessage;
30  import org.jdtaus.core.messages.ExceptionMessage;
31  import org.jdtaus.core.messages.IllegalNumberMessage;
32  import org.jdtaus.core.messages.IllegalPropertyMessage;
33  import org.jdtaus.core.messages.IllegalStringMessage;
34  import org.jdtaus.core.messages.InsertsBlocksMessage;
35  import org.jdtaus.core.messages.MandatoryPropertyMessage;
36  import org.jdtaus.core.messages.UndefinedApplicationStateMessage;
37  import org.jdtaus.core.text.Message;
38  
39  /**
40   * Unit tests for core application messages.
41   *
42   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
43   * @version $JDTAUS: MessagesTest.java 8794 2012-12-03 16:51:09Z schulte $
44   */
45  public class MessagesTest extends TestCase
46  {
47  
48      /** Tests instantiation of each core application message and for non-null texts for the current default locale. */
49      public void testMessages() throws Exception
50      {
51          this.assertNotNull( new ExceptionMessage( new IllegalArgumentException( "TEST" ) ) );
52          this.assertNotNull( new DeletesBlocksMessage() );
53          this.assertNotNull( new InsertsBlocksMessage() );
54          this.assertNotNull( new MandatoryPropertyMessage() );
55          this.assertNotNull( new IllegalPropertyMessage() );
56          this.assertNotNull( new UndefinedApplicationStateMessage() );
57          this.assertNotNull( new BugReportMessage( new File( System.getProperty( "user.home" ) ), null, null ) );
58          this.assertNotNull( new BugReportMessage( new File( System.getProperty( "user.home" ) ),
59                                                    new URL( "http://www.jdtaus.org" ), null ) );
60  
61          this.assertNotNull( new BugReportMessage( new File( System.getProperty( "user.home" ) ),
62                                                    null, "TEST" ) );
63  
64          this.assertNotNull( new BugReportMessage( new File( System.getProperty( "user.home" ) ),
65                                                    new URL( "http://www.jdtaus.org" ), "TEST" ) );
66  
67  
68          this.assertNotNull( new IllegalStringMessage( "TEST", new char[]
69              {
70                  'A', 'B', 'C'
71              }, new Integer( 10 ), new Integer( 10 ) ) );
72  
73          this.assertNotNull( new IllegalNumberMessage( new Integer( 10 ), new Integer( 10 ), new Integer( 10 ) ) );
74      }
75  
76      private void assertNotNull( final Message message )
77      {
78          Assert.assertNotNull( message.getText( Locale.getDefault() ) );
79          System.out.println( message.getText( Locale.getDefault() ) );
80      }
81  
82  }