use of org.xwiki.logging.event.LogEvent in project xwiki-platform by xwiki.
the class XWikiDocumentMergeTest method merge.
private MergeResult merge() throws Exception {
MergeResult result = this.currentDocument.merge(this.previousDocument, this.nextDocument, this.configuration, this.oldcore.getXWikiContext());
List<LogEvent> exception = result.getLog().getLogs(LogLevel.ERROR);
if (!exception.isEmpty()) {
throw new MergeException(exception.get(0).getFormattedMessage(), exception.get(0).getThrowable());
}
return result;
}
use of org.xwiki.logging.event.LogEvent in project xwiki-platform by xwiki.
the class XarExtensionHandlerTest method uninstall.
private void uninstall(ExtensionId extensionId, String wiki) throws Throwable {
UninstallRequest uninstallRequest = new UninstallRequest();
uninstallRequest.setProperty("user.reference", getXWikiContext().getUserReference());
uninstallRequest.setProperty("checkrights", true);
uninstallRequest.addExtension(extensionId);
if (wiki != null) {
uninstallRequest.addNamespace("wiki:" + wiki);
}
Job uninstallJob = this.jobExecutor.execute(UninstallJob.JOBTYPE, uninstallRequest);
uninstallJob.join();
List<LogEvent> errors = uninstallJob.getStatus().getLog().getLogsFrom(LogLevel.WARN);
if (!errors.isEmpty()) {
if (errors.get(0).getThrowable() != null) {
throw errors.get(0).getThrowable();
} else {
throw new Exception(errors.get(0).getFormattedMessage());
}
}
}
use of org.xwiki.logging.event.LogEvent in project xwiki-platform by xwiki.
the class XarExtensionHandlerTest method installOnNamespace.
private XarInstalledExtension installOnNamespace(ExtensionId extensionId, String namespace, DocumentReference user) throws Throwable {
InstallRequest installRequest = new InstallRequest();
if (user != null) {
installRequest.setProperty("user.reference", getXWikiContext().getUserReference());
installRequest.setProperty("checkrights", true);
}
installRequest.addExtension(extensionId);
if (namespace != null) {
installRequest.addNamespace(namespace);
}
Job installJob = this.jobExecutor.execute(InstallJob.JOBTYPE, installRequest);
installJob.join();
List<LogEvent> errors = installJob.getStatus().getLog().getLogsFrom(LogLevel.WARN);
if (!errors.isEmpty()) {
if (errors.get(0).getThrowable() != null) {
throw errors.get(0).getThrowable();
} else {
throw new Exception(errors.get(0).getFormattedMessage());
}
}
return (XarInstalledExtension) this.xarExtensionRepository.resolve(extensionId);
}
use of org.xwiki.logging.event.LogEvent in project xwiki-platform by xwiki.
the class TCPROMTest method testSerializableEvent.
/**
* Validate sharing a simple Serializable event between two instances of {@link RemoteObservationManager}.
*/
@Test
public void testSerializableEvent() throws InterruptedException {
final EventListener localListener = this.mockery.mock(EventListener.class, "local");
final EventListener remoteListener = this.mockery.mock(EventListener.class, "remote");
final TestEvent event = new TestEvent();
final Unserializable unserializable = new Unserializable();
this.mockery.checking(new Expectations() {
{
allowing(localListener).getName();
will(returnValue("mylistener"));
allowing(remoteListener).getName();
will(returnValue("mylistener"));
allowing(localListener).getEvents();
will(returnValue(Arrays.asList(event)));
allowing(remoteListener).getEvents();
will(returnValue(Arrays.asList(event)));
oneOf(localListener).onEvent(with(same(event)), with(equal("some source")), with(equal("some data")));
oneOf(localListener).onEvent(with(same(event)), with(same(unserializable)), with(same(unserializable)));
oneOf(remoteListener).onEvent(with(equal(event)), with(equal("some source")), with(equal("some data")));
}
});
getObservationManager1().addListener(localListener);
getObservationManager2().addListener(remoteListener);
getObservationManager1().notify(event, "some source", "some data");
getObservationManager1().notify(event, unserializable, unserializable);
getObservationManager1().notify(new LogEvent(), "some source", "some data");
// Make sure JGroups has enough time to send the message
Thread.sleep(1000);
}
use of org.xwiki.logging.event.LogEvent in project xwiki-platform by xwiki.
the class BaseObjectTest method testMerge.
@Test
public void testMerge() {
BaseObject previousObject = new BaseObject();
previousObject.setStringValue("str", "value");
BaseObject nextObject = new BaseObject();
nextObject.setStringValue("str", "newvalue");
BaseObject currentObject = new BaseObject();
currentObject.setStringValue("str", "value");
MergeConfiguration mergeConfiguration = new MergeConfiguration();
MergeResult mergeResult = new MergeResult();
currentObject.merge(previousObject, nextObject, mergeConfiguration, this.oldcore.getXWikiContext(), mergeResult);
List<LogEvent> errors = mergeResult.getLog().getLogsFrom(LogLevel.WARN);
if (errors.size() > 0) {
Assert.fail("Found error or warning during the merge (" + errors.get(0) + ")");
}
Assert.assertEquals("newvalue", currentObject.getStringValue("str"));
}
Aggregations