mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

smaguin
06.39.2007 95d6370de99c444f9f7931eb88a86401bad60068
opends/tests/functional-tests/shared/java/modifyAnAttribute.java
@@ -49,9 +49,7 @@
/**
  *  modify an entry with an attribute 
  *  the operation can be a replace, delete or a add new attribute
  *  if expectedErrorCode is set, we compare it with the ldap error code returned in the exception
  *  the function returns 0 if the code are equals
  *  otherwise, returns 1
  *  the function returns the ldap error code
  */
public class modifyAnAttribute {
@@ -69,7 +67,7 @@
     String errorCode=null;
     String errorMessage=null;
     String listAttributesToModify=null;
     String expectedErrorCode="0";
     
     int ind1;
     String attributeName;
@@ -109,9 +107,6 @@
       if (opt1.equals("-t")) {
          changetype = val1;
       }
       if (opt1.equals("-E")) {
          expectedErrorCode = val1;
       }
          if (opt1.equals("-l")) {
             listAttributesToModify = val1;
          
@@ -170,8 +165,8 @@
   try {
      
      CompositeName entryDN = new CompositeName (dnToModify);
      System.out.println(changetype + " attribute " + attributeToModify + " for entry " + dnToModify);
       CompositeName entryDN = new CompositeName (dnToModify);
      System.out.println("Modify the entry " + dnToModify);
      
      // connect to server
      ctx = new InitialLdapContext(envLdap, null);
@@ -188,8 +183,9 @@
          // add attribute
          ctx.modifyAttributes(entryDN, LdapContext.REMOVE_ATTRIBUTE , attributes);
       }
        ctx.close();
   } catch (CommunicationException e1) {
      errorMessage = e1.getMessage();
@@ -206,20 +202,13 @@
    else {
      System.out.println (errorMessage);
      int ind=errorMessage.indexOf("-");
      errorCode=errorMessage.substring(18, ind-1);
    }
   // Compare the errorCode and the expected error Code
    int diff=expectedErrorCode.compareTo(errorCode);
    if (diff == 0 ){
        // Got the expected error Code. The test is success
      System.exit(0);
    }
    else {
      System.out.println ("Error: modify request didn't return the expected error Code");
      System.out.println ("Expected " + expectedErrorCode + "; Got" + errorCode);
      System.exit(1);
      if ( ind > 0 ) {
       errorCode=errorMessage.substring(18, ind-1);
      }
      else errorCode="0";
    }
 
}
}
    int RC = Integer.parseInt(errorCode);
    System.exit(RC);
    }
}