📄 standardservicetest.java
字号:
_test.displayMsg(TestUtils.NEXT +
"Parameters = LazyDnCollection");
try
{
Collection cs = person.getSecretary();
_test.displayMsg("getSecretary size : " +
cs.size());
if ((cs == null) || (cs.size() == 0))
{
_test.displayResultFailure("No secretary");
}
else
{
Iterator it = cs.iterator();
boolean secretaryOk = true;
while (it.hasNext())
{
String dn = (String) it.next();
_test.displayMsg("DN : " + dn);
if (!htManagers.containsKey(dn))
{
secretaryOk = false;
}
}
if ((secretaryOk) && (cs.size() == 3))
{
_test.displayResultSuccess(null);
}
else
{
_test.displayResultFailure(null);
}
}
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
_test.displayMsg(TestUtils.NEXT +
"Parameters = LazyStringCollection");
try
{
Collection cml = person.getMail();
_test.displayMsg("getMail size : " + cml.size());
if ((cml == null) || (cml.size() == 0))
{
_test.displayResultFailure("No mail");
}
else
{
Iterator it = cml.iterator();
boolean mailOk = true;
while (it.hasNext())
{
String mail = (String) it.next();
_test.displayMsg("Mail : " + mail);
if (!htMails.containsKey(mail))
{
mailOk = false;
}
}
if ((mailOk) && (cml.size() == 3))
{
_test.displayResultSuccess(null);
}
else
{
_test.displayResultFailure(null);
}
}
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
_test.displayMsg(TestUtils.NEXT +
"Parameters = LazyBytesCollection");
try
{
Collection cp = person.getPhoto();
_test.displayMsg("getPhoto number : " + cp.size());
if ((cp == null) || (cp.size() == 0))
{
_test.displayResultFailure("No photo");
}
else
{
// r閏up鑢e la photo de r閒閞ence
byte[] refImage = _test.readBytesFromFile(IMAGE_NAME,
IMAGE_PATH);
_test.displayMsg(
"Size of the reference image : " +
refImage.length);
// compare les 2 photos
Iterator it = cp.iterator();
boolean photoOk = true;
while (it.hasNext())
{
byte[] photo = (byte[]) it.next();
_test.displayMsg("Size of the photo : " +
photo.length);
if (photo.length != refImage.length)
{
photoOk = false;
}
}
if (photoOk)
{
_test.displayResultSuccess(null);
}
else
{
_test.displayResultFailure(null);
}
}
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
}
else
{
_test.displayResultFailure("Dn incorrect : " +
person.getDn());
}
}
}
catch (ServiceException se)
{
_test.displayResultFailure(TestUtils.NEXT + se.toString());
}
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
_test.displayFooterMethod("testLoadLazyLoading");
}
/**
* Tests the modification of an user entry.
*
*/
public static void testModify()
{
_test.displayHeaderMethod("testModify");
// Test with user has not access
_test.displayMsg(TestUtils.NEXT +
"Parameters = Test with user has not access, " + "User Account : " +
DN_USER);
try
{
String givenNameRef = "Arthur1";
JBTop jbTop = StandardService.load(DN_USERWA, _USERCONTEXT);
if (jbTop instanceof PersonTest)
{
_test.displayMsg("Modify givenName");
String oldPrenom = ((PersonTest) jbTop).getPrenom();
((PersonTest) jbTop).setPrenom(givenNameRef);
StandardService.modify(jbTop, _USERCONTEXT);
_test.displayResultFailure(null);
}
else
{
_test.displayResultError(
"Problem during the loading of the entry : " + DN_USERWA);
}
}
catch (InsufficientAccessRights iar)
{
StringBuffer msg = new StringBuffer();
msg.append("InsufficientAccessRights : ");
msg.append(TestUtils.NEXT);
msg.append(iar.toString());
_test.displayResultSuccess(msg.toString());
}
catch (ServiceException se)
{
_test.displayResultSuccess(se.toString());
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
// Test with user having access
_test.displayMsg(TestUtils.NEXT +
"Parameters = Test with user having access, " +
"Administrator Account : " + DN_ADMIN);
try
{
String givenNameRef = "Arthur2";
JBTop jbTop = StandardService.load(DN_USERWA, _ADMINCONTEXT);
if (jbTop instanceof PersonTest)
{
_test.displayMsg("Modify givenName");
String oldPrenom = ((PersonTest) jbTop).getPrenom();
((PersonTest) jbTop).setPrenom(givenNameRef);
StandardService.modify(jbTop, _ADMINCONTEXT);
jbTop = StandardService.load(DN_USERWA, _ADMINCONTEXT);
String newPrenom = ((PersonTest) jbTop).getPrenom();
_test.compareValues(givenNameRef, newPrenom);
_test.displayMsg("Cancel givenName modification");
((PersonTest) jbTop).setPrenom(oldPrenom);
StandardService.modify(jbTop, _ADMINCONTEXT);
}
}
catch (ServiceException se)
{
_test.displayResultFailure(se.toString());
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
// Test with user having access
_test.displayMsg(TestUtils.NEXT +
"Parameters = Test with user having access, " +
"delete a value from an attribute ");
try
{
JBTop jbTop = StandardService.load(DN_USERWA, _ADMINCONTEXT);
if (jbTop instanceof PersonTest)
{
_test.displayMsg("Modify givenName");
String oldPrenom = ((PersonTest) jbTop).getPrenom();
((PersonTest) jbTop).setPrenom(null);
StandardService.modify(jbTop, _ADMINCONTEXT);
jbTop = StandardService.load(DN_USERWA, _ADMINCONTEXT);
String newPrenom = ((PersonTest) jbTop).getPrenom();
if (newPrenom == null)
{
_test.displayResultSuccess(null);
}
else
{
_test.displayResultFailure("Prenom= " + newPrenom);
}
_test.displayMsg("Cancel givenName modification");
((PersonTest) jbTop).setPrenom(oldPrenom);
StandardService.modify(jbTop, _ADMINCONTEXT);
}
}
catch (ServiceException se)
{
_test.displayResultFailure(se.toString());
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
//DW/2662/BeginPatch
_test.displayMsg(TestUtils.NEXT +
"Parameters = Test with user having access, " +
"modify RDN attribute ");
try
{
String idRef = "Arthur2";
JBTop jbTop = StandardService.load(DN_USERWA, _ADMINCONTEXT);
if (jbTop instanceof PersonTest)
{
_test.displayMsg("Modify uid");
String oldId = ((PersonTest) jbTop).getId();
((PersonTest) jbTop).setId(idRef);
StandardService.modify(jbTop, _ADMINCONTEXT);
jbTop = StandardService.load(DN_USERWA_M, _ADMINCONTEXT);
String newId = ((PersonTest) jbTop).getId();
_test.compareValues(idRef, newId);
_test.displayMsg("Cancel uid modification");
((PersonTest) jbTop).setId(oldId);
StandardService.modify(jbTop, _ADMINCONTEXT);
}
}
catch (ServiceException se)
{
_test.displayResultFailure(se.toString());
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
//DW/2662/EndPatch
// Test with user having access and cloned entry
_test.displayMsg(TestUtils.NEXT +
"Parameters = Test with user having access and cloned entry, " +
"Administrator Account : " + DN_ADMIN);
try
{
String givenNameRef = "Arthur2";
JBTop jbTop = StandardService.load(DN_USERWA, _ADMINCONTEXT);
if (jbTop instanceof PersonTest)
{
_test.displayMsg("Modify givenName");
String oldPrenom = ((PersonTest) jbTop).getPrenom();
PersonTest pclone = (PersonTest) jbTop.clone();
pclone.setPrenom(givenNameRef);
//DW/2661/BeginPatch
// Has to wait at least 1s before object cloning and call to modify.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -