Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2011-05-12 11:28:31 -0400
committerRyan D. Brooks2011-05-12 11:28:31 -0400
commit9f1cfdb6a8bc361ebd6f6ce48dd50daea1fb473c (patch)
tree6a217db3ee11799ece13ac7b26378dad160f8e4d /plugins/org.eclipse.osee.framework.skynet.core.test
parent3ba1e25f8586cb7ad79b61d9dbd0bf55a8100e08 (diff)
downloadorg.eclipse.osee-9f1cfdb6a8bc361ebd6f6ce48dd50daea1fb473c.tar.gz
org.eclipse.osee-9f1cfdb6a8bc361ebd6f6ce48dd50daea1fb473c.tar.xz
org.eclipse.osee-9f1cfdb6a8bc361ebd6f6ce48dd50daea1fb473c.zip
refactor: Utilize utility method Lib.fileToString instead of in-place code
Diffstat (limited to 'plugins/org.eclipse.osee.framework.skynet.core.test')
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMLExtractorDelegateTableOfContentsTest.java25
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMlResolutionGuiTest.java19
-rw-r--r--plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java19
3 files changed, 5 insertions, 58 deletions
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMLExtractorDelegateTableOfContentsTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMLExtractorDelegateTableOfContentsTest.java
index edd94cba1c..66064abb43 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMLExtractorDelegateTableOfContentsTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMLExtractorDelegateTableOfContentsTest.java
@@ -10,11 +10,8 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.importing.parsers;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.eclipse.osee.framework.core.operation.StringOperationLogger;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.junit.Assert;
@@ -39,7 +36,7 @@ public final class WordMLExtractorDelegateTableOfContentsTest {
StringOperationLogger logger = new StringOperationLogger();
- Matcher matcher = PARAGRAPHREGEX.matcher(getFileAsString(TABLE_OF_CONTENTS_FILE));
+ Matcher matcher = PARAGRAPHREGEX.matcher(Lib.fileToString(getClass(), TABLE_OF_CONTENTS_FILE));
boolean foundSomething = false;
while (matcher.find()) {
foundSomething = true;
@@ -50,22 +47,4 @@ public final class WordMLExtractorDelegateTableOfContentsTest {
logger.toString().isEmpty());
Assert.assertTrue(foundSomething);
}
-
- private static String getFileAsString(String nameOfFile) {
- StringBuilder buffer = new StringBuilder();
- InputStream inputStream = null;
- try {
- inputStream = WordMLExtractorDelegateTableOfContentsTest.class.getResourceAsStream(TABLE_OF_CONTENTS_FILE);
- buffer.append(Lib.inputStreamToString(inputStream));
- Assert.assertTrue(buffer.length() != 0);
- } catch (IOException ex) {
- Assert.assertTrue(String.format("%s something when wrong while reading a file...",
- WordMLExtractorDelegateTableOfContentsTest.class.getName()), true);
- } finally {
- Lib.close(inputStream);
- }
-
- return buffer.toString();
- }
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMlResolutionGuiTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMlResolutionGuiTest.java
index b5d95fbbba..39d4349559 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMlResolutionGuiTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordMlResolutionGuiTest.java
@@ -10,13 +10,9 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.importing.parsers;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-
import org.eclipse.osee.framework.jdk.core.util.Lib;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.framework.skynet.core.importing.RoughArtifact;
import org.eclipse.osee.framework.skynet.core.importing.RoughArtifactKind;
import org.eclipse.osee.framework.skynet.core.importing.operations.RoughArtifactCollector;
@@ -65,7 +61,7 @@ public class WordMlResolutionGuiTest {
resolvingGui.setMockUserAnswer(ContentType.CONTENT);
//pre load with some real data
- String rawData = getResourceData(FILE_INPUT);
+ String rawData = Lib.fileToString(getClass(), FILE_INPUT);
Matcher matcher = PARAGRAPH_REGEX.matcher(rawData);
boolean foundSomething = false;
matcher.find();//skip 1.0
@@ -93,17 +89,4 @@ public class WordMlResolutionGuiTest {
Assert.assertNull(delegate.getLastHeaderName());
Assert.assertNull(delegate.getLastContent());
}
-
- private static String getResourceData(String name) throws IOException {
-
- InputStream inputStream = null;
- try {
- inputStream = WordMlResolutionGuiTest.class.getResourceAsStream(name);
- String data = Lib.inputStreamToString(inputStream);
- Assert.assertTrue(Strings.isValid(data));
- return data;
- } finally {
- Lib.close(inputStream);
- }
- }
}
diff --git a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java
index baa5aa9822..6545e22ef7 100644
--- a/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java
+++ b/plugins/org.eclipse.osee.framework.skynet.core.test/src/org/eclipse/osee/framework/skynet/core/importing/parsers/WordOutlineTest.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.framework.skynet.core.importing.parsers;
-import java.io.IOException;
-import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -56,7 +54,7 @@ public final class WordOutlineTest {
/**
* Note: some of the data objects need to repeat data from previous test because they are considered to be
* lastHeaderNumber or lastHeaderName or lastContent
- *
+ *
* @return collection of data sets used as input for parameterized unit test
*/
@Parameters
@@ -81,7 +79,7 @@ public final class WordOutlineTest {
public void testDelegate() throws Exception {
delegate.initialize();
- String rawData = getResourceData(dataFileName);
+ String rawData = Lib.fileToString(getClass(), dataFileName);
Matcher matcher = PARAGRAPH_REGEX.matcher(rawData);
boolean foundSomething = false;
@@ -131,19 +129,6 @@ public final class WordOutlineTest {
return new DelegateData(headerNumber, headerName, content);
}
- private static String getResourceData(String name) throws IOException {
- InputStream inputStream = null;
- String data;
- try {
- inputStream = WordOutlineTest.class.getResourceAsStream(name);
- data = Lib.inputStreamToString(inputStream);
- Assert.assertTrue(Strings.isValid(data));
- } finally {
- Lib.close(inputStream);
- }
- return data;
- }
-
private static final class DelegateData {
private final String headerNumber;
private final String headerName;

Back to the top