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: IbanCheckDigitsExceptionTest.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.IbanCheckDigitsException;
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.IbanCheckDigitsException}.
040 *
041 * <dl>
042 *   <dt><b>Identifier:</b></dt><dd>jDTAUS ⁑ ISO-13616 ⁑ Tests ⁑ IBAN Check Digits Exception Test</dd>
043 *   <dt><b>Name:</b></dt><dd>jDTAUS ⁑ ISO-13616 ⁑ Tests ⁑ IBAN Check Digits 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 IbanCheckDigitsExceptionTest
060{
061    // SECTION-START[IbanCheckDigitsExceptionTest]
062
063    @Test public void LocalizedMessage() throws Exception
064    {
065        final IbanCheckDigitsException ibanCheckDigitsException =
066            new IbanCheckDigitsException( "TEST", Integer.MIN_VALUE );
067
068        try
069        {
070            ibanCheckDigitsException.getLocalizedMessage( null );
071            fail( "Expected 'NullPointerException' not thrown." );
072        }
073        catch ( final NullPointerException e )
074        {
075            System.out.println( e.toString() );
076            assertNotNull( e.getMessage() );
077        }
078
079        assertNotNull( ibanCheckDigitsException.getLocalizedMessage( Locale.GERMAN ) );
080        assertNotNull( ibanCheckDigitsException.getLocalizedMessage( Locale.ENGLISH ) );
081    }
082
083    @Test public void Serializable() throws Exception
084    {
085        final ObjectOutputStream out = new ObjectOutputStream( new ByteArrayOutputStream() );
086        out.writeObject( new IbanCheckDigitsException( "TEST", Integer.MIN_VALUE ) );
087        out.close();
088
089        final ObjectInputStream in =
090            new ObjectInputStream( this.getClass().getResourceAsStream( "IbanCheckDigitsException.ser" ) );
091
092        final IbanCheckDigitsException e = (IbanCheckDigitsException) in.readObject();
093        in.close();
094
095        System.out.println( e.toString() );
096        assertEquals( "TEST", e.getIban() );
097        assertEquals( Integer.MIN_VALUE, e.getCheckDigits() );
098    }
099//
100//    public static void main( final String... arguments ) throws Exception
101//    {
102//        final ObjectOutputStream out = new ObjectOutputStream( new FileOutputStream( "IbanCheckDigitsException.ser" ) );
103//        out.writeObject( new IbanCheckDigitsException( "TEST", Integer.MIN_VALUE ) );
104//        out.close();
105//    }
106//
107    // SECTION-END
108    // SECTION-START[Constructors]
109    // <editor-fold defaultstate="collapsed" desc=" Generated Constructors ">
110    /** Creates a new {@code IbanCheckDigitsExceptionTest} instance. */
111    @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
112    public IbanCheckDigitsExceptionTest()
113    {
114        // SECTION-START[Default Constructor]
115        super();
116        // SECTION-END
117    }
118    // </editor-fold>
119    // SECTION-END
120    // SECTION-START[Dependencies]
121    // SECTION-END
122    // SECTION-START[Properties]
123    // SECTION-END
124    // SECTION-START[Messages]
125    // SECTION-END
126}