/** * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control)'</p> * <p>Here we are going to test if we can get an instance with the controls sended.</p> */ public void testGetControlInstanceControl() { try { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory"); MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), }; MockControl cs2 = new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }); InitialLdapContext ilc=new InitialLdapContext(env, cs); assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env)); } catch (NamingException e) { } }
/** * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control)'</p> * <p>Here we are gonna test if we can get an instance with the controls sended.</p> */ public void testGetControlInstanceControl() { try { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory"); MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), }; MockControl cs2 = new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }); InitialLdapContext ilc=new InitialLdapContext(env, cs); assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env)); } catch (NamingException e) { } }
/** * convert raw controls to particular type of controls using * <code>getControlInstance(Control, Context, Hashtable<?, ?>)</code> * * @param rawControls * raw controls * @return particular type of controls * * @throws NamingException */ private Control[] narrowingControls(Control[] rawControls) throws NamingException { if (rawControls == null) { return null; } Control[] controls = new Control[rawControls.length]; for (int i = 0; i < rawControls.length; ++i) { controls[i] = ControlFactory.getControlInstance(rawControls[i], this, env); } return controls; }
/** * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control, Context, Hashtable<?, ?>)'</p> * <p>Here we are testing the static method of the class ControlFactory</p> * <p>The expected result is the control sended.</p> */ public void testGetControlInstanceControlContextHashtableOfQQ003() throws Exception { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory"); MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }), new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), }; MockControl cs2 = new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }); InitialLdapContext ilc=new InitialLdapContext(env, cs); assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env)); }
/** * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control, Context, Hashtable<?, ?>)'</p> * <p>Here we are testing the static method of the class ControlFactory</p> * <p>The expected result is the control sended.</p> */ public void testGetControlInstanceControlContextHashtableOfQQ004() throws Exception { Hashtable env = new Hashtable(); env.put(Context.INITIAL_CONTEXT_FACTORY,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockContextFactory"); env.put(LdapContext.CONTROL_FACTORIES,"org.apache.harmony.jndi.tests.javax.naming.spi.mock.ldap.MockControlFactory"); MockControl[] cs = { new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }),new MockControl("c1", true, new byte[] { 'a', 'b', 'c', 'd' }), }; MockControl cs2 = new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }); InitialLdapContext ilc=new InitialLdapContext(env, cs); assertEquals(cs2,ControlFactory.getControlInstance(cs2,ilc,env)); }
/** * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control, Context, Hashtable<?, ?>)'</p> * <p>Here we are testing the static method of the class ControlFactory</p> * <p>The expected result is null.</p> */ public void testGetControlInstanceControlContextHashtableOfQQ001() throws Exception { ControlFactory.getControlInstance(null,null,null); }
/** * <p>Test method for 'javax.naming.ldap.ControlFactory.getControlInstance(Control, Context, Hashtable<?, ?>)'</p> * <p>Here we are testing the static method of the class ControlFactory</p> * <p>The expected result is the control sended.</p> */ public void testGetControlInstanceControlContextHashtableOfQQ002() throws Exception { MockControl cs = new MockControl("c1", false, new byte[] { 1, 2, 3, 4 }); assertEquals(cs,ControlFactory.getControlInstance(cs,null,null)); }