1 19 20 package org.netbeans.modules.j2ee.ejbjar; 21 22 import java.io.File ; 23 import org.netbeans.junit.NbTestCase; 24 import org.netbeans.modules.j2ee.api.ejbjar.Car; 25 import org.netbeans.modules.j2ee.spi.ejbjar.CarProvider; 26 import org.openide.filesystems.FileObject; 27 import org.openide.filesystems.FileUtil; 28 import org.openide.filesystems.LocalFileSystem; 29 import org.openide.filesystems.Repository; 30 import org.openide.util.Lookup; 31 32 37 public class CustomProviderCarTest extends NbTestCase { 38 39 static { 40 CustomProviderCarTest.class.getClassLoader().setDefaultAssertionStatus(true); 41 } 42 43 public CustomProviderCarTest (String name) { 44 super(name); 45 } 46 47 private FileObject datadir; 48 49 protected void setUp() throws Exception { 50 super.setUp(); 51 File f = getDataDir(); 52 assertTrue("example dir exists", f.exists()); 53 LocalFileSystem lfs = new LocalFileSystem (); 54 lfs.setRootDirectory (f); 55 Repository.getDefault ().addFileSystem (lfs); 56 datadir = FileUtil.toFileObject (f); 57 assertNotNull ("no FileObject", datadir); 58 } 59 60 public void testProviders () throws Exception { 61 Lookup.Result res = Lookup.getDefault ().lookup (new Lookup.Template (CarProvider.class)); 62 assertEquals ("there should be 2 instances - one from j2ee/ejbapi and one from tests", 2, res.allInstances ().size ()); 63 } 64 65 public void testGetCar () throws Exception { 66 FileObject foo = datadir.getFileObject ("a.foo"); 67 FileObject bar = datadir.getFileObject ("b.bar"); 68 Car wm1 = Car.getCar (bar); 69 assertNotNull ("found car module", wm1); 70 Car wm2 = Car.getCar (foo); 71 assertNull ("no car module", wm2); 72 } 73 } 74 | Popular Tags |