use of com.enonic.xp.app.ApplicationKey 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.ApplicationKey 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.ApplicationKey in project xp by enonic.
the class SiteConfigsValidator method validate.
@Override
public void validate(final ContentValidatorParams params, final ValidationErrors.Builder validationErrorsBuilder) {
final SiteConfigs siteConfigs = new SiteConfigsDataSerializer().fromProperties(params.getData().getRoot()).build();
for (final SiteConfig siteConfig : siteConfigs) {
final ApplicationKey applicationKey = siteConfig.getApplicationKey();
final SiteDescriptor siteDescriptor = siteService.getDescriptor(applicationKey);
if (siteDescriptor != null) {
OccurrenceValidator.validate(siteDescriptor.getForm(), siteConfig.getConfig().getRoot(), validationErrorsBuilder);
try {
InputValidator.create().form(siteDescriptor.getForm()).inputTypeResolver(InputTypes.BUILTIN).build().validate(siteConfig.getConfig());
} catch (final Exception e) {
validationErrorsBuilder.add(ValidationError.generalError(ValidationErrorCode.from(ApplicationKey.SYSTEM, "cms.validation.siteConfigInvalid")).args(siteConfig.getApplicationKey()).build());
}
}
}
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class ServiceHandlerWorker method newWebSocketEndpoint.
private WebSocketEndpoint newWebSocketEndpoint(final WebSocketConfig config) {
final ApplicationKey app = this.request.getApplicationKey();
final Trace trace = Tracer.current();
if (trace != null && app != null && !trace.containsKey("app")) {
trace.put("app", app.toString());
}
return new WebSocketEndpointImpl(config, this::getScript);
}
use of com.enonic.xp.app.ApplicationKey in project xp by enonic.
the class XmlSiteParserTest method testSiteXmlWithUtf16LeBomEncoding.
@Test
public void testSiteXmlWithUtf16LeBomEncoding() {
final String xml = loadTestFile("utf16lebom.xml", StandardCharsets.UTF_16LE);
final SiteDescriptor.Builder siteDescriptorBuilder = SiteDescriptor.create();
ApplicationKey applicationKey = ApplicationKey.from("myapplication");
this.parser.source(xml).currentApplication(applicationKey).siteDescriptorBuilder(siteDescriptorBuilder).parse();
SiteDescriptor siteDescriptor = siteDescriptorBuilder.build();
assertEquals(1, siteDescriptor.getForm().getFormItems().size());
assertEquals(2, siteDescriptor.getXDataMappings().getSize());
assertEquals(2, siteDescriptor.getResponseProcessors().getSize());
assertEquals(0, siteDescriptor.getMappingDescriptors().getSize());
}
Aggregations