📄 standardservicetest.java
字号:
Thread.sleep(1000);
//DW/2661/EndPatch
StandardService.modify(pclone, _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 and cloned entry, " +
"delete a value from a dn attribute ");
try
{
JBTop jbTop = StandardService.load(DN_USERWA, _ADMINCONTEXT);
if (jbTop instanceof PersonTest)
{
_test.displayMsg("Modify manager attribute");
Collection oldManager = ((PersonTest) jbTop).getManager();
// Clones the entry
PersonTest pclone = (PersonTest) jbTop.clone();
pclone.setManager(null);
//DW/2661/BeginPatch
// Has to wait at least 1s before object cloning and call to modify.
Thread.sleep(1000);
//DW/2661/EndPatch
StandardService.modify(pclone, _ADMINCONTEXT);
jbTop = StandardService.load(DN_USERWA, _ADMINCONTEXT);
Collection manager = ((PersonTest) jbTop).getManager();
//DW/2661/BeginPatch
/*
* !!! with lazyCollection implementation, reloaded attribute is
* empty instead of being null.
*/
if ((manager == null) || manager.isEmpty())
//DW/2661/EndPatch
{
_test.displayResultSuccess(null);
}
else
{
_test.displayResultFailure(null);
}
_test.displayMsg("Cancel manager modification");
((PersonTest) jbTop).setManager(oldManager);
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 with user having access and cloned entry
_test.displayMsg(TestUtils.NEXT +
"Parameters = Test with user having access and cloned entry, " +
"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 pclone = (PersonTest) jbTop.clone();
pclone.setId(idRef);
// Has to wait at least 1s before object cloning and call to modify.
Thread.sleep(1000);
StandardService.modify(pclone, _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.displayFooterMethod("testModify");
}
/**
* Tests the modification of an attribute.
*
*/
public static void testModifyAttribute()
{
_test.displayHeaderMethod("testModifyAttribute");
// Test with user has not access
_test.displayMsg(TestUtils.NEXT +
"Parameters = Test with user has not access, " + "User Account : " +
DN_USER);
try
{
String givenNameRef = "Arthur3";
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, GIVENNAME_ATTRIBUTE, _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 = "Arthur4";
JBTop jbTop = StandardService.load(DN_USER, _ADMINCONTEXT);
if (jbTop instanceof PersonTest)
{
_test.displayMsg("Modify givenName");
String oldPrenom = ((PersonTest) jbTop).getPrenom();
((PersonTest) jbTop).setPrenom(givenNameRef);
StandardService.modify(jbTop, GIVENNAME_ATTRIBUTE, _ADMINCONTEXT);
jbTop = StandardService.load(DN_USER, _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.displayFooterMethod("testModifyAttribute");
}
/**
* Test the creation.
*
*/
public static void testCreate()
{
_test.displayHeaderMethod("testCreate");
try
{
PersonTest pt = new PersonTest();
ArrayList oclist = new ArrayList();
oclist.add("top");
oclist.add("organizationalperson");
oclist.add("person");
oclist.add("inetOrgPerson");
pt.setObjectClass(oclist);
pt.setNomPrenom("Delabranche Adalbert");
pt.setPrenom("Adalbert");
pt.setNom("Delabranche");
pt.setId("adelabranche");
pt.setPassword("anaconda");
String entryDN = "uid=adelabranche,ou=people,dc=mycompany,dc=com";
pt.setDn(entryDN);
ArrayList oulist = new ArrayList();
oulist.add("Product Testing");
pt.setOu(oulist);
// Test with user has not access
_test.displayMsg(TestUtils.NEXT +
"Parameters = Test with user has not access");
try
{
StandardService.create(pt, _USERCONTEXT);
_test.displayResultFailure(null);
}
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");
try
{
StandardService.create(pt, _ADMINCONTEXT);
JBTop jbTop = StandardService.load(entryDN, _ADMINCONTEXT);
if (jbTop != null)
{
if (_test.compareValues(entryDN, jbTop.getDn()))
{
// entry exists => deletes the entry
try
{
StandardService.delete(jbTop, _ADMINCONTEXT);
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append(
"Exception during the deletion of the entry : " +
entryDN);
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayMsg(msg.toString());
}
}
}
else
{
_test.displayResultFailure("No created entry : " + entryDN);
}
}
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());
}
}
catch (Exception ex)
{
StringBuffer msg = new StringBuffer();
msg.append("Exception : ");
msg.append(TestUtils.NEXT);
msg.append(ex.toString());
_test.displayResultError(msg.toString());
}
_test.displayFooterMethod("testCreate");
}
/**
* Test the deletion.
*
*/
public static void testDelete()
{
_test.displayHeaderMethod("testDelete");
try
{
PersonTest pt = new PersonTest();
ArrayList oclist = new ArrayList();
oclist.add("top");
oclist.add("organizationalPerson");
oclist.add("person");
oclist.add("inetOrgPerson");
pt.setObjectClass(oclist);
pt.setNomPrenom("Vudeloin Hontapa");
pt.setPrenom("Hontapa");
pt.setNom("Vudeloin");
pt.setId("hvudeloin");
pt.setPassword("escargot");
String entryDN = "uid=hvudeloin,ou=people,dc=mycompany,dc=
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -