2929 * @version $Id$
3030 */
3131public class RFC1522CodecTest extends TestCase {
32-
32+
3333 public RFC1522CodecTest (String name ) {
3434 super (name );
3535 }
3636
37- static class RFC1522TestCodec extends RFC1522Codec {
37+ static class RFC1522TestCodec extends RFC1522Codec {
3838
3939 protected byte [] doDecoding (byte [] bytes ) {
4040 return bytes ;
@@ -56,50 +56,29 @@ public void testNullInput() throws Exception {
5656 assertNull (testcodec .encodeText (null , CharEncoding .UTF_8 ));
5757 }
5858
59- public void testDecodeInvalid ( ) throws Exception {
59+ private void assertExpectedDecoderException ( String s ) throws Exception {
6060 RFC1522TestCodec testcodec = new RFC1522TestCodec ();
6161 try {
62- testcodec .decodeText ("whatever" );
63- fail ("DecoderException should have been thrown" );
64- } catch (DecoderException e ) {
65- // Expected. Move on
66- }
67- try {
68- testcodec .decodeText ("=?stuff?=" );
62+ testcodec .decodeText (s );
6963 fail ("DecoderException should have been thrown" );
7064 } catch (DecoderException e ) {
71- // Expected. Move on
72- }
73- try {
74- testcodec .decodeText ("=?UTF-8?stuff?=" );
75- fail ("DecoderException should have been thrown" );
76- } catch (DecoderException e ) {
77- // Expected. Move on
78- }
79- try {
80- testcodec .decodeText ("=?UTF-8?T?stuff" );
81- fail ("DecoderException should have been thrown" );
82- } catch (DecoderException e ) {
83- // Expected. Move on
84- }
85- try {
86- testcodec .decodeText ("=??T?stuff?=" );
87- fail ("DecoderException should have been thrown" );
88- } catch (DecoderException e ) {
89- // Expected. Move on
90- }
91- try {
92- testcodec .decodeText ("=?UTF-8??stuff?=" );
93- fail ("DecoderException should have been thrown" );
94- } catch (DecoderException e ) {
95- // Expected. Move on
96- }
97- try {
98- testcodec .decodeText ("=?UTF-8?W?stuff?=" );
99- fail ("DecoderException should have been thrown" );
100- } catch (DecoderException e ) {
101- // Expected. Move on
65+ // Expected.
10266 }
10367 }
10468
69+ public void testDecodeInvalid () throws Exception {
70+ assertExpectedDecoderException ("whatever" );
71+ assertExpectedDecoderException ("=?" );
72+ assertExpectedDecoderException ("?=" );
73+ assertExpectedDecoderException ("==" );
74+ assertExpectedDecoderException ("=??=" );
75+ assertExpectedDecoderException ("=?stuff?=" );
76+ assertExpectedDecoderException ("=?UTF-8??=" );
77+ assertExpectedDecoderException ("=?UTF-8?stuff?=" );
78+ assertExpectedDecoderException ("=?UTF-8?T?stuff" );
79+ assertExpectedDecoderException ("=??T?stuff?=" );
80+ assertExpectedDecoderException ("=?UTF-8??stuff?=" );
81+ assertExpectedDecoderException ("=?UTF-8?W?stuff?=" );
82+ }
83+
10584}
0 commit comments