1 7 package com.inversoft.savant.test; 8 9 10 import java.io.File ; 11 import java.net.MalformedURLException ; 12 13 import junit.framework.TestCase; 14 15 import com.inversoft.savant.Artifact; 16 import com.inversoft.savant.LocalCacheStore; 17 import com.inversoft.savant.SavantInternetProcess; 18 19 20 27 public class SavantInternetProcessTest extends TestCase { 28 29 32 public SavantInternetProcessTest(String name) { 33 super(name); 34 } 35 36 37 public void testProcess() throws Exception { 38 Artifact artifact = new Artifact(); 39 artifact.setGroup("my_group"); 40 artifact.setName("my_name"); 41 artifact.setProjectname("my_project"); 42 artifact.setType("exe"); 43 artifact.setVersion("2.0"); 44 45 LocalCacheStore store = new LocalCacheStore(new File ("test/cache")); 46 store.delete(artifact); 47 48 SavantInternetProcess sip = new SavantInternetProcess(); 49 sip.setDefaultdomain(makeCurDirURL() + "/test/savant"); 50 File file = sip.fetch(artifact, store); 51 assertNotNull(file); 52 53 String expected = makeCurDirURL() + "/test/cache/my_group/my_project/my_name-2.0.exe"; 54 System.out.println("Expected " + expected); 55 System.out.println("Actual " + file.toURL()); 56 assertEquals(expected, file.toURL().toString()); 57 } 58 59 public void testMD5Check() throws Exception { 60 Artifact artifact = new Artifact(); 61 artifact.setGroup("my_group"); 62 artifact.setName("my_md5_artifact"); 63 artifact.setProjectname("my_project"); 64 artifact.setType("jar"); 65 artifact.setVersion("2.0"); 66 67 LocalCacheStore store = new LocalCacheStore(new File ("test/cache")); 68 store.delete(artifact); 69 70 SavantInternetProcess sip = new SavantInternetProcess(); 71 sip.setDefaultdomain(makeCurDirURL() + "/test/savant"); 72 File file = sip.fetch(artifact, store); 73 assertNotNull(file); 74 75 String expected = makeCurDirURL() + "/test/cache/my_group/my_project/my_md5_artifact-2.0.jar"; 76 System.out.println("Expected " + expected); 77 System.out.println("Actual " + file.toURL()); 78 assertEquals(expected, file.toURL().toString()); 79 } 80 81 public void testDepsBuild() throws Exception { 82 Artifact artifact = new Artifact(); 83 artifact.setGroup("my_group"); 84 artifact.setName("my_complete_artifact"); 85 artifact.setProjectname("my_project"); 86 artifact.setType("jar"); 87 artifact.setVersion("42"); 88 89 LocalCacheStore store = new LocalCacheStore(new File ("test/cache")); 90 store.delete(artifact); 91 92 SavantInternetProcess sip = new SavantInternetProcess(); 93 sip.setDefaultdomain(makeCurDirURL() + "/test/savant"); 94 assertTrue(sip.resolveArtifactDependencies(artifact, store)); 95 assertEquals(2, artifact.getDependencies().size()); 96 97 Artifact dep = (Artifact) artifact.getDependencies().get(0); 98 assertEquals("my_md5_artifact", dep.getName()); 99 assertEquals("my_group", dep.getGroup()); 100 assertEquals("my_project", dep.getProjectname()); 101 assertEquals("jar", dep.getType()); 102 assertEquals("2.0", dep.getVersion()); 103 104 dep = (Artifact) artifact.getDependencies().get(1); 105 assertEquals("my_name", dep.getName()); 106 assertEquals("my_group", dep.getGroup()); 107 assertEquals("my_project", dep.getProjectname()); 108 assertEquals("exe", dep.getType()); 109 assertEquals("2.0", dep.getVersion()); 110 } 111 112 private String makeCurDirURL() throws MalformedURLException { 113 File file = new File (""); 114 return file.toURL().toString(); 115 } 116 }
| Popular Tags
|