You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Dirk Rudolph (JIRA)" <ji...@apache.org> on 2016/12/10 22:12:58 UTC

[jira] [Comment Edited] (SLING-6387) ContentLoader shouldn't commit changes or at least allow to disable auto commit

    [ https://issues.apache.org/jira/browse/SLING-6387?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15738301#comment-15738301 ] 

Dirk Rudolph edited comment on SLING-6387 at 12/10/16 10:12 PM:
----------------------------------------------------------------

My suggestion: Extend the API of {{ContentLoader}} with a optional boolean {{commit}} for each of the methods. Alternatively we could add a {{setAutoCommit}} method which enables/disables auto commit. This would introduce a state into the {{ContentLoader}} which I want to prevent.


was (Author: diru):
My suggestion: Extend the API of {{ContentLoader}} with a optional boolean {{commit}} for each of the methods. Alternatively we could add a {{setAutoCommit}} method which enables/disables auto commit. But this would introduce a state into the {{ContentLoader}} which I want to prevent.

> ContentLoader shouldn't commit changes or at least allow to disable auto commit
> -------------------------------------------------------------------------------
>
>                 Key: SLING-6387
>                 URL: https://issues.apache.org/jira/browse/SLING-6387
>             Project: Sling
>          Issue Type: Improvement
>          Components: Testing
>    Affects Versions: Testing Sling Mock 2.1.2
>            Reporter: Dirk Rudolph
>            Priority: Minor
>
> The {{ContentLoader}} always, automatically persists changes made to the given {{ResoureResolver}}. This makes it hard to use for test on classes implementing transactional changes. 
> Example: Having high-level APIs that do changes on the {{ResourceResolver}} allowing to automatically commiting them (PageManager, AssetManager in AEM as implementation on top of sling). But to keep it abstract, lets say I have a class {{SpecificBinaryFileSetResource}}, which has a method {{addBinaryFile}}. The goal is to implement a mock for that, so I'm using {{ContentLoader}} to create a binary file in the {{ResourceResolver}}. This will automatically commit the changes. Now lets extend the {{addBinaryFile}} to accept a boolean parameter to not automatically commit those changes (maybe because I want to make multiple changes rolling them back on error). This isn't not supported so far when using ContentLoader.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)