File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\test\src\test\java\hudson\bugs\DateConversionTest.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.bugs;
25
26 import com.thoughtworks.xstream.converters.basic.DateConverter;
27 import junit.framework.TestCase;
28 import org.jvnet.hudson.test.Email;
29
30 import java.util.ArrayList;
31 import java.util.List;
32 import java.util.concurrent.Callable;
33 import java.util.concurrent.ExecutorService;
34 import java.util.concurrent.Executors;
35 import java.util.concurrent.Future;
36
37 /**
38 * Testing date conversion.
39 * @author Kohsuke Kawaguchi
40 */
41 @Email("http://www.nabble.com/Date-conversion-problem-causes-IOException-reading-fingerprint-file.-td19201137.html")
42 public class DateConversionTest extends TestCase {
43 /**
44 * Put it under a high-concurrency to make sure nothing bad happens.
45 */
46 public void test1() throws Exception {
47 final DateConverter dc =new DateConverter();
48 ExecutorService es = Executors.newFixedThreadPool(10);
49
50 List<Future> futures = new ArrayList<Future>();
51 for(int i=0;i<10;i++) {
52 futures.add(es.submit(new Callable<Object>() {
53 public Object call() throws Exception {
54 for( int i=0; i<10000; i++ )
55 dc.fromString("2008-08-26 15:40:14.568 GMT-03:00");
56 return null;
57 }
58 }));
59 }
60
61 for (Future f : futures) {
62 f.get();
63 }
64 es.shutdown();
65 }
66 }
67