diff options
author | rbrooks | 2010-07-24 08:02:08 +0000 |
---|---|---|
committer | rbrooks | 2010-07-24 08:02:08 +0000 |
commit | 4ed8bddc791fda93940f238c5135556a07041dc0 (patch) | |
tree | 64a118285c5006c3a38320dbb2d374e8ea72a061 /plugins/org.eclipse.osee.framework.resource.management.test | |
parent | 542cc7344d3f129d64e47f547384297c8e1b1f43 (diff) | |
download | org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.tar.gz org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.tar.xz org.eclipse.osee-4ed8bddc791fda93940f238c5135556a07041dc0.zip |
converted all line terminators to unix style
Diffstat (limited to 'plugins/org.eclipse.osee.framework.resource.management.test')
16 files changed, 999 insertions, 999 deletions
diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/.classpath b/plugins/org.eclipse.osee.framework.resource.management.test/.classpath index 8a8f1668cdc..ad32c83a788 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/.classpath +++ b/plugins/org.eclipse.osee.framework.resource.management.test/.classpath @@ -1,7 +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>
+<?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/plugins/org.eclipse.osee.framework.resource.management.test/.project b/plugins/org.eclipse.osee.framework.resource.management.test/.project index eb36c93940f..bc2c4ea8b19 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/.project +++ b/plugins/org.eclipse.osee.framework.resource.management.test/.project @@ -1,28 +1,28 @@ -<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.osee.framework.resource.management.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>
+<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.eclipse.osee.framework.resource.management.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/plugins/org.eclipse.osee.framework.resource.management.test/build.properties b/plugins/org.eclipse.osee.framework.resource.management.test/build.properties index 41eb6ade2b4..34d2e4d2dad 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/build.properties +++ b/plugins/org.eclipse.osee.framework.resource.management.test/build.properties @@ -1,4 +1,4 @@ -source.. = src/
-output.. = bin/
-bin.includes = META-INF/,\
- .
+source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/OptionsTest.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/OptionsTest.java index 0f6acc0f44c..60e9fd8e388 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/OptionsTest.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/OptionsTest.java @@ -1,38 +1,38 @@ -/*******************************************************************************
- * 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.management.test;
-
-import org.eclipse.osee.framework.jdk.core.test.type.PropertyStoreTest;
-import org.eclipse.osee.framework.resource.management.Options;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test Cases for {@link Options}
- *
- * @author Roberto E. Escobar
- */
-public class OptionsTest extends PropertyStoreTest {
-
- @Test
- public void testClear() {
- Options options = new Options();
- options.put("a", true);
- options.put("b", 0.1);
- options.put("c", new String[] {"a", "b", "c"});
- Assert.assertEquals(1, options.arrayKeySet().size());
- Assert.assertEquals(2, options.keySet().size());
-
- options.clear();
- Assert.assertEquals(0, options.arrayKeySet().size());
- Assert.assertEquals(0, options.keySet().size());
- }
-}
+/******************************************************************************* + * 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.management.test; + +import org.eclipse.osee.framework.jdk.core.test.type.PropertyStoreTest; +import org.eclipse.osee.framework.resource.management.Options; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test Cases for {@link Options} + * + * @author Roberto E. Escobar + */ +public class OptionsTest extends PropertyStoreTest { + + @Test + public void testClear() { + Options options = new Options(); + options.put("a", true); + options.put("b", 0.1); + options.put("c", new String[] {"a", "b", "c"}); + Assert.assertEquals(1, options.arrayKeySet().size()); + Assert.assertEquals(2, options.keySet().size()); + + options.clear(); + Assert.assertEquals(0, options.arrayKeySet().size()); + Assert.assertEquals(0, options.keySet().size()); + } +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceLocatorManagerTest.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceLocatorManagerTest.java index cf8662d388a..6bf4fee7832 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceLocatorManagerTest.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceLocatorManagerTest.java @@ -1,144 +1,144 @@ -/*******************************************************************************
- * 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.management.test;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeStateException;
-import org.eclipse.osee.framework.resource.management.IResourceLocator;
-import org.eclipse.osee.framework.resource.management.IResourceLocatorManager;
-import org.eclipse.osee.framework.resource.management.IResourceLocatorProvider;
-import org.eclipse.osee.framework.resource.management.exception.MalformedLocatorException;
-import org.eclipse.osee.framework.resource.management.internal.ResourceLocatorManager;
-import org.eclipse.osee.framework.resource.management.test.mocks.MockLocatorProvider;
-import org.eclipse.osee.framework.resource.management.test.mocks.MockResourceLocator;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-/**
- * Test Cases for {@link ResourceLocatorManager}
- *
- * @author Roberto E. Escobar
- */
-public class ResourceLocatorManagerTest {
-
- private IResourceLocatorProvider provider1;
- private IResourceLocatorProvider provider2;
- private IResourceLocatorProvider provider3;
- private IResourceLocatorManager manager;
-
- @Before
- public void setup() {
- provider1 = new MockLocatorProvider("protocol1");
- provider2 = new MockLocatorProvider("protocol2");
- provider3 = new MockLocatorProvider("protocol3");
-
- manager = new ResourceLocatorManager();
- manager.addResourceLocatorProvider(provider1);
- manager.addResourceLocatorProvider(provider2);
- manager.addResourceLocatorProvider(provider3);
- }
-
- @Test
- public void testEmptyProvider() {
- IResourceLocatorManager manager = new ResourceLocatorManager();
- Assert.assertEquals(0, manager.getProtocols().size());
-
- try {
- manager.getResourceLocator("protocol");
- Assert.fail("This line should not be executed");
- } catch (OseeCoreException ex) {
- Assert.assertTrue(ex instanceof OseeStateException);
- }
- try {
- manager.generateResourceLocator(null, null, null);
- } catch (OseeCoreException ex) {
- Assert.assertTrue(ex instanceof OseeStateException);
- }
- }
-
- @Test
- public void testAddAndRemove() {
- IResourceLocatorManager testManager = new ResourceLocatorManager();
-
- Assert.assertTrue(testManager.addResourceLocatorProvider(provider1));
- Assert.assertTrue(testManager.addResourceLocatorProvider(provider2));
-
- Assert.assertEquals(2, testManager.getProtocols().size());
-
- Assert.assertFalse(testManager.addResourceLocatorProvider(provider2)); // Add the same one again
- Assert.assertEquals(2, testManager.getProtocols().size());
-
- Assert.assertTrue(testManager.removeResourceLocatorProvider(provider1));
- Assert.assertEquals(1, testManager.getProtocols().size());
-
- Assert.assertFalse(testManager.removeResourceLocatorProvider(provider1));// Remove the same one again
- Assert.assertEquals(1, testManager.getProtocols().size());
-
- Assert.assertTrue(testManager.removeResourceLocatorProvider(provider2));
- Assert.assertEquals(0, testManager.getProtocols().size());
- }
-
- @Test
- public void testGetProtocols() {
- List<String> actual = new ArrayList<String>(manager.getProtocols());
- Assert.assertEquals(3, actual.size());
-
- Collections.sort(actual);
- int index = 0;
- Assert.assertEquals("protocol1", actual.get(index++));
- Assert.assertEquals("protocol2", actual.get(index++));
- Assert.assertEquals("protocol3", actual.get(index++));
- }
-
- @Test
- public void testGenerateLocator() throws OseeCoreException {
- // Test Protocol not found
- try {
- manager.generateResourceLocator("dummyProcotol", "", "");
- Assert.fail("This line should not be executed");
- } catch (OseeCoreException ex) {
- Assert.assertTrue(ex instanceof MalformedLocatorException);
- }
-
- IResourceLocator locator = manager.generateResourceLocator("protocol1", "ABCDE", "name1");
- Assert.assertTrue(locator instanceof MockResourceLocator);
- MockResourceLocator mockLocator = (MockResourceLocator) locator;
- Assert.assertEquals("ABCDE", mockLocator.getSeed());
- Assert.assertEquals("name1", mockLocator.getName());
- Assert.assertNull(mockLocator.getRawPath());
- }
-
- @Test
- public void testGetLocator() throws OseeCoreException {
- // Test Protocol not found
- try {
- manager.getResourceLocator("dummyProcotol://hello");
- Assert.fail("This line should not be executed");
- } catch (OseeCoreException ex) {
- Assert.assertTrue(ex instanceof MalformedLocatorException);
- }
-
- IResourceLocator locator = manager.getResourceLocator("protocol1://one/two/three");
- Assert.assertEquals("protocol1", locator.getProtocol());
- Assert.assertEquals("protocol1://one/two/three", locator.getRawPath());
-
- locator = manager.getResourceLocator("protocol2://1");
- Assert.assertEquals("protocol2", locator.getProtocol());
- Assert.assertEquals("protocol2://1", locator.getRawPath());
-
- locator = manager.getResourceLocator("protocol3");
- Assert.assertEquals("protocol3", locator.getProtocol());
- }
-}
+/******************************************************************************* + * 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.management.test; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.exception.OseeStateException; +import org.eclipse.osee.framework.resource.management.IResourceLocator; +import org.eclipse.osee.framework.resource.management.IResourceLocatorManager; +import org.eclipse.osee.framework.resource.management.IResourceLocatorProvider; +import org.eclipse.osee.framework.resource.management.exception.MalformedLocatorException; +import org.eclipse.osee.framework.resource.management.internal.ResourceLocatorManager; +import org.eclipse.osee.framework.resource.management.test.mocks.MockLocatorProvider; +import org.eclipse.osee.framework.resource.management.test.mocks.MockResourceLocator; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +/** + * Test Cases for {@link ResourceLocatorManager} + * + * @author Roberto E. Escobar + */ +public class ResourceLocatorManagerTest { + + private IResourceLocatorProvider provider1; + private IResourceLocatorProvider provider2; + private IResourceLocatorProvider provider3; + private IResourceLocatorManager manager; + + @Before + public void setup() { + provider1 = new MockLocatorProvider("protocol1"); + provider2 = new MockLocatorProvider("protocol2"); + provider3 = new MockLocatorProvider("protocol3"); + + manager = new ResourceLocatorManager(); + manager.addResourceLocatorProvider(provider1); + manager.addResourceLocatorProvider(provider2); + manager.addResourceLocatorProvider(provider3); + } + + @Test + public void testEmptyProvider() { + IResourceLocatorManager manager = new ResourceLocatorManager(); + Assert.assertEquals(0, manager.getProtocols().size()); + + try { + manager.getResourceLocator("protocol"); + Assert.fail("This line should not be executed"); + } catch (OseeCoreException ex) { + Assert.assertTrue(ex instanceof OseeStateException); + } + try { + manager.generateResourceLocator(null, null, null); + } catch (OseeCoreException ex) { + Assert.assertTrue(ex instanceof OseeStateException); + } + } + + @Test + public void testAddAndRemove() { + IResourceLocatorManager testManager = new ResourceLocatorManager(); + + Assert.assertTrue(testManager.addResourceLocatorProvider(provider1)); + Assert.assertTrue(testManager.addResourceLocatorProvider(provider2)); + + Assert.assertEquals(2, testManager.getProtocols().size()); + + Assert.assertFalse(testManager.addResourceLocatorProvider(provider2)); // Add the same one again + Assert.assertEquals(2, testManager.getProtocols().size()); + + Assert.assertTrue(testManager.removeResourceLocatorProvider(provider1)); + Assert.assertEquals(1, testManager.getProtocols().size()); + + Assert.assertFalse(testManager.removeResourceLocatorProvider(provider1));// Remove the same one again + Assert.assertEquals(1, testManager.getProtocols().size()); + + Assert.assertTrue(testManager.removeResourceLocatorProvider(provider2)); + Assert.assertEquals(0, testManager.getProtocols().size()); + } + + @Test + public void testGetProtocols() { + List<String> actual = new ArrayList<String>(manager.getProtocols()); + Assert.assertEquals(3, actual.size()); + + Collections.sort(actual); + int index = 0; + Assert.assertEquals("protocol1", actual.get(index++)); + Assert.assertEquals("protocol2", actual.get(index++)); + Assert.assertEquals("protocol3", actual.get(index++)); + } + + @Test + public void testGenerateLocator() throws OseeCoreException { + // Test Protocol not found + try { + manager.generateResourceLocator("dummyProcotol", "", ""); + Assert.fail("This line should not be executed"); + } catch (OseeCoreException ex) { + Assert.assertTrue(ex instanceof MalformedLocatorException); + } + + IResourceLocator locator = manager.generateResourceLocator("protocol1", "ABCDE", "name1"); + Assert.assertTrue(locator instanceof MockResourceLocator); + MockResourceLocator mockLocator = (MockResourceLocator) locator; + Assert.assertEquals("ABCDE", mockLocator.getSeed()); + Assert.assertEquals("name1", mockLocator.getName()); + Assert.assertNull(mockLocator.getRawPath()); + } + + @Test + public void testGetLocator() throws OseeCoreException { + // Test Protocol not found + try { + manager.getResourceLocator("dummyProcotol://hello"); + Assert.fail("This line should not be executed"); + } catch (OseeCoreException ex) { + Assert.assertTrue(ex instanceof MalformedLocatorException); + } + + IResourceLocator locator = manager.getResourceLocator("protocol1://one/two/three"); + Assert.assertEquals("protocol1", locator.getProtocol()); + Assert.assertEquals("protocol1://one/two/three", locator.getRawPath()); + + locator = manager.getResourceLocator("protocol2://1"); + Assert.assertEquals("protocol2", locator.getProtocol()); + Assert.assertEquals("protocol2://1", locator.getRawPath()); + + locator = manager.getResourceLocator("protocol3"); + Assert.assertEquals("protocol3", locator.getProtocol()); + } +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceManagementTestSuite.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceManagementTestSuite.java index b7366036c4e..1df2e43364d 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceManagementTestSuite.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceManagementTestSuite.java @@ -1,25 +1,25 @@ -/*******************************************************************************
- * 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.management.test;
-
-import org.eclipse.osee.framework.resource.management.test.util.ResourceUtilTestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {ResourceUtilTestSuite.class, OptionsTest.class, ResourceLocatorManagerTest.class,
- ResourceManagerTest.class})
-/**
- * @author Roberto E. Escobar
- */
-public class ResourceManagementTestSuite {
-
-}
+/******************************************************************************* + * 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.management.test; + +import org.eclipse.osee.framework.resource.management.test.util.ResourceUtilTestSuite; +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( {ResourceUtilTestSuite.class, OptionsTest.class, ResourceLocatorManagerTest.class, + ResourceManagerTest.class}) +/** + * @author Roberto E. Escobar + */ +public class ResourceManagementTestSuite { + +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceManagerTest.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceManagerTest.java index 9f9fff11aa6..14944f0809c 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceManagerTest.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/ResourceManagerTest.java @@ -1,209 +1,209 @@ -/*******************************************************************************
- * 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.management.test;
-
-import org.eclipse.osee.framework.resource.management.IResourceListener;
-import org.eclipse.osee.framework.resource.management.IResourceManager;
-import org.eclipse.osee.framework.resource.management.IResourceProvider;
-import org.eclipse.osee.framework.resource.management.internal.ResourceManager;
-import org.eclipse.osee.framework.resource.management.test.mocks.MockResourceListener;
-import org.eclipse.osee.framework.resource.management.test.mocks.ResourceProviderAdaptor;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Resource Manager Test {@link ResourceManager}
- *
- * @author Andrew M. Finkbeiner
- */
-public class ResourceManagerTest {
-
- // private IResourceManager resourceManager;
- // private IResourceLocatorManager locatorManager;
- //
- // private URL testFileURL;
- //
- // @Before
- // public void setup() {
- // resourceManager = new ResourceManager();
- // locatorManager = new ResourceLocatorManager();
- // testFileURL =
- // getClass().getClassLoader().getResource("org/eclipse/osee/framework/resource/management/test/TestFile.txt");
- // }
-
- @Test
- public void testAddRemoveProvider() {
- IResourceManager resourceManagerX = new ResourceManager();
- IResourceProvider provider1 = new ResourceProviderAdaptor();
- Assert.assertTrue(resourceManagerX.addResourceProvider(provider1));
- Assert.assertFalse(resourceManagerX.addResourceProvider(provider1)); // Add again
- Assert.assertTrue(resourceManagerX.removeResourceProvider(provider1));
- }
-
- @Test
- public void testAddRemoveListener() {
- IResourceManager resourceManagerX = new ResourceManager();
- IResourceListener listener = new MockResourceListener();
- Assert.assertTrue(resourceManagerX.addResourceListener(listener));
- Assert.assertFalse(resourceManagerX.addResourceListener(listener)); // Add again
- Assert.assertTrue(resourceManagerX.removeResourceListener(listener));
- Assert.assertFalse(resourceManagerX.removeResourceListener(listener)); // Add again
- }
-
- @Test
- public void testExists() {
-
- // public boolean exists(IResourceLocator locator) throws OseeCoreException;
- }
-
- @Test
- public void testAcquire() {
- // public IResource acquire(IResourceLocator locator, Options options) throws OseeCoreException;
- }
-
- @Test
- public void testSave() {
- // public IResourceLocator save(final IResourceLocator locatorHint, final IResource resource, final Options options) throws OseeCoreException;
- }
-
- @Test
- public void testDelete() {
- // public int delete(IResourceLocator locator) throws OseeCoreException;
- }
-
- // @org.junit.Test
- // public void testSaveAquireDelete() throws Exception {
- // InputStream inputStream = null;
- // IResourceLocator fileLocation = null;
- // IResourceLocator actual = null;
- // IResourceManager rm = resourceManager;
- // IResourceLocatorManager rlg = locatorManager;
- // try {
- // fileLocation = rlg.generateResourceLocator("attr", "123456", "TestFile.txt");
- //
- // IResource file = new Resource(testFileURL.toURI(), false);
- // actual = rm.save(fileLocation, file, new Options());
- // Assert.assertNotNull(actual);
- // IResource resource = rm.acquire(actual, new Options());
- // Assert.assertNotNull(resource);
- // inputStream = resource.getContent();
- // InputStreamReader reader = new InputStreamReader(inputStream);
- // char[] buffer = new char[inputStream.available()];
- // reader.read(buffer);
- // Assert.assertEquals(new String(buffer), "This is a test.");
- // } finally {
- // if (inputStream != null) {
- // inputStream.close();
- // }
- // }
- //
- // int code = rm.delete(actual);
- // Assert.assertTrue(code == IResourceManager.OK);
- // Assert.assertNull(rm.acquire(actual, new Options()));
- // }
- //
- // @org.junit.Test
- // public void testSaveAquireDeleteZipExtension() throws Exception {
- // InputStream inputStream = null;
- // IResourceLocator fileLocation = null;
- // IResourceLocator actual = null;
- // IResourceManager rm = resourceManager;
- // IResourceLocatorManager rlg = locatorManager;
- // try {
- // fileLocation = rlg.generateResourceLocator("attr", "123456", "TestFile.txt");
- //
- // IResource file = new Resource(testFileURL.toURI(), false);
- // Options options = new Options();
- // options.put(StandardOptions.CompressOnSave.name(), "true");
- //
- // actual = rm.save(fileLocation, file, options);
- // Assert.assertTrue(actual.getLocation().toASCIIString().contains("TestFile.txt.zip"));
- // Assert.assertNotNull(actual);
- // IResource resource = rm.acquire(actual, new Options());
- // Assert.assertNotNull(resource);
- // } finally {
- // if (inputStream != null) {
- // inputStream.close();
- // }
- // }
- //
- // int code = rm.delete(actual);
- // Assert.assertTrue(code == IResourceManager.OK);
- // Assert.assertNull(rm.acquire(actual, new Options()));
- // }
- //
- // @org.junit.Test
- // public void testListeners() throws Exception {
- // IResourceManager rm = resourceManager;
- // IResourceLocatorManager rlg = locatorManager;
- // TestResourceListener listener = new TestResourceListener();
- // rm.addResourceListener(listener);
- //
- // checkListener(listener, false, false, false);
- //
- // IResourceLocator fileLocation = rlg.generateResourceLocator("attr", "123456", "TestFile.txt");
- //
- // IResource file = new Resource(testFileURL.toURI(), false);
- //
- // IResourceLocator actual = rm.save(fileLocation, file, new Options());
- // Assert.assertNotNull(actual);
- //
- // checkListener(listener, false, true, false);
- //
- // listener.reset();
- // IResource resource = rm.acquire(fileLocation, new Options());
- // Assert.assertNotNull(resource);
- // checkListener(listener, true, false, false);
- //
- // listener.reset();
- // int code = rm.delete(actual);
- // Assert.assertTrue(code == IResourceManager.OK);
- // checkListener(listener, false, false, true);
- // Assert.assertNull(rm.acquire(fileLocation, new Options()));
- // }
- //
- // @org.junit.Test
- // public void testForFailOnOverwriteOfFile() throws Exception {
- // IResourceLocator fileLocation = null;
- // IResourceLocator actual = null;
- // IResourceManager rm = resourceManager;
- // IResourceLocatorManager rlg = locatorManager;
- // fileLocation = rlg.generateResourceLocator("attr", "123456", "TestFile.txt");
- // IResource file = new Resource(testFileURL.toURI(), false);
- // actual = rm.save(fileLocation, file, new Options());
- //
- // boolean overwrote = true;
- // try {
- // actual = rm.save(fileLocation, file, new Options());
- // } catch (OseeCoreException ex) {
- // overwrote = false;
- // }
- // Assert.assertFalse(overwrote);
- //
- // Options options = new Options();
- // options.put(StandardOptions.Overwrite.name(), true);
- // actual = rm.save(fileLocation, file, options);
- //
- // rm.delete(actual);
- //
- // Assert.assertFalse(rm.exists(actual));
- // }
-
- // private void checkListener(MockResourceListener listener, boolean acquire, boolean save, boolean delete) {
- // Assert.assertEquals(acquire, listener.isPostAcquire());
- // Assert.assertEquals(acquire, listener.isPreAcquire());
- // Assert.assertEquals(save, listener.isPreSave());
- // Assert.assertEquals(save, listener.isPostSave());
- // Assert.assertEquals(delete, listener.isPreDelete());
- // Assert.assertEquals(delete, listener.isPostDelete());
- // }
-
-}
+/******************************************************************************* + * 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.management.test; + +import org.eclipse.osee.framework.resource.management.IResourceListener; +import org.eclipse.osee.framework.resource.management.IResourceManager; +import org.eclipse.osee.framework.resource.management.IResourceProvider; +import org.eclipse.osee.framework.resource.management.internal.ResourceManager; +import org.eclipse.osee.framework.resource.management.test.mocks.MockResourceListener; +import org.eclipse.osee.framework.resource.management.test.mocks.ResourceProviderAdaptor; +import org.junit.Assert; +import org.junit.Test; + +/** + * Resource Manager Test {@link ResourceManager} + * + * @author Andrew M. Finkbeiner + */ +public class ResourceManagerTest { + + // private IResourceManager resourceManager; + // private IResourceLocatorManager locatorManager; + // + // private URL testFileURL; + // + // @Before + // public void setup() { + // resourceManager = new ResourceManager(); + // locatorManager = new ResourceLocatorManager(); + // testFileURL = + // getClass().getClassLoader().getResource("org/eclipse/osee/framework/resource/management/test/TestFile.txt"); + // } + + @Test + public void testAddRemoveProvider() { + IResourceManager resourceManagerX = new ResourceManager(); + IResourceProvider provider1 = new ResourceProviderAdaptor(); + Assert.assertTrue(resourceManagerX.addResourceProvider(provider1)); + Assert.assertFalse(resourceManagerX.addResourceProvider(provider1)); // Add again + Assert.assertTrue(resourceManagerX.removeResourceProvider(provider1)); + } + + @Test + public void testAddRemoveListener() { + IResourceManager resourceManagerX = new ResourceManager(); + IResourceListener listener = new MockResourceListener(); + Assert.assertTrue(resourceManagerX.addResourceListener(listener)); + Assert.assertFalse(resourceManagerX.addResourceListener(listener)); // Add again + Assert.assertTrue(resourceManagerX.removeResourceListener(listener)); + Assert.assertFalse(resourceManagerX.removeResourceListener(listener)); // Add again + } + + @Test + public void testExists() { + + // public boolean exists(IResourceLocator locator) throws OseeCoreException; + } + + @Test + public void testAcquire() { + // public IResource acquire(IResourceLocator locator, Options options) throws OseeCoreException; + } + + @Test + public void testSave() { + // public IResourceLocator save(final IResourceLocator locatorHint, final IResource resource, final Options options) throws OseeCoreException; + } + + @Test + public void testDelete() { + // public int delete(IResourceLocator locator) throws OseeCoreException; + } + + // @org.junit.Test + // public void testSaveAquireDelete() throws Exception { + // InputStream inputStream = null; + // IResourceLocator fileLocation = null; + // IResourceLocator actual = null; + // IResourceManager rm = resourceManager; + // IResourceLocatorManager rlg = locatorManager; + // try { + // fileLocation = rlg.generateResourceLocator("attr", "123456", "TestFile.txt"); + // + // IResource file = new Resource(testFileURL.toURI(), false); + // actual = rm.save(fileLocation, file, new Options()); + // Assert.assertNotNull(actual); + // IResource resource = rm.acquire(actual, new Options()); + // Assert.assertNotNull(resource); + // inputStream = resource.getContent(); + // InputStreamReader reader = new InputStreamReader(inputStream); + // char[] buffer = new char[inputStream.available()]; + // reader.read(buffer); + // Assert.assertEquals(new String(buffer), "This is a test."); + // } finally { + // if (inputStream != null) { + // inputStream.close(); + // } + // } + // + // int code = rm.delete(actual); + // Assert.assertTrue(code == IResourceManager.OK); + // Assert.assertNull(rm.acquire(actual, new Options())); + // } + // + // @org.junit.Test + // public void testSaveAquireDeleteZipExtension() throws Exception { + // InputStream inputStream = null; + // IResourceLocator fileLocation = null; + // IResourceLocator actual = null; + // IResourceManager rm = resourceManager; + // IResourceLocatorManager rlg = locatorManager; + // try { + // fileLocation = rlg.generateResourceLocator("attr", "123456", "TestFile.txt"); + // + // IResource file = new Resource(testFileURL.toURI(), false); + // Options options = new Options(); + // options.put(StandardOptions.CompressOnSave.name(), "true"); + // + // actual = rm.save(fileLocation, file, options); + // Assert.assertTrue(actual.getLocation().toASCIIString().contains("TestFile.txt.zip")); + // Assert.assertNotNull(actual); + // IResource resource = rm.acquire(actual, new Options()); + // Assert.assertNotNull(resource); + // } finally { + // if (inputStream != null) { + // inputStream.close(); + // } + // } + // + // int code = rm.delete(actual); + // Assert.assertTrue(code == IResourceManager.OK); + // Assert.assertNull(rm.acquire(actual, new Options())); + // } + // + // @org.junit.Test + // public void testListeners() throws Exception { + // IResourceManager rm = resourceManager; + // IResourceLocatorManager rlg = locatorManager; + // TestResourceListener listener = new TestResourceListener(); + // rm.addResourceListener(listener); + // + // checkListener(listener, false, false, false); + // + // IResourceLocator fileLocation = rlg.generateResourceLocator("attr", "123456", "TestFile.txt"); + // + // IResource file = new Resource(testFileURL.toURI(), false); + // + // IResourceLocator actual = rm.save(fileLocation, file, new Options()); + // Assert.assertNotNull(actual); + // + // checkListener(listener, false, true, false); + // + // listener.reset(); + // IResource resource = rm.acquire(fileLocation, new Options()); + // Assert.assertNotNull(resource); + // checkListener(listener, true, false, false); + // + // listener.reset(); + // int code = rm.delete(actual); + // Assert.assertTrue(code == IResourceManager.OK); + // checkListener(listener, false, false, true); + // Assert.assertNull(rm.acquire(fileLocation, new Options())); + // } + // + // @org.junit.Test + // public void testForFailOnOverwriteOfFile() throws Exception { + // IResourceLocator fileLocation = null; + // IResourceLocator actual = null; + // IResourceManager rm = resourceManager; + // IResourceLocatorManager rlg = locatorManager; + // fileLocation = rlg.generateResourceLocator("attr", "123456", "TestFile.txt"); + // IResource file = new Resource(testFileURL.toURI(), false); + // actual = rm.save(fileLocation, file, new Options()); + // + // boolean overwrote = true; + // try { + // actual = rm.save(fileLocation, file, new Options()); + // } catch (OseeCoreException ex) { + // overwrote = false; + // } + // Assert.assertFalse(overwrote); + // + // Options options = new Options(); + // options.put(StandardOptions.Overwrite.name(), true); + // actual = rm.save(fileLocation, file, options); + // + // rm.delete(actual); + // + // Assert.assertFalse(rm.exists(actual)); + // } + + // private void checkListener(MockResourceListener listener, boolean acquire, boolean save, boolean delete) { + // Assert.assertEquals(acquire, listener.isPostAcquire()); + // Assert.assertEquals(acquire, listener.isPreAcquire()); + // Assert.assertEquals(save, listener.isPreSave()); + // Assert.assertEquals(save, listener.isPostSave()); + // Assert.assertEquals(delete, listener.isPreDelete()); + // Assert.assertEquals(delete, listener.isPostDelete()); + // } + +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockLocatorProvider.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockLocatorProvider.java index e78b66338be..8590939e363 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockLocatorProvider.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockLocatorProvider.java @@ -1,47 +1,47 @@ -/*******************************************************************************
- * 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.management.test.mocks;
-
-import org.eclipse.osee.framework.resource.management.IResourceLocator;
-import org.eclipse.osee.framework.resource.management.IResourceLocatorProvider;
-import org.eclipse.osee.framework.resource.management.exception.MalformedLocatorException;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockLocatorProvider implements IResourceLocatorProvider {
-
- private final String protocolToMatch;
-
- public MockLocatorProvider(String protocolToMatch) {
- this.protocolToMatch = protocolToMatch;
- }
-
- @Override
- public IResourceLocator generateResourceLocator(String seed, String name) throws MalformedLocatorException {
- return new MockResourceLocator(getSupportedProtocol(), seed, name, null);
- }
-
- @Override
- public IResourceLocator getResourceLocator(String path) throws MalformedLocatorException {
- return new MockResourceLocator(getSupportedProtocol(), null, null, path);
- }
-
- @Override
- public boolean isValid(String protocol) {
- return protocol != null && protocol.startsWith(getSupportedProtocol());
- }
-
- @Override
- public String getSupportedProtocol() {
- return protocolToMatch;
- }
+/******************************************************************************* + * 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.management.test.mocks; + +import org.eclipse.osee.framework.resource.management.IResourceLocator; +import org.eclipse.osee.framework.resource.management.IResourceLocatorProvider; +import org.eclipse.osee.framework.resource.management.exception.MalformedLocatorException; + +/** + * @author Roberto E. Escobar + */ +public class MockLocatorProvider implements IResourceLocatorProvider { + + private final String protocolToMatch; + + public MockLocatorProvider(String protocolToMatch) { + this.protocolToMatch = protocolToMatch; + } + + @Override + public IResourceLocator generateResourceLocator(String seed, String name) throws MalformedLocatorException { + return new MockResourceLocator(getSupportedProtocol(), seed, name, null); + } + + @Override + public IResourceLocator getResourceLocator(String path) throws MalformedLocatorException { + return new MockResourceLocator(getSupportedProtocol(), null, null, path); + } + + @Override + public boolean isValid(String protocol) { + return protocol != null && protocol.startsWith(getSupportedProtocol()); + } + + @Override + public String getSupportedProtocol() { + return protocolToMatch; + } }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockResourceListener.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockResourceListener.java index 4daf3b5e777..c4dfa6d5324 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockResourceListener.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockResourceListener.java @@ -1,113 +1,113 @@ -/*******************************************************************************
- * 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.management.test.mocks;
-
-import org.eclipse.osee.framework.resource.management.IResource;
-import org.eclipse.osee.framework.resource.management.IResourceListener;
-import org.eclipse.osee.framework.resource.management.IResourceLocator;
-import org.eclipse.osee.framework.resource.management.Options;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockResourceListener implements IResourceListener {
- private boolean postAcquire;
- private boolean preAcquire;
- private boolean preSave;
- private boolean postSave;
- private boolean preDelete;
- private boolean postDelete;
- private IResource resource;
- private IResourceLocator locator;
-
- public MockResourceListener() {
- reset();
- }
-
- public void reset() {
- postAcquire = false;
- preAcquire = false;
- preSave = false;
- postSave = false;
- preDelete = false;
- postDelete = false;
- this.resource = null;
- this.locator = null;
- }
-
- @Override
- public void onPostAcquire(IResource resource) {
- postAcquire = true;
- this.resource = resource;
- }
-
- @Override
- public void onPreAcquire(IResourceLocator locator) {
- preAcquire = true;
- this.locator = locator;
- }
-
- @Override
- public void onPostDelete(IResourceLocator locator) {
- postDelete = true;
- this.locator = locator;
- }
-
- @Override
- public void onPostSave(IResourceLocator locator, IResource resource, Options options) {
- postSave = true;
- this.resource = resource;
- }
-
- @Override
- public void onPreDelete(IResourceLocator locator) {
- preDelete = true;
- this.locator = locator;
- }
-
- @Override
- public void onPreSave(IResourceLocator locator, IResource resource, Options options) {
- preSave = true;
- this.locator = locator;
- }
-
- public boolean isPostAcquire() {
- return postAcquire;
- }
-
- public boolean isPreAcquire() {
- return preAcquire;
- }
-
- public boolean isPreSave() {
- return preSave;
- }
-
- public boolean isPostSave() {
- return postSave;
- }
-
- public boolean isPreDelete() {
- return preDelete;
- }
-
- public boolean isPostDelete() {
- return postDelete;
- }
-
- public IResource getResource() {
- return resource;
- }
-
- public IResourceLocator getLocator() {
- return locator;
- }
-}
+/******************************************************************************* + * 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.management.test.mocks; + +import org.eclipse.osee.framework.resource.management.IResource; +import org.eclipse.osee.framework.resource.management.IResourceListener; +import org.eclipse.osee.framework.resource.management.IResourceLocator; +import org.eclipse.osee.framework.resource.management.Options; + +/** + * @author Roberto E. Escobar + */ +public class MockResourceListener implements IResourceListener { + private boolean postAcquire; + private boolean preAcquire; + private boolean preSave; + private boolean postSave; + private boolean preDelete; + private boolean postDelete; + private IResource resource; + private IResourceLocator locator; + + public MockResourceListener() { + reset(); + } + + public void reset() { + postAcquire = false; + preAcquire = false; + preSave = false; + postSave = false; + preDelete = false; + postDelete = false; + this.resource = null; + this.locator = null; + } + + @Override + public void onPostAcquire(IResource resource) { + postAcquire = true; + this.resource = resource; + } + + @Override + public void onPreAcquire(IResourceLocator locator) { + preAcquire = true; + this.locator = locator; + } + + @Override + public void onPostDelete(IResourceLocator locator) { + postDelete = true; + this.locator = locator; + } + + @Override + public void onPostSave(IResourceLocator locator, IResource resource, Options options) { + postSave = true; + this.resource = resource; + } + + @Override + public void onPreDelete(IResourceLocator locator) { + preDelete = true; + this.locator = locator; + } + + @Override + public void onPreSave(IResourceLocator locator, IResource resource, Options options) { + preSave = true; + this.locator = locator; + } + + public boolean isPostAcquire() { + return postAcquire; + } + + public boolean isPreAcquire() { + return preAcquire; + } + + public boolean isPreSave() { + return preSave; + } + + public boolean isPostSave() { + return postSave; + } + + public boolean isPreDelete() { + return preDelete; + } + + public boolean isPostDelete() { + return postDelete; + } + + public IResource getResource() { + return resource; + } + + public IResourceLocator getLocator() { + return locator; + } +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockResourceLocator.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockResourceLocator.java index 89cc0930986..0b07c8a4159 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockResourceLocator.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/MockResourceLocator.java @@ -1,55 +1,55 @@ -/*******************************************************************************
- * 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.management.test.mocks;
-
-import java.net.URI;
-import org.eclipse.osee.framework.resource.management.IResourceLocator;
-
-/**
- * @author Roberto E. Escobar
- */
-public class MockResourceLocator implements IResourceLocator {
- private final String protocolToMatch;
- private final String rawPath;
- private final String seed;
- private final String name;
-
- public MockResourceLocator(String protocolToMatch, String seed, String name, String rawPath) {
- this.protocolToMatch = protocolToMatch;
- this.seed = seed;
- this.name = name;
- this.rawPath = rawPath;
- }
-
- public String getSeed() {
- return seed;
- }
-
- public String getName() {
- return name;
- }
-
- @Override
- public URI getLocation() {
- return null;
- }
-
- @Override
- public String getProtocol() {
- return protocolToMatch;
- }
-
- @Override
- public String getRawPath() {
- return rawPath;
- }
-
+/******************************************************************************* + * 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.management.test.mocks; + +import java.net.URI; +import org.eclipse.osee.framework.resource.management.IResourceLocator; + +/** + * @author Roberto E. Escobar + */ +public class MockResourceLocator implements IResourceLocator { + private final String protocolToMatch; + private final String rawPath; + private final String seed; + private final String name; + + public MockResourceLocator(String protocolToMatch, String seed, String name, String rawPath) { + this.protocolToMatch = protocolToMatch; + this.seed = seed; + this.name = name; + this.rawPath = rawPath; + } + + public String getSeed() { + return seed; + } + + public String getName() { + return name; + } + + @Override + public URI getLocation() { + return null; + } + + @Override + public String getProtocol() { + return protocolToMatch; + } + + @Override + public String getRawPath() { + return rawPath; + } + }
\ No newline at end of file diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/ResourceProviderAdaptor.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/ResourceProviderAdaptor.java index 838cdd76598..8dff51088a4 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/ResourceProviderAdaptor.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/mocks/ResourceProviderAdaptor.java @@ -8,49 +8,49 @@ * Contributors: * Boeing - initial API and implementation *******************************************************************************/ -package org.eclipse.osee.framework.resource.management.test.mocks;
-
-import java.util.Collection;
-import java.util.Collections;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.resource.management.IResource;
-import org.eclipse.osee.framework.resource.management.IResourceLocator;
-import org.eclipse.osee.framework.resource.management.IResourceProvider;
-import org.eclipse.osee.framework.resource.management.Options;
-
-/**
- * @author Roberto E. Escobar
- */
-public class ResourceProviderAdaptor implements IResourceProvider {
-
- @Override
- public IResource acquire(IResourceLocator locator, Options options) throws OseeCoreException {
- return null;
- }
-
- @Override
- public int delete(IResourceLocator locator) throws OseeCoreException {
- return 0;
- }
-
- @Override
- public boolean exists(IResourceLocator locator) throws OseeCoreException {
- return false;
- }
-
- @Override
- public boolean isValid(IResourceLocator locator) {
- return false;
- }
-
- @Override
- public IResourceLocator save(IResourceLocator locator, IResource resource, Options options) throws OseeCoreException {
- return null;
- }
-
- @Override
- public Collection<String> getSupportedProtocols() {
- return Collections.emptyList();
- }
-
-}
+package org.eclipse.osee.framework.resource.management.test.mocks; + +import java.util.Collection; +import java.util.Collections; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.resource.management.IResource; +import org.eclipse.osee.framework.resource.management.IResourceLocator; +import org.eclipse.osee.framework.resource.management.IResourceProvider; +import org.eclipse.osee.framework.resource.management.Options; + +/** + * @author Roberto E. Escobar + */ +public class ResourceProviderAdaptor implements IResourceProvider { + + @Override + public IResource acquire(IResourceLocator locator, Options options) throws OseeCoreException { + return null; + } + + @Override + public int delete(IResourceLocator locator) throws OseeCoreException { + return 0; + } + + @Override + public boolean exists(IResourceLocator locator) throws OseeCoreException { + return false; + } + + @Override + public boolean isValid(IResourceLocator locator) { + return false; + } + + @Override + public IResourceLocator save(IResourceLocator locator, IResource resource, Options options) throws OseeCoreException { + return null; + } + + @Override + public Collection<String> getSupportedProtocols() { + return Collections.emptyList(); + } + +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/OptionsProcessorTest.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/OptionsProcessorTest.java index 86d04ec6d03..86747025603 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/OptionsProcessorTest.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/OptionsProcessorTest.java @@ -1,31 +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.management.test.util;
-
-import org.eclipse.osee.framework.resource.management.util.OptionsProcessor;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Test Cases for {@link OptionsProcessor}
- *
- * @author Roberto E. Escobar
- */
-public class OptionsProcessorTest {
-
- @Ignore
- @Test
- public void testOptionsProcessor() {
- Assert.fail("Error - implement this");
- }
-
-}
+/******************************************************************************* + * 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.management.test.util; + +import org.eclipse.osee.framework.resource.management.util.OptionsProcessor; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Test Cases for {@link OptionsProcessor} + * + * @author Roberto E. Escobar + */ +public class OptionsProcessorTest { + + @Ignore + @Test + public void testOptionsProcessor() { + Assert.fail("Error - implement this"); + } + +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceLocatorTest.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceLocatorTest.java index a9add3e1f10..00487d08fff 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceLocatorTest.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceLocatorTest.java @@ -1,82 +1,82 @@ -/*******************************************************************************
- * 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.management.test.util;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import org.eclipse.osee.framework.core.exception.OseeArgumentException;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.resource.management.IResourceLocator;
-import org.eclipse.osee.framework.resource.management.util.ResourceLocator;
-import org.junit.Assert;
-import org.junit.Test;
-
-/**
- * Test Cases for {@link ResourceLocator}
- *
- * @author Roberto E. Escobar
- */
-public class ResourceLocatorTest {
-
- @Test
- public void testGetRawPath() throws OseeCoreException {
- IResourceLocator locator = createLocator("http://blah/www.myuri.com");
- Assert.assertEquals("blah/www.myuri.com", locator.getRawPath());
-
- locator = createLocator("file://a/b/c/d/e/f/x");
- Assert.assertEquals("a/b/c/d/e/f/x", locator.getRawPath());
- }
-
- @Test
- public void testGetProtocol() throws OseeCoreException {
- IResourceLocator locator = createLocator("http://blah/www.myuri.com");
- Assert.assertEquals("http", locator.getProtocol());
-
- locator = createLocator("file://blah");
- Assert.assertEquals("file", locator.getProtocol());
-
- locator = createLocator("protocol://blah");
- Assert.assertEquals("protocol", locator.getProtocol());
- }
-
- @Test
- public void testGetLocation() throws OseeCoreException {
- IResourceLocator locator = createLocator("http://blah/www.myuri.com");
- Assert.assertEquals("http://blah/www.myuri.com", locator.getLocation().toASCIIString());
-
- locator = createLocator("protocol://a/b/c/d/e/f/location");
- Assert.assertEquals("protocol://a/b/c/d/e/f/location", locator.getLocation().toASCIIString());
-
- locator = createLocator("x://a/b/c/");
- Assert.assertEquals("x://a/b/c/", locator.getLocation().toASCIIString());
- }
-
- @Test
- public void testNull() {
- try {
- new ResourceLocator(null);
- } catch (OseeCoreException ex) {
- Assert.assertTrue(ex instanceof OseeArgumentException);
- }
- }
-
- private IResourceLocator createLocator(String path) throws OseeCoreException {
- IResourceLocator locator = null;
- try {
- URI uri = new URI(path);
- locator = new ResourceLocator(uri);
- } catch (URISyntaxException ex) {
- OseeExceptions.wrapAndThrow(ex);
- }
- return locator;
- }
-}
+/******************************************************************************* + * 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.management.test.util; + +import java.net.URI; +import java.net.URISyntaxException; +import org.eclipse.osee.framework.core.exception.OseeArgumentException; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.exception.OseeExceptions; +import org.eclipse.osee.framework.resource.management.IResourceLocator; +import org.eclipse.osee.framework.resource.management.util.ResourceLocator; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test Cases for {@link ResourceLocator} + * + * @author Roberto E. Escobar + */ +public class ResourceLocatorTest { + + @Test + public void testGetRawPath() throws OseeCoreException { + IResourceLocator locator = createLocator("http://blah/www.myuri.com"); + Assert.assertEquals("blah/www.myuri.com", locator.getRawPath()); + + locator = createLocator("file://a/b/c/d/e/f/x"); + Assert.assertEquals("a/b/c/d/e/f/x", locator.getRawPath()); + } + + @Test + public void testGetProtocol() throws OseeCoreException { + IResourceLocator locator = createLocator("http://blah/www.myuri.com"); + Assert.assertEquals("http", locator.getProtocol()); + + locator = createLocator("file://blah"); + Assert.assertEquals("file", locator.getProtocol()); + + locator = createLocator("protocol://blah"); + Assert.assertEquals("protocol", locator.getProtocol()); + } + + @Test + public void testGetLocation() throws OseeCoreException { + IResourceLocator locator = createLocator("http://blah/www.myuri.com"); + Assert.assertEquals("http://blah/www.myuri.com", locator.getLocation().toASCIIString()); + + locator = createLocator("protocol://a/b/c/d/e/f/location"); + Assert.assertEquals("protocol://a/b/c/d/e/f/location", locator.getLocation().toASCIIString()); + + locator = createLocator("x://a/b/c/"); + Assert.assertEquals("x://a/b/c/", locator.getLocation().toASCIIString()); + } + + @Test + public void testNull() { + try { + new ResourceLocator(null); + } catch (OseeCoreException ex) { + Assert.assertTrue(ex instanceof OseeArgumentException); + } + } + + private IResourceLocator createLocator(String path) throws OseeCoreException { + IResourceLocator locator = null; + try { + URI uri = new URI(path); + locator = new ResourceLocator(uri); + } catch (URISyntaxException ex) { + OseeExceptions.wrapAndThrow(ex); + } + return locator; + } +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceTest.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceTest.java index 42b2f13cef2..b126ec967c5 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceTest.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceTest.java @@ -1,80 +1,80 @@ -/*******************************************************************************
- * 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.management.test.util;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.osee.framework.resource.management.IResource;
-import org.eclipse.osee.framework.resource.management.util.Resource;
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-@RunWith(Parameterized.class)
-/**
- * Test Cases for {@link Resource}
- *
- * @author Roberto E. Escobar
- */
-public class ResourceTest {
-
- private IResource resource;
- private final String expectedName;
- private final boolean expectedCompressed;
- private final String rawPath;
-
- public ResourceTest(String rawPath, String expectedName, boolean expectedCompressed) {
- this.rawPath = rawPath;
- this.expectedName = expectedName;
- this.expectedCompressed = expectedCompressed;
- construct();
- }
-
- private void construct() {
- try {
- this.resource = new Resource(new URI(rawPath), expectedCompressed);
- } catch (Exception ex) {
- Assert.fail("Failed Resource creation");
- }
- Assert.assertNotNull(resource);
- }
-
- @Test
- public void testIsCompressed() throws IOException {
- Assert.assertEquals(expectedCompressed, resource.isCompressed());
- }
-
- @Test
- public void testGetName() throws IOException {
- Assert.assertEquals(expectedName, resource.getName());
- }
-
- @Test
- public void testGetLocation() throws IOException {
- Assert.assertEquals(rawPath, resource.getLocation().toASCIIString());
- }
-
- @Parameters
- public static Collection<Object[]> data() throws URISyntaxException {
- List<Object[]> data = new ArrayList<Object[]>();
- data.add(new Object[] {"file://1/sample.file", "sample.file", true});
- data.add(new Object[] {"http://www.url.com", "www.url.com", false,});
- data.add(new Object[] {"http://www.url.com/hello", "hello", false,});
-
- return data;
- }
-}
+/******************************************************************************* + * 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.management.test.util; + +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import org.eclipse.osee.framework.resource.management.IResource; +import org.eclipse.osee.framework.resource.management.util.Resource; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +@RunWith(Parameterized.class) +/** + * Test Cases for {@link Resource} + * + * @author Roberto E. Escobar + */ +public class ResourceTest { + + private IResource resource; + private final String expectedName; + private final boolean expectedCompressed; + private final String rawPath; + + public ResourceTest(String rawPath, String expectedName, boolean expectedCompressed) { + this.rawPath = rawPath; + this.expectedName = expectedName; + this.expectedCompressed = expectedCompressed; + construct(); + } + + private void construct() { + try { + this.resource = new Resource(new URI(rawPath), expectedCompressed); + } catch (Exception ex) { + Assert.fail("Failed Resource creation"); + } + Assert.assertNotNull(resource); + } + + @Test + public void testIsCompressed() throws IOException { + Assert.assertEquals(expectedCompressed, resource.isCompressed()); + } + + @Test + public void testGetName() throws IOException { + Assert.assertEquals(expectedName, resource.getName()); + } + + @Test + public void testGetLocation() throws IOException { + Assert.assertEquals(rawPath, resource.getLocation().toASCIIString()); + } + + @Parameters + public static Collection<Object[]> data() throws URISyntaxException { + List<Object[]> data = new ArrayList<Object[]>(); + data.add(new Object[] {"file://1/sample.file", "sample.file", true}); + data.add(new Object[] {"http://www.url.com", "www.url.com", false,}); + data.add(new Object[] {"http://www.url.com/hello", "hello", false,}); + + return data; + } +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceUtilTestSuite.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceUtilTestSuite.java index 6fc9bbf0c8f..af57483edd8 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceUtilTestSuite.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourceUtilTestSuite.java @@ -1,23 +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.management.test.util;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-@RunWith(Suite.class)
-@Suite.SuiteClasses( {ResourceTest.class, ResourceLocatorTest.class, ResourcesTest.class, OptionsProcessorTest.class})
-/**
- * @author Roberto E. Escobar
- */
-public class ResourceUtilTestSuite {
-
-}
+/******************************************************************************* + * 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.management.test.util; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; + +@RunWith(Suite.class) +@Suite.SuiteClasses( {ResourceTest.class, ResourceLocatorTest.class, ResourcesTest.class, OptionsProcessorTest.class}) +/** + * @author Roberto E. Escobar + */ +public class ResourceUtilTestSuite { + +} diff --git a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourcesTest.java b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourcesTest.java index 734e565b958..3844e77e8b0 100644 --- a/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourcesTest.java +++ b/plugins/org.eclipse.osee.framework.resource.management.test/src/org/eclipse/osee/framework/resource/management/test/util/ResourcesTest.java @@ -1,69 +1,69 @@ -/*******************************************************************************
- * 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.management.test.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import org.eclipse.osee.framework.core.exception.OseeCoreException;
-import org.eclipse.osee.framework.core.exception.OseeExceptions;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.resource.management.IResource;
-import org.eclipse.osee.framework.resource.management.internal.CompressedResourceBridge;
-import org.eclipse.osee.framework.resource.management.util.Resources;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-/**
- * Test Cases for {@link Resources} {@link CompressedResourceBridge}
- *
- * @author Roberto E. Escobar
- */
-public class ResourcesTest {
-
- @Test
- public void testResourceFromBytes() throws OseeCoreException {
- checkResourceFromBytes("file://myfile.txt", "myfile.txt", false, new byte[] {0, 1, 2, 3});
- checkResourceFromBytes("http://a/b/c/d/e/file.zip", "file.zip", true, new byte[] {4, 5, 6, 7, 8, 9});
- }
-
- @Ignore
- @Test
- public void testCompressResource() {
- Assert.fail("Error - implement this");
- // Resources.compressResource(resource)
- // Resources.decompressResource(resource)
- }
-
- @Ignore
- @Test
- public void testDeCompressResource() {
- Assert.fail("Error - implement this");
- // Resources.compressResource(resource)
- }
-
- private void checkResourceFromBytes(String path, String name, boolean isCompressed, byte[] data) throws OseeCoreException {
- IResource resource = Resources.createResourceFromBytes(data, path, isCompressed);
- Assert.assertEquals(isCompressed, resource.isCompressed());
- Assert.assertEquals(path, resource.getLocation().toASCIIString());
- Assert.assertEquals(name, resource.getName());
- InputStream inputStream = null;
- try {
- inputStream = resource.getContent();
- byte[] actuals = Lib.inputStreamToBytes(inputStream);
- Assert.assertArrayEquals(data, actuals);
- } catch (IOException ex) {
- OseeExceptions.wrapAndThrow(ex);
- } finally {
- Lib.close(inputStream);
- }
- }
-}
+/******************************************************************************* + * 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.management.test.util; + +import java.io.IOException; +import java.io.InputStream; +import org.eclipse.osee.framework.core.exception.OseeCoreException; +import org.eclipse.osee.framework.core.exception.OseeExceptions; +import org.eclipse.osee.framework.jdk.core.util.Lib; +import org.eclipse.osee.framework.resource.management.IResource; +import org.eclipse.osee.framework.resource.management.internal.CompressedResourceBridge; +import org.eclipse.osee.framework.resource.management.util.Resources; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Test Cases for {@link Resources} {@link CompressedResourceBridge} + * + * @author Roberto E. Escobar + */ +public class ResourcesTest { + + @Test + public void testResourceFromBytes() throws OseeCoreException { + checkResourceFromBytes("file://myfile.txt", "myfile.txt", false, new byte[] {0, 1, 2, 3}); + checkResourceFromBytes("http://a/b/c/d/e/file.zip", "file.zip", true, new byte[] {4, 5, 6, 7, 8, 9}); + } + + @Ignore + @Test + public void testCompressResource() { + Assert.fail("Error - implement this"); + // Resources.compressResource(resource) + // Resources.decompressResource(resource) + } + + @Ignore + @Test + public void testDeCompressResource() { + Assert.fail("Error - implement this"); + // Resources.compressResource(resource) + } + + private void checkResourceFromBytes(String path, String name, boolean isCompressed, byte[] data) throws OseeCoreException { + IResource resource = Resources.createResourceFromBytes(data, path, isCompressed); + Assert.assertEquals(isCompressed, resource.isCompressed()); + Assert.assertEquals(path, resource.getLocation().toASCIIString()); + Assert.assertEquals(name, resource.getName()); + InputStream inputStream = null; + try { + inputStream = resource.getContent(); + byte[] actuals = Lib.inputStreamToBytes(inputStream); + Assert.assertArrayEquals(data, actuals); + } catch (IOException ex) { + OseeExceptions.wrapAndThrow(ex); + } finally { + Lib.close(inputStream); + } + } +} |