KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derbyTesting > junit > ChangeUserSetup


1 /*
2  *
3  * Derby - Class org.apache.derbyTesting.junit.ChangeUserSetup
4  *
5  * Licensed to the Apache Software Foundation (ASF) under one or more
6  * contributor license agreements. See the NOTICE file distributed with
7  * this work for additional information regarding copyright ownership.
8  * The ASF licenses this file to You under the Apache License, Version 2.0
9  * (the "License"); you may not use this file except in compliance with
10  * the License. You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17  * either express or implied. See the License for the specific
18  * language governing permissions and limitations under the License.
19  */

20 package org.apache.derbyTesting.junit;
21
22 import junit.extensions.TestSetup;
23 import junit.framework.Test;
24
25 /**
26  * A decorator that changes the default user and password
27  * for the current configuration. Its tearDown method restores
28  * the previous configuration.
29  *
30  */

31 final class ChangeUserSetup extends TestSetup {
32     
33     private final String JavaDoc user;
34     private final String JavaDoc password;
35     private TestConfiguration old;
36     
37     ChangeUserSetup(Test test, String JavaDoc user, String JavaDoc password)
38     {
39         super(test);
40         this.user = user;
41         this.password = password;
42     }
43     
44     protected void setUp()
45     {
46         old = TestConfiguration.getCurrent();
47         TestConfiguration config = new TestConfiguration(old, user, password);
48         TestConfiguration.setCurrent(config);
49     }
50     
51     protected void tearDown()
52     {
53         TestConfiguration.setCurrent(old);
54     }
55 }
56
Popular Tags