Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-05-20 21:38:45 +0000
committerslewis2008-05-20 21:38:45 +0000
commit6dedbbff20216c9523f0317ad923b3008e99decd (patch)
tree6083caa7afba8bd1e25296a8170ca092c3f3e935
parent3f4cb880de2857fb6e527a53637b396be77d5be3 (diff)
downloadorg.eclipse.ecf-6dedbbff20216c9523f0317ad923b3008e99decd.tar.gz
org.eclipse.ecf-6dedbbff20216c9523f0317ad923b3008e99decd.tar.xz
org.eclipse.ecf-6dedbbff20216c9523f0317ad923b3008e99decd.zip
Additions to ContainerStore/ContainerEntry
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/internal/tests/securestorage/Activator.java14
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/tests/securestorage/ContainerStoreTest.java79
2 files changed, 93 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/internal/tests/securestorage/Activator.java b/tests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/internal/tests/securestorage/Activator.java
index 675b1494b..b9fbdadb7 100755
--- a/tests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/internal/tests/securestorage/Activator.java
+++ b/tests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/internal/tests/securestorage/Activator.java
@@ -1,5 +1,6 @@
package org.eclipse.ecf.internal.tests.securestorage;
+import org.eclipse.ecf.storage.IContainerStore;
import org.eclipse.ecf.storage.IIDStore;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
@@ -12,6 +13,7 @@ public class Activator implements BundleActivator {
private BundleContext context;
ServiceTracker storageServiceTracker;
+ ServiceTracker containerStorageServiceTracker;
public static Activator getDefault() {
return plugin;
@@ -34,6 +36,14 @@ public class Activator implements BundleActivator {
return (IIDStore) storageServiceTracker.getService();
}
+ public IContainerStore getContainerStore() {
+ if (containerStorageServiceTracker == null) {
+ containerStorageServiceTracker = new ServiceTracker(context, IContainerStore.class.getName(), null);
+ containerStorageServiceTracker.open();
+ }
+ return (IContainerStore) containerStorageServiceTracker.getService();
+ }
+
/*
* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
@@ -43,6 +53,10 @@ public class Activator implements BundleActivator {
storageServiceTracker.close();
storageServiceTracker = null;
}
+ if (containerStorageServiceTracker != null) {
+ containerStorageServiceTracker.close();
+ containerStorageServiceTracker = null;
+ }
this.context = null;
plugin = null;
}
diff --git a/tests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/tests/securestorage/ContainerStoreTest.java b/tests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/tests/securestorage/ContainerStoreTest.java
new file mode 100755
index 000000000..e064ad710
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.storage/src/org/eclipse/ecf/tests/securestorage/ContainerStoreTest.java
@@ -0,0 +1,79 @@
+/****************************************************************************
+ * Copyright (c) 2008 Composent, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Composent, Inc. - initial API and implementation
+ *****************************************************************************/
+
+package org.eclipse.ecf.tests.securestorage;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.ContainerCreateException;
+import org.eclipse.ecf.core.ContainerFactory;
+import org.eclipse.ecf.core.IContainer;
+import org.eclipse.ecf.internal.tests.securestorage.Activator;
+import org.eclipse.ecf.storage.IContainerEntry;
+import org.eclipse.ecf.storage.IContainerStore;
+import org.eclipse.ecf.storage.IStorableContainerAdapter;
+import org.eclipse.equinox.security.storage.ISecurePreferences;
+
+/**
+ *
+ */
+public class ContainerStoreTest extends TestCase {
+
+ IContainerStore containerStore;
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ protected void setUp() throws Exception {
+ super.setUp();
+ containerStore = Activator.getDefault().getContainerStore();
+ }
+
+ protected void clearStore() {
+ final IContainerEntry[] containerEntries = containerStore.getContainerEntries();
+ for (int i = 0; i < containerEntries.length; i++) {
+ containerEntries[i].delete();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ clearStore();
+ containerStore = null;
+ }
+
+ public void testContainerStore() {
+ assertNotNull(containerStore);
+ }
+
+ IContainer createContainer() throws ContainerCreateException {
+ return ContainerFactory.getDefault().createContainer("ecf.storage.basecontainer");
+ }
+
+ IStorableContainerAdapter getStorableContainerAdapter(IContainer container) {
+ return (IStorableContainerAdapter) container.getAdapter(IStorableContainerAdapter.class);
+ }
+
+ IContainerEntry storeContainer(IStorableContainerAdapter containerAdapter) {
+ return containerStore.store(containerAdapter);
+ }
+
+ public void testStoreContainer() throws Exception {
+ final IContainer container = createContainer();
+ final IContainerEntry containerEntry = storeContainer(getStorableContainerAdapter(container));
+ final ISecurePreferences prefs = containerEntry.getPreferences();
+ assertNotNull(prefs);
+ }
+
+}

Back to the top