Search in sources :

Example 86 with Dictionary

use of java.util.Dictionary in project sling by apache.

the class DataSourceIT method testDataSourceAsService.

@SuppressWarnings("unchecked")
@Test
public void testDataSourceAsService() throws Exception {
    Configuration config = ca.createFactoryConfiguration(PID, null);
    Dictionary<String, Object> p = new Hashtable<String, Object>();
    p.put("url", "jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
    p.put("datasource.name", "test");
    p.put("initialSize", "5");
    p.put("defaultAutoCommit", "default");
    p.put("defaultReadOnly", "false");
    p.put("datasource.svc.properties", new String[] { "initSQL=SELECT 1" });
    p.put("maxActive", 70);
    config.update(p);
    Filter filter = context.createFilter("(&(objectclass=javax.sql.DataSource)(datasource.name=test))");
    ServiceTracker<DataSource, DataSource> st = new ServiceTracker<DataSource, DataSource>(context, filter, null);
    st.open();
    DataSource ds = st.waitForService(10000);
    assertNotNull(ds);
    Connection conn = ds.getConnection();
    assertNotNull(conn);
    //Cannot access directly so access via reflection
    assertEquals("70", getProperty(ds, "poolProperties.maxActive"));
    assertEquals("5", getProperty(ds, "poolProperties.initialSize"));
    assertEquals("SELECT 1", getProperty(ds, "poolProperties.initSQL"));
    assertEquals("false", getProperty(ds, "poolProperties.defaultReadOnly"));
    assertNull(getProperty(ds, "poolProperties.defaultAutoCommit"));
    config = ca.listConfigurations("(datasource.name=test)")[0];
    Dictionary dic = config.getProperties();
    dic.put("defaultReadOnly", Boolean.TRUE);
    config.update(dic);
    TimeUnit.MILLISECONDS.sleep(100);
    assertEquals("true", getProperty(ds, "poolProperties.defaultReadOnly"));
}
Also used : Dictionary(java.util.Dictionary) Configuration(org.osgi.service.cm.Configuration) Filter(org.osgi.framework.Filter) ServiceTracker(org.osgi.util.tracker.ServiceTracker) Hashtable(java.util.Hashtable) Connection(java.sql.Connection) DataSource(javax.sql.DataSource) Test(org.junit.Test)

Example 87 with Dictionary

use of java.util.Dictionary in project opennms by OpenNMS.

the class EchoRpcThreadIT method addServicesOnStartup.

@SuppressWarnings("rawtypes")
@Override
protected void addServicesOnStartup(Map<String, KeyValueHolder<Object, Dictionary>> services) {
    services.put(MinionIdentity.class.getName(), new KeyValueHolder<Object, Dictionary>(new MockMinionIdentity(REMOTE_LOCATION_NAME), new Properties()));
    Properties props = new Properties();
    props.setProperty("alias", "opennms.broker");
    services.put(Component.class.getName(), new KeyValueHolder<Object, Dictionary>(queuingservice, props));
    services.put(RpcModule.class.getName(), new KeyValueHolder<Object, Dictionary>(lockingRpcModule, new Properties()));
}
Also used : MockMinionIdentity(org.opennms.core.rpc.camel.MockMinionIdentity) Dictionary(java.util.Dictionary) RpcModule(org.opennms.core.rpc.api.RpcModule) MockMinionIdentity(org.opennms.core.rpc.camel.MockMinionIdentity) MinionIdentity(org.opennms.minion.core.api.MinionIdentity) Properties(java.util.Properties) Component(org.apache.camel.Component)

Example 88 with Dictionary

use of java.util.Dictionary in project rt.equinox.framework by eclipse.

the class StateResolverTest method testNativeCodeResolution01.

public void testNativeCodeResolution01() throws BundleException {
    State state = buildEmptyState();
    Dictionary[] props = new Dictionary[] { new Hashtable() };
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.arch", "x86");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.nl", "en_US");
    state.setPlatformProperties(props);
    Hashtable manifest = new Hashtable();
    long bundleID = 0;
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=Windows2000;osname=\"Windows 2003\";osname=Windows95;osname=Windows98;osname=WindowsNT;osname=WindowsXP;osname=\"Windows NT (unknown)\";osname=\"Windows Vista\"; language=en");
    // $NON-NLS-1$
    BundleDescription testNativeBundle = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    state.addBundle(testNativeBundle);
    state.resolve();
    // $NON-NLS-1$
    assertTrue("1.0", testNativeBundle.isResolved());
}
Also used : Dictionary(java.util.Dictionary) State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 89 with Dictionary

use of java.util.Dictionary in project rt.equinox.framework by eclipse.

the class StateResolverTest method testNativeCodeResolution05.

public void testNativeCodeResolution05() throws BundleException {
    State state = buildEmptyState();
    Dictionary[] props = new Dictionary[] { new Hashtable(), new Hashtable(), new Hashtable() };
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.arch", "x86");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[0].put("osgi.nl", "en_US");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.arch", "x86_64");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.nl", "en_US");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.arch", "x86");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.nl", "fr_FR");
    state.setPlatformProperties(props);
    Hashtable manifest = new Hashtable();
    long bundleID = 0;
    manifest.clear();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle1");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=win32; language=en");
    // $NON-NLS-1$
    BundleDescription testNativeBundle1 = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    manifest.clear();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86_64;osname=win32; language=en");
    // $NON-NLS-1$
    BundleDescription testNativeBundle2 = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    manifest.clear();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle3");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=win32; language=fr");
    // $NON-NLS-1$
    BundleDescription testNativeBundle3 = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    state.addBundle(testNativeBundle1);
    state.addBundle(testNativeBundle2);
    state.addBundle(testNativeBundle3);
    state.resolve();
    // $NON-NLS-1$
    assertTrue("1.0", testNativeBundle1.isResolved());
    // $NON-NLS-1$
    assertTrue("2.0", testNativeBundle2.isResolved());
    // $NON-NLS-1$
    assertTrue("3.0", testNativeBundle3.isResolved());
}
Also used : Dictionary(java.util.Dictionary) State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 90 with Dictionary

use of java.util.Dictionary in project rt.equinox.framework by eclipse.

the class StateResolverTest method testNativeCodeResolution06.

public void testNativeCodeResolution06() throws BundleException {
    State state = buildEmptyState();
    Dictionary[] props = new Dictionary[] { new Hashtable(), new Hashtable(), new Hashtable() };
    // empty props[0]
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[1].put("osgi.arch", "x86_64");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.ws", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.os", "win32");
    // $NON-NLS-1$ //$NON-NLS-2$
    props[2].put("osgi.arch", "x86");
    state.setPlatformProperties(props);
    Hashtable manifest = new Hashtable();
    long bundleID = 0;
    manifest.clear();
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_MANIFESTVERSION, "2");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_SYMBOLICNAME, "NativeBundle1");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_VERSION, "1.0.0");
    // $NON-NLS-1$
    manifest.put(Constants.BUNDLE_NATIVECODE, "Bundle-NativeCode: nativefile1.txt;processor=x86;osname=win32");
    // $NON-NLS-1$
    BundleDescription testNativeBundle1 = state.getFactory().createBundleDescription(state, manifest, "NativeBundle", bundleID++);
    state.addBundle(testNativeBundle1);
    state.resolve();
    // $NON-NLS-1$
    assertTrue("1.0", testNativeBundle1.isResolved());
}
Also used : Dictionary(java.util.Dictionary) State(org.eclipse.osgi.service.resolver.State) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Aggregations

Dictionary (java.util.Dictionary)198 Hashtable (java.util.Hashtable)91 Test (org.junit.Test)48 Configuration (org.osgi.service.cm.Configuration)33 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)28 State (org.eclipse.osgi.service.resolver.State)28 Enumeration (java.util.Enumeration)27 Properties (java.util.Properties)27 BundleContext (org.osgi.framework.BundleContext)24 ArrayList (java.util.ArrayList)22 ServiceReference (org.osgi.framework.ServiceReference)21 HashMap (java.util.HashMap)20 ServiceRegistration (org.osgi.framework.ServiceRegistration)20 IOException (java.io.IOException)17 Map (java.util.Map)17 Bundle (org.osgi.framework.Bundle)16 LinkedHashMap (java.util.LinkedHashMap)13 List (java.util.List)13 Matchers.anyString (org.mockito.Matchers.anyString)11 MinionIdentity (org.opennms.minion.core.api.MinionIdentity)11