Search in sources :

Example 1 with SlingSettingsService

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

the class MockFactory method mockSlingSettingsService.

public static SlingSettingsService mockSlingSettingsService(final String slingId) {
    Mockery context = new JUnit4Mockery();
    final SlingSettingsService settingsService = context.mock(SlingSettingsService.class);
    context.checking(new Expectations() {

        {
            allowing(settingsService).getSlingId();
            will(returnValue(slingId));
            allowing(settingsService).getSlingHomePath();
            will(returnValue("/n/a"));
        }
    });
    return settingsService;
}
Also used : Expectations(org.jmock.Expectations) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Mockery(org.jmock.Mockery) SlingSettingsService(org.apache.sling.settings.SlingSettingsService)

Example 2 with SlingSettingsService

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

the class NoClusterDiscoveryServiceTest method createService.

private DiscoveryService createService(final boolean activate) {
    final DiscoveryService service = new NoClusterDiscoveryService();
    setField(service, "settingsService", new SlingSettingsService() {

        @Override
        public String getSlingId() {
            return "my-sling-id";
        }

        @Override
        public String getSlingHomePath() {
            return null;
        }

        @Override
        public URL getSlingHome() {
            return null;
        }

        @Override
        public Set<String> getRunModes() {
            return null;
        }

        @Override
        public String getAbsolutePathWithinSlingHome(String relativePath) {
            return null;
        }
    });
    if (activate) {
        invoke(service, "activate");
    }
    return service;
}
Also used : Set(java.util.Set) DiscoveryService(org.apache.sling.discovery.DiscoveryService) SlingSettingsService(org.apache.sling.settings.SlingSettingsService) URL(java.net.URL)

Example 3 with SlingSettingsService

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

the class RunModeImplTest method testEmptyRunModesWithOptions.

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

Example 4 with SlingSettingsService

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

the class RunModeImplTest method testInstallOptionsMultipleSelected.

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

Example 5 with SlingSettingsService

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

the class RunModeImplTest method testOptionsSelected.

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

Aggregations

SlingSettingsService (org.apache.sling.settings.SlingSettingsService)25 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