Revision: 5898
          http://jnode.svn.sourceforge.net/jnode/?rev=5898&view=rev
Author:   galatnm
Date:     2012-04-27 06:53:38 +0000 (Fri, 27 Apr 2012)
Log Message:
-----------
Add basic unit tests for FileSystemManager.

Modified Paths:
--------------
    trunk/JNode.ipr
    trunk/fs/.classpath

Added Paths:
-----------
    trunk/fs/src/test/org/jnode/fs/service/
    trunk/fs/src/test/org/jnode/fs/service/def/
    trunk/fs/src/test/org/jnode/fs/service/def/FileSystemManagerTest.java

Modified: trunk/JNode.ipr
===================================================================
--- trunk/JNode.ipr     2012-04-19 15:52:49 UTC (rev 5897)
+++ trunk/JNode.ipr     2012-04-27 06:53:38 UTC (rev 5898)
@@ -186,6 +186,7 @@
   <component name="CopyrightManager" default="">
     <module2copyright />
   </component>
+  <component name="CppTools.Loader" reportImplicitCastToBool="false" 
reportNameReferencedOnce="false" warnedAboutFileOutOfSourceRoot="true" 
version="3" compilerSelect="AUTO" />
   <component name="DependenciesAnalyzeManager">
     <option name="myForwardDirection" value="false" />
   </component>
@@ -364,6 +365,99 @@
       </item>
     </group>
   </component>
+  <component name="ProjectCodeStyleSettingsManager">
+    <option name="PER_PROJECT_SETTINGS">
+      <value>
+        <option name="JAVA_INDENT_OPTIONS">
+          <value>
+            <option name="INDENT_SIZE" value="4" />
+            <option name="CONTINUATION_INDENT_SIZE" value="4" />
+            <option name="TAB_SIZE" value="4" />
+            <option name="USE_TAB_CHARACTER" value="false" />
+            <option name="SMART_TABS" value="false" />
+            <option name="LABEL_INDENT_SIZE" value="-4" />
+            <option name="LABEL_INDENT_ABSOLUTE" value="false" />
+            <option name="USE_RELATIVE_INDENTS" value="false" />
+          </value>
+        </option>
+        <option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
+        <option name="NAMES_COUNT_TO_USE_IMPORT_ON_DEMAND" value="100" />
+        <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
+          <value />
+        </option>
+        <option name="IMPORT_LAYOUT_TABLE">
+          <value>
+            <package name="" withSubpackages="true" static="false" />
+            <emptyLine />
+            <package name="javax" withSubpackages="false" static="false" />
+            <package name="java" withSubpackages="false" static="false" />
+            <emptyLine />
+            <package name="" withSubpackages="true" static="true" />
+          </value>
+        </option>
+        <option name="CALL_PARAMETERS_WRAP" value="1" />
+        <option name="METHOD_PARAMETERS_WRAP" value="1" />
+        <option name="THROWS_LIST_WRAP" value="1" />
+        <option name="EXTENDS_KEYWORD_WRAP" value="1" />
+        <option name="THROWS_KEYWORD_WRAP" value="1" />
+        <option name="METHOD_CALL_CHAIN_WRAP" value="1" />
+        <option name="BINARY_OPERATION_WRAP" value="1" />
+        <option name="TERNARY_OPERATION_WRAP" value="1" />
+        <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+        <option name="ASSIGNMENT_WRAP" value="1" />
+        <XML>
+          <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
+        </XML>
+        <ADDITIONAL_INDENT_OPTIONS fileType="gsp">
+          <option name="INDENT_SIZE" value="2" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="scala">
+          <option name="INDENT_SIZE" value="2" />
+          <option name="TAB_SIZE" value="2" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="sql">
+          <option name="INDENT_SIZE" value="2" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <ADDITIONAL_INDENT_OPTIONS fileType="yml">
+          <option name="INDENT_SIZE" value="2" />
+        </ADDITIONAL_INDENT_OPTIONS>
+        <codeStyleSettings language="Groovy">
+          <option name="CALL_PARAMETERS_WRAP" value="1" />
+          <option name="METHOD_PARAMETERS_WRAP" value="1" />
+          <option name="THROWS_LIST_WRAP" value="1" />
+          <option name="EXTENDS_KEYWORD_WRAP" value="1" />
+          <option name="THROWS_KEYWORD_WRAP" value="1" />
+          <option name="METHOD_CALL_CHAIN_WRAP" value="1" />
+          <option name="BINARY_OPERATION_WRAP" value="1" />
+          <option name="TERNARY_OPERATION_WRAP" value="1" />
+          <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+          <option name="ASSIGNMENT_WRAP" value="1" />
+          <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+          <indentOptions>
+            <option name="INDENT_SIZE" value="2" />
+          </indentOptions>
+        </codeStyleSettings>
+        <codeStyleSettings language="JAVA">
+          <option name="CALL_PARAMETERS_WRAP" value="1" />
+          <option name="METHOD_PARAMETERS_WRAP" value="1" />
+          <option name="THROWS_LIST_WRAP" value="1" />
+          <option name="EXTENDS_KEYWORD_WRAP" value="1" />
+          <option name="THROWS_KEYWORD_WRAP" value="1" />
+          <option name="METHOD_CALL_CHAIN_WRAP" value="1" />
+          <option name="BINARY_OPERATION_WRAP" value="1" />
+          <option name="TERNARY_OPERATION_WRAP" value="1" />
+          <option name="ARRAY_INITIALIZER_WRAP" value="1" />
+          <option name="ASSIGNMENT_WRAP" value="1" />
+          <option name="PARENT_SETTINGS_INSTALLED" value="true" />
+          <indentOptions>
+            <option name="CONTINUATION_INDENT_SIZE" value="4" />
+            <option name="LABEL_INDENT_SIZE" value="-4" />
+          </indentOptions>
+        </codeStyleSettings>
+      </value>
+    </option>
+    <option name="USE_PER_PROJECT_SETTINGS" value="true" />
+  </component>
   <component name="ProjectDetails">
     <option name="projectName" value="JNode" />
   </component>
@@ -389,7 +483,7 @@
   <component name="ProjectResources">
     <default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
   </component>
-  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" 
assert-keyword="true" jdk-15="true" project-jdk-name="1.6 - jnode" 
project-jdk-type="JavaSDK" />
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" 
assert-keyword="true" jdk-15="true" project-jdk-name="1.6" 
project-jdk-type="JavaSDK" />
   <component name="ResourceManagerContainer">
     <option name="myResourceBundles">
       <value>
@@ -403,20 +497,6 @@
         <entry key="$PROJECT_DIR$">
           <value>
             <SvnBranchConfiguration>
-              <option name="branchMap">
-                <map>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/branches";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/tags";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                </map>
-              </option>
               <option name="branchUrls">
                 <list>
                   <option 
value="https://jnode.svn.sourceforge.net/svnroot/jnode/branches"; />
@@ -430,25 +510,6 @@
         <entry key="$PROJECT_DIR$/distr">
           <value>
             <SvnBranchConfiguration>
-              <option name="branchMap">
-                <map>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/branches";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/classlib6";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/tags";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                </map>
-              </option>
               <option name="branchUrls">
                 <list>
                   <option 
value="https://jnode.svn.sourceforge.net/svnroot/jnode/branches"; />
@@ -463,25 +524,6 @@
         <entry key="$PROJECT_DIR$/gui">
           <value>
             <SvnBranchConfiguration>
-              <option name="branchMap">
-                <map>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/branches";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/classlib6";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/tags";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                </map>
-              </option>
               <option name="branchUrls">
                 <list>
                   <option 
value="https://jnode.svn.sourceforge.net/svnroot/jnode/branches"; />
@@ -496,25 +538,6 @@
         <entry key="$PROJECT_DIR$/net">
           <value>
             <SvnBranchConfiguration>
-              <option name="branchMap">
-                <map>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/branches";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/classlib6";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                  <entry 
key="https://jnode.svn.sourceforge.net/svnroot/jnode/tags";>
-                    <value>
-                      <list />
-                    </value>
-                  </entry>
-                </map>
-              </option>
               <option name="branchUrls">
                 <list>
                   <option 
value="https://jnode.svn.sourceforge.net/svnroot/jnode/branches"; />

Modified: trunk/fs/.classpath
===================================================================
--- trunk/fs/.classpath 2012-04-19 15:52:49 UTC (rev 5897)
+++ trunk/fs/.classpath 2012-04-27 06:53:38 UTC (rev 5898)
@@ -17,5 +17,6 @@
        <classpathentry kind="lib" path="/core/lib/log4j-1.2.8.jar"/>
        <classpathentry kind="lib" path="/core/lib/junit-4.5.jar"/>
        <classpathentry kind="lib" path="/all/lib/classlib.jar" 
sourcepath="/all/lib/classlib-src.jar"/>
+       <classpathentry kind="lib" path="/core/lib/mockito-all-1.8.5.jar"/>
        <classpathentry kind="output" path="build/classes"/>
 </classpath>

Added: trunk/fs/src/test/org/jnode/fs/service/def/FileSystemManagerTest.java
===================================================================
--- trunk/fs/src/test/org/jnode/fs/service/def/FileSystemManagerTest.java       
                        (rev 0)
+++ trunk/fs/src/test/org/jnode/fs/service/def/FileSystemManagerTest.java       
2012-04-27 06:53:38 UTC (rev 5898)
@@ -0,0 +1,58 @@
+package org.jnode.fs.service.def;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertNotNull;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Collection;
+
+import org.jnode.driver.Device;
+import org.jnode.fs.FileSystem;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FileSystemManagerTest {
+
+    private FileSystemManager fsm;
+    private FileSystem<?> fs;
+    private Device device;
+
+    @Before
+    public void setUp() throws Exception {
+        fsm = new FileSystemManager();
+        device = mock(Device.class);
+        fs = mock(FileSystem.class);
+        when(fs.getDevice()).thenReturn(device);
+    }
+
+    @Test
+    public void testUnregisterFileSystem() throws Exception {
+       fsm.registerFileSystem(fs);
+       FileSystem<?> result = fsm.unregisterFileSystem(device);
+        assertNotNull(result);
+    }
+
+    @Test
+    public void testGetFileSystem() throws Exception {
+       fsm.registerFileSystem(fs);
+       FileSystem<?> result = fsm.getFileSystem(device);
+       assertNotNull(result);
+    }
+
+    @Test
+    public void testFileSystems() throws Exception {
+       fsm.registerFileSystem(fs);
+        Collection<FileSystem<?>> result = fsm.fileSystems();
+        assertNotNull(result);
+        assertEquals(1,result.size());
+        
+        fsm.unregisterFileSystem(device);
+        
+        result = fsm.fileSystems();
+        assertNotNull(result);
+        assertEquals(0,result.size());
+    }
+    
+    
+}

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Jnode-svn-commits mailing list
Jnode-svn-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits

Reply via email to