KickJava   Java API By Example, From Geeks To Geeks.

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


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.Ear;
25 import org.netbeans.modules.j2ee.spi.ejbjar.EarProvider;
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  */

36 public class CustomProviderEarTest extends NbTestCase {
37     
38     static {
39         CustomProviderTest.class.getClassLoader().setDefaultAssertionStatus(true);
40     }
41     
42     public CustomProviderEarTest (String JavaDoc name) {
43         super(name);
44     }
45     
46     private FileObject datadir;
47     
48     protected void setUp() throws Exception JavaDoc {
49         super.setUp();
50         File JavaDoc f = getDataDir();
51         assertTrue("example dir exists", f.exists());
52         LocalFileSystem lfs = new LocalFileSystem ();
53         lfs.setRootDirectory (f);
54         Repository.getDefault ().addFileSystem (lfs);
55         datadir = FileUtil.toFileObject (f);
56         assertNotNull ("no FileObject", datadir);
57     }
58
59     public void testProviders () throws Exception JavaDoc {
60         Lookup.Result res = Lookup.getDefault ().lookup (new Lookup.Template (EarProvider.class));
61         assertEquals ("there should be 2 instances - one from j2ee/ejbapi and one from tests", 2, res.allInstances ().size ());
62     }
63     
64     public void testGetEar () throws Exception JavaDoc {
65         FileObject foo = datadir.getFileObject ("a.foo");
66         FileObject bar = datadir.getFileObject ("b.bar");
67         FileObject biz = datadir.getFileObject ("c.biz");
68         Ear wm1 = Ear.getEar (foo);
69         assertNotNull ("found ejb module", wm1);
70         Ear wm2 = Ear.getEar (bar);
71         assertNotNull ("found car module", wm2);
72         Ear wm3 = Ear.getEar (biz);
73         assertNull ("no ear module", wm3);
74    }
75 }
76
Popular Tags