1 /* Copyright (c) 2009 Peter Troshin
\r
3 * JAva Bioinformatics Analysis Web Services (JABAWS) @version: 1.0
\r
5 * This library is free software; you can redistribute it and/or modify it under the terms of the
\r
6 * Apache License version 2 as published by the Apache Software Foundation
\r
8 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
\r
9 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Apache
\r
10 * License for more details.
\r
12 * A copy of the license is in apache_license.txt. It is also available here:
\r
13 * @see: http://www.apache.org/licenses/LICENSE-2.0.txt
\r
15 * Any republication or derived work distributed in source code form
\r
16 * must include this copyright and license notice.
\r
19 package compbio.engine.client;
\r
21 import static org.testng.Assert.assertFalse;
\r
22 import static org.testng.Assert.assertTrue;
\r
23 import static org.testng.Assert.fail;
\r
25 import java.io.File;
\r
26 import java.io.IOException;
\r
27 import java.net.URISyntaxException;
\r
28 import java.net.URL;
\r
30 import org.testng.annotations.Test;
\r
32 import compbio.engine.client.PathValidator;
\r
33 import compbio.runner.msa.ClustalW;
\r
34 import compbio.util.SysPrefs;
\r
36 public class PathValidatorTester {
\r
39 public void testIsAbsolutePath() {
\r
41 if (SysPrefs.isWindows) {
\r
43 * slash(\) has to be prefixed with another slash to produce a
\r
46 assertTrue(PathValidator.isAbsolutePath("d:\\temp"));
\r
47 assertFalse(PathValidator.isAbsolutePath("/home"));
\r
49 assertFalse(PathValidator.isAbsolutePath("d:\\temp"));
\r
50 assertTrue(PathValidator.isAbsolutePath("/home"));
\r
52 assertFalse(PathValidator.isAbsolutePath("home"));
\r
56 public void testGetClassPath() {
\r
57 String clname = ClustalW.class.getSimpleName();
\r
58 System.out.println("%" + clname);
\r
59 URL url = ClustalW.class.getResource(clname + ".class");
\r
60 URL url2 = ClassLoader.getSystemResource("Engine.local.properties");
\r
63 File f = new File(url.toURI());
\r
64 System.out.println("&" + f.getAbsolutePath());
\r
65 System.out.println("&" + f.getCanonicalPath());
\r
66 System.out.println("&" + f.getParent());
\r
67 } catch (URISyntaxException e) {
\r
68 e.printStackTrace();
\r
69 fail(e.getLocalizedMessage());
\r
70 } catch (IOException e) {
\r
71 e.printStackTrace();
\r
72 fail(e.getLocalizedMessage());
\r
74 System.out.println("!!" + url2);
\r
75 System.out.println("!" + url.getFile());
\r
76 System.out.println("!" + System.getProperty("java.class.path", null));
\r