KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > schlichtherle > util > zip > TextDataZipTest


1 /*
2  * TextDataZipTest.java
3  *
4  * Created on 14. Oktober 2005, 16:49
5  */

6 /*
7  * Copyright 2005 Schlichtherle IT Services
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */

21
22 package de.schlichtherle.util.zip;
23
24 import java.util.logging.Logger JavaDoc;
25
26 import junit.framework.*;
27
28 /**
29  * Tests compression of a data with about 1MB of highly compressible text.
30  *
31  * @author Christian Schlichtherle
32  */

33 public class TextDataZipTest extends ZipTestBase {
34
35     private static final Logger JavaDoc logger
36             = Logger.getLogger(TextDataZipTest.class.getName());
37
38     private static final byte[] data;
39     static {
40         boolean ea = false;
41         assert ea = true; // NOT ea == true !
42
logger.config("Java assertions enabled: " + ea);
43
44         final String JavaDoc text = "This is a truly compressible text!\n";
45         final int count = 1024 * 1024 / text.length();
46         final int length = count * text.length(); // rounded down
47
StringBuffer JavaDoc buf = new StringBuffer JavaDoc(length);
48         for (int i = 0; i < count; i++) {
49             buf.append(text);
50         }
51         data = buf.toString().getBytes();
52         logger.config("Created " + data.length + " bytes of highly compressible text as the data.");
53     }
54
55     public static Test suite() throws Exception JavaDoc {
56         TestSuite suite = new TestSuite(TextDataZipTest.class);
57         
58         return suite;
59     }
60     
61     /** Creates a new instance of RandomMessageZipTest */
62     public TextDataZipTest(String JavaDoc testName) {
63         super(testName);
64     }
65
66     protected void setUp() throws Exception JavaDoc {
67         super.data = TextDataZipTest.data;
68         
69         super.setUp();
70     }
71 }
72
Popular Tags