001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.harmony.jndi.tests.javax.naming;
018:
019: import javax.naming.NameClassPair;
020:
021: import junit.framework.TestCase;
022:
023: public class NameClassPairTest extends TestCase {
024:
025: /**
026: * Constructor for TestNameClassPair.
027: *
028: * @param arg0
029: */
030: public NameClassPairTest(String arg0) {
031: super (arg0);
032: }
033:
034: /*
035: * @see TestCase#setUp()
036: */
037: @Override
038: protected void setUp() throws Exception {
039: super .setUp();
040: }
041:
042: /*
043: * @see TestCase#tearDown()
044: */
045: @Override
046: protected void tearDown() throws Exception {
047: super .tearDown();
048: }
049:
050: public void testConstructor_Simple() {
051: NameClassPair p;
052:
053: p = new NameClassPair("name1", "class1");
054: assertEquals("name1", p.getName());
055: assertEquals("class1", p.getClassName());
056:
057: p = new NameClassPair("name2", "class2", false);
058: assertEquals("name2", p.getName());
059: assertEquals("class2", p.getClassName());
060: assertFalse(p.isRelative());
061: }
062:
063: public void testConstructor_NullValue() {
064: NameClassPair p;
065:
066: p = new NameClassPair("name1", null);
067: assertEquals("name1", p.getName());
068: assertNull(p.getClassName());
069: }
070:
071: public void testConstructor_DefaultRelativeValue() {
072: NameClassPair p;
073:
074: p = new NameClassPair("name1", null);
075: assertTrue(p.isRelative());
076: }
077:
078: public void testToString() {
079: NameClassPair p;
080:
081: p = new NameClassPair("name1", null, false);
082: assertTrue(p.toString().startsWith("(not relative"));
083: }
084:
085: public void testGetSetName() {
086: NameClassPair p;
087:
088: p = new NameClassPair("name1", null, true);
089: p.setName("aname");
090: assertEquals("aname", p.getName());
091: }
092:
093: public void testGetSetClassName() {
094: NameClassPair p;
095:
096: p = new NameClassPair("name1", null, true);
097: p.setClassName("aclassname");
098: assertEquals("aclassname", p.getClassName());
099: }
100:
101: public void testGetSetRelative() {
102: NameClassPair p;
103:
104: p = new NameClassPair("name1", null, true);
105: p.setRelative(false);
106: assertFalse(p.isRelative());
107: }
108: }
|