01: /*
02: *
03: * Derby - Class org.apache.derbyTesting.junit.ChangeUserSetup
04: *
05: * Licensed to the Apache Software Foundation (ASF) under one or more
06: * contributor license agreements. See the NOTICE file distributed with
07: * this work for additional information regarding copyright ownership.
08: * The ASF licenses this file to You under the Apache License, Version 2.0
09: * (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 user;
34: private final String password;
35: private TestConfiguration old;
36:
37: ChangeUserSetup(Test test, String user, String password) {
38: super (test);
39: this .user = user;
40: this .password = password;
41: }
42:
43: protected void setUp() {
44: old = TestConfiguration.getCurrent();
45: TestConfiguration config = new TestConfiguration(old, user,
46: password);
47: TestConfiguration.setCurrent(config);
48: }
49:
50: protected void tearDown() {
51: TestConfiguration.setCurrent(old);
52: }
53: }
|