-
-
Notifications
You must be signed in to change notification settings - Fork 552
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XWIKI-21257: Rollback is not triggering a UserUpdatingDocumentEvent
* Ensure that the rollback API properly calls the check method * Back the changes in a unit test that check events triggered in rollback (cherry picked from commit 4de7287)
- Loading branch information
Showing
8 changed files
with
488 additions
and
11 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
...skin-test-docker/src/main/java/org/xwiki/test/CustomUserUpdatedDocumentEventListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* See the NOTICE file distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.xwiki.test; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Named; | ||
import javax.inject.Singleton; | ||
|
||
import org.apache.commons.lang3.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.xwiki.component.annotation.Component; | ||
import org.xwiki.model.reference.DocumentReference; | ||
import org.xwiki.observation.AbstractEventListener; | ||
import org.xwiki.observation.event.Event; | ||
|
||
import com.xpn.xwiki.doc.XWikiDocument; | ||
import com.xpn.xwiki.internal.event.UserUpdatingDocumentEvent; | ||
|
||
/** | ||
* Listener dedicated to cancel a specific rolling back event triggered in VersionIT test. | ||
* | ||
* @version $Id$ | ||
* @since 14.10.17 | ||
* @since 15.5.3 | ||
* @since 15.8RC1 | ||
*/ | ||
@Component | ||
@Singleton | ||
@Named(CustomUserUpdatedDocumentEventListener.NAME) | ||
public class CustomUserUpdatedDocumentEventListener extends AbstractEventListener | ||
{ | ||
static final String NAME = "CustomUserUpdatedDocumentEventListener"; | ||
|
||
@Inject | ||
private Logger logger; | ||
|
||
/** | ||
* Default constructor. | ||
*/ | ||
public CustomUserUpdatedDocumentEventListener() | ||
{ | ||
super(NAME, new UserUpdatingDocumentEvent()); | ||
} | ||
|
||
@Override | ||
public void onEvent(Event event, Object source, Object data) | ||
{ | ||
UserUpdatingDocumentEvent userEvent = (UserUpdatingDocumentEvent) event; | ||
XWikiDocument sourceDoc = (XWikiDocument) source; | ||
DocumentReference expectedReference = new DocumentReference("xwiki", "XWiki", "XWikiPreferences"); | ||
if (StringUtils.equals(userEvent.getUserReference().getName(), "DeleteVersionTestUserCancelEvent") | ||
&& sourceDoc.getDocumentReference().equals(expectedReference)) { | ||
logger.info("Cancelling user event on purpose"); | ||
userEvent.cancel(); | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...-test/xwiki-platform-flamingo-skin-test-docker/src/main/resources/META-INF/components.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
org.xwiki.test.CustomUserUpdatedDocumentEventListener | ||
org.xwiki.test.TestMacro |
324 changes: 324 additions & 0 deletions
324
...tform-flamingo-skin-test-docker/src/test/it/org/xwiki/flamingo/test/docker/VersionIT.java
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters