Search in sources :

Example 1 with SimpleConnectorConfig

use of org.apache.sling.discovery.base.its.setup.mock.SimpleConnectorConfig in project sling by apache.

the class AnnouncementRegistryImplTest method setup.

@Before
public void setup() throws Exception {
    resourceResolverFactory = MockFactory.mockResourceResolverFactory();
    config = new SimpleConnectorConfig() {

        public long getConnectorPingTimeout() {
            // 10s for tests that also run on apache jenkins
            return 10;
        }

        ;
    };
    slingId = UUID.randomUUID().toString();
    Session l = RepositoryProvider.instance().getRepository().loginAdministrative(null);
    try {
        l.removeItem("/var");
        l.save();
        l.logout();
    } catch (Exception e) {
        l.refresh(false);
        l.logout();
    }
    registry = AnnouncementRegistryImpl.testConstructorAndActivate(resourceResolverFactory, new DummySlingSettingsService(slingId), config);
}
Also used : SimpleConnectorConfig(org.apache.sling.discovery.base.its.setup.mock.SimpleConnectorConfig) DummySlingSettingsService(org.apache.sling.discovery.commons.providers.spi.base.DummySlingSettingsService) Session(javax.jcr.Session) Before(org.junit.Before)

Example 2 with SimpleConnectorConfig

use of org.apache.sling.discovery.base.its.setup.mock.SimpleConnectorConfig in project sling by apache.

the class TopologyRequestValidatorTest method before.

@Before
public void before() throws SecurityException, IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
    BaseConfig config = new SimpleConnectorConfig();
    setPrivate(config, "sharedKey", "testKey");
    setPrivate(config, "hmacEnabled", true);
    setPrivate(config, "encryptionEnabled", true);
    setPrivate(config, "keyInterval", 3600 * 100 * 4);
    topologyRequestValidator = new TopologyRequestValidator(config);
}
Also used : SimpleConnectorConfig(org.apache.sling.discovery.base.its.setup.mock.SimpleConnectorConfig) BaseConfig(org.apache.sling.discovery.base.connectors.BaseConfig) Before(org.junit.Before)

Example 3 with SimpleConnectorConfig

use of org.apache.sling.discovery.base.its.setup.mock.SimpleConnectorConfig in project sling by apache.

the class ConnectorRegistryImplTest method testRegisterUnregister.

@Test
public void testRegisterUnregister() throws Exception {
    BaseConfig config = new SimpleConnectorConfig() {

        @Override
        public long getConnectorPingTimeout() {
            return 20000;
        }
    };
    AnnouncementRegistryImpl announcementRegistry = AnnouncementRegistryImpl.testConstructorAndActivate(MockFactory.mockResourceResolverFactory(), new DummySlingSettingsService(UUID.randomUUID().toString()), config);
    ConnectorRegistry c = ConnectorRegistryImpl.testConstructor(announcementRegistry, config);
    final URL url = new URL("http://localhost:1234/connector");
    final ClusterViewService cvs = i.getClusterViewService();
    try {
        c.registerOutgoingConnector(null, url);
        fail("should have complained");
    } catch (IllegalArgumentException e) {
    // ok
    }
    try {
        c.registerOutgoingConnector(cvs, null);
        fail("should have complained");
    } catch (IllegalArgumentException e) {
    // ok
    }
    TopologyConnectorClientInformation client = c.registerOutgoingConnector(cvs, url);
    try {
        // should not be able to register same url twice
        client = c.registerOutgoingConnector(cvs, url);
    // ok - no longer complains - SLING-3446
    } catch (IllegalStateException e) {
        // SLING-3446
        fail("should no longer be thrown");
    }
    try {
        c.unregisterOutgoingConnector(null);
        fail("should have complained");
    } catch (IllegalArgumentException e) {
    // ok
    }
    c.unregisterOutgoingConnector(client.getId());
}
Also used : SimpleConnectorConfig(org.apache.sling.discovery.base.its.setup.mock.SimpleConnectorConfig) AnnouncementRegistryImpl(org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistryImpl) BaseConfig(org.apache.sling.discovery.base.connectors.BaseConfig) DummySlingSettingsService(org.apache.sling.discovery.commons.providers.spi.base.DummySlingSettingsService) ClusterViewService(org.apache.sling.discovery.base.commons.ClusterViewService) URL(java.net.URL) Test(org.junit.Test)

Aggregations

SimpleConnectorConfig (org.apache.sling.discovery.base.its.setup.mock.SimpleConnectorConfig)3 BaseConfig (org.apache.sling.discovery.base.connectors.BaseConfig)2 DummySlingSettingsService (org.apache.sling.discovery.commons.providers.spi.base.DummySlingSettingsService)2 Before (org.junit.Before)2 URL (java.net.URL)1 Session (javax.jcr.Session)1 ClusterViewService (org.apache.sling.discovery.base.commons.ClusterViewService)1 AnnouncementRegistryImpl (org.apache.sling.discovery.base.connectors.announcement.AnnouncementRegistryImpl)1 Test (org.junit.Test)1