Search in sources :

Example 16 with SlingSettingsService

use of org.apache.sling.settings.SlingSettingsService in project sling by apache.

the class RunModeImplTest method testInstallOptions.

@org.junit.Test
public void testInstallOptions() {
    final SlingSettingsService rm = new SlingSettingsServiceImpl(new BundleContextMock("foo,bar", null, "a,b,c|d,e,f"));
    assertActive(rm, true, "foo", "bar", "a", "d");
    assertActive(rm, false, "b", "c", "e", "f");
}
Also used : SlingSettingsService(org.apache.sling.settings.SlingSettingsService)

Example 17 with SlingSettingsService

use of org.apache.sling.settings.SlingSettingsService in project sling by apache.

the class RunModeImplTest method testInstallOptionsSelected.

@org.junit.Test
public void testInstallOptionsSelected() {
    final SlingSettingsService rm = new SlingSettingsServiceImpl(new BundleContextMock("foo,bar,c,e", null, "a,b,c|d,e,f"));
    assertActive(rm, true, "foo", "bar", "c", "e");
    assertActive(rm, false, "a", "b", "d", "f");
}
Also used : SlingSettingsService(org.apache.sling.settings.SlingSettingsService)

Example 18 with SlingSettingsService

use of org.apache.sling.settings.SlingSettingsService in project sling by apache.

the class RunModeImplTest method testInstallOptionsMultipleSelected2.

@org.junit.Test
public void testInstallOptionsMultipleSelected2() {
    final SlingSettingsService rm = new SlingSettingsServiceImpl(new BundleContextMock("foo,bar,c,d,f,a", null, "a,b,c|d,e,f"));
    assertActive(rm, true, "foo", "bar", "a", "d");
    assertActive(rm, false, "b", "c", "e", "f");
}
Also used : SlingSettingsService(org.apache.sling.settings.SlingSettingsService)

Example 19 with SlingSettingsService

use of org.apache.sling.settings.SlingSettingsService in project sling by apache.

the class SlingSettingsServiceImplTest method testGetSlingIdFromTooLargeData.

@Test
public void testGetSlingIdFromTooLargeData() throws IOException {
    final String expected = SlingIdUtil.createSlingId();
    // 1MB long random String
    final String data = expected + RandomStringUtils.randomAscii(1024 * 1024);
    SlingIdUtil.writeSlingId(slingIdFile, data);
    final SlingSettingsService slingSettingsService = createSlingSettingsService(slingIdFile, optionsFile);
    final String slingId = slingSettingsService.getSlingId();
    assertNotNull(slingId);
    assertEquals(expected, slingId);
}
Also used : SlingSettingsService(org.apache.sling.settings.SlingSettingsService) Test(org.junit.Test)

Example 20 with SlingSettingsService

use of org.apache.sling.settings.SlingSettingsService in project sling by apache.

the class SlingContextImpl method runMode.

/**
     * Set current run mode(s).
     * @param runModes Run mode(s).
     */
public final void runMode(String... runModes) {
    Set<String> newRunModes = ImmutableSet.<String>builder().add(runModes).build();
    ServiceReference<SlingSettingsService> ref = bundleContext().getServiceReference(SlingSettingsService.class);
    if (ref != null) {
        MockSlingSettingService slingSettings = (MockSlingSettingService) bundleContext().getService(ref);
        slingSettings.setRunModes(newRunModes);
    }
}
Also used : MockSlingSettingService(org.apache.sling.testing.mock.sling.services.MockSlingSettingService) SlingSettingsService(org.apache.sling.settings.SlingSettingsService)

Aggregations

SlingSettingsService (org.apache.sling.settings.SlingSettingsService)24 Test (org.junit.Test)7 URL (java.net.URL)3 HashSet (java.util.HashSet)3 Attributes (java.util.jar.Attributes)2 JarFile (java.util.jar.JarFile)2 Manifest (java.util.jar.Manifest)2 ZipEntry (java.util.zip.ZipEntry)2 ZipInputStream (java.util.zip.ZipInputStream)2 OsgiInstaller (org.apache.sling.installer.api.OsgiInstaller)2 RegisteredResource (org.apache.sling.installer.api.tasks.RegisteredResource)2 TransformationResult (org.apache.sling.installer.api.tasks.TransformationResult)2 DeleteOnCloseFileInputStream (org.apache.sling.installer.factories.subsystems.base.impl.SubsystemBaseTransformer.DeleteOnCloseFileInputStream)2 Dictionary (java.util.Dictionary)1 Hashtable (java.util.Hashtable)1 Set (java.util.Set)1 ResourceResolverFactory (org.apache.sling.api.resource.ResourceResolverFactory)1 ResourceChange (org.apache.sling.api.resource.observation.ResourceChange)1 DiscoveryService (org.apache.sling.discovery.DiscoveryService)1 LaunchpadContentProvider (org.apache.sling.launchpad.api.LaunchpadContentProvider)1