harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r512830 [2/2] - in /harmony/enhanced/classlib/trunk/modules/jndi: make/ src/main/java/javax/naming/ldap/ src/main/java/org/apache/harmony/jndi/internal/tls/config/ src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/ src/test/java...
Date Wed, 28 Feb 2007 16:20:16 GMT
Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestInitialLdapContext.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestInitialLdapContext.java?view=diff&rev=512830&r1=512829&r2=512830
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestInitialLdapContext.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestInitialLdapContext.java Wed Feb 28 08:20:15 2007
@@ -22,673 +22,626 @@
  */
 package org.apache.harmony.jndi.tests.javax.naming.ldap;
 
+import java.util.Arrays;
 import java.util.Hashtable;
+
 import javax.naming.Context;
 import javax.naming.NamingException;
 import javax.naming.NoInitialContextException;
-import javax.naming.ldap.*;
+import javax.naming.ldap.Control;
+import javax.naming.ldap.InitialLdapContext;
+import javax.naming.ldap.StartTlsRequest;
+import javax.naming.ldap.StartTlsResponse;
+
+import junit.framework.TestCase;
 
 import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockControl;
 import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockInitialLdapContext;
-import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockStartTlsResponse;
-
-
-import junit.framework.TestCase;
 
-/**
- * <p>This Test class is testing the class InitialLdapContext in the javax.naming.ldap package.</p>
- * <p>Here in the next tables we are gonna find all methods to be tested:</p>
- *  <table class="t" cellspacing="0">
-	<tbody><th>Constructors:</th>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="InitialLdapContext()" id="f10"></td>
-			
-		</tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="InitialLdapContext(Hashtable<?,?> environment, Control[] connCtls)" id="f10"></td>
-			
-		</tr>
-		
-	</tbody>
-	<table>
-	<tbody><th>Method Summary:</th>
-		<tr><TD>Return</TD><TD>Method</TD></tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="ExtendedResponse" id="f00"></TD>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="extendedOperation(ExtendedRequest request)" id="f10"></td>
-			
-		</tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="Control[]" id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="getConnectControls()" id="f10"></td>
-			
-		</tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="Control[]" id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="getRequestControls()" id="f10"></td>
-			
-		</tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="Control[]" id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="getResponseControls()" id="f10"></td>
-			
-		</tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="LdapContext " id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="newInstance(Control[] reqCtls)" id="f10"></td>
-			
-		</tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="void " id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="reconnect(Control[] connCtls)" id="f10"></td>
-			
-		</tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="void " id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="65" name="sas9nt21" readonly="readonly" value="setRequestControls(Control[] requestControls)" id="f10"></td>
-			
-		</tr>
-			
-	</tbody>
-	</table>
- * <hr>
- * 
- */
 public class TestInitialLdapContext extends TestCase {
 
-	/**
-	 * <p>This method is not implemted.</p>
-	 * @param args Possible parameter to help us initiate all tests.
-	 */
-	public static void main(String[] args) {
-	}
-
-	/**
-	 * <p>Constructor method of the test class.</p>
-	 * <p>Here in this case we initiate the inherited constructor.</p>
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-		
-	}
-
-	protected void tearDown() throws Exception {
-		super.tearDown();
-		
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext()'
-	 * <p>Here we are testing if this method constructs an initial context using no environment properties
-	 * or connection request controls.</p>
-	 * <p>The expected result is a not null instance of the class.</p> 
-	 *
-	 */
-	public void testInitilLdapContext001(){
-		
-		try {
-			assertNotNull(new InitialLdapContext());
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		} 
-		
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext()'
-	 * <p>Here we are testing if this method constructs an initial context using no environment properties
-	 * or connection request controls.</p>
-	 * <p>The expected result is an exception when we try to get the environment properties or connections controls.</p> 
-	 *
-	 */
-	public void testInitilLdapContext002(){
-		
-		System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		InitialLdapContext lctx=null;
-		try {
-			lctx=new InitialLdapContext();
-			assertNull(lctx.getConnectControls());
-			
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		} 
-		try {
-			assertNull(lctx.getEnvironment());
-			
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-		try {
-			lctx.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-		
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?, ?>, Control[])'</p>
-	 * <p>Here we are testing the method that constructs an initial context using environment properties and connection
-	 * request controls, in this case we use two null arguments.</p>
-	 * <p>The expected result is an instance of this class.</p< 
-	 */
-	public void testInitialLdapContextHashtableOfQQControlArray001() {
-		
-		try {
-			InitialLdapContext ilc = new InitialLdapContext(null,null);
-			assertNotNull(ilc);
-			ilc.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?, ?>, Control[])'</p>
-	 * <p>Here we are testing the method that constructs an initial context using environment properties and connection
-	 * request controls, in this case we use two not null arguments.</p>
-	 * <p>The expected result is an instance of this class.</p>
-	 */
-	public void testInitialLdapContextHashtableOfQQControlArray002() {
-		
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		Control[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), 
-				new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-		try {
-			InitialLdapContext ilc=new InitialLdapContext(env, cs);
-			assertNotNull(ilc);
-			ilc.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-				
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?, ?>, Control[])'</p>
-	 * <p>Here we are testing the method that constructs an initial context using environment properties and connection
-	 * request controls, in this case we use two not null arguments, and INITIAL_CONTEXT_FACTORY constant not reference to 
-	 * a correct class.</p>
-	 * <p>The expected result is an exception like "NoInitialContextException".</p>
-	 */
-	public void testInitialLdapContextHashtableOfQQControlArray003() {
-		
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"ThisNotExist");
-		Control[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), 
-				new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-		try {
-			InitialLdapContext x=new InitialLdapContext(env, cs);
-			fail("Failed the INITIAL_CONTEXT_FACTORY not exist, an exception must be thrown.");
-		} catch (NoInitialContextException e) {
-			
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-				
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?, ?>, Control[])'</p>
-	 * <p>Here we are testing the method that constructs an initial context using environment properties and connection
-	 * request controls, in this case we use and INITIAL_CONTEXT_FACTORY constant reference to 
-	 * a correct class, but with no controls.</p>
-	 * <p>The expected result is an exception of the class".</p>
-	 */
-	public void testInitialLdapContextHashtableOfQQControlArray004() {
-		
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		Control[] cs = null;
-		try {
-			InitialLdapContext x=new InitialLdapContext(env, cs);
-			assertNotNull(x);
-			x.close();
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-				
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?, ?>, Control[])'</p>
-	 * <p>Here we are testing the method that constructs an initial context using environment properties and connection
-	 * request controls, in this case we use two not null arguments, and here the hashtable is empty.</p>
-	 * <p>The expected result is an instance of the context.</p>
-	 */
-	public void testInitialLdapContextHashtableOfQQControlArray005() {
-		
-		Hashtable env = new Hashtable();
-		Control[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), 
-				new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-		try {
-			InitialLdapContext x=new InitialLdapContext(env, cs);
-			assertNotNull(x);
-			x.close();
-		}catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-				
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?, ?>, Control[])'</p>
-	 * <p>Here we are testing the method that constructs an initial context using environment properties and connection
-	 * request controls, in this case we use two not null arguments, and here the hashtable is not empty but with data unsuitable and 
-	 * the controls is not empty.</p>
-	 * <p>The expected result is an instance of the context.</p>
-	 */
-	public void testInitialLdapContextHashtableOfQQControlArray006() {
-		
-		Control[] cf = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), 
-				new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-		Hashtable ht = new Hashtable();
-	    ht.put("one", new Integer(1));
-	    ht.put("two", new Integer(2));
-	    ht.put("three", new Integer(3));
-	    try {
-			InitialLdapContext ilc = new InitialLdapContext(ht , cf);
-			assertNotNull(ilc);
-			ilc.close();
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?, ?>, Control[])'</p>
-	 * <p>Here we are testing the method that constructs an initial context using environment properties and connection
-	 * request controls, in this case we use two not null arguments, and here the hashtable is not empty but with data unsuitable.</p>
-	 * <p>The expected result is an instance of the context.</p>
-	 */
-	public void testInitialLdapContextHashtableOfQQControlArray007() {
-		
-		Control[] cf = null;
-		Hashtable ht = new Hashtable();
-	    ht.put("one", new Integer(1));
-	    ht.put("two", new Integer(2));
-	    ht.put("three", new Integer(3));
-	    try {
-			InitialLdapContext ilc = new InitialLdapContext(ht , cf);
-			assertNotNull(ilc);
-			ilc.close();
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.extendedOperation(ExtendedRequest)'</p>
-	 * <p>Here we are testing if this method performs an extended operation. Here we send a null extended operation.</p>
-	 * <p>The expected result is a "NullpointerException".</p>
-	 */
-	public void testExtendedOperation001() {
-		
-		try {
-			System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			InitialLdapContext ilc=new InitialLdapContext();
-			MockStartTlsResponse x=(MockStartTlsResponse) ilc.extendedOperation(null);
-			fail("Should not nitialize a ldap context with null.");
-		}  catch (NullPointerException e) {
-			
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-		
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.extendedOperation(ExtendedRequest)'</p>
-	 * <p>Here we are testing if this method performs an extended operation. Here we send a not null extended operation.</p>
-	 * <p>The expected result is an Extended Response.</p>
-	 */
-	public void testExtendedOperation002() {
-		
-		try {
-			System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			InitialLdapContext x=new InitialLdapContext();
-			MockStartTlsResponse f=(MockStartTlsResponse) x.extendedOperation(new StartTlsRequest());
-			assertNotNull(f);
-			f.close();
-			x.close();
-			
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.newInstance(Control[])'</p>
-	 * <p>Here we are testing if this method creates a new instance of this context initialized using request controls. In this
-	 * case we are using as a parameters null controls.</p>
-	 * <p>The expected result is a not null initial ladp context.</p>
-	 */
-	public void testNewInstance001() {
-		
-		try {
-			Hashtable env = new Hashtable();
-			env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			InitialLdapContext x=new InitialLdapContext(env,null);
-			InitialLdapContext t=(InitialLdapContext) x.newInstance(null);
-			assertNotNull(t);
-			assertNotSame(x,t);
-			x.close();
-			t.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.newInstance(Control[])'</p>
-	 * <p>Here we are testing if this method creates a new instance of this context initialized using request controls. In this
-	 * case we are using as a parameters null controls.</p>
-	 * <p>The expected result is a not null initial ladp context.</p>
-	 */
-	public void testNewInstance002() {
-		
-		try {
-			Hashtable env = new Hashtable();
-			env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			Control[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), 
-					new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-			InitialLdapContext x=new InitialLdapContext(env,null);
-			InitialLdapContext t=(InitialLdapContext) x.newInstance(cs);
-			assertNotNull(x);
-			assertNotSame(x,t);
-			x.close();
-			t.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-	}
-
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.reconnect(Control[])'</p>
-	 * <p>Here we are testing if this method reconnects to the LDAP server using the supplied controls and this context's environment.
-	 * In this case we are sending a set of null controls.</p>
-	 * <p>The expected result is a reconection with no controls.</p>
-	 */
-	public void testReconnect001() {
-		
-		try {
-			System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			InitialLdapContext ilc = new InitialLdapContext();
-			ilc.reconnect(null);
-			assertNull(ilc.getConnectControls());
-			ilc.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-		
-
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.reconnect(Control[])'</p>
-	 * <p>Here we are testing if this method reconnects to the LDAP server using the supplied controls and this context's environment.
-	 * In this case we are sending a set not null of controls.</p>
-	 * <p>The expected result is a reconection with the controls sended.</p>
-	 */
-	public void testReconnect002() {
-		
-		try {
-			System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			Control[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), 
-					new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-			InitialLdapContext ilc = new InitialLdapContext();
-			ilc.reconnect(cs);
-			assertEquals(cs,ilc.getConnectControls());
-			ilc.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-		
-
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.reconnect(Control[])'</p>
-	 * <p>Here we are testing if this method reconnects to the LDAP server using the supplied controls and this context's environment.
-	 * In this case we are sending a new set of controls to reconection.</p>
-	 * <p>The expected result is a reconection with the new set of controls.</p>
-	 */
-	public void testReconnect003() {
-		
-		try {
-			System.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			Control[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), 
-					new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-			Control[] cs2 = { new MockControl("c2", false, new byte[] { 1, 2, 3, 4 }), 
-					new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-			InitialLdapContext ilc = new InitialLdapContext(null,cs);
-			ilc.reconnect(cs2);
-			assertEquals(cs2,ilc.getConnectControls());
-			ilc.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-		
-
-	}
-
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.getConnectControls()'</p>
-	 * <p>Here we are testing if this method retrieves the connection request controls in effect for 
-	 * this context. In this case we use a null array control.</p>
-	 * <p>The expected result is the controls that we use to create the context.</p> 
-	 */
-	public void testGetConnectControls001() {
-			
-		try {
-			Hashtable env = new Hashtable();
-			env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			Control[] cs = { new MockControl("c1", false,new byte[] { 1, 2, 3, 4 }),
-					new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-			MyInitialLdapContext x=new MyInitialLdapContext(env,cs);
-			MockInitialLdapContext defaultCtx = (MockInitialLdapContext) x.getDefaultContext();
-			Object objCs = defaultCtx.getProps().get("java.naming.ldap.control.connect");
-			Control[] cs2 = (Control[]) objCs;
-			for (int i = 0; i < cs.length; i++) {
-				assertEquals(cs2[i], cs[i]);
-			}
-			
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-		
-		
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.getConnectControls()'</p>
-	 * <p>Here we are testing if this method retrieves the connection request controls in effect for 
-	 * this context. In this case we use a null array control.</p>
-	 * <p>The expected result is the controls that we use to create the context.</p> 
-	 */
-	public void testGetConnectControls002() {
-			
-		try {
-			Hashtable env = new Hashtable();
-			env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-			InitialLdapContext x=new InitialLdapContext(env,null);
-			assertNull(x.getConnectControls());
-			x.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-		
-		
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.setRequestControls(Control[])'</p>
-	 * <p>Here we are testing if this method sets the request controls for methods subsequently invoked on this context.</p>
-	 * <p>The expected result is that the context keep the new request controls.</p> 
-	 */
-	public void testSetRequestControls001() {
-
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		InitialLdapContext x;
-		try {
-			x = new InitialLdapContext(env,null);
-			Control[] cs = { new MockControl("c1", false,new byte[] { 1, 2, 3, 4 }),
-					new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-			assertNull(x.getRequestControls());
-			x.setRequestControls(cs);
-			assertNotNull(x.getRequestControls());
-			x.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-			
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.setRequestControls(Control[])'</p>
-	 * <p>Here we are testing if this method sets the request controls for methods subsequently invoked on this context.</p>
-	 * <p>The expected result is that the context keep the new request controls.</p> 
-	 */
-	public void testSetRequestControls002() {
-
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		InitialLdapContext x;
-		try {
-			x = new InitialLdapContext(env,null);
-			Control[] cs = null;
-			Control[] cs2 = { new MockControl("c1", false,new byte[] { 1, 2, 3, 4 }),
-					new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-			
-			x.setRequestControls(cs2);
-			assertNotNull(x.getRequestControls());
-			x.setRequestControls(cs);
-			assertNull(x.getRequestControls());
-			x.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-			
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.getRequestControls()'</p>
-	 * <p>Here we are testing if this method retrieves the request controls in effect for this context.</p>
-	 * <p>The expected result is a null set of controls.</p>
-	 */
-	public void testGetRequestControls001() {
-
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		InitialLdapContext x;
-		try {
-			x = new InitialLdapContext(env,null);
-			assertNull(x.getRequestControls());
-			x.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.getRequestControls()'</p>
-	 * <p>Here we are testing if this method retrieves the request controls in effect for this context.</p>
-	 * <p>The expected result is a not null set of controls and also in the same order.</p>
-	 */
-	public void testGetRequestControls002() {
-
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		InitialLdapContext x;
-		try {
-			x = new InitialLdapContext(env,null);
-			Control[] cs = { new MockControl("c1", false,new byte[] { 1, 2, 3, 4 }),
-					new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-			x.setRequestControls(cs);
-			for(int i=0;i<x.getRequestControls().length;i++){
-				assertEquals(cs[i],x.getRequestControls()[i]);
-			}
-			
-			x.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-	}
-
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.getResponseControls()'</p>
-	 * <p>Here we are testing if this method retrieves the response controls produced as a 
-	 * result of the last method invoked on this context.</p>
-	 * <p>The expected result is a null set of controls.</p>
-	 */
-	public void testGetResponseControls001() {
-
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		InitialLdapContext x;
-		try {
-			x = new InitialLdapContext(env,null);
-			assertNull(x.getResponseControls());
-			x.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-	}
-	
-	/**
-	 * <p>Test method for 'javax.naming.ldap.InitialLdapContext.getResponseControls()'</p>
-	 * <p>Here we are testing if this method retrieves the response controls produced as a result of the last method invoked on this context.</p>
-	 * <p>The expected result is a not null set of controls.</p>
-	 */
-	public void testGetResponseControls002() {
-
-		Hashtable env = new Hashtable();
-		env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
-		Control[] cs = { new MockControl("c1", false,new byte[] { 1, 2, 3, 4 }),
-				new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
-		InitialLdapContext x;
-		try {
-			x = new InitialLdapContext(env,cs);
-			Control[] temp=x.getConnectControls();
-			assertEquals(temp,x.getResponseControls());
-			x.close();
-		} catch (NamingException e) {
-			fail("Failed with:"+e);
-		}
-	}
-	
-	/**
-	 * <p>This class is use to get the default context.</p>
-	 *
-	 */
-	class MyInitialLdapContext extends InitialLdapContext {
-
-		/**
-		 * Constructor to the Initial Ldap Context.
-		 * @param h The environment.
-		 * @param cs The Controls to be use.
-		 * @throws NamingException This is thrown in case of an error.
-		 */
-		public MyInitialLdapContext(Hashtable h, Control[] cs)
-				throws NamingException {
-			super(h, cs);
-		}
-
-		/**
-		 * <p>Method to get the default context.</p>
-		 * @return The default context.
-		 */
-		public Context getDefaultContext() {
-			return super.defaultInitCtx;
-		}
-	}
+    /**
+     * <p>
+     * Test method for 'javax.naming.ldap.InitialLdapContext()'
+     * <p>
+     * Here we are testing if this method constructs an initial context using no
+     * environment properties or connection request controls.
+     * </p>
+     * <p>
+     * The expected result is an exception when we try to get the environment
+     * properties or connections controls.
+     * </p>
+     * 
+     */
+    public void testInitilLdapContext002() throws Exception {
+
+        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+
+        InitialLdapContext lctx = new InitialLdapContext();
+
+        assertNull(lctx.getConnectControls());
+        assertNull(lctx.getEnvironment());
+
+        lctx.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?,
+     * ?>, Control[])'
+     * </p>
+     * <p>
+     * Here we are testing the method that constructs an initial context using
+     * environment properties and connection request controls, in this case we
+     * use two null arguments.
+     * </p>
+     * <p>
+     * The expected result is an instance of this class.</p<
+     */
+    public void testInitialLdapContextHashtableOfQQControlArray001()
+            throws Exception {
+
+        InitialLdapContext ilc = new InitialLdapContext(null, null);
+        ilc.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?,
+     * ?>, Control[])'
+     * </p>
+     * <p>
+     * Here we are testing the method that constructs an initial context using
+     * environment properties and connection request controls, in this case we
+     * use two not null arguments.
+     * </p>
+     * <p>
+     * The expected result is an instance of this class.
+     * </p>
+     */
+    public void testInitialLdapContextHashtableOfQQControlArray002()
+            throws Exception {
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        Control[] cs = { new MockControl("c1", false, new byte[4]),
+                new MockControl("c1", true, new byte[4]) };
+
+        InitialLdapContext ilc = new InitialLdapContext(env, cs);
+        ilc.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?,
+     * ?>, Control[])'
+     * </p>
+     * <p>
+     * Here we are testing the method that constructs an initial context using
+     * environment properties and connection request controls, in this case we
+     * use two not null arguments, and INITIAL_CONTEXT_FACTORY constant not
+     * reference to a correct class.
+     * </p>
+     * <p>
+     * The expected result is an exception like "NoInitialContextException".
+     * </p>
+     */
+    public void testInitialLdapContextHashtableOfQQControlArray003()
+            throws Exception {
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY, "ThisNotExist");
+        Control[] cs = { new MockControl("c1", false, new byte[4]),
+                new MockControl("c1", true, new byte[4]) };
+        try {
+            new InitialLdapContext(env, cs);
+            fail("Failed the INITIAL_CONTEXT_FACTORY not exist, an exception must be thrown.");
+        } catch (NoInitialContextException e) {}
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?,
+     * ?>, Control[])'
+     * </p>
+     * <p>
+     * Here we are testing the method that constructs an initial context using
+     * environment properties and connection request controls, in this case we
+     * use and INITIAL_CONTEXT_FACTORY constant reference to a correct class,
+     * but with no controls.
+     * </p>
+     * <p>
+     * The expected result is an exception of the class".
+     * </p>
+     */
+    public void testInitialLdapContextHashtableOfQQControlArray004()
+            throws Exception {
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        Control[] cs = null;
+
+        InitialLdapContext x = new InitialLdapContext(env, cs);
+        assertNotNull(x);
+        x.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?,
+     * ?>, Control[])'
+     * </p>
+     * <p>
+     * Here we are testing the method that constructs an initial context using
+     * environment properties and connection request controls, in this case we
+     * use two not null arguments, and here the hashtable is empty.
+     * </p>
+     * <p>
+     * The expected result is an instance of the context.
+     * </p>
+     */
+    public void testInitialLdapContextHashtableOfQQControlArray005()
+            throws Exception {
+        Hashtable env = new Hashtable();
+        Control[] cs = {
+                new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+
+        InitialLdapContext x = new InitialLdapContext(env, cs);
+        x.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?,
+     * ?>, Control[])'
+     * </p>
+     * <p>
+     * Here we are testing the method that constructs an initial context using
+     * environment properties and connection request controls, in this case we
+     * use two not null arguments, and here the hashtable is not empty but with
+     * data unsuitable and the controls is not empty.
+     * </p>
+     * <p>
+     * The expected result is an instance of the context.
+     * </p>
+     */
+    public void testInitialLdapContextHashtableOfQQControlArray006()
+            throws Exception {
+        Control[] cf = {
+                new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+        Hashtable ht = new Hashtable();
+        ht.put("one", new Integer(1));
+        ht.put("two", new Integer(2));
+        ht.put("three", new Integer(3));
+
+        InitialLdapContext ilc = new InitialLdapContext(ht, cf);
+        assertNotNull(ilc);
+        ilc.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.InitialLdapContext(Hashtable<?,
+     * ?>, Control[])'
+     * </p>
+     * <p>
+     * Here we are testing the method that constructs an initial context using
+     * environment properties and connection request controls, in this case we
+     * use two not null arguments, and here the hashtable is not empty but with
+     * data unsuitable.
+     * </p>
+     * <p>
+     * The expected result is an instance of the context.
+     * </p>
+     */
+    public void testInitialLdapContextHashtableOfQQControlArray007()
+            throws Exception {
+        Control[] cf = null;
+        Hashtable ht = new Hashtable();
+        ht.put("one", new Integer(1));
+        ht.put("two", new Integer(2));
+        ht.put("three", new Integer(3));
+
+        InitialLdapContext ilc = new InitialLdapContext(ht, cf);
+        assertNotNull(ilc);
+        ilc.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.extendedOperation(ExtendedRequest)'
+     * </p>
+     * <p>
+     * Here we are testing if this method performs an extended operation. Here
+     * we send a null extended operation.
+     * </p>
+     * <p>
+     * The expected result is a "NullpointerException".
+     * </p>
+     */
+    public void testExtendedOperation001() throws Exception {
+        try {
+            System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+                           "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+            InitialLdapContext ilc = new InitialLdapContext();
+            ilc.extendedOperation(null);
+            fail("Should not nitialize a ldap context with null.");
+        } catch (NullPointerException e) {}
+
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.extendedOperation(ExtendedRequest)'
+     * </p>
+     * <p>
+     * Here we are testing if this method performs an extended operation. Here
+     * we send a not null extended operation.
+     * </p>
+     * <p>
+     * The expected result is an Extended Response.
+     * </p>
+     */
+    public void testExtendedOperation002() throws Exception {
+        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        InitialLdapContext x = new InitialLdapContext();
+        StartTlsResponse f = (StartTlsResponse)x.extendedOperation(new StartTlsRequest());
+        assertNotNull(f);
+        x.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.newInstance(Control[])'
+     * </p>
+     * <p>
+     * Here we are testing if this method creates a new instance of this context
+     * initialized using request controls. In this case we are using as a
+     * parameters null controls.
+     * </p>
+     * <p>
+     * The expected result is a not null initial ladp context.
+     * </p>
+     */
+    public void testNewInstance001() throws Exception {
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        InitialLdapContext x = new InitialLdapContext(env, null);
+        InitialLdapContext t = (InitialLdapContext) x.newInstance(null);
+        assertNotNull(t);
+        assertNotSame(x, t);
+        x.close();
+        t.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.newInstance(Control[])'
+     * </p>
+     * <p>
+     * Here we are testing if this method creates a new instance of this context
+     * initialized using request controls. In this case we are using as a
+     * parameters null controls.
+     * </p>
+     * <p>
+     * The expected result is a not null initial ladp context.
+     * </p>
+     */
+    public void testNewInstance002() throws Exception {
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        Control[] cs = {
+                new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+        InitialLdapContext x = new InitialLdapContext(env, null);
+        InitialLdapContext t = (InitialLdapContext) x.newInstance(cs);
+        assertNotNull(x);
+        assertNotSame(x, t);
+        x.close();
+        t.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.reconnect(Control[])'
+     * </p>
+     * <p>
+     * Here we are testing if this method reconnects to the LDAP server using
+     * the supplied controls and this context's environment. In this case we are
+     * sending a set of null controls.
+     * </p>
+     * <p>
+     * The expected result is a reconection with no controls.
+     * </p>
+     */
+    public void testReconnect001() throws Exception {
+        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        InitialLdapContext ilc = new InitialLdapContext();
+        ilc.reconnect(null);
+        assertNull(ilc.getConnectControls());
+        ilc.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.reconnect(Control[])'
+     * </p>
+     * <p>
+     * Here we are testing if this method reconnects to the LDAP server using
+     * the supplied controls and this context's environment. In this case we are
+     * sending a set not null of controls.
+     * </p>
+     * <p>
+     * The expected result is a reconection with the controls sended.
+     * </p>
+     */
+    public void testReconnect002() throws Exception {
+        System.setProperty(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        Control[] cs = {
+                new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+        InitialLdapContext ilc = new InitialLdapContext();
+        ilc.reconnect(cs);
+        assertEquals(cs, ilc.getConnectControls());
+        ilc.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.reconnect(Control[])'
+     * </p>
+     * <p>
+     * Here we are testing if this method reconnects to the LDAP server using
+     * the supplied controls and this context's environment. In this case we are
+     * sending a new set of controls to reconection.
+     * </p>
+     * <p>
+     * The expected result is a reconection with the new set of controls.
+     * </p>
+     */
+    public void testReconnect003() throws Exception {
+        System
+                .setProperty(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        Control[] cs = {
+                new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+        Control[] cs2 = {
+                new MockControl("c2", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+        InitialLdapContext ilc = new InitialLdapContext(null, cs);
+        ilc.reconnect(cs2);
+        assertEquals(cs2, ilc.getConnectControls());
+        ilc.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.getConnectControls()'
+     * </p>
+     * <p>
+     * Here we are testing if this method retrieves the connection request
+     * controls in effect for this context. In this case we use a null array
+     * control.
+     * </p>
+     * <p>
+     * The expected result is the controls that we use to create the context.
+     * </p>
+     */
+    public void testGetConnectControls001() throws Exception {
+
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        Control[] cs = {
+                new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+        MyInitialLdapContext x = new MyInitialLdapContext(env, cs);
+        MockInitialLdapContext defaultCtx = (MockInitialLdapContext) x
+                .getDefaultContext();
+        Object objCs = defaultCtx.getProps().get(
+                "java.naming.ldap.control.connect");
+        Control[] cs2 = (Control[]) objCs;
+        for (int i = 0; i < cs.length; i++) {
+            assertEquals(cs2[i], cs[i]);
+        }
+
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.getConnectControls()'
+     * </p>
+     * <p>
+     * Here we are testing if this method retrieves the connection request
+     * controls in effect for this context. In this case we use a null array
+     * control.
+     * </p>
+     * <p>
+     * The expected result is the controls that we use to create the context.
+     * </p>
+     */
+    public void testGetConnectControls002() throws Exception {
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        InitialLdapContext x = new InitialLdapContext(env, null);
+        assertNull(x.getConnectControls());
+        x.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.setRequestControls(Control[])'
+     * </p>
+     * <p>
+     * Here we are testing if this method sets the request controls for methods
+     * subsequently invoked on this context.
+     * </p>
+     * <p>
+     * The expected result is that the context keep the new request controls.
+     * </p>
+     */
+    public void testSetRequestControls001() throws Exception {
+
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        InitialLdapContext x;
+
+        x = new InitialLdapContext(env, null);
+        Control[] cs = {
+                new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+        assertNull(x.getRequestControls());
+        x.setRequestControls(cs);
+        assertNotNull(x.getRequestControls());
+        x.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.setRequestControls(Control[])'
+     * </p>
+     * <p>
+     * Here we are testing if this method sets the request controls for methods
+     * subsequently invoked on this context.
+     * </p>
+     * <p>
+     * The expected result is that the context keep the new request controls.
+     * </p>
+     */
+    public void testSetRequestControls002() throws Exception {
+
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        InitialLdapContext x;
+
+        x = new InitialLdapContext(env, null);
+        Control[] cs = null;
+        Control[] cs2 = {
+                new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),
+                new MockControl("c2", true, new byte[] { 'a', 'b', 'c', 'd' }), };
+
+        x.setRequestControls(cs2);
+        assertNotNull(x.getRequestControls());
+        x.setRequestControls(cs);
+        assertNull(x.getRequestControls());
+        x.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.getRequestControls()'
+     * </p>
+     * <p>
+     * Here we are testing if this method retrieves the request controls in
+     * effect for this context.
+     * </p>
+     * <p>
+     * The expected result is a null set of controls.
+     * </p>
+     */
+    public void testGetRequestControls001() throws Exception {
+
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        InitialLdapContext x;
+
+        x = new InitialLdapContext(env, null);
+        assertNull(x.getRequestControls());
+
+
+        Control[] cs = { new MockControl("c1", false, new byte[4]),
+                new MockControl("c2", true, new byte[4]) };
+        x.setRequestControls(cs);
+
+        assertTrue(Arrays.equals(cs, x.getRequestControls()));
+
+        x.close();
+    }
+
+    /**
+     * <p>
+     * Test method for
+     * 'javax.naming.ldap.InitialLdapContext.getResponseControls()'
+     * </p>
+     * <p>
+     * Here we are testing if this method retrieves the response controls
+     * produced as a result of the last method invoked on this context.
+     * </p>
+     * <p>
+     * The expected result is a null set of controls.
+     * </p>
+     */
+    public void testGetResponseControls() throws Exception {
+
+        Hashtable env = new Hashtable();
+        env.put(Context.INITIAL_CONTEXT_FACTORY,
+                        "org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory");
+        InitialLdapContext x;
+
+        x = new InitialLdapContext(env, null);
+        assertNull(x.getResponseControls());
+        x.close();
+
+        Control[] cs = { new MockControl("c1", false, new byte[4]),
+                new MockControl("c2", true, new byte[4]) };
+
+        x = new InitialLdapContext(env, cs);
+        assertEquals(x.getConnectControls(), x.getResponseControls());
+        x.close();
+    }
+
+    /**
+     * <p>This class is use to get the default context.</p>
+     *
+     */
+    class MyInitialLdapContext extends InitialLdapContext {
+
+        /**
+         * Constructor to the Initial Ldap Context.
+         * @param h The environment.
+         * @param cs The Controls to be use.
+         * @throws NamingException This is thrown in case of an error.
+         */
+        public MyInitialLdapContext(Hashtable h, Control[] cs)
+                throws NamingException {
+            super(h, cs);
+        }
+
+        /**
+         * <p>Method to get the default context.</p>
+         * @return The default context.
+         */
+        public Context getDefaultContext() {
+            return super.defaultInitCtx;
+        }
+    }
 
 }

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java?view=diff&rev=512830&r1=512829&r2=512830
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/ldap/TestUnsolicitedNotificationEvent.java Wed Feb 28 08:20:15 2007
@@ -22,61 +22,13 @@
  */
 package org.apache.harmony.jndi.tests.javax.naming.ldap;
 
-import javax.naming.ldap.UnsolicitedNotification;
 import javax.naming.ldap.UnsolicitedNotificationEvent;
-import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockUnsolicitedNotification;
-import junit.framework.TestCase;
-
-/**
- * <p>This class has all test for the class UnsolicitedNotificationEvent.</p>
- * <p>Here we are gonna test all its methods as we see in the next table:</p>
- * <table class="t" cellspacing="0">
-	<tbody><th>Constructors:</th>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="" id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="80" name="sas9nt21" readonly="readonly" value="UnsolicitedNotificationEvent(Object src, UnsolicitedNotification notice)" id="f10"></td>
-			
-		</tr>
-		
-	</tbody>
-	<table>
-	<tbody><th>Method Summary:</th>
-		<tr><TD>Return</TD><TD>Method</TD></tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="void" id="f00"></TD>
-			<td class="c0" id="c10"><input class="a0" size="80" name="sas9nt21" readonly="readonly" value="dispatch(UnsolicitedNotificationListener listener)" id="f10"></td>
-			
-		</tr>
-		<tr>
-			<td class="c0" id="c00"><input class="a0" size="30" name="sas9nt11" readonly="readonly" value="UnsolicitedNotification" id="f00"></td>
-			<td class="c0" id="c10"><input class="a0" size="80" name="sas9nt21" readonly="readonly" value="getNotification()" id="f10"></td>
-			
-		</tr>
-		
-	</tbody>
-	</table> 
- *
- */
-public class TestUnsolicitedNotificationEvent extends TestCase {
 
-	/**
-	 * <p>This method is not implemted.</p>
-	 * @param args Possible parameter to help us initiate all tests.
-	 */
-	public static void main(String[] args) {
-	}
+import junit.framework.TestCase;
 
-	/**
-	 * <p>Constructor method of the test class.</p>
-	 * <p>Here in this case we do not do anything else of initiate the inherited constructor.</p>
-	 */
-	protected void setUp() throws Exception {
-		super.setUp();
-	}
+import org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockUnsolicitedNotification;
 
-	protected void tearDown() throws Exception {
-		super.tearDown();
-	}
+public class TestUnsolicitedNotificationEvent extends TestCase {
 
 	/**
 	 * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'</p>
@@ -85,30 +37,13 @@
 	 * <p>The expected result is an Illegal argument exception.</p>
 	 */
 	public void testUnsolicitedNotificationEvent001() {
+        new UnsolicitedNotificationEvent(new Object(), null);
 
-		try{
-			UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(null,null);
-			fail("The arguments could not be null.");
-		} catch (IllegalArgumentException e) {
-			
-		}
-	}
-
-	/**
-	 * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'</p>
-	 * <p>This is the constructor method that constructs a new instance of UnsolicitedNotificationEvent. In this case we are sending 
-	 * one null arguments. This is not specified in the API.</p>
-	 * <p>The expected result is an Illegal Argument exception.</p>
-	 */
-	public void testUnsolicitedNotificationEvent002() {
-		try{
-			Object x=new Object();
-			UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,null);
-			fail("The arguments could not be null.");
-		} catch (IllegalArgumentException e) {
-            
-		}
-	}
+        try {
+            new UnsolicitedNotificationEvent(null, null);
+            fail("The arguments could not be null.");
+        } catch (IllegalArgumentException e) {}
+    }
 
 	/**
 	 * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'</p>
@@ -117,15 +52,12 @@
 	 * <p>The expected result is an Illegal Argument exception.</p>
 	 */
 	public void testUnsolicitedNotificationEvent003() {
-
-		try{
-			MockUnsolicitedNotification u=new MockUnsolicitedNotification();
-			UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(null,u);
-			fail("The arguments could not be null.");
-		} catch (IllegalArgumentException e) {
-			
-		}
-	}
+        try {
+            MockUnsolicitedNotification u = new MockUnsolicitedNotification();
+            new UnsolicitedNotificationEvent(null, u);
+            fail("The arguments could not be null.");
+        } catch (IllegalArgumentException e) {}
+    }
 	
 	/**
 	 * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.UnsolicitedNotificationEvent(Object, UnsolicitedNotification)'</p>
@@ -134,18 +66,10 @@
 	 * <p>The expected result is an Illegal Argument exception.</p>
 	 */
 	public void testUnsolicitedNotificationEvent004() {
+        MockUnsolicitedNotification u = new MockUnsolicitedNotification();
+        new UnsolicitedNotificationEvent(new Object(), u);
+    }
 
-		try{
-			Object x=new Object();
-			MockUnsolicitedNotification u = new MockUnsolicitedNotification();
-			UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,u);
-			
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-	}
-
-	
 	/**
 	 * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.getNotification()'</p>
 	 * <p>Here we are testing if the method returns the unsolicited notification. In this case we create a notification
@@ -153,18 +77,11 @@
 	 * <p>The expected result is a not null notification.</p>
 	 */
 	public void testGetNotification001() {
+        UnsolicitedNotificationEvent une = new UnsolicitedNotificationEvent(
+                new Object(), null);
 
-		try{
-			Object x=new Object();
-			MockUnsolicitedNotification u=null;
-			UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,u);
-			UnsolicitedNotification ret = une.getNotification();//because the notification was null, but see here the error of create a UNE with a null
-			fail("The notification must not be null.");
-		} catch (Throwable e) {
-			
-		}
-
-	}
+        assertNull(une.getNotification());
+    }
 
 	/**
 	 * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.getNotification()'</p>
@@ -173,17 +90,11 @@
 	 * <p>The expected result is a not null notification.</p>
 	 */
 	public void testGetNotification002() {
-
-		try{
-			Object x=new Object();
-			MockUnsolicitedNotification u = new MockUnsolicitedNotification();
-			UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,u);
-			assertEquals(u,une.getNotification());
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-
-	}
+        Object x = new Object();
+        MockUnsolicitedNotification u = new MockUnsolicitedNotification();
+        UnsolicitedNotificationEvent une = new UnsolicitedNotificationEvent(x, u);
+        assertEquals(u, une.getNotification());
+    }
 	
 	/**
 	 * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.dispatch(UnsolicitedNotificationListener)'</p>
@@ -192,18 +103,14 @@
 	 * <p>The expected result is a null pointer exception.</p>
 	 */
 	public void testDispatch001() {
-        Object x=new Object();
-        UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,new MockUnsolicitedNotification());
-		try{
-			une.dispatch(null);
-			fail("Failed notification is null.");
-		} catch (NullPointerException e) {
-			
-		} catch (IllegalArgumentException e) {
-            fail("Should not raise IllegalArgument");
-        }
-
-	}
+        Object x = new Object();
+        UnsolicitedNotificationEvent une = new UnsolicitedNotificationEvent(x,
+                new MockUnsolicitedNotification());
+        try {
+            une.dispatch(null);
+            fail("Failed notification is null.");
+        } catch (NullPointerException e) {}
+    }
 	
 	/**
 	 * <p>Test method for 'javax.naming.ldap.UnsolicitedNotificationEvent.dispatch(UnsolicitedNotificationListener)'</p>
@@ -212,18 +119,11 @@
 	 * <p>The expected result is a null pointer exception.</p>
 	 */
 	public void testDispatch002() {
-		try{
-			Object x=new Object();
-			MockUnsolicitedNotification u=new MockUnsolicitedNotification();
-			MockUnsolicitedNotification f=new MockUnsolicitedNotification();			
-			UnsolicitedNotificationEvent une=new UnsolicitedNotificationEvent(x,u);
-			une.dispatch(f);
-			assertTrue(f.getFlag());
-		} catch (Throwable e) {
-			fail("Failed with:"+e);
-		}
-
-	}
-	
-
+        Object x = new Object();
+        MockUnsolicitedNotification u = new MockUnsolicitedNotification();
+        MockUnsolicitedNotification f = new MockUnsolicitedNotification();
+        UnsolicitedNotificationEvent une = new UnsolicitedNotificationEvent(x, u);
+        une.dispatch(f);
+        assertTrue(f.getFlag());
+    }
 }

Modified: harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ldap/MockStartTlsResponse.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ldap/MockStartTlsResponse.java?view=diff&rev=512830&r1=512829&r2=512830
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ldap/MockStartTlsResponse.java (original)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/java/org/apache/harmony/jndi/tests/javax/naming/spi/mock/ldap/MockStartTlsResponse.java Wed Feb 28 08:20:15 2007
@@ -41,57 +41,24 @@
 	 */
 	private static final long serialVersionUID = 1L;
 
-	/**
-	 * Constructor method to our TLSResponse.
-	 *
-	 */
-	public MockStartTlsResponse() {
-		super();
-		// TODO Auto-generated constructor stub
-	}
-
-	/**
-	 * <p>Method not implemented yet.</p>
-	 */
-	public void setEnabledCipherSuites(String[] arg0) {
-		// TODO Auto-generated method stub
-
-	}
-
-	/**
-	 * <p>Method not implemented yet.</p>
-	 */
-	public void setHostnameVerifier(HostnameVerifier arg0) {
-		// TODO Auto-generated method stub
-
-	}
-
-	/**
-	 * <p>Method not implemented yet.</p>
-	 */
-	public SSLSession negotiate() throws IOException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	/**
-	 * <p>Method not implemented yet.</p>
-	 */
-	public SSLSession negotiate(SSLSocketFactory arg0) throws IOException {
-		// TODO Auto-generated method stub
-		return null;
-	}
-
-	/**
-	 * Method to close our TlsResponse.
-	 */
-	public void close() throws IOException {
-		try {
-			super.finalize();
-		} catch (Throwable e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-		}
-	}
+    public SSLSession negotiate() throws IOException {
+        throw new Error("should not be here");
+    }
+
+    public SSLSession negotiate(SSLSocketFactory factory) throws IOException {
+        throw new Error("should not be here");
+    }
+
+    public void setEnabledCipherSuites(String[] suites) {
+        throw new Error("should not be here");
+    }
+
+    public void setHostnameVerifier(HostnameVerifier verifier) {
+        throw new Error("should not be here");
+    }
+
+    public void close() throws IOException {
+        throw new Error("should not be here");
+    }
 
 }

Added: harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/META-INF/services/javax.naming.ldap.StartTlsResponse
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/META-INF/services/javax.naming.ldap.StartTlsResponse?view=auto&rev=512830
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/META-INF/services/javax.naming.ldap.StartTlsResponse (added)
+++ harmony/enhanced/classlib/trunk/modules/jndi/src/test/resources/META-INF/services/javax.naming.ldap.StartTlsResponse Wed Feb 28 08:20:15 2007
@@ -0,0 +1,26 @@
+# some comment
+
+Do.Not.Exist
+
+## Another comment
+
+# some empty lines
+
+# not a StartTlsResponse class
+org.apache.harmony.jndi.tests.javax.naming.ldap.StartTlsRequestTest
+
+# throws Exception while initializing
+org.apache.harmony.jndi.tests.javax.naming.ldap.StartTlsRequestTest$MockStartTlsResponse1
+
+# has protected constructor
+org.apache.harmony.jndi.tests.javax.naming.ldap.StartTlsRequestTest$MockStartTlsResponse2
+
+# package-access class
+org.apache.harmony.jndi.tests.javax.naming.ldap.StartTlsRequestTest$MockStartTlsResponse3
+
+
+## and now valid class name edged by spaces and tabs ##
+	  	org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockStartTlsResponse	  	
+
+
+# that's it
\ No newline at end of file



Mime
View raw message