KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ejbjar > CustomProviderCarTest


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.ejbjar;
21
22 import java.io.File JavaDoc;
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 /**
33  * Base class for web module project tests.
34  * @author Pavel Buzek
35  * @author Lukas Jungmann
36  */

37 public class CustomProviderCarTest extends NbTestCase {
38     
39     static {
40         CustomProviderCarTest.class.getClassLoader().setDefaultAssertionStatus(true);
41     }
42     
43     public CustomProviderCarTest (String JavaDoc name) {
44         super(name);
45     }
46     
47     private FileObject datadir;
48     
49     protected void setUp() throws Exception JavaDoc {
50         super.setUp();
51         File JavaDoc 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 JavaDoc {
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 JavaDoc {
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