Last change
on this file since 3284 was 3284, checked in by kjdon, 22 years ago |
more functionality added along with Test classes
|
-
Property svn:keywords
set to
Author Date Id Revision
|
File size:
1.2 KB
|
Line | |
---|
1 | package org.greenstone.gsdl3.util;
|
---|
2 |
|
---|
3 | import junit.framework.*;
|
---|
4 | import java.io.File;
|
---|
5 |
|
---|
6 | public class GSFileTest extends TestCase {
|
---|
7 |
|
---|
8 | /** what type of test - used by the testing framework */
|
---|
9 | public static final String TEST_ALL_TEST_TYPE="UNIT";
|
---|
10 |
|
---|
11 | public GSFileTest(String name) {
|
---|
12 | super(name);
|
---|
13 | }
|
---|
14 |
|
---|
15 | /** test suite that dynamically runs all the tests */
|
---|
16 | public static Test suite() {
|
---|
17 | return new TestSuite(GSFileTest.class);
|
---|
18 | }
|
---|
19 |
|
---|
20 | public void testBase64Conversion() {
|
---|
21 |
|
---|
22 | // start off with reverse conversion - decode then encode
|
---|
23 | String data = "sdkfjho9w4385khrf9ow834rfia8ufd38rhf9812";
|
---|
24 | File outfile;
|
---|
25 | try {
|
---|
26 | outfile = File.createTempFile("b64convert_test", "");
|
---|
27 | } catch (java.io.IOException e) {
|
---|
28 | fail("couldn't create a temporary file in default temp dir");
|
---|
29 | return;
|
---|
30 | }
|
---|
31 | String filename = outfile.getAbsolutePath();
|
---|
32 |
|
---|
33 | String newdata;
|
---|
34 | if (GSFile.base64DecodeToFile(data, filename)) {
|
---|
35 | newdata = GSFile.base64EncodeFromFile(filename);
|
---|
36 |
|
---|
37 | assertEquals("decoded/encoded string does not match the origianl",
|
---|
38 | data, newdata);
|
---|
39 | // clean up
|
---|
40 | outfile.delete();
|
---|
41 | } else {
|
---|
42 | fail("couldn't decode the data string");
|
---|
43 | }
|
---|
44 |
|
---|
45 | //try with a real file???
|
---|
46 |
|
---|
47 | }
|
---|
48 |
|
---|
49 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.