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: /**
18: * @author Hugo Beilis
19: * @author Leonardo Soler
20: * @author Gabriel Miretti
21: * @version 1.0
22: */package org.apache.harmony.jndi.tests.javax.naming.ldap.whitebox;
23:
24: import javax.naming.Context;
25: import javax.naming.NamingException;
26: import javax.naming.NoInitialContextException;
27: import javax.naming.ldap.InitialLdapContext;
28: import junit.framework.TestCase;
29:
30: /**
31: * <p>This class test is made to test all cases of package where the coverage was not 100%.</p>
32: * <p>We are going to find here a lot cases from different classes, notice here that the conventional structure
33: * followed in the rest of the project is applied here.</p>
34: *
35: */
36: public class TestInitialLdapContextWhiteBoxDevelopment extends TestCase {
37:
38: public static void main(String[] args) {
39: }
40:
41: public TestInitialLdapContextWhiteBoxDevelopment(String name) {
42: super (name);
43: }
44:
45: protected void setUp() throws Exception {
46: super .setUp();
47: }
48:
49: protected void tearDown() throws Exception {
50: super .tearDown();
51: }
52:
53: /**
54: * <p>Test method for 'javax.naming.ldap.InitialLdapContext.getEnviroment()'</p>
55: * <p>Here we are testing if this method can throw an exception of the type NoInitialContextException.</p>
56: */
57: public void testGetEnviroment() {
58: try {
59: System
60: .setProperty(Context.INITIAL_CONTEXT_FACTORY,
61: "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
62: InitialLdapContext ilc = new InitialLdapContext(null, null);
63: ilc.getEnvironment();
64:
65: } catch (NoInitialContextException e) {
66: fail("Failed with:" + e);
67: } catch (NamingException e) {
68: fail("Failed with:" + e);
69: }
70:
71: }
72:
73: /**
74: * <p>Test method for 'javax.naming.ldap.InitialLdapContext.getConnectControls()'</p>
75: * <p>Here we are testing if this method can throw an exception of the type NoInitialContextException.</p>
76: */
77: public void testgetConnectControls() {
78: try {
79: System
80: .setProperty(Context.INITIAL_CONTEXT_FACTORY,
81: "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
82: InitialLdapContext ilc = new InitialLdapContext(null, null);
83: ilc.getConnectControls();
84:
85: } catch (NamingException e) {
86: fail("Failed with:" + e);
87: }
88:
89: }
90:
91: }
|