01: /*
02: *******************************************************************************
03: * Copyright (C) 1996-2006, International Business Machines Corporation and *
04: * others. All Rights Reserved. *
05: *******************************************************************************
06: *
07: */
08:
09: package com.ibm.icu.dev.test.serializable;
10:
11: import java.util.Locale;
12:
13: import com.ibm.icu.impl.InvalidFormatException;
14: import com.ibm.icu.text.ArabicShapingException;
15: import com.ibm.icu.text.StringPrepParseException;
16: import com.ibm.icu.util.UResourceTypeMismatchException;
17:
18: /**
19: * @author emader
20: *
21: * TODO To change the template for this generated type comment go to
22: * Window - Preferences - Java - Code Style - Code Templates
23: */
24: public class ExceptionTests {
25: static abstract class ExceptionHandler implements
26: SerializableTest.Handler {
27: abstract public Object[] getTestObjects();
28:
29: public boolean hasSameBehavior(Object a, Object b) {
30: Exception ea = (Exception) a;
31: Exception eb = (Exception) b;
32:
33: return ea.toString().equals(eb.toString());
34: }
35: }
36:
37: static class ArabicShapingExceptionHandler extends ExceptionHandler {
38: public Object[] getTestObjects() {
39: Locale locales[] = SerializableTest.getLocales();
40: ArabicShapingException exceptions[] = new ArabicShapingException[locales.length];
41:
42: for (int i = 0; i < locales.length; i += 1) {
43: exceptions[i] = new ArabicShapingException(locales[i]
44: .toString());
45: }
46:
47: return exceptions;
48: }
49: }
50:
51: static class StringPrepParseExceptionHandler extends
52: ExceptionHandler {
53: public Object[] getTestObjects() {
54: Locale locales[] = SerializableTest.getLocales();
55: String rules = "This is a very odd little set of rules, just for testing, you know...";
56: StringPrepParseException exceptions[] = new StringPrepParseException[locales.length];
57:
58: for (int i = 0; i < locales.length; i += 1) {
59: exceptions[i] = new StringPrepParseException(locales[i]
60: .toString(), i, rules, i);
61: }
62:
63: return exceptions;
64: }
65: }
66:
67: static class UResourceTypeMismatchExceptionHandler extends
68: ExceptionHandler {
69: public Object[] getTestObjects() {
70: Locale locales[] = SerializableTest.getLocales();
71: UResourceTypeMismatchException exceptions[] = new UResourceTypeMismatchException[locales.length];
72:
73: for (int i = 0; i < locales.length; i += 1) {
74: exceptions[i] = new UResourceTypeMismatchException(
75: locales[i].toString());
76: }
77:
78: return exceptions;
79: }
80: }
81:
82: static class InvalidFormatExceptionHandler extends ExceptionHandler {
83: public Object[] getTestObjects() {
84: Locale locales[] = SerializableTest.getLocales();
85: InvalidFormatException exceptions[] = new InvalidFormatException[locales.length];
86:
87: for (int i = 0; i < locales.length; i += 1) {
88: exceptions[i] = new InvalidFormatException(locales[i]
89: .toString());
90: }
91:
92: return exceptions;
93: }
94: }
95:
96: public static void main(String[] args) {
97: }
98: }
|