View Javadoc
1   // SECTION-START[License Header]
2   // <editor-fold defaultstate="collapsed" desc=" Generated License ">
3   /*
4    *   jDTAUS ⁑ ISO-13616
5    *   Copyright (C) Christian Schulte, 2013-222
6    *
7    *   Permission to use, copy, modify, and/or distribute this software for any
8    *   purpose with or without fee is hereby granted, provided that the above
9    *   copyright notice and this permission notice appear in all copies.
10   *
11   *   THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12   *   WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13   *   MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14   *   ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15   *   WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16   *   ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17   *   OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18   *
19   *   $JDTAUS: IbanCheckDigitsExceptionTest.java 8901 2015-06-20 18:30:19Z schulte $
20   *
21   */
22  // </editor-fold>
23  // SECTION-END
24  package org.jdtaus.iso13616.test;
25  
26  import java.io.ByteArrayOutputStream;
27  import java.io.ObjectInputStream;
28  import java.io.ObjectOutputStream;
29  import java.util.Locale;
30  import org.jdtaus.iso13616.IbanCheckDigitsException;
31  import org.junit.Test;
32  import static org.junit.Assert.assertEquals;
33  import static org.junit.Assert.assertNotNull;
34  import static org.junit.Assert.fail;
35  
36  // SECTION-START[Documentation]
37  // <editor-fold defaultstate="collapsed" desc=" Generated Documentation ">
38  /**
39   * Testcases for class {@code org.jdtaus.iban.IbanCheckDigitsException}.
40   *
41   * <dl>
42   *   <dt><b>Identifier:</b></dt><dd>jDTAUS ⁑ ISO-13616 ⁑ Tests ⁑ IBAN Check Digits Exception Test</dd>
43   *   <dt><b>Name:</b></dt><dd>jDTAUS ⁑ ISO-13616 ⁑ Tests ⁑ IBAN Check Digits Exception Test</dd>
44   *   <dt><b>Abstract:</b></dt><dd>No</dd>
45   *   <dt><b>Final:</b></dt><dd>Yes</dd>
46   *   <dt><b>Stateless:</b></dt><dd>Yes</dd>
47   * </dl>
48   *
49   * @author <a href="mailto:cs@schulte.it">Christian Schulte</a>
50   * @version 1.1
51   */
52  // </editor-fold>
53  // SECTION-END
54  // SECTION-START[Annotations]
55  // <editor-fold defaultstate="collapsed" desc=" Generated Annotations ">
56  @javax.annotation.Generated( value = "org.jomc.tools.SourceFileProcessor 1.9", comments = "See http://www.jomc.org/jomc/1.9/jomc-tools-1.9" )
57  // </editor-fold>
58  // SECTION-END
59  public class IbanCheckDigitsExceptionTest
60  {
61      // SECTION-START[IbanCheckDigitsExceptionTest]
62  
63      @Test public void LocalizedMessage() throws Exception
64      {
65          final IbanCheckDigitsException ibanCheckDigitsException =
66              new IbanCheckDigitsException( "TEST", Integer.MIN_VALUE );
67  
68          try
69          {
70              ibanCheckDigitsException.getLocalizedMessage( null );
71              fail( "Expected 'NullPointerException' not thrown." );
72          }
73          catch ( final NullPointerException e )
74          {
75              System.out.println( e.toString() );
76              assertNotNull( e.getMessage() );
77          }
78  
79          assertNotNull( ibanCheckDigitsException.getLocalizedMessage( Locale.GERMAN ) );
80          assertNotNull( ibanCheckDigitsException.getLocalizedMessage( Locale.ENGLISH ) );
81      }
82  
83      @Test public void Serializable() throws Exception
84      {
85          final ObjectOutputStream out = new ObjectOutputStream( new ByteArrayOutputStream() );
86          out.writeObject( new IbanCheckDigitsException( "TEST", Integer.MIN_VALUE ) );
87          out.close();
88  
89          final ObjectInputStream in =
90              new ObjectInputStream( this.getClass().getResourceAsStream( "IbanCheckDigitsException.ser" ) );
91  
92          final IbanCheckDigitsException e = (IbanCheckDigitsException) in.readObject();
93          in.close();
94  
95          System.out.println( e.toString() );
96          assertEquals( "TEST", e.getIban() );
97          assertEquals( Integer.MIN_VALUE, e.getCheckDigits() );
98      }
99  //
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 }