KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > petals > util > NioUtilTest


1 /**
2  * PETALS - PETALS Services Platform.
3  * Copyright (c) 2005 EBM Websourcing, http://www.ebmwebsourcing.com/
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * -------------------------------------------------------------------------
19  * $Id: NioUtilTest.java 15:30:52 ddesjardins $
20  * -------------------------------------------------------------------------
21  */

22 package org.objectweb.petals.util;
23
24 import java.io.File JavaDoc;
25 import java.io.FileInputStream JavaDoc;
26 import java.io.IOException JavaDoc;
27
28 import junit.framework.TestCase;
29
30 /**
31  * Class used to test the NioUtil class
32  *
33  * @author ddesjardins - eBMWebsourcing
34  */

35 public class NioUtilTest extends TestCase {
36
37     /**
38      * Base directory of the project
39      */

40     private String JavaDoc baseDir;
41
42     /**
43      * Set up the base directory for the test
44      */

45     public void setUp() {
46         baseDir = this.getClass().getResource(".").toString();
47         baseDir = baseDir.substring(0, baseDir.indexOf("target"));
48         baseDir = baseDir.substring(baseDir.indexOf(":") + 1);
49     }
50
51     /**
52      * Copy a file to another file
53      *
54      * @throws IOException
55      */

56     public void testCopyStreamToFile() throws IOException JavaDoc {
57         FileInputStream JavaDoc inputStream = new FileInputStream JavaDoc(baseDir + "src"
58             + File.separator + "test-data" + File.separator + "fileToCopy.txt");
59         NioUtil.copyStreamToFile(inputStream, new File JavaDoc(baseDir + "src"
60             + File.separator + "test-data" + File.separator + "destFile.txt"));
61     }
62
63 }
64
Popular Tags