From 7c30dbb5403772b323df3ad907d9ed15d23b5aee Mon Sep 17 00:00:00 2001
From: ludovicp <ludovicp@localhost>
Date: Thu, 29 Apr 2010 20:35:40 +0000
Subject: [PATCH] Last batch of changes for this week. This adds support for the IETF based Password Policy for LDAP as SubEntry. Also resolves the following issues : - 4544 :  initializeBackend() should not set JE env config params directly. - 4478 : ECL in draft compat mode / search lastchangenumber can be very long - 4538 : Virtual attributes not retrieved when entry cache configured - 4547 : Search Filter Matching differ for cn=Directory Manager and plain user. - 4514 : Logs shows unexpected message with replication monitoring data missing (Partial fix) - 4534 : Replication using security does not work after server restart - 4516 : SEVERE_ERROR: servers (...) have the same ServerId In addition, they also improve reliability and performance in various areas including CollectiveAttributes, Virtual Attributes and Subentries management, Schema loading, Replication...

---
 opends/tests/staf-tests/shared/java/ldapjdk/PSearch.java |  214 +++++++++++++++++++++++++++++------------------------
 1 files changed, 117 insertions(+), 97 deletions(-)

diff --git a/opends/tests/staf-tests/shared/java/ldapjdk/PSearch.java b/opends/tests/staf-tests/shared/java/ldapjdk/PSearch.java
index 3169c5c..925b523 100644
--- a/opends/tests/staf-tests/shared/java/ldapjdk/PSearch.java
+++ b/opends/tests/staf-tests/shared/java/ldapjdk/PSearch.java
@@ -22,109 +22,129 @@
  * CDDL HEADER END
  *
  *
- *      Copyright 2009 Sun Microsystems, Inc.
+ *      Copyright 2009-2010 Sun Microsystems, Inc.
  */
 
 import netscape.ldap.util.GetOpt;
+import com.ibm.staf.STAFHandle;
 
 public class PSearch {
 
-    public static void main(String[] args) {
-        String usage = "Usage: psearch -h <hostname> -p <port> -b <suffix>" + "[-D bindDN] [-w bindPW]" + "-f <fileURL+file name>" + "-l <y>" + "-n <number of thread>" + " -o <add,modify,delete,moddn>";
-        String hostname = "localhost";
-        int portnumber = 1389; //LDAPv3.DEFAULT_PORT;
-        int nbThreads = 1;//number of thread by default        
-        // Check for these options. -H means to print out a usage message.
-        GetOpt options = new GetOpt("h:p:b:D:w:H:f:n:o:l", args);
+  public static void main(String[] args) {
+    String usage = "Usage: psearch -h <hostname> -p <port> -b <suffix>" + "[-D bindDN] [-w bindPW]" + "-f <fileURL+file name>" + "-s" + "-n <number of thread>" + " -o <add,modify,delete,moddn>"+ " -l";
+    String hostname = "localhost";
+    int portnumber = 1389; //LDAPv3.DEFAULT_PORT;
+    int nbThreads = 1;//number of thread by default
+    // Check for these options. -H means to print out a usage message.
+    GetOpt options = new GetOpt("h:p:b:D:w:H:f:n:o:s:l", args);
 
-        // Get the arguments specified for each option.
-        String host = options.getOptionParam('h');
-        // host
-        if (options.hasOption('h')) {
-            if (host == null) {
-                // usage
-                System.out.println(usage);
-                System.exit(1);
-            } else {
-                hostname = host;
-            }
-        }
-        String port = options.getOptionParam('p');
-        // If a port number was specified, convert the port value
-        // to an integer.
-        if (port != null) {
-            try {
-                portnumber = java.lang.Integer.parseInt(port);
-            } catch (java.lang.Exception e) {
-                System.out.println("Invalid port number: " + port);
-                System.out.println(usage);
-                System.exit(1);
-            }
-        }
-        //number of thread
-        String nbT = options.getOptionParam('n');
-        if (nbT != null) {
-            try {
-                nbThreads = java.lang.Integer.parseInt(nbT);
-            } catch (java.lang.Exception e) {
-                System.out.println("Invalid Thread number: " + nbT);
-                System.out.println(usage);
-                System.exit(1);
-            }
-        }
-        // PSearch suffix
-        String suffix = options.getOptionParam('b');
-
-        String bindDN = options.getOptionParam('D');
-
-        String bindPW = options.getOptionParam('w');
-
-        //operations all by default
-        String operation = PSearchOperations.ALL;
-        if (options.hasOption('o')) {
-            String opParam = options.getOptionParam('o');
-            if (opParam.equals("add")) {
-                operation = PSearchOperations.ADD;
-            } else if (opParam.equals("modify")) {
-                operation = PSearchOperations.MODIFY;
-            } else if (opParam.equals("delete")) {
-                operation = PSearchOperations.DELETE;
-            } else if (opParam.equals("moddn")) {
-                operation = PSearchOperations.MODDN;
-            }else if (opParam.equals("all")) {
-                operation = PSearchOperations.ALL;;
-            } else {
-                System.out.println("Invalid operation type: " + opParam);
-                System.out.println(usage);
-                System.exit(1);
-            }
-        }
-
-        // to disable the log files
-        boolean useFile = false;
-        String fileName = "logLile";
-        if (options.hasOption('f')) {
-            useFile = options.hasOption('f');
-            fileName = options.getOptionParam('f');
-        }
-        // to enable system out logs
-        boolean output = options.hasOption('l');
-
-        System.out.println("Connecting to " + hostname + ":" + portnumber +
-                " as \"" + bindDN + "\"" +
-                " on suffix \"" + suffix + "\"" +
-                " on operation \"" + operation + "\"" +
-                " use file: \"" + useFile + "\" output: \"" + output + "\"");
-        //start all thread
-        for (int i = 0; i < nbThreads; i++) {
-            PSearchOperations ps = new PSearchOperations(i, hostname, portnumber, bindDN, bindPW, suffix);
-            if (useFile) {
-                ps.useLogFile(useFile);
-                ps.setLogFile(fileName);
-            }
-            ps.setOutput(output);
-            ps.setOperation(operation);
-            ps.start();
-        }
+    // Get the arguments specified for each option.
+    String host = options.getOptionParam('h');
+    // host
+    if (options.hasOption('h')) {
+      if (host == null) {
+        // usage
+        System.out.println(usage);
+        System.exit(1);
+      } else {
+        hostname = host;
+      }
     }
+    String port = options.getOptionParam('p');
+    // If a port number was specified, convert the port value
+    // to an integer.
+    if (port != null) {
+      try {
+        portnumber = java.lang.Integer.parseInt(port);
+      } catch (java.lang.Exception e) {
+        System.out.println("Invalid port number: " + port);
+        System.out.println(usage);
+        System.exit(1);
+      }
+    }
+    //number of thread
+    String nbT = options.getOptionParam('n');
+    if (nbT != null) {
+      try {
+        nbThreads = java.lang.Integer.parseInt(nbT);
+      } catch (java.lang.Exception e) {
+        System.out.println("Invalid Thread number: " + nbT);
+        System.out.println(usage);
+        System.exit(1);
+      }
+    }
+    // PSearch suffix
+    String suffix = options.getOptionParam('b');
+
+    String bindDN = options.getOptionParam('D');
+
+    String bindPW = options.getOptionParam('w');
+
+    //operations all by default
+    String operation = PSearchOperations.ALL;
+    if (options.hasOption('o')) {
+      String opParam = options.getOptionParam('o');
+      if (opParam.equals("add")) {
+        operation = PSearchOperations.ADD;
+      } else if (opParam.equals("modify")) {
+        operation = PSearchOperations.MODIFY;
+      } else if (opParam.equals("delete")) {
+        operation = PSearchOperations.DELETE;
+      } else if (opParam.equals("moddn")) {
+        operation = PSearchOperations.MODDN;
+      } else if (opParam.equals("all")) {
+        operation = PSearchOperations.ALL;
+        ;
+      } else {
+        System.out.println("Invalid operation type: " + opParam);
+        System.out.println(usage);
+        System.exit(1);
+      }
+    }
+
+    // to disable the log files
+    boolean useFile = false;
+    String fileName = "logLile";
+    if (options.hasOption('f')) {
+      useFile = options.hasOption('f');
+      fileName = options.getOptionParam('f');
+    }
+
+    // to enable diff format
+    boolean ldifFormat = options.hasOption('l');
+
+    // to enable system out logs
+    boolean output = options.hasOption('s');
+
+    System.out.println("Connecting to " + hostname + ":" + portnumber +
+            " as \"" + bindDN + "\"" +
+            " on suffix \"" + suffix + "\"" +
+            " on operation \"" + operation + "\"" +
+            " use file: \"" + useFile + "\" output: \"" + output + "\"");
+    //start all thread
+
+
+    for (int i = 0; i < nbThreads; i++) {
+      PSearchOperations ps = new PSearchOperations(i, hostname, portnumber, bindDN, bindPW, suffix);
+      if (useFile) {
+        ps.useLogFile(useFile);
+        ps.setLogFile(fileName);
+      }
+      ps.setOutput(output);
+      ps.setLdifFormat(ldifFormat);
+      ps.setOperation(operation);
+      ps.start();
+    }
+    
+        try {
+      STAFHandle handle = new STAFHandle("PSearch listener");
+      handle.submit2(hostname, "SEM", "PULSE EVENT PSearch/Ready");
+      handle.submit2(hostname, "SEM", "WAIT EVENT PSearch tests/Completed");
+      handle.submit2(hostname, "SEM", "DELETE EVENT PSearch tests/Completed");
+      System.exit(0);
+    } catch (Exception e) {
+      System.out.println("STAF Handle fail");
+    }
+
+  }
 }

--
Gitblit v1.10.0