Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » No Notification send in Pde Test while executing Recoeding Command (No Notification send in Pde Test while executing Recoeding Command )
No Notification send in Pde Test while executing Recoeding Command [message #1097136] Thu, 29 August 2013 09:21 Go to next message
Parth Ghodadara is currently offline Parth GhodadaraFriend
Messages: 2
Registered: August 2013
Junior Member
I am using Recording Command in my productive code.

I have added a ResouceSetListener to the editing domain. And since Recording command is used it is expected that the Listner's resourceSetChanged method will be called only once. Now I am testing the same in a PdeTest.

Now in PdeTest I call the productive code which executes the Recording Command but after commit no notification is send to the listeners. The same works fine in Productive code and I would get notification for the same in my Listners. But in PdeTest notification is not send. I have tried using thread.sleep aswell but still no Luck.
Re: No Notification send in Pde Test while executing Recoeding Command [message #1097313 is a reply to message #1097136] Thu, 29 August 2013 14:26 Go to previous messageGo to next message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi,

See some replies in-line, below.

Cheers,

Christian


On 2013-08-29 14:05:42 +0000, Parth Ghodadara said:

> I am using Recording Command in my productive code.
>
> I have added a ResouceSetListener to the editing domain. And since
> Recording command is used it is expected that the Listner's
> resourceSetChanged method will be called only once. Now I am testing
> the same in a PdeTest.

resourceSetChanged occurs generally once for each commit of a top-level
transaction; it has nothing to do with how the transaction effected
changes to the model (whether by RecordingCommands or otherwise). In
fact, transactions can be created without any commands at all.


> Now in PdeTest I call the productive code which executes the Recording
> Command but after commit no notification is send to the listeners. The
> same works fine in Productive code and I would get notification for the
> same in my Listners. But in PdeTest notification is not send. I have
> tried using thread.sleep aswell but still no Luck.

What thread are you trying to sleep? I don't see how sleeping any
threads could help anything.

I can only suggest that you debug the TransactionImpl class's
implementation of commit. My first suspicion is that your command
either is not actually executed or it doesn't change anything,
resulting in the commit having no notifications to broadcast to
listeners. But, as you provide no information about how your command
is implemented, what it does, and how your test executes, I can only
guess (once).
Re: No Notification send in Pde Test while executing Recoeding Command [message #1097939 is a reply to message #1097313] Fri, 30 August 2013 11:19 Go to previous messageGo to next message
Parth Ghodadara is currently offline Parth GhodadaraFriend
Messages: 2
Registered: August 2013
Junior Member
Hi,

I have a recording command inside which I have several commands executed one after the another. But since they are inside one recording command resourceSetChanged is called only one for my productive code which is the expected behavior in my case.


Now Coming to the Test, Inside test I am calling this method which executes the recording command. And I am sure the command is executed because the model has changed I have assert statements for the same. I have even Debug the code so I am certain commands are executed.

My test is something like this

attachResourceSetListner() -> I have tested it the listner is attached properly
executeFunctionalityWithRecordingCommandWithMultipleCommandInsideARecordingCommand()
testIfTheDesiredChangesToModelAreDone() -> PASS (thus the commands are executed)
testThatResourceSetListnerIsCalledOnlyOnce() -> FAILS(resourceSetListneer is never called).


I have debug the code and in class "TransactionEditingDomainImpl"


protected void postcommit(final InternalTransaction tx) {
if (Tracing.shouldTrace(EMFTransactionDebugOptions.TRANSACTIONS)) {
Tracing.trace(">>> Postcommitting " + getDebugID(tx) + " at " + Tracing.now()); //$NON-NLS-1$ //$NON-NLS-2$
}

final List<Notification> notifications = validator.getNotificationsForPostcommit(
tx);
if ((notifications == null) || notifications.isEmpty()) {
return;
}


notifications is empty for testcase thus it returns from there itself whereas in productive code



final ResourceSetListener[] listeners = getPostcommitListeners();

try {
runExclusive(new Runnable() {
public void run() {
for (ResourceSetListener element : listeners) {
try {
List<Notification> filtered = FilterManager.getInstance().select(
notifications,
element.getFilter(),
cache);

if (!filtered.isEmpty()) {
element.resourceSetChanged(
new ResourceSetChangeEvent(
TransactionalEditingDomainImpl.this,
tx,
filtered));


It reached there thus event is created



Regards,
Parth.
Re: No Notification send in Pde Test while executing Recoeding Command [message #1097945 is a reply to message #1097939] Fri, 30 August 2013 11:30 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

Hi, Parth,

Ah, OK. So the most likely explanation is that in the case of your
test execution, the editing domain's change-recorder is not getting
notifications from your model elements as they change. The probable
reason for this is that your model elements are not in a resource in
the resource set to which the change-recorder is attached.

Can you verify that your test case properly attaches the
model-under-test to a resource in the editing domain's resource-set?
You might further debug to check that the TransactionChangeRecorder is
attached to all of your model elements in their eAdapters lists.

HTH,

Christian


On 2013-08-30 11:19:58 +0000, Parth Ghodadara said:

> Hi,
>
> I have a recording command inside which I have several commands
> executed one after the another. But since they are inside one recording
> command resourceSetChanged is called only one for my productive code
> which is the expected behavior in my case.
>
>
> Now Coming to the Test, Inside test I am calling this method which
> executes the recording command. And I am sure the command is executed
> because the model has changed I have assert statements for the same. I
> have even Debug the code so I am certain commands are executed.
>
> My test is something like this
>
> attachResourceSetListner() -> I have tested it the listner is
> attached properly
> executeFunctionalityWithRecordingCommandWithMultipleCommandInsideARecordingCommand()
>
> testIfTheDesiredChangesToModelAreDone() -> PASS (thus the commands are
> executed)
> testThatResourceSetListnerIsCalledOnlyOnce() ->
> FAILS(resourceSetListneer is never called).
>
>
> I have debug the code and in class "TransactionEditingDomainImpl"
>
>
> protected void postcommit(final InternalTransaction tx) {
> if (Tracing.shouldTrace(EMFTransactionDebugOptions.TRANSACTIONS)) {
> Tracing.trace(">>> Postcommitting " + getDebugID(tx) + " at " +
> Tracing.now()); //$NON-NLS-1$ //$NON-NLS-2$
> }
>
> final List<Notification> notifications =
> validator.getNotificationsForPostcommit(
> tx);
> if ((notifications == null) || notifications.isEmpty()) {
> return;
> }
>
> notifications is empty for testcase thus it returns from there itself
> whereas in productive code
>
>
> final ResourceSetListener[] listeners = getPostcommitListeners();
>
> try {
> runExclusive(new Runnable() {
> public void run() {
> for (ResourceSetListener element : listeners) {
> try {
> List<Notification> filtered = FilterManager.getInstance().select(
> notifications,
> element.getFilter(),
> cache);
>
> if (!filtered.isEmpty()) {
> element.resourceSetChanged(
> new ResourceSetChangeEvent(
> TransactionalEditingDomainImpl.this,
> tx,
> filtered));
>
> It reached there thus event is created
>
>
>
> Regards,
> Parth.
Previous Topic:EMF and REST (JAX-RS)
Next Topic:[cdo] which class is responsible for deleting a model element
Goto Forum:
  


Current Time: Fri Apr 26 23:21:28 GMT 2024

Powered by FUDForum. Page generated in 0.03527 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top