1 /*
2 * Copyright 2004-2008 the Seasar Foundation and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.seasar.uruma.util.win32;
17
18 import junit.framework.TestCase;
19
20 /**
21 * {@link Win32API} のためのテストクラスです。<br />
22 *
23 * @author y-komori
24 */
25 public class Win32APITest extends TestCase {
26 /**
27 * {@link Win32API#getComputerName()} のテストです。<br />
28 */
29 public void testGetComputerName() {
30 System.out.println(Win32API.getComputerName());
31 }
32
33 /**
34 * {@link Win32API#getLogicalDrives()} のテストです。<br />
35 */
36 public void testGetLogicalDrives() {
37 String[] drives = Win32API.getLogicalDrives();
38 for (int i = 0; i < drives.length; i++) {
39 System.out.println(drives[i]);
40 }
41 }
42
43 /**
44 * {@link Win32API#getVolumeInformation(String)} のテストです。<br />
45 */
46 public void testGetVolumeInformation() {
47 VolumeInformation info = Win32API.getVolumeInformation("c:\\");
48 System.out.println(info);
49 }
50
51 /**
52 * {@link Win32API#getDriveType(String)} のテストです。<br />
53 */
54 public void testGetDriveType() {
55 String[] drives = Win32API.getLogicalDrives();
56 for (int i = 0; i < drives.length; i++) {
57 DriveType type = Win32API.getDriveType(drives[i]);
58 System.out.println(drives[i] + "..." + type);
59 }
60 }
61
62 /**
63 * {@link Win32API#getFileTypeName(String)} のテストです。<br />
64 */
65 public void testGetFileTypeName() {
66 String[] drives = Win32API.getLogicalDrives();
67 for (int i = 0; i < drives.length; i++) {
68 String type = Win32API.getFileTypeName(drives[i]);
69 System.out.println(drives[i] + "..." + type);
70 }
71 }
72
73 /**
74 * {@link Win32API#getFileDisplayName(String)} のテストです。<br />
75 */
76 public void testGetFileDisplayName() {
77 String[] drives = Win32API.getLogicalDrives();
78 for (int i = 0; i < drives.length; i++) {
79 String type = Win32API.getFileDisplayName(drives[i]);
80 System.out.println(drives[i] + "..." + type);
81 }
82 }
83
84 /**
85 * {@link Win32API#expandEnvironmentStrings(String)} のテストです。<br />
86 */
87 public void testExpandEnvironmentStrings() {
88 String sysroot = System.getenv("systemroot");
89 String expSysroot = Win32API.expandEnvironmentStrings("%systemroot%");
90 assertEquals("1", sysroot, expSysroot);
91
92 assertEquals("2", "noenv", Win32API.expandEnvironmentStrings("noenv"));
93 }
94 }