< prev index next >
test/jdk/javax/naming/module/src/test/test/ConnectWithAuthzId.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
--- 1,7 ----
/*
! * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*** 27,36 ****
--- 27,37 ----
* is supplied by a third-party module.
*/
package test;
+ import java.io.PrintStream;
import java.net.*;
import java.util.*;
import javax.naming.*;
import javax.naming.directory.*;
import javax.naming.ldap.*;
*** 38,53 ****
import org.example.authz.AuthzIdRequestControl;
import org.example.authz.AuthzIdResponseControl;
public class ConnectWithAuthzId {
// LDAP capture file
private static final String LDAP_CAPTURE_FILE =
System.getProperty("test.src") +
"/src/test/test/ConnectWithAuthzId.ldap";
- // LDAPServer socket
- private static ServerSocket serverSocket;
public static void main(String[] args) throws Exception {
/*
* Process arguments
--- 39,60 ----
import org.example.authz.AuthzIdRequestControl;
import org.example.authz.AuthzIdResponseControl;
public class ConnectWithAuthzId {
+ static {
+ final PrintStream out = new PrintStream(System.out, true);
+ final PrintStream err = new PrintStream(System.err, true);
+
+ System.setOut(out);
+ System.setErr(err);
+ }
+
// LDAP capture file
private static final String LDAP_CAPTURE_FILE =
System.getProperty("test.src") +
"/src/test/test/ConnectWithAuthzId.ldap";
public static void main(String[] args) throws Exception {
/*
* Process arguments
*** 66,76 ****
/*
* Launch the LDAP server with the ConnectWithAuthzId.ldap capture file
*/
! serverSocket = new ServerSocket(0);
new Thread(new Runnable() {
@Override
public void run() {
try {
new LDAPServer(serverSocket, LDAP_CAPTURE_FILE);
--- 73,84 ----
/*
* Launch the LDAP server with the ConnectWithAuthzId.ldap capture file
*/
! try (ServerSocket serverSocket = new ServerSocket()) {
! serverSocket.bind(new InetSocketAddress(InetAddress.getLoopbackAddress(), 0));
new Thread(new Runnable() {
@Override
public void run() {
try {
new LDAPServer(serverSocket, LDAP_CAPTURE_FILE);
*** 130,135 ****
--- 138,144 ----
if (ctx != null) {
ctx.close();
}
}
}
+ }
}
< prev index next >