1 package de.fu_berlin.ties.io;
2
3 import junit.framework.TestCase;
4
5 import java.io.File;
6 import java.net.URL;
7
8 import de.fu_berlin.ties.TiesConfiguration;
9
10
11 /***
12 * Generated by JUnitDoclet, a tool provided by
13 * ObjectFab GmbH under LGPL.
14 * Please see www.junitdoclet.org, www.gnu.org
15 * and www.objectfab.de for informations about
16 * the tool, the licence and the authors.
17 */
18
19
20 public class ContentTypeTest
21
22 extends TestCase
23
24 {
25
26 de.fu_berlin.ties.io.ContentType contenttype = null;
27
28
29 public ContentTypeTest(String name) {
30
31 super(name);
32
33 }
34
35 public de.fu_berlin.ties.io.ContentType createInstance() throws Exception {
36
37 return null;
38
39 }
40
41 protected void setUp() throws Exception {
42
43 super.setUp();
44 contenttype = createInstance();
45
46 }
47
48 protected void tearDown() throws Exception {
49
50 contenttype = null;
51 super.tearDown();
52
53 }
54
55 public void testDetermineContentType() throws Exception {
56
57 String[][] urlInput = {
58 {"application/PDF", ""},
59 {"application/rtf", null},
60 {"application/xhtml+xml", ""},
61 {"application/xml", ""},
62 {"model/vrml", null},
63 {"text/css; charset=iso8859-4", ""},
64 {"text/html; param1=bla; CharSet=UTF-8; param2=\"blub\"", "xml"},
65 {"text/plain; param1=\"bla\"; Charset=\"ISO8859-1\"; par2=\"xy\"",
66 ""},
67 {"txt/rtf", ""},
68 {"Text/URI-list;charset = utf-8", ""},
69 {null, "URIs"},
70 {"text/xml;charset= ENC-7 ;param2=blub", ""},
71 {"text/xml; charset= \"UTF-8\"", "html"},
72 {"text/xml", "pdf"},
73 {"text/bla", "PDF"},
74 {"", "xml"},
75 {"", "HTML"},
76 {null, "htm"},
77 {null, null}
78 };
79 String[][] urlOutput = {
80 {"application/pdf", null},
81 {"text/rtf", null},
82 {"text/html", null},
83 {"text/xml", null},
84 {"model/vrml", null},
85 {"text/css", "iso8859-4"},
86 {"text/html", "UTF-8"},
87 {"text/plain", "ISO8859-1"},
88 {"txt/rtf", null},
89 {"text/uri-list", "utf-8"},
90 {"text/uri-list", null},
91 {"text/xml", "ENC-7"},
92 {"text/xml", "UTF-8"},
93 {"text/xml", null},
94 {"text/bla", null},
95 {"text/xml", null},
96 {"text/html", null},
97 {"text/html", null},
98 {null, null},
99 };
100
101 String[] fileInput = {
102 "bla.xHtml",
103 "tmp/file.txt",
104 "Source.java",
105 "/path/to/dir/text.converted.rtf",
106 "/path/to/dir/README",
107 null,
108 };
109 String[] fileOutput = {
110 "text/html",
111 "text/plain",
112 null,
113 "text/rtf",
114 null,
115 null,
116 };
117
118 URL url;
119 ContentType type;
120
121 for (int i = 0; i < urlInput.length; i++) {
122 url = (urlInput[i][1] == null) ? null
123 : new URL("http://test.com/dir/file." + urlInput[i][1]);
124 type = ContentType.determineContentType(url,
125 urlInput[i][0], TiesConfiguration.CONF);
126
127 assertEquals(urlOutput[i][0], type.getMimeType());
128 assertEquals(urlOutput[i][1], type.getCharset());
129
130
131
132
133
134
135
136
137 }
138
139 File file;
140
141 for (int i = 0; i < fileInput.length; i++) {
142 file = (fileInput[i] == null) ? null : new File(fileInput[i]);
143 type = ContentType.determineContentType(file,
144 TiesConfiguration.CONF);
145
146 assertEquals(fileOutput[i], type.getMimeType());
147 assertNull(type.getCharset());
148
149
150
151
152
153
154
155
156 }
157
158 }
159
160 public void testGetCharset() throws Exception {
161
162
163 }
164
165 public void testGetMimeType() throws Exception {
166
167
168 }
169
170 public void testToString() throws Exception {
171
172
173 }
174
175
176
177 /***
178 * JUnitDoclet moves marker to this method, if there is not match
179 * for them in the regenerated code and if the marker is not empty.
180 * This way, no test gets lost when regenerating after renaming.
181 * Method testVault is supposed to be empty.
182 */
183 public void testVault() throws Exception {
184
185
186 }
187
188 public static void main(String[] args) {
189
190 junit.textui.TestRunner.run(ContentTypeTest.class);
191
192 }
193 }