1 19 20 package org.netbeans.modules.apisupport.project.metainf; 21 22 import java.io.File ; 23 import java.io.IOException ; 24 import java.util.Iterator ; 25 import java.util.List ; 26 import junit.framework.Test; 27 import junit.framework.TestSuite; 28 import org.netbeans.modules.apisupport.project.NbModuleProject; 29 import org.netbeans.modules.apisupport.project.TestBase; 30 import org.openide.filesystems.FileUtil; 31 32 35 public class ServiceTest extends TestBase { 36 37 public ServiceTest(String testName) { 38 super(testName); 39 } 40 41 public static Test suite() { 42 return new TestSuite(ServiceTest.class); 43 } 44 45 public void testReadServices() { 46 File jarFile = new File (getDataDir(),"ServiceTest.jar"); 47 List services = Service.readServices(jarFile); 48 49 Iterator it = services.iterator() ; 50 51 Service service = (Service) it.next(); 52 assertEquals("testicek", service.getCodebase() ); 53 assertEquals("java.io.InputStream", service.getFileName()); 54 Iterator cIt = service.getClasses().iterator() ; 55 assertEquals("java.io.FileInputStream",cIt.next()); 56 assertEquals("java.io.BufferedInputStream",cIt.next()); 57 assertFalse(cIt.hasNext()); 58 59 service = (Service) it.next(); 60 assertEquals("testicek", service.getCodebase() ); 61 assertEquals("java.util.Collection", service.getFileName()); 62 cIt = service.getClasses().iterator() ; 63 assertEquals("java.util.ArrayList",cIt.next()); 64 assertEquals("java.util.Stack",cIt.next()); 65 assertFalse(cIt.hasNext()); 66 } 67 68 public void testGetOnlyProjectServices() throws IOException { 69 NbModuleProject module = generateStandaloneModule("module"); 70 FileUtil.createData(module.getSourceDirectory(), "META-INF/services/some.test.MyService"); 71 FileUtil.createData(module.getSourceDirectory(), "META-INF/services/.#some.test.MyService.1.2"); 72 assertEquals("one service", 1, Service.getOnlyProjectServices(module).size()); 73 } 74 75 } 76 | Popular Tags |