Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-03-12 18:27:25 +0000
committerrescobar2010-03-12 18:27:25 +0000
commit205aa057fa925d37a3a5375aa8418b9567e99c6d (patch)
treed33f80b9f727c479b8031aeb352494c38ad9878d /plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org
parent0e6d2b595cfb4d54eccdf3479e7c5d74d9c736a5 (diff)
downloadorg.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.tar.gz
org.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.tar.xz
org.eclipse.osee-205aa057fa925d37a3a5375aa8418b9567e99c6d.zip
Diffstat (limited to 'plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org')
-rw-r--r--plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AttributeLocatorProviderTest.java154
-rw-r--r--plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AttributeLocatorProviderTestSuite.java23
2 files changed, 177 insertions, 0 deletions
diff --git a/plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AttributeLocatorProviderTest.java b/plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AttributeLocatorProviderTest.java
new file mode 100644
index 00000000000..15d92f952eb
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AttributeLocatorProviderTest.java
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * 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 org.eclipse.osee.framework.core.exception.OseeCoreException;
+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;
+import org.junit.Assert;
+
+/**
+ * Test Cases for {@link AttributeLocatorProvider}
+ *
+ * @author Roberto E. Escobar
+ */
+public class AttributeLocatorProviderTest {
+
+ @org.junit.Test
+ public void testCreateAttributeLocatorProvider() {
+ Assert.assertNotNull(new AttributeLocatorProvider());
+ }
+
+ @org.junit.Test
+ 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]);
+ Assert.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;
+ }
+
+ @org.junit.Test
+ 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 (OseeCoreException ex) {
+ Assert.assertTrue(ex instanceof MalformedLocatorException);
+ Assert.assertEquals(data.getId(), data.getShouldException(), true);
+ }
+ Assert.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;
+ }
+
+ @org.junit.Test
+ 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 (OseeCoreException ex) {
+ Assert.assertTrue(ex instanceof MalformedLocatorException);
+ Assert.assertEquals(data.getId(), data.getShouldException(), true);
+ }
+ Assert.assertEquals(data.getId(), data.getExpected(),
+ locator != null ? locator.getLocation().toASCIIString() : null);
+ }
+ }
+
+ private final class TestData {
+ private final String id;
+ private String seed;
+ private String name;
+ private String path;
+ private final boolean shouldException;
+ private final 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
diff --git a/plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AttributeLocatorProviderTestSuite.java b/plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AttributeLocatorProviderTestSuite.java
new file mode 100644
index 00000000000..5b3d373f477
--- /dev/null
+++ b/plugins/org.eclipse.osee.framework.resource.locator.attribute.test/src/org/eclipse/osee/framework/resource/locator/attribute/test/AttributeLocatorProviderTestSuite.java
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+@RunWith(Suite.class)
+@Suite.SuiteClasses( {AttributeLocatorProviderTest.class})
+/**
+ * @author Roberto E. Escobar
+ */
+public class AttributeLocatorProviderTestSuite {
+
+}

Back to the top