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: IbanSyntaxExceptionTest.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.IbanSyntaxException;
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.IbanSyntaxException}.
40 *
41 * <dl>
42 * <dt><b>Identifier:</b></dt><dd>jDTAUS ⁑ ISO-13616 ⁑ Tests ⁑ IBAN Syntax Exception Test</dd>
43 * <dt><b>Name:</b></dt><dd>jDTAUS ⁑ ISO-13616 ⁑ Tests ⁑ IBAN Syntax 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 IbanSyntaxExceptionTest
60 {
61 // SECTION-START[IbanSyntaxExceptionTest]
62
63 @Test public void LocalizedMessage() throws Exception
64 {
65 final IbanSyntaxException ibanSyntaxException = new IbanSyntaxException( "TEST", Integer.MAX_VALUE );
66
67 try
68 {
69 ibanSyntaxException.getLocalizedMessage( null );
70 fail( "Expected 'NullPointerException' not thrown." );
71 }
72 catch ( final NullPointerException e )
73 {
74 System.out.println( e.toString() );
75 assertNotNull( e.getMessage() );
76 }
77
78 assertNotNull( ibanSyntaxException.getLocalizedMessage( Locale.GERMAN ) );
79 assertNotNull( ibanSyntaxException.getLocalizedMessage( Locale.ENGLISH ) );
80 }
81
82 @Test public void Serializable() throws Exception
83 {
84 final ObjectOutputStream out = new ObjectOutputStream( new ByteArrayOutputStream() );
85 out.writeObject( new IbanSyntaxException( "TEST", Integer.MAX_VALUE ) );
86 out.close();
87
88 final ObjectInputStream in =
89 new ObjectInputStream( this.getClass().getResourceAsStream( "IbanSyntaxException.ser" ) );
90
91 final IbanSyntaxException e = (IbanSyntaxException) in.readObject();
92 in.close();
93
94 System.out.println( e.toString() );
95 assertEquals( "TEST", e.getMalformedText() );
96 assertEquals( Integer.MAX_VALUE, e.getErrorIndex() );
97 }
98 //
99 // 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 }