1 19 20 package org.netbeans.modules.autoupdate; 21 22 import java.io.File ; 23 import java.util.List ; 24 import junit.framework.TestCase; 25 import org.netbeans.junit.NbTestCase; 26 import org.netbeans.updater.UpdateTracking; 27 28 32 public class AutoupdaterTest extends NbTestCase { 33 34 private File platformDir; 35 36 private File userDir; 37 38 private File filesDir; 39 40 private File strangeDir; 41 42 public AutoupdaterTest (String testName) { 43 super (testName); 44 } 45 46 protected void setUp () throws Exception { 47 super.setUp (); 48 49 this.clearWorkDir(); 51 52 platformDir = new File (getWorkDir(), "platform"); 53 assertTrue (platformDir.mkdirs ()); 54 filesDir = new File (getWorkDir(), "program files"); 55 assertTrue (filesDir.mkdirs ()); 56 userDir = new File (getWorkDir(), "documents and settings"); 57 assertTrue (userDir.mkdirs ()); 58 strangeDir = new File (getWorkDir(), "strange"); 59 assertTrue (strangeDir.mkdirs ()); 60 61 System.setProperty("netbeans.dirs", filesDir.toString ()); 62 System.setProperty("netbeans.home", platformDir.toString ()); 63 assertEquals (platformDir.toString (), System.getProperty ("netbeans.home")); 64 System.setProperty("netbeans.user", userDir.toString ()); 65 assertEquals (userDir.toString (), System.getProperty ("netbeans.user")); 66 } 67 68 public void testGetClustersWithUser () throws Exception { 69 List l = UpdateTracking.clusters (true); 70 assertTrue (platformDir + " among clusters " + l, l.contains (platformDir)); 71 assertTrue (filesDir + " among clusters " + l, l.contains (filesDir)); 72 assertTrue (userDir + " among clusters " + l, l.contains (userDir)); 73 assertFalse (strangeDir + " is not among clusters " + l, l.contains (strangeDir)); 74 } 75 76 public void testGetClustersWithoutUser () throws Exception { 77 List l = UpdateTracking.clusters (false); 78 assertTrue (platformDir + " among clusters " + l, l.contains (platformDir)); 79 assertTrue (filesDir + " among clusters " + l, l.contains (filesDir)); 80 assertFalse (userDir + " is not among clusters " + l, l.contains (userDir)); 81 assertFalse (strangeDir + " is not among clusters " + l, l.contains (strangeDir)); 82 } 83 84 public void testPatchesDir () throws Exception { 85 List l = Autoupdater.Support.getPatchDirectories (); 86 File platformDirPatches = new File (new File (platformDir, "lib"), "patches"); 87 File userDirPatches = new File (new File (userDir, "lib"), "patches"); 88 File filesDirPatches = new File (new File (filesDir, "lib"), "patches"); 89 File strangeDirPatches = new File (new File (strangeDir, "lib"), "patches"); 90 assertTrue (platformDirPatches + " among patches dirs " + l, l.contains (platformDirPatches)); 91 assertTrue (filesDirPatches + " among patches dirs " + l, l.contains (filesDirPatches)); 92 assertTrue (userDirPatches + " among patches dirs " + l, l.contains (userDirPatches)); 93 assertFalse (strangeDirPatches + " is not among patches dirs " + l, l.contains (strangeDirPatches)); 94 } 95 } 96 | Popular Tags |