Java 类javax.naming.CannotProceedException 实例源码

项目:OpenJSharp    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:jdk8u-jdk    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:openjdk-jdk10    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a {@code DirContext} operation.
  * Operates just like {@code NamingManager.getContinuationContext()},
  * only the continuation context returned is a {@code DirContext}.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null {@code DirContext} object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:openjdk9    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a {@code DirContext} operation.
  * Operates just like {@code NamingManager.getContinuationContext()},
  * only the continuation context returned is a {@code DirContext}.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null {@code DirContext} object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:Java8CN    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:jdk8u_jdk    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:lookaside_java-1.8.0-openjdk    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:infobip-open-jdk-8    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:jdk8u-dev-jdk    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:OLD-OpenJDK8    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
@SuppressWarnings("unchecked")
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable<Object,Object> env = (Hashtable<Object,Object>)cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable<>(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable<Object,Object>) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}
项目:cn1    文件:DirectoryManagerJCKTest.java   
public void testGetContinuationDirContext() throws NamingException {
    // Step 1: Write a simple class which implements
    // LdapContext and InitialContextFactory.
    // Please refer to the following class MyLdapContext

    // Step 2: Create an instance of MyLdapContext
    DirContext context = new MyLdapContext();

    // Step 3: Create an instance of CannotProceedException,
    // and set the resolve object as "context"
    CannotProceedException exception = new CannotProceedException(
            "TestGetContinuationDirContext");
    exception.setResolvedObj(context);
    // Step 4: Call DirectoryManager.getContinuationDirContext and pass
    // the "exception";

    DirContext newContext = DirectoryManager
            .getContinuationDirContext(exception);
    // Step 5: check result
    assertNotNull(newContext);
    // System.out.println(context);
    // System.out.println(newContext);
}
项目:cn1    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_badnameh()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_badnameh()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h.put(Context.OBJECT_FACTORIES, "bad name:asdfa");
    cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, obj);
    }
}
项目:cn1    文件:NamingManagerTest.java   
private void assertCPE(CannotProceedException cpe, CompositeName altName,
        MockContext context, Hashtable<String, String> h, CannotProceedException e,
        Object obj) {
    assertNull(e.getExplanation());
    assertNull(e.getMessage());
    assertNull(e.getRootCause());
    assertNull(e.getRemainingName());
    assertNull(e.getRemainingNewName());
    assertNull(e.getResolvedName());
    assertSame(e.getAltName(), altName);
    assertSame(e.getAltNameCtx(), context);
    assertEquals(e.getResolvedObj(), obj);
    assertSame(e, cpe);
    if (h != null) {
        assertSame(e.getEnvironment(), h);
    } else {
        assertSame(e.getEnvironment().get(NamingManager.CPE), e);
    }
}
项目:cn1    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_wrongh()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_wrongh()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);

    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h
            .put(Context.OBJECT_FACTORIES,
                    "org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactory");
    cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, obj);
    }
}
项目:cn1    文件:NamingManagerTest.java   
public void testGetContinuationContext_null_name_context_h()
        throws NamingException {
    log.setMethod("testGetContinuationContext_null_name_context_h()");
    CannotProceedException cpe = new CannotProceedException();
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h.put(Context.OBJECT_FACTORIES,"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockContextObjectFactory");
       cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, null);
    }
}
项目:cn1    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_null()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_null()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, null, e, obj);
    }
}
项目:cn1    文件:CannotProceedExceptionTest.java   
public void testConstructorAndGetterSetter() throws InvalidNameException {
    log.setMethod("testConstructorAndGetterSetter()");

    CannotProceedException cpe = new CannotProceedException();
    Name altName = new CompositeName("1");
    Context altContext = null;
    Hashtable<?, ?> h = new Hashtable<Object, Object>();
    Name newName = new CompositeName("2");

    cpe.setAltName(altName);
    assertEquals(altName, cpe.getAltName());

    cpe.setAltNameCtx(altContext);
    assertEquals(altContext, cpe.getAltNameCtx());

    cpe.setEnvironment(h);
    assertEquals(h, cpe.getEnvironment());

    cpe.setRemainingNewName(newName);
    assertEquals(newName, cpe.getRemainingNewName());
}
项目:video-batch    文件:XugglerAnalyzer.java   
public static int getMeanGOPLength(IContainer container) throws CannotProceedException, IOException {
 int numStreams = container.getNumStreams();

 if( numStreams <= 0 )
     throw new IOException( "No streams found in container." );

 List<IIndexEntry> index_list = null;

 for( int j = 0; j < container.getNumStreams(); j++ ) {
     IStream stream = container.getStream(j);
     IStreamCoder coder = stream.getStreamCoder();
     if( coder.getCodecType() != ICodec.Type.CODEC_TYPE_VIDEO)
         continue;
     index_list = stream.getIndexEntries();
 }

 if( index_list == null || index_list.size() == 0)
     throw new CannotProceedException( "No index entries found!" );

 int k = 0;
 for( int i = 0; i < index_list.size(); i++ )
    if ( index_list.get(i).isKeyFrame() ) k++; 

    return index_list.size() / k;
}
项目:video-batch    文件:XugglerVideoAnalyzer.java   
public static int getMeanGOPLength(IContainer container) throws CannotProceedException, IOException {
 int numStreams = container.getNumStreams();

 if( numStreams <= 0 )
     throw new IOException( "No streams found in container." );

 List<IIndexEntry> index_list = null;

 for( int j = 0; j < container.getNumStreams(); j++ ) {
     IStream stream = container.getStream(j);
     IStreamCoder coder = stream.getStreamCoder();
     if( coder.getCodecType() != ICodec.Type.CODEC_TYPE_VIDEO)
         continue;
     index_list = stream.getIndexEntries();
 }

 if( index_list == null || index_list.size() == 0)
     throw new CannotProceedException( "No index entries found!" );

 int k = 0;
 for( int i = 0; i < index_list.size(); i++ )
    if ( index_list.get(i).isKeyFrame() ) k++; 

    return index_list.size() / k;
}
项目:freeVM    文件:DirectoryManager.java   
/**
 * Create the next <code>DirContext</code> when using federation so that 
 * the <code>DirContext</code> operation can be reinvoked.
 * This should work similarly to 
 * <code>NamingManager.getContinuationContext</code> except that a 
 * reference to a <code>DirContext</code> is returned.
 * <p>
 * This method is also responsible for setting the property denoted by the
 * <code>CPE</code> string to be the supplied
 * <code>CannotProceedException</code> for that environment.</p>
 *
 * @param cpe   the <code>CannotProceedException</code> generated by the
 *              <code>DirContext</code> of the previous naming system when
 *              it can proceed no further.
 * @return      the next <code>DirContext</code> when using federation
 * @throws  NamingException if the resolved object is not set or if a
 *          <code>DirContext</code>  cannot be obtained from it either
 *          directly or indirectly.
 */
public static DirContext getContinuationDirContext(CannotProceedException cpe)
    throws NamingException {
    // obtain next context using NamingManager
    Context nextContext = null;
    try {
        nextContext = NamingManager.getContinuationContext(cpe);
    } catch (CannotProceedException e) {
        // tolerate CannotProceedException here
    }

    // if it is a DirContext
    if (nextContext instanceof DirContext) {
        // return as DirContext
        return (DirContext) nextContext;
    } else {
        // in case it's Context but not DirContext, wrap it as DirContext and return
        return new Context2DirContextWrapper(nextContext, cpe);
    }
}
项目:freeVM    文件:DirectoryManagerJCKTest.java   
public void testGetContinuationDirContext() throws NamingException {
    // Step 1: Write a simple class which implements
    // LdapContext and InitialContextFactory.
    // Please refer to the following class MyLdapContext

    // Step 2: Create an instance of MyLdapContext
    DirContext context = new MyLdapContext();

    // Step 3: Create an instance of CannotProceedException,
    // and set the resolve object as "context"
    CannotProceedException exception = new CannotProceedException(
            "TestGetContinuationDirContext");
    exception.setResolvedObj(context);
    // Step 4: Call DirectoryManager.getContinuationDirContext and pass
    // the "exception";

    DirContext newContext = DirectoryManager
            .getContinuationDirContext(exception);
    // Step 5: check result
    assertNotNull(newContext);
    // System.out.println(context);
    // System.out.println(newContext);
}
项目:freeVM    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_badnameh()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_badnameh()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h.put(Context.OBJECT_FACTORIES, "bad name:asdfa");
    cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, obj);
    }
}
项目:freeVM    文件:NamingManagerTest.java   
private void assertCPE(CannotProceedException cpe, CompositeName altName,
        MockContext context, Hashtable<String, String> h, CannotProceedException e,
        Object obj) {
    assertNull(e.getExplanation());
    assertNull(e.getMessage());
    assertNull(e.getRootCause());
    assertNull(e.getRemainingName());
    assertNull(e.getRemainingNewName());
    assertNull(e.getResolvedName());
    assertSame(e.getAltName(), altName);
    assertSame(e.getAltNameCtx(), context);
    assertEquals(e.getResolvedObj(), obj);
    assertSame(e, cpe);
    if (h != null) {
        assertSame(e.getEnvironment(), h);
    } else {
        assertSame(e.getEnvironment().get(NamingManager.CPE), e);
    }
}
项目:freeVM    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_wrongh()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_wrongh()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);

    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h
            .put(Context.OBJECT_FACTORIES,
                    "org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactory");
    cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, obj);
    }
}
项目:freeVM    文件:NamingManagerTest.java   
public void testGetContinuationContext_null_name_context_h()
        throws NamingException {
    log.setMethod("testGetContinuationContext_null_name_context_h()");
    CannotProceedException cpe = new CannotProceedException();
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h.put(Context.OBJECT_FACTORIES,"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockContextObjectFactory");
       cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, null);
    }
}
项目:freeVM    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_null()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_null()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, null, e, obj);
    }
}
项目:freeVM    文件:CannotProceedExceptionTest.java   
public void testConstructorAndGetterSetter() throws InvalidNameException {
    log.setMethod("testConstructorAndGetterSetter()");

    CannotProceedException cpe = new CannotProceedException();
    Name altName = new CompositeName("1");
    Context altContext = null;
    Hashtable<?, ?> h = new Hashtable<Object, Object>();
    Name newName = new CompositeName("2");

    cpe.setAltName(altName);
    assertEquals(altName, cpe.getAltName());

    cpe.setAltNameCtx(altContext);
    assertEquals(altContext, cpe.getAltNameCtx());

    cpe.setEnvironment(h);
    assertEquals(h, cpe.getEnvironment());

    cpe.setRemainingNewName(newName);
    assertEquals(newName, cpe.getRemainingNewName());
}
项目:freeVM    文件:DirectoryManagerJCKTest.java   
public void testGetContinuationDirContext() throws NamingException {
    // Step 1: Write a simple class which implements
    // LdapContext and InitialContextFactory.
    // Please refer to the following class MyLdapContext

    // Step 2: Create an instance of MyLdapContext
    DirContext context = new MyLdapContext();

    // Step 3: Create an instance of CannotProceedException,
    // and set the resolve object as "context"
    CannotProceedException exception = new CannotProceedException(
            "TestGetContinuationDirContext");
    exception.setResolvedObj(context);
    // Step 4: Call DirectoryManager.getContinuationDirContext and pass
    // the "exception";

    DirContext newContext = DirectoryManager
            .getContinuationDirContext(exception);
    // Step 5: check result
    assertNotNull(newContext);
    // System.out.println(context);
    // System.out.println(newContext);
}
项目:freeVM    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_badnameh()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_badnameh()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h.put(Context.OBJECT_FACTORIES, "bad name:asdfa");
    cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, obj);
    }
}
项目:freeVM    文件:NamingManagerTest.java   
private void assertCPE(CannotProceedException cpe, CompositeName altName,
        MockContext context, Hashtable<String, String> h, CannotProceedException e,
        Object obj) {
    assertNull(e.getExplanation());
    assertNull(e.getMessage());
    assertNull(e.getRootCause());
    assertNull(e.getRemainingName());
    assertNull(e.getRemainingNewName());
    assertNull(e.getResolvedName());
    assertSame(e.getAltName(), altName);
    assertSame(e.getAltNameCtx(), context);
    assertEquals(e.getResolvedObj(), obj);
    assertSame(e, cpe);
    if (h != null) {
        assertSame(e.getEnvironment(), h);
    } else {
        assertSame(e.getEnvironment().get(NamingManager.CPE), e);
    }
}
项目:freeVM    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_wrongh()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_wrongh()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);

    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h
            .put(Context.OBJECT_FACTORIES,
                    "org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockObjectFactory");
    cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, obj);
    }
}
项目:freeVM    文件:NamingManagerTest.java   
public void testGetContinuationContext_null_name_context_h()
        throws NamingException {
    log.setMethod("testGetContinuationContext_null_name_context_h()");
    CannotProceedException cpe = new CannotProceedException();
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    Hashtable<String, String> h = new Hashtable<String, String>();
    h.put(Context.OBJECT_FACTORIES,"org.apache.harmony.jndi.tests.javax.naming.spi.NamingManagerTest$MockContextObjectFactory");
       cpe.setEnvironment(h);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, h, e, null);
    }
}
项目:freeVM    文件:NamingManagerTest.java   
public void testGetContinuationContext_OBJ_name_context_null()
        throws NamingException {
    log.setMethod("testGetContinuationContext_OBJ_name_context_null()");
    CannotProceedException cpe = new CannotProceedException();
    Object obj = "resolved object";
    cpe.setResolvedObj(obj);
    CompositeName altName = new CompositeName("abc/abc");
    cpe.setAltName(altName);
    MockContext context = new MockContext(new Hashtable<String, Object>());
    cpe.setAltNameCtx(context);
    try {
        NamingManager.getContinuationContext(cpe);
        fail();
    } catch (CannotProceedException e) {
        assertCPE(cpe, altName, context, null, e, obj);
    }
}
项目:freeVM    文件:CannotProceedExceptionTest.java   
public void testConstructorAndGetterSetter() throws InvalidNameException {
    log.setMethod("testConstructorAndGetterSetter()");

    CannotProceedException cpe = new CannotProceedException();
    Name altName = new CompositeName("1");
    Context altContext = null;
    Hashtable<?, ?> h = new Hashtable<Object, Object>();
    Name newName = new CompositeName("2");

    cpe.setAltName(altName);
    assertEquals(altName, cpe.getAltName());

    cpe.setAltNameCtx(altContext);
    assertEquals(altContext, cpe.getAltNameCtx());

    cpe.setEnvironment(h);
    assertEquals(h, cpe.getEnvironment());

    cpe.setRemainingNewName(newName);
    assertEquals(newName, cpe.getRemainingNewName());
}
项目:freeVM    文件:MyObjectFactory2.java   
/**
 * Returns new instance of the
 * org.apache.harmony.test.func.api.javax.naming.directory.provider.dns.TestCtxFactory
 * 
 * @param obj
 * @param name
 * @param nameCtx
 * @param environment
 * @param attrs
 * @return
 * @throws Exception
 */
public Object getObjectInstance(Object obj, Name name, Context nameCtx,
    Hashtable environment, Attributes attrs) throws Exception {
    Object o = environment.get("java.naming.spi.CannotProceedException");
    if ((o instanceof CannotProceedException)
        && (nameCtx instanceof DirContext)) {

        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY,
            "org.apache.harmony.test.func.api.javax."
                + "naming.provider.dns.TestCtxFactory");

        return new InitialDirContext(env);
    }
    return null;
}
项目:marshalsec    文件:JDKUtil.java   
public static DirContext makeContinuationContext ( String codebase, String clazz ) throws Exception {
    Class<?> ccCl = Class.forName("javax.naming.spi.ContinuationDirContext"); //$NON-NLS-1$
    Constructor<?> ccCons = ccCl.getDeclaredConstructor(CannotProceedException.class, Hashtable.class);
    ccCons.setAccessible(true);
    CannotProceedException cpe = new CannotProceedException();
    Reflections.setFieldValue(cpe, "stackTrace", new StackTraceElement[0]);
    cpe.setResolvedObj(new Reference("Foo", clazz, codebase));
    return (DirContext) ccCons.newInstance(cpe, null);
}
项目:c2mon-web-ui    文件:ConfigLoaderService.java   
/**
 * Applies the specified configuration and stores the Configuration Report for
 * later viewing.
 *
 * @param configurationId id of the configuration of the request
 * @throws CannotProceedException In case a serious error occurs (for example
 *           in case a null Configuration Report is received).
 */
public void applyConfiguration(final long configurationId) throws CannotProceedException {

  ReportHandler reportHandler = new ReportHandler(configurationId);
  progressReports.put(String.valueOf(configurationId), reportHandler);

  ConfigurationReport report = configurationService.applyConfiguration(configurationId, reportHandler);

  logger.debug("getConfigurationReport: Received configuration report? -> " + configurationId + ": " + (report == null ? "NULL" : "SUCCESS"));

  if (report == null) {
    logger.error("Received NULL Configuration report for configuration id:" + configurationId);
    throw new CannotProceedException("Did not receive Configuration Report.");
  }
  logger.debug("getConfigurationReport: Report=" + report.toXML());

  if (report.getName().equals("UNKNOWN")) {
    if (configurationReports.containsKey(String.valueOf(configurationId))) {
      configurationReports.get(String.valueOf(configurationId)).add(report);
    } else {
      List<ConfigurationReport> reports = getConfigurationReports(String.valueOf(configurationId));
      if (reports.isEmpty()) {
        reports.add(report);
      }
      configurationReports.put(String.valueOf(configurationId), reports);
    }
  }

  // store the report for viewing later
  ConfigurationReportHeader header = new ConfigurationReportHeader(report.getId(), report.getName(), report.getUser(), report.getStatus(),
      report.getStatusDescription(), report.getTimestamp());
  configurationReportHeaders.add(header);
}
项目:javify    文件:NamingManager.java   
/**
 * Creates a context in which the context operation must be continued.
 * This method is used by operations on names that span multiple namespaces.
 *
 * @param cpe the exception that triggered this continuation. This method
 * obtains the environment ({@link CannotProceedException#getEnvironment()}
 * and sets the environment property {@link #CPE} = cpe.
 *
 * @return a non null context for continuing the operation
 *
 * @throws NamingException if the naming problems have occured
 */
public static Context getContinuationContext (CannotProceedException cpe)
  throws NamingException
{
  Hashtable env = cpe.getEnvironment ();
  if (env != null)
    env.put (CPE, cpe);

  // TODO: Check if this implementation matches the API specification
  try
    {
      Object obj = getObjectInstance (cpe.getResolvedObj(),
                                      cpe.getAltName (),
                                      cpe.getAltNameCtx (),
                                      env);
      if (obj != null)
        return (Context) obj;
    }
  catch (Exception _)
    {
    }

  // fix stack trace for re-thrown exception (message confusing otherwise)
  cpe.fillInStackTrace();

  throw cpe;
}
项目:jvm-stm    文件:NamingManager.java   
/**
  * Creates a context in which the context operation must be continued.
  * This method is used by operations on names that span multiple namespaces.
  * 
  * @param cpe the exception that triggered this continuation. This method
  * obtains the environment ({@link CannotProceedException#getEnvironment()}
  * and sets the environment property {@link #CPE} = cpe.
  * 
  * @return a non null context for continuing the operation
  * 
  * @throws NamingException if the naming problems have occured
  */
 public static Context getContinuationContext (CannotProceedException cpe)
   throws NamingException
 {
   Hashtable env = cpe.getEnvironment ();
   if (env != null)
     env.put (CPE, cpe);

   // TODO: Check if this implementation matches the API specification
   try
     {
Object obj = getObjectInstance (cpe.getResolvedObj(),
                cpe.getAltName (),
                cpe.getAltNameCtx (), 
                env);
if (obj != null)
  return (Context) obj;
     }
   catch (Exception _)
     {
     }

   // fix stack trace for re-thrown exception (message confusing otherwise)
   cpe.fillInStackTrace();

   throw cpe;
 }
项目:jdk7-jdk    文件:DirectoryManager.java   
/**
  * Creates a context in which to continue a <tt>DirContext</tt> operation.
  * Operates just like <tt>NamingManager.getContinuationContext()</tt>,
  * only the continuation context returned is a <tt>DirContext</tt>.
  *
  * @param cpe
  *         The non-null exception that triggered this continuation.
  * @return A non-null <tt>DirContext</tt> object for continuing the operation.
  * @exception NamingException If a naming exception occurred.
  *
  * @see NamingManager#getContinuationContext(CannotProceedException)
  */
public static DirContext getContinuationDirContext(
        CannotProceedException cpe) throws NamingException {

    Hashtable env = cpe.getEnvironment();
    if (env == null) {
        env = new Hashtable(7);
    } else {
        // Make a (shallow) copy of the environment.
        env = (Hashtable) env.clone();
    }
    env.put(CPE, cpe);

    return (new ContinuationDirContext(cpe, env));
}