summaryrefslogtreecommitdiffstats
path: root/src/com.gluster.storage.management.core/junit
diff options
context:
space:
mode:
authorShireesh Anjal <anjalshireesh@gmail.com>2011-03-28 06:58:51 -0700
committerShireesh Anjal <anjalshireesh@gmail.com>2011-03-28 06:58:51 -0700
commitbf531d097bc99db08bda4d1a1dec541c57c7933c (patch)
tree253a3fc82d5bac3755fc7e32f8456879b69b9979 /src/com.gluster.storage.management.core/junit
parentb27c5d68d3ffa47c92e0fcd7d0873ac2d6b8fca8 (diff)
Preparing src for migration to github
Diffstat (limited to 'src/com.gluster.storage.management.core/junit')
-rw-r--r--src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java84
-rw-r--r--src/com.gluster.storage.management.core/junit/core.junit.launch15
-rw-r--r--src/com.gluster.storage.management.core/junit/test/test.txt1
3 files changed, 100 insertions, 0 deletions
diff --git a/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java
new file mode 100644
index 00000000..8902ae8f
--- /dev/null
+++ b/src/com.gluster.storage.management.core/junit/com/gluster/storage/management/core/utils/TestFileUtil.java
@@ -0,0 +1,84 @@
+/**
+ * TestFileUtil.java
+ *
+ * Copyright (c) 2011 Gluster, Inc. <http://www.gluster.com>
+ * This file is part of Gluster Management Console.
+ *
+ * Gluster Management Console is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Gluster Management Console is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+package com.gluster.storage.management.core.utils;
+
+import static org.junit.Assert.assertTrue;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.OutputStreamWriter;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class TestFileUtil {
+ private String testFileName;
+ private String fileContent;
+ private FileUtil fileUtil;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ testFileName = "testFileUtil.txt";
+ fileContent = "Testing FileUtil class.";
+ fileUtil = new FileUtil();
+
+ BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(testFileName));
+ OutputStreamWriter writer = new OutputStreamWriter(outStream);
+ writer.write(fileContent);
+ writer.close();
+ outStream.close();
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ File testFile = new File(testFileName);
+ testFile.delete();
+ }
+
+ /**
+ * Test method for {@link com.gluster.storage.management.core.utils.FileUtil#readFileAsString(java.io.File)}.
+ */
+ @Test
+ public final void testReadFileAsString() {
+ String readContent = fileUtil.readFileAsString(new File(testFileName));
+ assertTrue("File contents expected [" + fileContent + "], actual [" + readContent + "]",
+ readContent.equals(fileContent));
+ }
+
+ /**
+ * Test method for {@link com.gluster.storage.management.core.utils.FileUtil#loadResource(java.lang.String)}.
+ */
+ @Test
+ public final void testLoadResource() {
+ InputStream inputStream = fileUtil.loadResource("test/test.txt");
+ Assert.assertNotNull(inputStream);
+ }
+}
diff --git a/src/com.gluster.storage.management.core/junit/core.junit.launch b/src/com.gluster.storage.management.core/junit/core.junit.launch
new file mode 100644
index 00000000..0bf6dc30
--- /dev/null
+++ b/src/com.gluster.storage.management.core/junit/core.junit.launch
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
+<listEntry value="/com.gluster.storage.management.core"/>
+</listAttribute>
+<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
+<listEntry value="4"/>
+</listAttribute>
+<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=com.gluster.storage.management.core"/>
+<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
+<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
+<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
+<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
+<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.gluster.storage.management.core"/>
+</launchConfiguration>
diff --git a/src/com.gluster.storage.management.core/junit/test/test.txt b/src/com.gluster.storage.management.core/junit/test/test.txt
new file mode 100644
index 00000000..267ce144
--- /dev/null
+++ b/src/com.gluster.storage.management.core/junit/test/test.txt
@@ -0,0 +1 @@
+Test Resource \ No newline at end of file