public abstract class JcmsTestCaseUtil extends java.lang.Object implements JcmsConstants
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
A_VERY_LONG_TEXT |
static long |
ASYNC_TEST__ITERATION_WAIT_TIME |
static long |
ASYNC_TEST__MAX_ITERATION |
static long |
ASYNC_TEST__MAX_WAIT_TIME_BEFORE_FAILURE |
ADATE_SEARCH, ADMIN_NOTES_PROP, ADVANCED_TAB, AJAX_MODE_ATTR, ARCHIVES_DIR, ASCII_WIDTH, CATEGORY_TAB, CDATE_SEARCH, COMMON_ALARM, CONTENT_TAB, COOKIE_MAX_AGE, COUNTRY_SPRITE, CTRL_TOPIC_INTERNAL, CTRL_TOPIC_REF, CTRL_TOPIC_VALUE, CTRL_TOPIC_WRITE, CUSTOM_PROP, DOCCHOOSER_HEIGHT, DOCCHOOSER_WIDTH, DOCS_DIR, EDATE_SEARCH, EMAIL_REGEXP, ERROR_MSG, FORBIDDEN_FILE_ACCESS, FORBIDDEN_REDIRECT, FORCE_REDIRECT, GLYPH_ICON_PREFIX, ICON_ARCHIVE, ICON_ICON_PREFIX, ICON_LOCK, ICON_LOCK_STRONG, ICON_PREFIX_PROP, ICON_WARN, ICON_WH_BOOK_CLOSED, ICON_WH_BOOK_OPEN, INFORMATION_MSG, JALIOS_JUNIT_PROP, JCMS_CADDY, JCMS_MSG_LIST, JCMS_TOASTR_COLLECTION, JSYNC_DOWNLOAD_DIR, JSYNC_SYNC_ALARM, LANG_SPRITE, LOG_FILE, LOG_TOPIC_SECURITY, LOGGER_PROP, LOGGER_XMLPROP, MBR_PHOTO_DIR, MDATE_SEARCH, MONITOR_XML, OP_CREATE, OP_CREATE_STR, OP_DEEP_COPY, OP_DEEP_COPY_STR, OP_DEEP_DELETE, OP_DEEP_DELETE_STR, OP_DELETE, OP_DELETE_STR, OP_MERGE, OP_MERGE_STR, OP_UPDATE, OP_UPDATE_STR, ORGANIZATION_ROOT_GROUP_PROP, PDATE_SEARCH, PHOTO_DIR, PHOTO_ICON, PHOTO_ICON_HEIGHT, PHOTO_ICON_PROP_PREFIX, PHOTO_ICON_WIDTH, PHOTO_LARGE, PHOTO_LARGE_HEIGHT, PHOTO_LARGE_PROP_PREFIX, PHOTO_LARGE_WIDTH, PHOTO_NORMAL, PHOTO_NORMAL_HEIGHT, PHOTO_NORMAL_PROP_PREFIX, PHOTO_NORMAL_WIDTH, PHOTO_SMALL, PHOTO_SMALL_HEIGHT, PHOTO_SMALL_PROP_PREFIX, PHOTO_SMALL_WIDTH, PHOTO_TINY, PHOTO_TINY_HEIGHT, PHOTO_TINY_PROP_PREFIX, PHOTO_TINY_WIDTH, PREVIOUS_TAB, PRINT_VIEW, PRIVATE_FILE_ACCESS, PUBLIC_FILE_ACCESS, READ_RIGHT_TAB, REVISION, SDATE_SEARCH, SEARCHENGINE_ALARM, SESSION_AUTHORIZED_FILENAMES_SET, SPRITE_ICON_PREFIX, STATS_REPORT_DIR, STATUS_PROP, STORE_XML, SUCCESS_MSG, TEMPLATE_TAB, THUMBNAIL_LARGE_HEIGHT, THUMBNAIL_LARGE_WIDTH, THUMBNAIL_SMALL_HEIGHT, THUMBNAIL_SMALL_WIDTH, TTCARD_MEDIA_HEIGHT, TTCARD_MEDIA_WIDTH, TYPES_ICON_ALT_PROP, TYPES_ICON_SUFFIX_PROP, TYPES_ICON_TITLE_PROP, TYPES_PREFIX_PROP, TYPES_THUMB_SUFFIX_PROP, UDATE_SEARCH, UPDATE_RIGHT_TAB, UPLOAD_DIR, UPLOAD_PERMISSION_SIZE_PROP_PREFIX, URL_REGEXP, VID_LOGGED_MEMBER, WARNING_MSG, WEBAPP_PROP, WFEXPRESS_ALARM, WFREMINDER_ALARM, WORKFLOW_TAB, WORKFLOW_XML
CRLF, MILLIS_IN_ONE_DAY, MILLIS_IN_ONE_HOUR, MILLIS_IN_ONE_MINUTE, MILLIS_IN_ONE_MONTH, MILLIS_IN_ONE_SECOND, MILLIS_IN_ONE_WEEK, MILLIS_IN_ONE_YEAR
Constructor and Description |
---|
JcmsTestCaseUtil() |
Modifier and Type | Method and Description |
---|---|
static java.util.Set<Group> |
addReadRights(Publication pub,
Group... groups)
Convenient method to add read right Groups on given publication.
|
static java.util.Set<Member> |
addReadRights(Publication pub,
Member... members)
Convenient method to add read right Members on given publication.
|
static void |
beginTransaction() |
static void |
commitTransaction() |
static generated.Article |
createArticle(Member writer,
Workspace ws,
boolean deleteOnTearDown) |
static DBFileDocument |
createDBFileDocument(Member writer,
Workspace ws,
java.lang.String title,
java.lang.String filename) |
static DBMember |
createDBMember(java.lang.String name,
boolean deleteOnTearDown,
Group... groups) |
static void |
createFile(java.io.File file,
java.lang.String content) |
static java.lang.String |
createFile(java.lang.String filename) |
static FileDocument |
createFileDocument(Member writer,
Workspace ws,
java.lang.String title,
java.lang.String filename) |
static generated.Media |
createMedia(Member writer,
Workspace ws,
java.lang.String title,
java.lang.String filename) |
static Member |
createMember(java.lang.String name,
boolean deleteOnTearDown,
Group... groups) |
static AbstractShortcut |
createShortcut(Publication pub,
Member writer,
Workspace ws,
boolean deleteOnTearDown) |
static AbstractShortcut |
createShortcut(java.lang.String link,
Member writer,
Workspace ws,
boolean deleteOnTearDown) |
static generated.SmallNews |
createSmallNews(Member writer,
Workspace ws,
boolean deleteOnTearDown) |
static void |
createWorkspace(Workspace workspace)
Utility method to create the given Workspace by admin Member.
|
static void |
createWorkspace(Workspace workspace,
Member author)
Utility method to create the given Workspace by admin Member.
|
static java.lang.String |
dataToDebugString(Data data)
Produces a String representation of given Data for debug, log purpose.
|
static void |
deleteAll(java.lang.Class<? extends DBData> dbDataClazz) |
static void |
deleteAllAlerts() |
static void |
deleteAllAlerts(Member mbr) |
static void |
deleteData(Data... array) |
static void |
deleteData(java.lang.String... ids) |
static void |
deleteOnTearDown(Data data) |
static void |
deleteOnTearDown(Workspace ws,
java.util.Set<Data> initialDataSet)
Deletes on tear down the workspace, and all its Datas,
but not those contained in optional initialDataSet.
The initialDataSet should be initialized before the Workspace was created, using for example : |
static java.lang.Object |
deserialize(java.io.File file)
Deserialize the given file into a new object which is returned.
|
static void |
disableJSync()
Disable JSync in Junit prop.
|
static void |
disableLdap()
Disable LDAP in Junit prop.
|
static void |
enableJSync()
Enable JSync in Junit prop.
|
static void |
enableLdap()
Enable LDAP in Junit prop.
|
static generated.Article |
getArticle(Member writer,
Workspace ws) |
static DBFileDocument |
getDBFileDocument(Member writer,
Workspace ws,
java.lang.String title,
java.lang.String filename) |
static FileDocument |
getFileDocument(Member writer,
Workspace ws,
java.lang.String title,
java.lang.String filename) |
static generated.Media |
getMedia(Member writer,
Workspace ws,
java.lang.String title,
java.lang.String filename) |
static javax.servlet.http.HttpServletRequest |
getMockHttpServletRequest()
Convenient Method to return a new instance of a fake http servlet request.
|
static javax.servlet.http.HttpServletRequest |
getMockHttpServletRequest(javax.servlet.http.HttpSession session)
Convenient Method to return a new instance of a fake http servlet request
using the specified mock session
|
static javax.servlet.http.HttpServletResponse |
getMockHttpServletResponse()
Convenient Method to return a new instance of a fake http servlet response.
|
static javax.servlet.http.HttpServletResponse |
getMockHttpServletResponse(javax.servlet.http.HttpSession session)
Convenient Method to return a new instance of a fake http servlet response
using the specified mock session
|
static javax.servlet.http.HttpSession |
getMockHttpSession()
Convenient Method to return a new instance of a fake http session.
|
static JcmsJspContext |
getMockJcmsJspContext()
Retrieve a mock explorer JcmsJspContext.
|
static JcmsJspContext |
getMockJcmsJspContext(javax.servlet.http.HttpServletRequest request)
Retrieve a mock explorer JcmsJspContext based on the specified request
|
static javax.servlet.ServletContext |
getMockServletContext()
Convenient Method to return the fake servlet context used for this JCMS test.
|
static java.io.File |
getResourceFile(java.lang.Class<?> clazz,
java.lang.String name)
Retrieves a new File instance pointing to the specified resource name.
|
static AbstractShortcut |
getShortcut(Member writer,
Workspace ws) |
static AbstractShortcut |
getShortcut(Publication pub,
Member writer,
Workspace ws) |
static AbstractShortcut |
getShortcut(java.lang.String link,
Member writer,
Workspace ws) |
protected static generated.SmallNews |
getSmallNews(Member writer,
Workspace ws,
boolean insertDateInContent) |
static java.util.Set<Data> |
getWorkspaceDeleteOnTearDownSet(Workspace ws,
java.util.Set<Data> initialDataSet)
Returns a collection of Datas (bound to the Workspace) that have been created since the workspace
creation.
|
static boolean |
ignoreUnstableTest() |
static void |
logC3P0Data()
Retrieve current C3P0 information from JXM and log them.
|
static void |
publishPublicationTransaction(java.lang.String pubId,
Member opAuthor)
Delegates to
updatePstatusTransaction(String, Member, int)
using pstatus WorkflowConstants.PUBLISHED_PSTATUS . |
static void |
restoreAuthenticationRequired()
Restores property "channel.is-authentication-required".
|
static void |
restoreIncomingMail()
Restores property "mail.incoming.enabled".
|
static void |
restoreProperties(java.util.Collection<java.lang.String> names)
Restores given properties represented by their names.
|
static void |
restoreProperties(JProperties properties)
Restores given JProperties.
|
static void |
restoreProperty(java.lang.String name)
Restores given property.
|
static void |
restoreReadRightsGroups(Publication pub,
java.util.Collection<Group> initialAuthorizedGroups) |
static void |
restoreReadRightsMembers(Publication pub,
java.util.Collection<Member> initialAuthorizedMembers) |
static java.io.File |
serialize(java.lang.Object obj)
Serialize the given object into a temp file and return this file.
|
static void |
setAuthenticationRequired(boolean isAuthRequired)
Sets property "channel.is-authentication-required" to isAuthRequired.
|
static void |
setIncomingMail(boolean enabled)
Sets property "mail.incoming.enabled" to enabled.
|
static void |
setProperties(JProperties properties)
Sets given JProperties.
|
static void |
setProperties(java.util.Map<java.lang.String,java.lang.String> map) |
static void |
setProperty(java.lang.String name,
java.lang.String value) |
static void |
sleep(long millis) |
static void |
updatePstatusTransaction(java.lang.String pubId,
Member opAuthor,
int newPstatus)
Checks and performs update the publication (makes an update instance) with
given pstatus.
|
static void |
updateWorkspaceTypeWorkflow(Workspace ws,
java.lang.Class<? extends Data> typeClass,
java.lang.Object workflowToUse)
An utility method to update the given Workspace, with the chosen Workflow associated to the given Type.
|
static void |
updateWorkspaceTypeWorkflow(Workspace ws,
java.util.HashMap<java.lang.Class<?>,java.lang.Object> subTypeMap)
An utility method to update the given Workspace typeMap.
|
static java.lang.String |
voteForPubTransaction(java.lang.String pubId,
java.lang.String voterId)
Adds a 1 point vote on given pub by given member.
|
static void |
waitForAlarm(long time,
AlarmManager alarmMgr,
boolean reallyWaitFor,
java.lang.String logPrefix) |
static void |
waitForDBTimePrecision()
wait 1 ms if the DB support time with ms precision, otherwise 1 s
|
static void |
waitForFileAvailability(java.io.File file) |
static void |
waitForLuceneIndexation(boolean checkFileContentIndexing,
Publication... pubs) |
static void |
waitForLuceneIndexation(Publication... pubs)
Wait for the specified publication(s) to be indexed in all
the lucene publication index in its current version
as returned by
Publication.getVersionString() . |
static void |
waitForMemberLuceneIndexation(Member... mbrs)
Wait for the specified Members(s) to be indexed in
the lucene member index in its current mdate
as returned by
BasicStorable.getMdate() . |
static void |
waitForMemberLuceneIndexation(java.lang.String... ids)
Wait for the specified Members(s) to be indexed in
the lucene member index in its current mdate
as returned by
BasicStorable.getMdate() . |
public static java.lang.String A_VERY_LONG_TEXT
public static long ASYNC_TEST__MAX_WAIT_TIME_BEFORE_FAILURE
public static long ASYNC_TEST__ITERATION_WAIT_TIME
public static long ASYNC_TEST__MAX_ITERATION
public static javax.servlet.ServletContext getMockServletContext()
MockServletContext
public static javax.servlet.http.HttpSession getMockHttpSession()
HttpSession
public static javax.servlet.http.HttpServletRequest getMockHttpServletRequest()
MockHttpServletRequest
public static javax.servlet.http.HttpServletRequest getMockHttpServletRequest(javax.servlet.http.HttpSession session)
session
- the sessionMockHttpServletRequest
public static javax.servlet.http.HttpServletResponse getMockHttpServletResponse()
MockHttpServletResponse
public static javax.servlet.http.HttpServletResponse getMockHttpServletResponse(javax.servlet.http.HttpSession session)
session
- the sessionMockHttpServletResponse
public static JcmsJspContext getMockJcmsJspContext()
public static JcmsJspContext getMockJcmsJspContext(javax.servlet.http.HttpServletRequest request)
request
- the mock request to use, if null a new mock request is createdpublic static java.io.File serialize(java.lang.Object obj) throws java.lang.Exception
obj
- the Object to be serializedjava.lang.Exception
- if an error occurspublic static java.lang.Object deserialize(java.io.File file) throws java.lang.Exception
file
- the filejava.lang.Exception
- if an error occurspublic static void beginTransaction()
public static void commitTransaction()
public static void deleteData(Data... array)
public static void deleteData(java.lang.String... ids)
public static void deleteOnTearDown(Data data)
public static void deleteOnTearDown(Workspace ws, java.util.Set<Data> initialDataSet)
Set<Data> initialDataSet = channel.getAllDataSet();Then, the workspace is created, using :
Workspace workspace = new Workspace(); ... workspace.performCreate(admin);Then you might want to delete it on tear down, using :
deleteOnTearDown(workspace, initialDataSet);
Deleted datas will be :
ws
- the workspace to delete.initialDataSet
- a Set of Datas not to delete, since already
existing before the start of the testpublic static java.util.Set<Data> getWorkspaceDeleteOnTearDownSet(Workspace ws, java.util.Set<Data> initialDataSet)
Helper method to retrieve datas to delete when the Workspace needs to be deleted.
ws
- the workspace to retrieve its created Data to deleteinitialDataSet
- the collection of existing datas before workspace has been
created.public static void deleteAll(java.lang.Class<? extends DBData> dbDataClazz)
public static void deleteAllAlerts()
public static void deleteAllAlerts(Member mbr)
public static java.io.File getResourceFile(java.lang.Class<?> clazz, java.lang.String name)
File testFile1 = getResourceFile("com/company/jcms/MyFeature_testFile1.txt");Current implementation is to invoke class loader of current class :
return new
File(clazzInstance.getClass().getClassLoader().getResource(name).getFile());
clazz
- the clazz where to find the filename
- the name of the resource, a '/'-separated path name that
identifies the resource. e.g "com/company/jcms/MyFeature_testFile1.txt"
public static void sleep(long millis)
millis
- the length of time to sleep in milliseconds.public static void waitForAlarm(long time, AlarmManager alarmMgr, boolean reallyWaitFor, java.lang.String logPrefix)
public static void waitForLuceneIndexation(Publication... pubs)
Publication.getVersionString()
.
For this method to work properly with DBData, it must be
invoked in a different transaction than the transaction
in which the create/update operation of the DBData was
performed. Indeed indexing is trigger by the
PublicationSearchEngineListener
during the
transaction commit, thus indexing will have been performed
only after transaction end.
If needed, several verification for the maximum duration
specified ASYNC_TEST__MAX_WAIT_TIME_BEFORE_FAILURE
.
pubs
- the publications to found in index.public static void waitForLuceneIndexation(boolean checkFileContentIndexing, Publication... pubs)
public static void waitForMemberLuceneIndexation(java.lang.String... ids) throws java.lang.Exception
BasicStorable.getMdate()
.
For this method to work properly with DBMember, it must be
invoked in a different transaction than the transaction
in which the create/update operation of the DBMember was
performed. Indeed indexing is trigger by the
MemberSearchEngineListener
during the
transaction commit, thus indexing will have been performed
only after transaction end.
If needed, several verification for the maximum duration
specified ASYNC_TEST__MAX_WAIT_TIME_BEFORE_FAILURE
.
ids
- the ids of Member to found in index.java.lang.Exception
- if index could not be read or member could not be foundpublic static void waitForMemberLuceneIndexation(Member... mbrs) throws java.lang.Exception
BasicStorable.getMdate()
.
For this method to work properly with DBMember, it must be
invoked in a different transaction than the transaction
in which the create/update operation of the DBMember was
performed. Indeed indexing is trigger by the
MemberSearchEngineListener
during the
transaction commit, thus indexing will have been performed
only after transaction end.
If needed, several verification for the maximum duration
specified ASYNC_TEST__MAX_WAIT_TIME_BEFORE_FAILURE
.
mbrs
- the Members to found in index.java.lang.Exception
- if index could not be read or member could not be foundpublic static void logC3P0Data()
public static void waitForDBTimePrecision()
public static void setProperty(java.lang.String name, java.lang.String value)
name
- the property name to setvalue
- the property value to setsetProperties(JProperties)
public static void setProperties(java.util.Map<java.lang.String,java.lang.String> map)
map
- the map of properties to setsetProperties(JProperties)
public static void setProperties(JProperties properties)
First call of this method will backup propertys current value, for automatic restore in test tear down.
Example:
// How to disabled channel mails setProperty("mail.enabled", "false"); // How to update several properties JProperties props = new JProperties(); props.put("my-first-property", "true"); props.put("my-second-property", "foo"); setProperties(props); // How to restore properties (If not done, it will be restored automatically during tearDown()) // Using a single String restoreProperty("mail.enabled"); // Restore one property // Using a Collection<String> restoreProperties(Util.getArrayList("my-first-property", "my-second-property"); // Restore several properties // Using a JProperties restoreProperties((JProperties) props); // Restore several properties
Complete Test Case:
If you had to write a unit test which is only relevant when site authentication is required.
Preparing and restoring the environnement at start and end of each test can be painful.
To make this initialization easier, you can do:
PrivateSiteTest extends JcmsTestCase { @Override protected void setUp() throws Exception { super.setUp(); logger.info("Channel authentication required: " + channel.isAuthenticationRequired()); // Prints "false" by default setAuthenticationRequired(true); } public void testPrivateSite() { assertTrue("The site must be private to run this test...", channel.isAuthenticationRequired()); ... } private void setAuthenticationRequired(boolean isPrivateSite) { setProperty("channel.is-authentication-required", String.valuedOf(isPrivateSite)); } }You may also want to restore initial value during the test:
PrivateSiteTest extends JcmsTestCase { ... public void testPrivateSite() { assertTrue("The site must be private to run this test...", channel.isAuthenticationRequired()); // ... first test with authentication required restoreAuthenticationRequired(); assertFalse("The site must be public to run this test...", channel.isAuthenticationRequired()); // ... second test with initial authentication required } private void restoreAuthenticationRequired() { restoreProperty("channel.is-authentication-required"); } }Implementation details:
properties
- the JProperties to setpublic static void restoreProperty(java.lang.String name)
name
- the name of property to restorerestoreProperties(JProperties)
public static void restoreProperties(java.util.Collection<java.lang.String> names)
names
- the names of properties to restorerestoreProperties(JProperties)
public static void restoreProperties(JProperties properties)
properties
- the JProperties to restore.public static void setIncomingMail(boolean enabled)
enabled
- the value to set.public static void restoreIncomingMail()
public static void setAuthenticationRequired(boolean isAuthRequired)
isAuthRequired
- the value to set.public static void restoreAuthenticationRequired()
public static void enableJSync()
Sets property "jsync.enabled" to true.
public static void disableJSync()
Sets property "jsync.enabled" to false.
public static void enableLdap()
Sets property "ldap.enabled" to true.
public static void disableLdap()
Sets property "ldap.enabled" to false.
public static void createWorkspace(Workspace workspace)
Manages deleteOnTearDown, and clears the workspace's id if already set.
Use as follow:
Workspace ws = new Workspace(otherWs); // Bootstraps a Workspace based on another WS ws.setTitle("my test workspace"); // ws customization createWorkspace(ws); // handles deleteOnTearDown
workspace
- the workspace to createpublic static void createWorkspace(Workspace workspace, Member author)
Manages deleteOnTearDown, and clears the workspace's id if already set.
Use as follow:
Workspace ws = new Workspace(otherWs); // Bootstraps a Workspace based on another WS ws.setTitle("my test workspace"); // ws customization createWorkspace(ws, author); // handles deleteOnTearDownUtility method to create the given Workspace.
Manages deleteOnTearDown.
workspace
- the workspace to createauthor
- the create operation authorpublic static Member createMember(java.lang.String name, boolean deleteOnTearDown, Group... groups)
public static DBMember createDBMember(java.lang.String name, boolean deleteOnTearDown, Group... groups)
public static java.lang.String createFile(java.lang.String filename)
public static void createFile(java.io.File file, java.lang.String content) throws java.lang.Exception
java.lang.Exception
public static void waitForFileAvailability(java.io.File file) throws java.lang.Exception
java.lang.Exception
public static FileDocument getFileDocument(Member writer, Workspace ws, java.lang.String title, java.lang.String filename)
public static FileDocument createFileDocument(Member writer, Workspace ws, java.lang.String title, java.lang.String filename)
public static DBFileDocument getDBFileDocument(Member writer, Workspace ws, java.lang.String title, java.lang.String filename)
public static DBFileDocument createDBFileDocument(Member writer, Workspace ws, java.lang.String title, java.lang.String filename)
public static generated.Media createMedia(Member writer, Workspace ws, java.lang.String title, java.lang.String filename)
public static generated.Media getMedia(Member writer, Workspace ws, java.lang.String title, java.lang.String filename)
public static generated.Article createArticle(Member writer, Workspace ws, boolean deleteOnTearDown)
protected static generated.SmallNews getSmallNews(Member writer, Workspace ws, boolean insertDateInContent)
public static generated.SmallNews createSmallNews(Member writer, Workspace ws, boolean deleteOnTearDown)
public static AbstractShortcut getShortcut(java.lang.String link, Member writer, Workspace ws)
public static AbstractShortcut getShortcut(Publication pub, Member writer, Workspace ws)
public static AbstractShortcut getShortcut(Member writer, Workspace ws)
public static AbstractShortcut createShortcut(Publication pub, Member writer, Workspace ws, boolean deleteOnTearDown)
public static AbstractShortcut createShortcut(java.lang.String link, Member writer, Workspace ws, boolean deleteOnTearDown)
public static java.util.Set<Member> addReadRights(Publication pub, Member... members)
Can be used as follow:
Set<Member> initialAuthMemberSet = addReadRights(pub, member1, member2); // custom processing here // [...] // Restore restoreReadRightsMembers(pub, initialAuthMemberSet);
pub
- the pub to add a read right on given Membersmembers
- the member(s) to add in pub's authorizedMemberSetpublic static java.util.Set<Group> addReadRights(Publication pub, Group... groups)
Can be used as follow:
Set<Group> initialAuthGroupSet = addReadRights(pub, group1, group2); // custom processing here // [...] // Restore restoreReadRightsGroups(pub, initialAuthGroupSet);
pub
- the pub to add a read right on given Groupsgroups
- the group(s) to add in pub's authorizedGroupSetpublic static void restoreReadRightsMembers(Publication pub, java.util.Collection<Member> initialAuthorizedMembers)
pub
- the pub to restore its initial authorizedMemberSetinitialAuthorizedMembers
- initial authorized members to restore (typically returned by addReadRights(Publication, Member...)
)public static void restoreReadRightsGroups(Publication pub, java.util.Collection<Group> initialAuthorizedGroups)
pub
- the pub to restore its initial authorizedGrouSetinitialAuthorizedGroups
- initial authorized groups to restore (typically returned by addReadRights(Publication, Group...)
)public static void updatePstatusTransaction(java.lang.String pubId, Member opAuthor, int newPstatus)
If pstatus is WorkflowConstants.PUBLISHED_PSTATUS
, and
publication's pdate is null, sets a new pdate.
Opens and closes a new transaction.
pubId
- the id of publication to udpate its pstatusopAuthor
- the author of operationnewPstatus
- the new pstatus to setPublication.updatePstatus(Member, int, String)
public static void publishPublicationTransaction(java.lang.String pubId, Member opAuthor)
updatePstatusTransaction(String, Member, int)
using pstatus WorkflowConstants.PUBLISHED_PSTATUS
.pubId
- the id of publication to udpate its pstatusopAuthor
- the author of operationupdatePstatusTransaction(String, Member, int)
public static boolean ignoreUnstableTest()
public static void updateWorkspaceTypeWorkflow(Workspace ws, java.lang.Class<? extends Data> typeClass, java.lang.Object workflowToUse)
An utility method to update the given Workspace, with the chosen Workflow associated to the given Type.
Note: It is better to make a backup of the Type Workflow in order to restore at the end of the test:
Object wfBackup = myWs.getTypeMap().get(MyType.class); JcmsTestCaseUtil.updateWorkspaceTypeWorkflow(myWs, MyType.class, ""); // ... (processing) JcmsTestCaseUtil.updateWorkspaceTypeWorkflow(myWs, MyType.class, wfBackup);
ws
- the workspacetypeClass
- the classworkflowToUse
- the workflow Id. Use an empty string if it is just to activate the type.public static void updateWorkspaceTypeWorkflow(Workspace ws, java.util.HashMap<java.lang.Class<?>,java.lang.Object> subTypeMap)
An utility method to update the given Workspace typeMap.
Note: It is better to make a backup of the Type Workflow in order to restore at the end of the test:
Object wfBackup = myWs.getTypeMap().get(MyType.class); JcmsTestCaseUtil.updateWorkspaceTypeWorkflow(myWs, MyType.class, ""); // ... (processing) JcmsTestCaseUtil.updateWorkspaceTypeWorkflow(myWs, MyType.class, wfBackup);Update given workspace's typeMap with given subset typeMap.
ws
- the workspace to apply changessubTypeMap
- the typeMap subset to changepublic static java.lang.String voteForPubTransaction(java.lang.String pubId, java.lang.String voterId)
May return null if no pub or no member.
Opens and closes a new transaction.
pubId
- the publication to vote forvoterId
- the member performing the votepublic static java.lang.String dataToDebugString(Data data)
data
- the data to get the debug string.JcmsUtil.dataToString(Data)
Copyright © 2001-2018 Jalios SA. All Rights Reserved.