01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.harmony.jndi.tests.javax.naming;
18:
19: import java.util.Hashtable;
20:
21: import javax.naming.CannotProceedException;
22: import javax.naming.CompositeName;
23: import javax.naming.Context;
24: import javax.naming.InvalidNameException;
25: import javax.naming.Name;
26:
27: import org.apache.harmony.jndi.tests.javax.naming.util.Log;
28: import junit.framework.TestCase;
29:
30: public class CannotProceedExceptionTest extends TestCase {
31:
32: private static final Log log = new Log(
33: CannotProceedExceptionTest.class);
34:
35: public void testConstructorAndGetterSetter()
36: throws InvalidNameException {
37: log.setMethod("testConstructorAndGetterSetter()");
38:
39: CannotProceedException cpe = new CannotProceedException();
40: Name altName = new CompositeName("1");
41: Context altContext = null;
42: Hashtable<?, ?> h = new Hashtable<Object, Object>();
43: Name newName = new CompositeName("2");
44:
45: cpe.setAltName(altName);
46: assertEquals(altName, cpe.getAltName());
47:
48: cpe.setAltNameCtx(altContext);
49: assertEquals(altContext, cpe.getAltNameCtx());
50:
51: cpe.setEnvironment(h);
52: assertEquals(h, cpe.getEnvironment());
53:
54: cpe.setRemainingNewName(newName);
55: assertEquals(newName, cpe.getRemainingNewName());
56: }
57:
58: public void testConstructor_defaultValue() {
59: CannotProceedException cpe = new CannotProceedException();
60: assertNull(cpe.getMessage());
61: assertNull(cpe.getAltName());
62: assertNull(cpe.getAltNameCtx());
63: assertNull(cpe.getEnvironment());
64: assertNull(cpe.getRemainingNewName());
65: }
66:
67: public void testGetEnvironment() {
68: CannotProceedException exception = new CannotProceedException(
69: "Test");
70: assertNull(exception.getEnvironment());
71: }
72: }
|