Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormmayworm2008-10-06 21:32:42 +0000
committermmayworm2008-10-06 21:32:42 +0000
commita37b27567d20a2f4eff5808292596d2f53682331 (patch)
treee94ce65fd6faeba196ecc764e7376a5cf50ca2b1
parent6929d0e33b1b52599390139d0793c6b1da2ca6bd (diff)
downloadorg.eclipse.ecf-a37b27567d20a2f4eff5808292596d2f53682331.tar.gz
org.eclipse.ecf-a37b27567d20a2f4eff5808292596d2f53682331.tar.xz
org.eclipse.ecf-a37b27567d20a2f4eff5808292596d2f53682331.zip
Bundle for sync api tests
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/.classpath7
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/.project34
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/.settings/org.eclipse.jdt.core.prefs7
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/.settings/org.eclipse.pde.core.prefs4
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/META-INF/MANIFEST.MF20
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/about.html28
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/build.properties10
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/plugin.properties11
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/src/org/eclipse/ecf/internal/tests/sync/Activator.java81
-rwxr-xr-xtests/bundles/org.eclipse.ecf.tests.sync/src/org/eclipse/ecf/tests/sync/SyncServiceTests.java28
10 files changed, 230 insertions, 0 deletions
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/.classpath b/tests/bundles/org.eclipse.ecf.tests.sync/.classpath
new file mode 100755
index 000000000..731ea5fad
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/.project b/tests/bundles/org.eclipse.ecf.tests.sync/.project
new file mode 100755
index 000000000..79a4ad3a4
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/.project
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.ecf.tests.sync</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
+ </natures>
+</projectDescription>
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/.settings/org.eclipse.jdt.core.prefs b/tests/bundles/org.eclipse.ecf.tests.sync/.settings/org.eclipse.jdt.core.prefs
new file mode 100755
index 000000000..0ec2e7151
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Sun Oct 05 14:53:02 PDT 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.source=1.3
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/.settings/org.eclipse.pde.core.prefs b/tests/bundles/org.eclipse.ecf.tests.sync/.settings/org.eclipse.pde.core.prefs
new file mode 100755
index 000000000..bb8f0a794
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/.settings/org.eclipse.pde.core.prefs
@@ -0,0 +1,4 @@
+#Sun Oct 05 14:53:03 PDT 2008
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/META-INF/MANIFEST.MF b/tests/bundles/org.eclipse.ecf.tests.sync/META-INF/MANIFEST.MF
new file mode 100755
index 000000000..ac3d78721
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/META-INF/MANIFEST.MF
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %plugin.name
+Bundle-SymbolicName: org.eclipse.ecf.tests.sync
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: org.eclipse.ecf.internal.tests.sync.Activator
+Bundle-Vendor: %plugin.provider
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Import-Package: org.eclipse.ecf.core,
+ org.eclipse.ecf.core.identity,
+ org.eclipse.ecf.sync,
+ org.eclipse.ecf.sync.doc,
+ org.osgi.framework;version="1.3.0",
+ org.osgi.util.tracker;version="1.3.3"
+Bundle-ActivationPolicy: lazy
+Require-Bundle: org.junit;bundle-version="3.8.2",
+ org.eclipse.equinox.common;bundle-version="3.4.0"
+Export-Package: org.eclipse.ecf.internal.tests.sync;x-internal:=true,
+ org.eclipse.ecf.tests.sync
+Bundle-Localization: plugin
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/about.html b/tests/bundles/org.eclipse.ecf.tests.sync/about.html
new file mode 100755
index 000000000..3ac3c743e
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/about.html
@@ -0,0 +1,28 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
+<title>About</title>
+</head>
+<body lang="EN-US">
+<h2>About This Content</h2>
+
+<p>June 25, 2008</p>
+<h3>License</h3>
+
+<p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
+indicated below, the Content is provided to you under the terms and conditions of the
+Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
+at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
+For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
+
+<p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
+being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
+apply to your use of any object code in the Content. Check the Redistributor's license that was
+provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
+indicated below, the terms and conditions of the EPL still apply to any source code in the Content
+and such source code may be obtained at <a href="/">http://www.eclipse.org</a>.</p>
+
+</body>
+</html> \ No newline at end of file
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/build.properties b/tests/bundles/org.eclipse.ecf.tests.sync/build.properties
new file mode 100755
index 000000000..11f4a3607
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/build.properties
@@ -0,0 +1,10 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ about.html,\
+ plugin.properties
+src.includes = plugin.properties,\
+ src/,\
+ about.html,\
+ META-INF/
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/plugin.properties b/tests/bundles/org.eclipse.ecf.tests.sync/plugin.properties
new file mode 100755
index 000000000..730a0805f
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/plugin.properties
@@ -0,0 +1,11 @@
+############################################################################
+# Copyright (c) 2007 Composent Inc., IBM Corp, 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
+#
+############################################################################
+plugin.name=ECF Sync Tests
+plugin.provider=Eclipse.org
+
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/src/org/eclipse/ecf/internal/tests/sync/Activator.java b/tests/bundles/org.eclipse.ecf.tests.sync/src/org/eclipse/ecf/internal/tests/sync/Activator.java
new file mode 100755
index 000000000..2723001b8
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/src/org/eclipse/ecf/internal/tests/sync/Activator.java
@@ -0,0 +1,81 @@
+package org.eclipse.ecf.internal.tests.sync;
+
+import org.eclipse.ecf.sync.IServiceConstants;
+import org.eclipse.ecf.sync.doc.IDocumentSynchronizationStrategyFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.ServiceReference;
+import org.osgi.util.tracker.ServiceTracker;
+
+public class Activator implements BundleActivator {
+
+ private BundleContext context;
+ private ServiceTracker serviceTracker;
+
+ private static Activator plugin;
+
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext ctxt) throws Exception {
+ plugin = this;
+ this.context = ctxt;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ if (serviceTracker != null) {
+ serviceTracker.close();
+ serviceTracker = null;
+ }
+ plugin = null;
+ this.context = null;
+ }
+
+ public IDocumentSynchronizationStrategyFactory [] getSynchStrategyFactories() {
+ if (serviceTracker == null) {
+ serviceTracker = new ServiceTracker(context,IDocumentSynchronizationStrategyFactory.class.getName(),null);
+ serviceTracker.open();
+ }
+ ServiceReference [] refs = serviceTracker.getServiceReferences();
+ if (refs == null) return null;
+ IDocumentSynchronizationStrategyFactory [] strats = new IDocumentSynchronizationStrategyFactory [refs.length];
+ for(int i =0; i < refs.length; i++) {
+ strats[i] = (IDocumentSynchronizationStrategyFactory) serviceTracker.getService(refs[i]);
+ }
+ return strats;
+ }
+
+ public IDocumentSynchronizationStrategyFactory getSynchStrategyFactory(String serviceProvider) {
+ if (serviceTracker == null) {
+ serviceTracker = new ServiceTracker(context,IDocumentSynchronizationStrategyFactory.class.getName(),null);
+ serviceTracker.open();
+ }
+ ServiceReference [] refs = serviceTracker.getServiceReferences();
+ if (refs == null) return null;
+ IDocumentSynchronizationStrategyFactory result = null;
+ for(int i =0; i < refs.length; i++) {
+ String prop = (String) refs[i].getProperty(IServiceConstants.SYNCSTRATEGY_TYPE_PROPERTY);
+ if (prop != null && prop.equals(serviceProvider)) {
+ result = (IDocumentSynchronizationStrategyFactory) serviceTracker.getService(refs[i]);
+ }
+ }
+ return result;
+ }
+
+ public IDocumentSynchronizationStrategyFactory getColaSynchronizationStrategyFactory() {
+ return getSynchStrategyFactory("org.eclipse.ecf.internal.sync.doc.cola");
+ }
+
+ public IDocumentSynchronizationStrategyFactory getIdentitySynchronizationStrategy() {
+ return getSynchStrategyFactory("org.eclipse.ecf.sync.doc.identity");
+ }
+}
diff --git a/tests/bundles/org.eclipse.ecf.tests.sync/src/org/eclipse/ecf/tests/sync/SyncServiceTests.java b/tests/bundles/org.eclipse.ecf.tests.sync/src/org/eclipse/ecf/tests/sync/SyncServiceTests.java
new file mode 100755
index 000000000..4c68abb65
--- /dev/null
+++ b/tests/bundles/org.eclipse.ecf.tests.sync/src/org/eclipse/ecf/tests/sync/SyncServiceTests.java
@@ -0,0 +1,28 @@
+package org.eclipse.ecf.tests.sync;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ecf.core.identity.IDFactory;
+import org.eclipse.ecf.internal.tests.sync.Activator;
+import org.eclipse.ecf.sync.doc.IDocumentSynchronizationStrategy;
+import org.eclipse.ecf.sync.doc.IDocumentSynchronizationStrategyFactory;
+
+public class SyncServiceTests extends TestCase {
+
+ protected IDocumentSynchronizationStrategyFactory getColaSyncStrategyFactory() {
+ return Activator.getDefault().getColaSynchronizationStrategyFactory();
+ }
+
+ public void testGetAllSyncFactory() throws Exception {
+ IDocumentSynchronizationStrategyFactory []factories = Activator.getDefault().getSynchStrategyFactories();
+ assertNotNull(factories);
+ assertTrue(factories.length == 2);
+ }
+
+ public void testGetColaSyncFactory() throws Exception {
+ IDocumentSynchronizationStrategyFactory factory = getColaSyncStrategyFactory();
+ assertNotNull(factory);
+ IDocumentSynchronizationStrategy strategy = factory.createDocumentSynchronizationStrategy(IDFactory.getDefault().createStringID("cola"), true);
+ assertNotNull(strategy);
+ }
+}

Back to the top