本文整理汇总了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());
}
示例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) {
}
}
示例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));
}
示例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());
}