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 java.util.Hashtable;
25: import javax.naming.Context;
26: import javax.naming.NamingException;
27: import javax.naming.ldap.ControlFactory;
28: import javax.naming.ldap.InitialLdapContext;
29: import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockControl;
30: import junit.framework.TestCase;
31:
32: /**
33: * <p>This class test is made to test all cases of package where the coverage was not 100%.</p>
34: * <p>We are going to find here a lot cases from different classes, notice here that the conventional structure
35: * followed in the rest of the project is applied here.</p>
36: *
37: */
38: public class TestControlFactoryWhiteBoxDevelopment extends TestCase {
39:
40: public static void main(String[] args) {
41: }
42:
43: public TestControlFactoryWhiteBoxDevelopment(String name) {
44: super (name);
45: }
46:
47: protected void setUp() throws Exception {
48: super .setUp();
49: }
50:
51: protected void tearDown() throws Exception {
52: super .tearDown();
53: }
54:
55: /**
56: * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control)'</p>
57: * <p>Here we are going to test if we can get an instance with the controls sended.</p>
58: */
59: public void testGetControlInstanceControl() {
60:
61: try {
62:
63: Hashtable env = new Hashtable();
64: env
65: .put(Context.INITIAL_CONTEXT_FACTORY,
66: "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
67: MockControl[] cs = {
68: new MockControl("c1", false, new byte[] { 1, 2, 3,
69: 4 }),
70: new MockControl("c1", true, new byte[] { 'a', 'b',
71: 'c', 'd' }), };
72: MockControl cs2 = new MockControl("c1", false, new byte[] {
73: 1, 2, 3, 4 });
74: InitialLdapContext ilc = new InitialLdapContext(env, cs);
75: assertEquals(cs2, ControlFactory.getControlInstance(cs2,
76: ilc, env));
77:
78: } catch (NamingException e) {
79:
80: }
81: }
82:
83: }
|