-
Notifications
You must be signed in to change notification settings - Fork 21
Added some tests for version restore functionality #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
||
public function testRestoreBaseProperties() | ||
{ | ||
// TODO also check for primary node type and uuid once it can be changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu I am not sure about this one. The specification says how to handle these properties on restore, but if I try to write a test for it jackalope says it's not allowed to change these properties. Am I missing something? Is this just a rarely happening edge case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would think that the primary type never changes, or can it? if it does not change it also does not need to be reverted...
and the uuid of the original node should stay the same when restoring, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got the same understanding until now, but after having a look at the specification I am not sure if there are some edge cases at which this properties can change. Otherwise 15.7.2 on http://www.day.com/specs/jcr/2.0/15_Versioning.html doesn't make any sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$this->vm->restore(true, $version); | ||
|
||
$node = $this->session->getNode($nodePath); | ||
$this->assertEquals(array('mix:versionable'), $node->getPropertyValue('jcr:mixinTypes')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also assert that there is no created
property anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But then it might be possible that all mixinTypes are gone, which would be a wrong behavior. Maybe I also should add the complete array check instead of assertContains
a few lines earlier?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i mean the jcr:created property that the mix:created made jackalope write.
for the mixins i think its fine like this, or you will need to make sure not to rely on a particular order of the mixins as that is not determined...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that the properties are not deleted after the mixin is removed? Because it seems to me like that... And actually that would also make sense to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would expect that if the frozen node has no jcr:created property and it is restored, that property should be removed.
are you saying jackrabbit does not do that? even when refreshing the session after restoring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought so, it has been some time since I've checked the last time 😉 Will check hopefully again next week.
Do you really would expect that? Isn't it possible that the jcr:created
property has been there before the mixin has been added? Would feel strange to me if removing the mixin is then also removing the property...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is jcr:created not backed up? if it is backed up, restoring the old version should have deleted it like it deletes other properties that where not existing when the version was created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you please check this bit? otherwise i think this would be ready to merge, the issue below is indeed a bug in the code and the test is correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have added this check.
jackalope-jackrabbit is happy with these tests so far. so the assumptions seem correct. |
Yeah, I write them in jackalope-jackrabbit first, and take over the changes and required implementations to jackalope-doctrine-dbal afterwards :-) |
…ests into version-restore
|
||
$this->assertCount(2, $node->getNodes()); | ||
$this->assertEquals('child1', $node->getNode('childNode1')->getPropertyValue('foo')); | ||
$this->assertEquals('child2', $node->getNode('childNode2')->getPropertyValue('foo')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu @lsmith77 This is failing for jackrabbit. But I guess this should be the behavior as I read in 15.7.6 in http://www.day.com/specs/jcr/2.0/15_Versioning.html. It basically says that each child from the frozen node should replace any existing child in the actual node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is interesting, it looks to me like this is an error in the jackalope jackrabbit transport layer, since jackrabbit itself (I have tested it via the cli in jackrabbit-standalone.jar) behaves as expected, as you can see in the following script:
[/] > addnode test
[/*] > addmixin mix:versionable test
[/*] > cd test
[/test*] > addnode childnode1
[/test*] > cd childnode1
[/test/childnode1*] > setprop foo child1
[/test/childnode1*] > cd ..
[/test*] > addnode childnode2
[/test*] > cd childnode2
[/test/childnode2*] > setprop foo child2
[/test/childnode2*] > cd ..
[/test*] > save
[/test] > checkin
[/test] > cd childnode1
[/test/childnode1] > lsprop
name multiple type length preview
------------------------------ --------- --------- -------- ------------------
jcr:primaryType false Name 15 nt:unstructured
foo false String 6 child1
total
2 nodes
[/test/childnode1] > cd ../childnode2
[/test/childnode2] > lsprop
name multiple type length preview
------------------------------ --------- --------- -------- ------------------
foo false String 6 child2
jcr:primaryType false Name 15 nt:unstructured
total
2 nodes
[/test/childnode2] > cd ..
[/test] > checkout
[/test] > rm childnode1
[/test*] > cd childnode2
[/test/childnode2*] > setprop foo child1
[/test/childnode2*] > save
[/test/childnode2] > cd ..
[/test] > ls
name type node new modified
------------------------------ --------------- --------- --------- ---------
childnode2 nt:unstructured true false false
jcr:isCheckedOut Boolean false false false
jcr:versionHistory Reference false false false
jcr:mixinTypes Name false false false
jcr:predecessors Reference false false false
jcr:baseVersion Reference false false false
jcr:uuid String false false false
jcr:primaryType Name false false false
total
[/test] > cd childnode2
[/test/childnode2] > lsprop
name multiple type length preview
------------------------------ --------- --------- -------- ------------------
foo false String 6 child1
jcr:primaryType false Name 15 nt:unstructured
total
2 nodes
[/test/childnode2] > cd ..
[/test] > lsversions
version labels
-------------------- --------------------------------------------------
jcr:rootVersion
1.0
[/test] > restore 1.0
[/test] > ls
name type node new modified
------------------------------ --------------- --------- --------- ---------
childnode1 nt:unstructured true false false
childnode2 nt:unstructured true false false
jcr:isCheckedOut Boolean false false false
jcr:versionHistory Reference false false false
jcr:mixinTypes Name false false false
jcr:predecessors Reference false false false
jcr:baseVersion Reference false false false
jcr:uuid String false false false
jcr:primaryType Name false false false
total
[/test] > cd childnode1
[/test/childnode1] > lsprop
name multiple type length preview
------------------------------ --------- --------- -------- ------------------
jcr:primaryType false Name 15 nt:unstructured
foo false String 6 child1
jcr:mixinTypes true[0] Name 0
total
3 nodes
[/test/childnode1] > cd ../childnode2
[/test/childnode2] > lsprop
name multiple type length preview
------------------------------ --------- --------- -------- ------------------
jcr:mixinTypes true[0] Name 0
foo false String 6 child2
jcr:primaryType false Name 15 nt:unstructured
total
3 nodes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dbu I am missing a comment of yours on this one :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will have to investigate this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. the expectations seem correct, this is a problem with jackalope-jackrabbit not noticing that the children also changed. fixed in jackalope/jackalope#294
can you check if things still work out when you have these changes with your code? i wonder if marking nodes as dirty could cause side effects when you restore nodes in memory instead.
rebased on master and will create a new PR |
see #166 |
No description provided.