diff options
author | afinkbein | 2009-01-14 23:30:36 +0000 |
---|---|---|
committer | afinkbein | 2009-01-14 23:30:36 +0000 |
commit | 3290cce0ff19ab212f99299304a98f2a429b2239 (patch) | |
tree | 499d4d7cc63e276a6c956b26f867229a8206a6af | |
parent | 1c6287200c2121dc02775afd3051d7762ad286fc (diff) | |
download | org.eclipse.osee-3290cce0ff19ab212f99299304a98f2a429b2239.tar.gz org.eclipse.osee-3290cce0ff19ab212f99299304a98f2a429b2239.tar.xz org.eclipse.osee-3290cce0ff19ab212f99299304a98f2a429b2239.zip |
9 files changed, 265 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/.classpath b/org.eclipse.osee.framework.resource.locator.attribute.test/.classpath new file mode 100644 index 00000000000..8a8f1668cdc --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/.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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/.project b/org.eclipse.osee.framework.resource.locator.attribute.test/.project new file mode 100644 index 00000000000..5693c236da6 --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.osee.framework.resource.locator.attribute.test</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>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/.settings/org.eclipse.pde.core.prefs b/org.eclipse.osee.framework.resource.locator.attribute.test/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 00000000000..1f3b33102e6 --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Tue Apr 15 12:48:51 MST 2008
+eclipse.preferences.version=1
+pluginProject.extensions=false
+resolve.requirebundle=false
diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/META-INF/MANIFEST.MF b/org.eclipse.osee.framework.resource.locator.attribute.test/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..1b47e6c3c2d --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/META-INF/MANIFEST.MF @@ -0,0 +1,16 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Test Plug-in +Bundle-SymbolicName: org.eclipse.osee.framework.resource.locator.attribute.test;singleton:=true +Bundle-Version: 0.2.0.qualifier +Bundle-Activator: org.eclipse.osee.framework.resource.locator.attribute.test.Activator +Bundle-Vendor: Boeing +Bundle-ActivationPolicy: lazy +Service-Component: OSGI-INF/tests.xml +Import-Package: junit.framework;version="3.8.2", + org.eclipse.osee.framework.resource.locator.attribute, + org.eclipse.osee.framework.resource.management, + org.eclipse.osee.framework.resource.management.exception, + org.osgi.framework;version="1.3.0", + org.osgi.util.tracker;version="1.3.3" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/OSGI-INF/tests.xml b/org.eclipse.osee.framework.resource.locator.attribute.test/OSGI-INF/tests.xml new file mode 100644 index 00000000000..e039565c72b --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/OSGI-INF/tests.xml @@ -0,0 +1,7 @@ +<?xml version="1.0"?>
+<component name="resource.locator.attribute.tests">
+ <implementation class="org.eclipse.osee.framework.resource.locator.attribute.test.AllResourceLocatorAttributeTests"/>
+ <service>
+ <provide interface="junit.framework.Test"/>
+ </service>
+</component>
\ No newline at end of file diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/build.properties b/org.eclipse.osee.framework.resource.locator.attribute.test/build.properties new file mode 100644 index 00000000000..a65755cb2a8 --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/build.properties @@ -0,0 +1,5 @@ +source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ OSGI-INF/
diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/Activator.java b/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/Activator.java new file mode 100644 index 00000000000..9b0fc990aa9 --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/Activator.java @@ -0,0 +1,31 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.resource.locator.attribute.test; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + } +} diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AllResourceLocatorAttributeTests.java b/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AllResourceLocatorAttributeTests.java new file mode 100644 index 00000000000..263b3f878c1 --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AllResourceLocatorAttributeTests.java @@ -0,0 +1,24 @@ +/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.resource.locator.attribute.test;
+
+import junit.framework.TestSuite;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class AllResourceLocatorAttributeTests extends TestSuite {
+
+ public AllResourceLocatorAttributeTests() {
+ addTestSuite(TestResourceLocatorAttribute.class);
+ }
+
+}
diff --git a/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/TestResourceLocatorAttribute.java b/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/TestResourceLocatorAttribute.java new file mode 100644 index 00000000000..0c41fcd9ddd --- /dev/null +++ b/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/TestResourceLocatorAttribute.java @@ -0,0 +1,143 @@ +/*******************************************************************************
+ * Copyright (c) 2004, 2007 Boeing.
+ * 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:
+ * Boeing - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.osee.framework.resource.locator.attribute.test;
+
+import java.util.ArrayList;
+import java.util.List;
+import junit.framework.TestCase;
+import org.eclipse.osee.framework.resource.locator.attribute.AttributeLocatorProvider;
+import org.eclipse.osee.framework.resource.management.IResourceLocator;
+import org.eclipse.osee.framework.resource.management.exception.MalformedLocatorException;
+
+/**
+ * @author Roberto E. Escobar
+ */
+public class TestResourceLocatorAttribute extends TestCase {
+
+ public void testCreateAttributeLocatorProvider() {
+ assertNotNull(new AttributeLocatorProvider());
+ }
+
+ public void testIsValid() {
+ AttributeLocatorProvider provider = new AttributeLocatorProvider();
+ String[] data = new String[] {"a", "", null, "attr://", "attr"};
+ boolean[] expected = new boolean[] {false, false, false, false, true};
+
+ for (int index = 0; index < 0; index++) {
+ boolean result = provider.isValid(data[index]);
+ assertEquals(expected[index], result);
+ }
+ }
+
+ private List<TestData> getTestGenerateLocatorData() {
+ List<TestData> cases = new ArrayList<TestData>();
+ cases.add(new TestData("1", "", null, true, null));
+ cases.add(new TestData("2", null, null, true, null));
+ cases.add(new TestData("3", null, "", true, null));
+ cases.add(new TestData("4", "", "", true, null));
+ cases.add(new TestData("5", "123", "", true, null));
+ cases.add(new TestData("6", "123", "hello.txt", false, "attr://123/hello.txt"));
+ cases.add(new TestData("7", "1234", "hello.txt", false, "attr://123/4/hello.txt"));
+ cases.add(new TestData("8", "1", "hello", false, "attr://1/hello"));
+ return cases;
+ }
+
+ public void testGenerateLocator() {
+ AttributeLocatorProvider provider = new AttributeLocatorProvider();
+ List<TestData> cases = getTestGenerateLocatorData();
+ for (TestData data : cases) {
+ IResourceLocator locator = null;
+ try {
+ locator = provider.generateResourceLocator(data.getSeed(), data.getName());
+ } catch (MalformedLocatorException ex) {
+ assertEquals(data.getId(), data.getShouldException(), true);
+ }
+ assertEquals(data.getId(), data.getExpected(), locator != null ? locator.getLocation().toASCIIString() : null);
+ }
+ }
+
+ private List<TestData> getTestGetResourceLocatorData() {
+ List<TestData> cases = new ArrayList<TestData>();
+ cases.add(new TestData("1", "", true, null));
+ cases.add(new TestData("2", null, true, null));
+ cases.add(new TestData("3", "$%#", true, null));
+ cases.add(new TestData("4", "x://", true, null));
+ cases.add(new TestData("5", "x:1234/4", true, null));
+ cases.add(new TestData("6", "attr:123", true, null));
+ cases.add(new TestData("7", "attr://123", false, "attr://123"));
+ cases.add(new TestData("8", "attr://123/hello.txt", false, "attr://123/hello.txt"));
+ return cases;
+ }
+
+ public void testAcquireResourceAttributeLocator() {
+ AttributeLocatorProvider provider = new AttributeLocatorProvider();
+ List<TestData> cases = getTestGetResourceLocatorData();
+ for (TestData data : cases) {
+ IResourceLocator locator = null;
+ try {
+ locator = provider.getResourceLocator(data.getPath());
+ } catch (MalformedLocatorException ex) {
+ assertEquals(data.getId(), data.getShouldException(), true);
+ }
+ assertEquals(data.getId(), data.getExpected(), locator != null ? locator.getLocation().toASCIIString() : null);
+ }
+ }
+
+ private final class TestData {
+ private String id;
+ private String seed;
+ private String name;
+ private String path;
+ private boolean shouldException;
+ private String expected;
+
+ public TestData(String id, String path, boolean shouldException, String expected) {
+ super();
+ this.id = id;
+ this.path = path;
+ this.shouldException = shouldException;
+ this.expected = expected;
+ }
+
+ public TestData(String id, String seed, String name, boolean shouldException, String expected) {
+ super();
+ this.id = id;
+ this.seed = seed;
+ this.name = name;
+ this.shouldException = shouldException;
+ this.expected = expected;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public String getSeed() {
+ return seed;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public String getExpected() {
+ return expected;
+ }
+
+ public boolean getShouldException() {
+ return shouldException;
+ }
+ }
+}
\ No newline at end of file |