001// SECTION-START[License Header]
002// <editor-fold defaultstate="collapsed" desc=" Generated License ">
003/*
004 *   jDTAUS ⁑ ISO-13616
005 *   Copyright (C) Christian Schulte, 2013-222
006 *
007 *   Permission to use, copy, modify, and/or distribute this software for any
008 *   purpose with or without fee is hereby granted, provided that the above
009 *   copyright notice and this permission notice appear in all copies.
010 *
011 *   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
012 *   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
013 *   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
014 *   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
015 *   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
016 *   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
017 *   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
018 *
019 *   $JDTAUS: IbanSyntaxExceptionTest.java 8901 2015-06-20 18:30:19Z schulte $
020 *
021 */
022// </editor-fold>
023// SECTION-END
024package org.jdtaus.iso13616.test;
025
026import java.io.ByteArrayOutputStream;
027import java.io.ObjectInputStream;
028import java.io.ObjectOutputStream;
029import java.util.Locale;
030import org.jdtaus.iso13616.IbanSyntaxException;
031import org.junit.Test;
032import static org.junit.Assert.assertEquals;
033import static org.junit.Assert.assertNotNull;
034import static org.junit.Assert.fail;
035
036// SECTION-START[Documentation]
037// <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
038/**
039 * Testcases for class {@code org.jdtaus.iban.IbanSyntaxException}.
040 *
041 * <dl>
042 *   <dt><b>Identifier:</b></dt><dd>jDTAUS ⁑ ISO-13616 ⁑ Tests ⁑ IBAN Syntax Exception Test</dd>
043 *   <dt><b>Name:</b></dt><dd>jDTAUS ⁑ ISO-13616 ⁑ Tests ⁑ IBAN Syntax Exception Test</dd>
044 *   <dt><b>Abstract:</b></dt><dd>No</dd>
045 *   <dt><b>Final:</b></dt><dd>Yes</dd>
046 *   <dt><b>Stateless:</b></dt><dd>Yes</dd>
047 * </dl>
048 *
049 * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
050 * @version 1.1
051 */
052// </editor-fold>
053// SECTION-END
054// SECTION-START[Annotations]
055// <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
056@javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
057// </editor-fold>
058// SECTION-END
059public class IbanSyntaxExceptionTest
060{
061    // SECTION-START[IbanSyntaxExceptionTest]
062
063    @Test public void LocalizedMessage() throws Exception
064    {
065        final IbanSyntaxException ibanSyntaxException = new IbanSyntaxException( "TEST", Integer.MAX_VALUE );
066
067        try
068        {
069            ibanSyntaxException.getLocalizedMessage( null );
070            fail( "Expected 'NullPointerException' not thrown." );
071        }
072        catch ( final NullPointerException e )
073        {
074            System.out.println( e.toString() );
075            assertNotNull( e.getMessage() );
076        }
077
078        assertNotNull( ibanSyntaxException.getLocalizedMessage( Locale.GERMAN ) );
079        assertNotNull( ibanSyntaxException.getLocalizedMessage( Locale.ENGLISH ) );
080    }
081
082    @Test public void Serializable() throws Exception
083    {
084        final ObjectOutputStream out = new ObjectOutputStream( new ByteArrayOutputStream() );
085        out.writeObject( new IbanSyntaxException( "TEST", Integer.MAX_VALUE ) );
086        out.close();
087
088        final ObjectInputStream in =
089            new ObjectInputStream( this.getClass().getResourceAsStream( "IbanSyntaxException.ser" ) );
090
091        final IbanSyntaxException e = (IbanSyntaxException) in.readObject();
092        in.close();
093
094        System.out.println( e.toString() );
095        assertEquals( "TEST", e.getMalformedText() );
096        assertEquals( Integer.MAX_VALUE, e.getErrorIndex() );
097    }
098//
099//    public static void main( final String... arguments ) throws Exception
100//    {
101//        final ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream( "IbanSyntaxException.ser" ) );
102//        out.writeObject( new IbanSyntaxException( "TEST", Integer.MAX_VALUE ) );
103//        out.close();
104//    }
105//
106    // SECTION-END
107    // SECTION-START[Constructors]
108    // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
109    /** Creates a new {@code IbanSyntaxExceptionTest} instance. */
110    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
111    public IbanSyntaxExceptionTest()
112    {
113        // SECTION-START[Default Constructor]
114        super();
115        // SECTION-END
116    }
117    // </editor-fold>
118    // SECTION-END
119    // SECTION-START[Dependencies]
120    // SECTION-END
121    // SECTION-START[Properties]
122    // SECTION-END
123    // SECTION-START[Messages]
124    // SECTION-END
125}