KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > barracuda > testbed > LocaleTestSuiteSetup


1 /*
2  * Copyright (C) 2003 Christian Cryder [christianc@granitepeaks.com]
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * $Id: LocaleTestSuiteSetup.java,v 1.4 2004/02/01 05:16:32 christianc Exp $
19  */

20 package org.enhydra.barracuda.testbed;
21
22 import junit.framework.Test;
23 import junit.extensions.TestSetup;
24
25 import java.util.*;
26
27 //
28
// a test setup that will set the default locale in setUp()
29
// and reset it in tearDown(). Used for running test cases in different locales
30
// (see TestDateValidator.java and TestDateRangeValidator.java)
31
//
32
public class LocaleTestSuiteSetup extends TestSetup {
33
34     //===========================================================================
35
// CONSTRUCTORS
36
//===========================================================================
37

38     /**
39      * Default constructor
40      *
41      * @param theTest a Test object
42      * @param theNewLocale the preferred local with which to test
43      */

44     public LocaleTestSuiteSetup(Test theTest, Locale theNewLocale) {
45         super(theTest);
46         this.myNewLocale = theNewLocale;
47     }
48
49     //===========================================================================
50
// QUERY METHODS
51
//===========================================================================
52

53     //===========================================================================
54
// MUTATOR METHODS
55
//===========================================================================
56

57     public void setUp() {
58         this.myOriginalLocale = Locale.getDefault();
59         Locale.setDefault(this.myNewLocale);
60     }
61
62     public void tearDown() {
63         Locale.setDefault(this.myOriginalLocale);
64     }
65
66     //===========================================================================
67
// HELPER METHODS
68
//===========================================================================
69

70     //===========================================================================
71
// DATA MEMBERS
72
//===========================================================================
73

74     private Locale myOriginalLocale = null;
75     private Locale myNewLocale = null;
76
77     //===========================================================================
78
// STATIC DATA MEMBERS
79
//===========================================================================
80

81 }
82
Popular Tags