How to create Service test cases to schedule a task
Hi,
I have implemented a scheduled task which extends AbstractAutoScheduledTask.
I want to create a service junit test case to programmatically schedule this task.
Iam referring to the following tutorial on WIKI:
http://jazz.net/wiki/bin/view/Main/QueryDevGuide, which says for that you will have to get the handle of
IAsynchronousTaskSchedulerService in your testcase.
Can you please share with me how to do this. Also, If you can share with me any RTC service test cases, it will be an immense help.
Regards,
Meghana
I have implemented a scheduled task which extends AbstractAutoScheduledTask.
I want to create a service junit test case to programmatically schedule this task.
Iam referring to the following tutorial on WIKI:
http://jazz.net/wiki/bin/view/Main/QueryDevGuide, which says for that you will have to get the handle of
IAsynchronousTaskSchedulerService in your testcase.
Can you please share with me how to do this. Also, If you can share with me any RTC service test cases, it will be an immense help.
Regards,
Meghana
36 answers
Sorry for the delay. I would expect that to work. Maybe it's getting confused by the use of a dynamic query model, but I believe the dynamic approach should work fine.
You could try instead using the static query model:
I realize this is referring to an internal class, but I don't see any other way of doing it. This approach is used in the Process component's own code, in:
com.ibm.team.process.internal.service.web.ProcessRestService.getProjectAreas()
and
com.ibm.team.process.internal.client.ProcessClientService.findAllProjectAreas(Collection, IProgressMonitor)
Regards,
Nick
You could try instead using the static query model:
IQueryModel model = com.ibm.team.process.internal.common.query.BaseProjectAreaQueryModel.ProjectAreaQueryModel;
...
I realize this is referring to an internal class, but I don't see any other way of doing it. This approach is used in the Process component's own code, in:
com.ibm.team.process.internal.service.web.ProcessRestService.getProjectAreas()
and
com.ibm.team.process.internal.client.ProcessClientService.findAllProjectAreas(Collection, IProgressMonitor)
Regards,
Nick
Hi,
Thanks for your reply and after using the static query model it worked for me.
I have another query related to scheduled tasks:
The current implementation of my task fetches all the workitems belonging to all the project areas(except archived) in the repo and sends reminder mail to the owners ,if the workitems are still in LIVE state even post their due dates.
Wanted to know, if there was a way to turn this task, on/off on the server proprieties.
Or any other way by which one can subscribe or unsubscribe with this task.
Thanks & Regards,
Meghana
Thanks for your reply and after using the static query model it worked for me.
I have another query related to scheduled tasks:
The current implementation of my task fetches all the workitems belonging to all the project areas(except archived) in the repo and sends reminder mail to the owners ,if the workitems are still in LIVE state even post their due dates.
Wanted to know, if there was a way to turn this task, on/off on the server proprieties.
Or any other way by which one can subscribe or unsubscribe with this task.
Thanks & Regards,
Meghana
There are lots of options here:
- a global property for the service that an admin could tweak via the admin web UI, similar to the property for how often the task runs,
- per-project configuration data settings, similar to how one can configure work item types and their presentation,
- per-user settings, with contributed UI in the user editor, similar to how work item email notifications work
Let me know which one you want to explore, and I can give you some pointers.
- a global property for the service that an admin could tweak via the admin web UI, similar to the property for how often the task runs,
- per-project configuration data settings, similar to how one can configure work item types and their presentation,
- per-user settings, with contributed UI in the user editor, similar to how work item email notifications work
Let me know which one you want to explore, and I can give you some pointers.
Hi,
Thanks for your reply.
We would like to implement all the three ways you mentioned . So plz provide me some pointers on these to start off.
But most importantly and urgently, I need to knowhow to set the global property for the service that an admin could change via the admin web UI.
Thanks & Regards
Meghana
Thanks for your reply.
We would like to implement all the three ways you mentioned . So plz provide me some pointers on these to start off.
But most importantly and urgently, I need to know
Thanks & Regards
Meghana
For the global property option, any service may define configuration properties. For example, the Build scheduler task is declared as:
In this case, the property name (<taskId>.fixedDelay) is one that's specially recognized for all such tasks, but that doesn't really matter -- you may define as many properties as you like.
These are editable in the admin web UI:
- go to <repo address>/admin
- click on 'Advanced Properties' in the bar at left
<extension
point="com.ibm.team.repository.service.asynchronousTask">
<asynchronousTask
taskId="BuildSchedulerTask">
<extensionService
componentId="com.ibm.team.build"
implementationClass="com.ibm.team.build.internal.service.schedule.BuildSchedulerTask">
<prerequisites>
<requiredService interface="com.ibm.team.build.internal.service.IInternalTeamBuildService"/>
<configurationProperties>
<configurationProperty
accessPolicy="OPEN"
description="%BuildSchedulerTask.FixedDelay.Description"
displayableName="%BuildSchedulerTask.FixedDelay.DisplayName"
name="BuildSchedulerTask.fixedDelay"
type="LONG"
default="60"
required="true"
updatePolicy="FRAMEWORK_RESTART_REQUIRED">
</configurationProperty>
...
</configurationProperties>
</prerequisites>
</extensionService>
</asynchronousTask>
</extension>
In this case, the property name (<taskId>.fixedDelay) is one that's specially recognized for all such tasks, but that doesn't really matter -- you may define as many properties as you like.
These are editable in the admin web UI:
- go to <repo address>/admin
- click on 'Advanced Properties' in the bar at left
The service can obtain the value of the property with the following methods on itself (they're protected methods defined in AbstractService):
getConfigurationProperty(String propertyId)
getBooleanConfigProperty...
getLongConfigProperty...
getIntegerConfigProperty...
getStringConfigProperty
The method used should correspond to the type declared in the extension.
getConfigurationProperty(String propertyId)
getBooleanConfigProperty...
getLongConfigProperty...
getIntegerConfigProperty...
getStringConfigProperty
The method used should correspond to the type declared in the extension.
For the approach of using per-project configuration data (i.e. configured in the project area editor's Process Specification tab), see the Configuration Data sections at: https://jazz.net/wiki/bin/view/Main/TeamProcessDeveloperGuide
UI for editing such configuration can also be contributed. See https://jazz.net/wiki/bin/view/Main/ProcessAspectEditorCreation
For per-user configuration, you can look at how the Work Items component contributes the Mail Configuration tab in the user editor. To see this, choose Open My User Editor on the repository connection node in the Team Artifacts view. There's an extension for this:
But apparently this uses an extension point that's intended to be internal to RTC. You could use it, but there's no guarantee that it won't change or go away.
To store the extra info, it uses string extensions on the IContributorDetails item for a given IContributor. For more details, see the implementation of:
com.ibm.team.workitem.ide.ui.internal.mailconfig.MailConfigEditorInput.loadContributorDetails(IProgressMonitor)
and
com.ibm.team.workitem.ide.ui.internal.mailconfig.MailConfigFormPage.loadConfiguration().
UI for editing such configuration can also be contributed. See https://jazz.net/wiki/bin/view/Main/ProcessAspectEditorCreation
For per-user configuration, you can look at how the Work Items component contributes the Mail Configuration tab in the user editor. To see this, choose Open My User Editor on the repository connection node in the Team Artifacts view. There's an extension for this:
<extension
point="com.ibm.team.process.ide.ui.internalContributorEditorPages">
<editorPages
factoryClass="com.ibm.team.workitem.ide.ui.internal.mailconfig.MailConfigEditorPageFactory">
</editorPages>
</extension>
But apparently this uses an extension point that's intended to be internal to RTC. You could use it, but there's no guarantee that it won't change or go away.
To store the extra info, it uses string extensions on the IContributorDetails item for a given IContributor. For more details, see the implementation of:
com.ibm.team.workitem.ide.ui.internal.mailconfig.MailConfigEditorInput.loadContributorDetails(IProgressMonitor)
and
com.ibm.team.workitem.ide.ui.internal.mailconfig.MailConfigFormPage.loadConfiguration().
Hi,
Thanks a lot again.
I was able to add the global property and am trying to implement it at project area level. :)
For now, Iam facing some other issue related to creation(contribution) of a new link type.
Here is the snippet from plugin.xml (of a common plug in)to contribute a new linktype:
Now after installing this on the server, when I go to the workitem editor, and hit the add link button on the Links page, I don't see this new link type there? Now my question is, is there something I have missed here?
Also, from my REST service, this is how I try to create a new link of this new type as follows :
and saved the workitem, I couldnot see any new link created nor is there any exception thrown.
Can you please guide me what went wrong or is there a better way to create
this new link from the server side.
Thanks & Regards,
Meghana
Thanks a lot again.
I was able to add the global property and am trying to implement it at project area level. :)
For now, Iam facing some other issue related to creation(contribution) of a new link type.
Here is the snippet from plugin.xml (of a common plug in)to contribute a new linktype:
<extension
point="com.ibm.team.repository.common.linkTypes">
<linkType
constrained="false"
id="com.ibm.af.workitem.link.common.continuationLinkType2"
internal="false">
<target>
<endpoint
displayName="Continues By"
id="af.continues.by"
multiplicity="0..n">
<itemReferenceType
itemTypeName="WorkItem"
packageURI="com.ibm.team.workitem">
</itemReferenceType></endpoint>
</target>
<source>
<endpoint
displayName="Continues"
id="af.continues"
multiplicity="0..n">
<itemReferenceType
itemTypeName="WorkItem"
packageURI="com.ibm.team.workitem">
</itemReferenceType></endpoint>
</source>
</linkType>
</extension>
Now after installing this on the server, when I go to the workitem editor, and hit the add link button on the Links page, I don't see this new link type there? Now my question is, is there something I have missed here?
Also, from my REST service, this is how I try to create a new link of this new type as follows :
IWorkItemCommon workItemCommon = getService(IWorkItemCommon.class);
ILinkServiceLibrary linkService = getLinkServiceLibrary();
IItemReference source = IReferenceFactory.INSTANCE
.createReferenceToItem(sourceHandle);
IItemReference target = IReferenceFactory.INSTANCE
.createReferenceToItem(targetHandle);
ILink link = linkService.createLink(type, source, target);
private ILinkServiceLibrary getLinkServiceLibrary() {
return (ILinkServiceLibrary) getService(ILinkService.class).getServiceLibrary(ILinkServiceLibrary.class);
}
and saved the workitem, I couldnot see any new link created nor is there any exception thrown.
Can you please guide me what went wrong or is there a better way to create
this new link from the server side.
Thanks & Regards,
Meghana
Hi,
I'm trying to do something similar. I can contribute a menu for a new link type in the workitem UI but I don't know where I should add the code to invoke a service to create a new link of this new type. I've created a new plugin for my REST service but where should I invoke it without changing the RTC workitem.common and workitem.service plugins?
Also is it possible to invoke one's own UI when selecting the menu to create the new link type.
If you could share some of your discoveries that would be very helpful.
Thanks in advance.
Zac.
I'm trying to do something similar. I can contribute a menu for a new link type in the workitem UI but I don't know where I should add the code to invoke a service to create a new link of this new type. I've created a new plugin for my REST service but where should I invoke it without changing the RTC workitem.common and workitem.service plugins?
Also is it possible to invoke one's own UI when selecting the menu to create the new link type.
If you could share some of your discoveries that would be very helpful.
Thanks in advance.
Zac.
page 2of 1 pagesof 2 pagesof 3 pagesof 4 pages