001/*
002 *  jDTAUS Core Messages
003 *  Copyright (C) 2005 Christian Schulte
004 *  <cs@schulte.it>
005 *
006 *  This library is free software; you can redistribute it and/or
007 *  modify it under the terms of the GNU Lesser General Public
008 *  License as published by the Free Software Foundation; either
009 *  version 2.1 of the License, or any later version.
010 *
011 *  This library is distributed in the hope that it will be useful,
012 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
013 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 *  Lesser General Public License for more details.
015 *
016 *  You should have received a copy of the GNU Lesser General Public
017 *  License along with this library; if not, write to the Free Software
018 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
019 *
020 */
021package org.jdtaus.core.messages.test;
022
023import java.io.File;
024import java.net.URL;
025import java.util.Locale;
026import junit.framework.Assert;
027import junit.framework.TestCase;
028import org.jdtaus.core.messages.BugReportMessage;
029import org.jdtaus.core.messages.DeletesBlocksMessage;
030import org.jdtaus.core.messages.ExceptionMessage;
031import org.jdtaus.core.messages.IllegalNumberMessage;
032import org.jdtaus.core.messages.IllegalPropertyMessage;
033import org.jdtaus.core.messages.IllegalStringMessage;
034import org.jdtaus.core.messages.InsertsBlocksMessage;
035import org.jdtaus.core.messages.MandatoryPropertyMessage;
036import org.jdtaus.core.messages.UndefinedApplicationStateMessage;
037import org.jdtaus.core.text.Message;
038
039/**
040 * Unit tests for core application messages.
041 *
042 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
043 * @version $JDTAUS: MessagesTest.java 8794 2012-12-03 16:51:09Z schulte $
044 */
045public class MessagesTest extends TestCase
046{
047
048    /** Tests instantiation of each core application message and for non-null texts for the current default locale. */
049    public void testMessages() throws Exception
050    {
051        this.assertNotNull( new ExceptionMessage( new IllegalArgumentException( "TEST" ) ) );
052        this.assertNotNull( new DeletesBlocksMessage() );
053        this.assertNotNull( new InsertsBlocksMessage() );
054        this.assertNotNull( new MandatoryPropertyMessage() );
055        this.assertNotNull( new IllegalPropertyMessage() );
056        this.assertNotNull( new UndefinedApplicationStateMessage() );
057        this.assertNotNull( new BugReportMessage( new File( System.getProperty( "user.home" ) ), null, null ) );
058        this.assertNotNull( new BugReportMessage( new File( System.getProperty( "user.home" ) ),
059                                                  new URL( "http://www.jdtaus.org" ), null ) );
060
061        this.assertNotNull( new BugReportMessage( new File( System.getProperty( "user.home" ) ),
062                                                  null, "TEST" ) );
063
064        this.assertNotNull( new BugReportMessage( new File( System.getProperty( "user.home" ) ),
065                                                  new URL( "http://www.jdtaus.org" ), "TEST" ) );
066
067
068        this.assertNotNull( new IllegalStringMessage( "TEST", new char[]
069            {
070                'A', 'B', 'C'
071            }, new Integer( 10 ), new Integer( 10 ) ) );
072
073        this.assertNotNull( new IllegalNumberMessage( new Integer( 10 ), new Integer( 10 ), new Integer( 10 ) ) );
074    }
075
076    private void assertNotNull( final Message message )
077    {
078        Assert.assertNotNull( message.getText( Locale.getDefault() ) );
079        System.out.println( message.getText( Locale.getDefault() ) );
080    }
081
082}