use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationServiceImplTest method update_installed_local_application.
@Test
public void update_installed_local_application() throws Exception {
final Node node = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").build();
final String bundleName = "my-bundle";
mockRepoCreateNode(node);
when(this.repoService.updateApplicationNode(Mockito.isA(Application.class), Mockito.isA(ByteSource.class))).thenReturn(node);
mockRepoGetNode(node, bundleName);
final Application originalApplication = this.service.installLocalApplication(ByteSource.wrap(ByteStreams.toByteArray(newBundle(bundleName, true, "1.0.0").build())), bundleName);
final Application updatedApplication = this.service.installLocalApplication(ByteSource.wrap(ByteStreams.toByteArray(newBundle(bundleName, true, "1.0.1").build())), bundleName);
assertEquals("1.0.0", originalApplication.getVersion().toString());
assertEquals("1.0.1", updatedApplication.getVersion().toString());
assertTrue(this.service.isLocalApplication(updatedApplication.getKey()));
assertEquals(updatedApplication, this.service.getInstalledApplication(updatedApplication.getKey()));
verifyInstalledEvents(node, never());
verifyStartedEvent(updatedApplication.getKey(), never());
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationServiceImplTest method uninstall_local_reinstall_global.
@Test
public void uninstall_local_reinstall_global() throws Exception {
PropertyTree data = new PropertyTree();
data.setBoolean(ApplicationPropertyNames.STARTED, true);
final Node node = Node.create().id(NodeId.from("myNode")).parentPath(NodePath.ROOT).name("myNode").data(data).build();
final String bundleName = "my-bundle";
mockRepoCreateNode(node);
when(this.repoService.updateApplicationNode(Mockito.isA(Application.class), Mockito.isA(ByteSource.class))).thenReturn(node);
mockRepoGetNode(node, bundleName);
final Application originalApplication = this.service.installGlobalApplication(ByteSource.wrap(ByteStreams.toByteArray(newBundle(bundleName, true, "1.0.0").build())), bundleName);
final ApplicationKey applicationKey = originalApplication.getKey();
assertFalse(this.service.isLocalApplication(applicationKey));
assertEquals("1.0.0", originalApplication.getVersion().toString());
final Application updatedApplication = this.service.installLocalApplication(ByteSource.wrap(ByteStreams.toByteArray(newBundle(bundleName, true, "1.0.1").build())), bundleName);
assertEquals("1.0.1", updatedApplication.getVersion().toString());
assertTrue(this.service.isLocalApplication(applicationKey));
assertEquals(updatedApplication, this.service.getInstalledApplication(applicationKey));
assertTrue(this.service.isLocalApplication(applicationKey));
when(this.repoService.getApplicationSource(node.id())).thenReturn(ByteSource.wrap(ByteStreams.toByteArray(newBundle("my-bundle", true, "1.0.0").build())));
this.service.uninstallApplication(updatedApplication.getKey(), false);
assertEquals(originalApplication.getVersion(), this.service.getInstalledApplication(applicationKey).getVersion());
assertFalse(this.service.isLocalApplication(updatedApplication.getKey()));
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationServiceImplTest method configuration_comes_twice.
@Test
public void configuration_comes_twice() throws Exception {
final ApplicationKey key = ApplicationKey.from("myapp");
final Bundle bundle = deployAppBundle("myapp");
applicationRegistry.installApplication(bundle);
final Application app = service.getInstalledApplication(key);
final ApplicationInvalidator mock = mock(ApplicationInvalidator.class);
applicationRegistry.addInvalidator(mock);
applicationRegistry.configureApplication(bundle, ConfigBuilder.create().add("a", "b").build());
applicationRegistry.configureApplication(bundle, ConfigBuilder.create().add("c", "d").build());
assertEquals(ConfigBuilder.create().add("c", "d").build(), app.getConfig());
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationServiceImplTest method uninstall_global_application.
@Test
public void uninstall_global_application() throws Exception {
final Node node = Node.create().id(NodeId.from("myNodeId")).name("myBundle").parentPath(ApplicationRepoServiceImpl.APPLICATION_PATH).build();
final String bundleName = "my-bundle";
when(this.repoService.getApplicationSource(node.id())).thenReturn(createBundleSource(bundleName));
final Application application = this.service.installStoredApplication(node.id());
this.service.uninstallApplication(application.getKey(), true);
assertNull(this.service.getInstalledApplication(application.getKey()));
verify(this.eventPublisher, times(1)).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.uninstall(application.getKey()))));
verify(this.eventPublisher, times(1)).publish(Mockito.argThat(new ApplicationEventMatcher(ApplicationClusterEvents.uninstalled(application.getKey()))));
}
use of com.enonic.xp.app.Application in project xp by enonic.
the class ApplicationListenerHubTest method testActivatedDeactivated.
@Test
void testActivatedDeactivated() {
final Application app = mock(Application.class);
ApplicationListenerHub dispatcher = new ApplicationListenerHub();
final ApplicationListener listener = mock(ApplicationListener.class);
dispatcher.addListener(listener);
dispatcher.activated(app);
dispatcher.deactivated(app);
final InOrder inOrder = inOrder(listener);
inOrder.verify(listener, times(1)).activated(same(app));
inOrder.verify(listener, times(1)).deactivated(same(app));
}
Aggregations