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.conf;
\r
21 import static org.testng.Assert.assertEquals;
\r
22 import static org.testng.Assert.assertTrue;
\r
24 import java.util.HashSet;
\r
25 import java.util.Set;
\r
27 import org.testng.annotations.Test;
\r
29 import compbio.runner.msa.ClustalW;
\r
30 import compbio.util.SysPrefs;
\r
32 public class DirectoryManagerTester {
\r
34 @Test(invocationCount = 4, threadPoolSize = 4, sequential = false)
\r
35 public void testGetDirectory() {
\r
36 Set<Long> set = new HashSet<Long>();
\r
37 for (int i = 0; i < 20000; i++) {
\r
38 long number = DirectoryManager.getNonRepeatableNumber();
\r
39 assertTrue(set.add(number));
\r
40 // Cannot rely on the length is the returned long, as precision is
\r
41 // implementation dependent
\r
42 // see testNanoTime method below
\r
43 // assertEquals(Long.toString(number).length(), 17);
\r
45 String name = DirectoryManager.getTaskDirectory(ClustalW.class);
\r
46 assertTrue(name.startsWith(ClustalW.class.getSimpleName()));
\r
50 * In fact the precision of System.nanoTime() varies depending on the JVM
\r
51 * Sun 1.6.0_17 JVM gives the same precision on linux x64 as on windows x32
\r
52 * but openjdk 1.6.x gives more digits on linux than sun JVM It looks like
\r
53 * the precision is desided at runtime, so the number of digits returned is
\r
56 @Test(enabled = false)
\r
57 public void testNanoTime() {
\r
58 if (SysPrefs.isWindows) {
\r
59 assertEquals(Long.toString(System.nanoTime()).length(), 16);
\r
61 // This is not always true for Linux
\r
62 assertEquals(Long.toString(System.nanoTime()).length(), 14);
\r