当前位置: 首页>>代码示例>>Java>>正文


Java UnsolicitedNotification类代码示例

本文整理汇总了Java中javax.naming.ldap.UnsolicitedNotification的典型用法代码示例。如果您正苦于以下问题:Java UnsolicitedNotification类的具体用法?Java UnsolicitedNotification怎么用?Java UnsolicitedNotification使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UnsolicitedNotification类属于javax.naming.ldap包,在下文中一共展示了UnsolicitedNotification类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testConstructor_simple

import javax.naming.ldap.UnsolicitedNotification; //导入依赖的package包/类
public void testConstructor_simple() {
	NamingException exception = new NamingException(
			"MockUnsolicitedNotification: naming exception");
	String[] referral = { "Red", "Blue", };
	UnsolicitedNotification notification = new MockUnsolicitedNotification(
			referral, exception);
	Object src = "source";
	UnsolicitedNotificationEvent event = new UnsolicitedNotificationEvent(
			src, notification);

	assertEquals(src, event.getSource());
	assertEquals(notification, event.getNotification());

	assertSame(notification, event.getNotification());
	assertSame(src, event.getSource());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:UnsolicitedNotificationEventTest.java

示例2: testConstructor_src_null

import javax.naming.ldap.UnsolicitedNotification; //导入依赖的package包/类
public void testConstructor_src_null() {
	NamingException exception = new NamingException(
			"MockUnsolicitedNotification: naming exception");
	String[] referral = { "Red", "Blue", };
	UnsolicitedNotification notification = new MockUnsolicitedNotification(
			referral, exception);
	Object src = null;
	try {
		new UnsolicitedNotificationEvent(
				src, notification);
	} catch (IllegalArgumentException e) {
	}
}
 
开发者ID:shannah,项目名称:cn1,代码行数:14,代码来源:UnsolicitedNotificationEventTest.java

示例3: testDispatch

import javax.naming.ldap.UnsolicitedNotification; //导入依赖的package包/类
public void testDispatch() {
	NamingException exception = new NamingException(
			"MockUnsolicitedNotification: naming exception");
	String[] referral = { "Red", "Blue", };
	UnsolicitedNotification notification = new MockUnsolicitedNotification(
			referral, exception);
	Object src = "source";
	UnsolicitedNotificationEvent event = new UnsolicitedNotificationEvent(
			src, notification);
	MockUnsolicitedNotificationListener listener = new MockUnsolicitedNotificationListener();
	event.dispatch(listener);
	assertTrue(listener.hasEvent(event));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:14,代码来源:UnsolicitedNotificationEventTest.java

示例4: testUnsolicitedNotification

import javax.naming.ldap.UnsolicitedNotification; //导入依赖的package包/类
public void testUnsolicitedNotification() throws Exception {
    server.setResponseSeq(new LdapMessage[] { new LdapMessage(
            LdapASN1Constant.OP_BIND_RESPONSE, new BindResponse(), null) });
    LdapContext context = new InitialLdapContext(env, null);

    server.setResponseSeq(new LdapMessage[] { new LdapMessage(
            LdapASN1Constant.OP_SEARCH_RESULT_DONE,
            new EncodableLdapResult(), null) });
    EventDirContext eventContext = (EventDirContext) context.lookup("");

    assertTrue(eventContext.targetMustExist());

    MockUnsolicitedNotificationListener listener = new MockUnsolicitedNotificationListener();

    MockLdapMessage message = new MockLdapMessage(new LdapMessage(
            LdapASN1Constant.OP_EXTENDED_RESPONSE,
            new DisconnectResponse(), null));
    message.setMessageId(0);
    server.setResponseSeq(new LdapMessage[] { message });

    eventContext.addNamingListener("", "(objectclass=cn)", new Object[0],
            new SearchControls(), listener);
    server.disconnectNotify();
    Thread.sleep(500);
    assertNull(listener.exceptionEvent);
    assertNotNull(listener.unsolicatedEvent);
    assertTrue(listener.unsolicatedEvent.getSource() instanceof LdapContext);
    UnsolicitedNotification notification = listener.unsolicatedEvent
            .getNotification();
    assertNotNull(notification);
    assertEquals(DisconnectResponse.oid, notification.getID());
    assertNull(notification.getControls());
    assertNull(notification.getException());
    assertNull(notification.getReferrals());
    assertNull(notification.getEncodedValue());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:37,代码来源:LdapContextServerMockedTest.java


注:本文中的javax.naming.ldap.UnsolicitedNotification类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。