KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > sapia > magnet > domain > test > ProtocolHandlerTest


1 package org.sapia.magnet.domain.test;
2
3 import junit.framework.TestCase;
4 import junit.textui.TestRunner;
5
6 import org.sapia.magnet.domain.Exclude;
7 import org.sapia.magnet.domain.Include;
8 import org.sapia.magnet.domain.Path;
9 import org.sapia.magnet.domain.FileProtocolHandler;
10 import org.sapia.magnet.domain.HttpProtocolHandler;
11
12 /**
13  *
14  *
15  * @author Jean-Cedric Desrochers
16  * <dl>
17  * <dt><b>Copyright:</b><dd>Copyright &#169; 2002-2003 <a HREF="http://www.sapia-oss.org">Sapia Open Source Software</a>. All Rights Reserved.</dd></dt>
18  * <dt><b>License:</b><dd>Read the license.txt file of the jar or visit the
19  * <a HREF="http://www.sapia-oss.org/license.html" target="sapia-license">license page</a> at the Sapia OSS web site</dd></dt>
20  * </dl>
21  */

22 public class ProtocolHandlerTest extends TestCase {
23
24   public static void main(String JavaDoc[] args) {
25     TestRunner.run(ProtocolHandlerTest.class);
26   }
27
28   public ProtocolHandlerTest(String JavaDoc aName) {
29     super(aName);
30   }
31
32   public void testBasicPath() throws Exception JavaDoc {
33     FileProtocolHandler aHandler = new FileProtocolHandler();
34     Path aPath = new Path();
35     aPath.setDirectory(System.getProperty("user.dir"));
36     aPath.addInclude(new Include("**/*"));
37     aPath.addExclude(new Exclude("**/bin/*"));
38
39     System.out.println("INCLUDES: " + aHandler.resolveResources(aPath, Path.SORTING_ASCENDING));
40   }
41
42   public void testBasicHttpPath() throws Exception JavaDoc {
43     HttpProtocolHandler aHandler = new HttpProtocolHandler();
44     Path aPath = new Path();
45     aPath.setProtocol(Path.PROTOCOL_HTTP);
46     aPath.setHost("192.168.0.130:8200");
47     aPath.setDirectory("/sapia/codebase");
48     aPath.addInclude(new Include("interafces.jar"));
49     aPath.addInclude(new Include("implAplha.jar"));
50     aPath.addExclude(new Exclude("*.jar"));
51
52     System.out.println("INCLUDES: " + aHandler.resolveResources(aPath, Path.SORTING_DESCENDING));
53   }
54 }
Popular Tags