KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2  * TestMessageZipTest.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.security.SecureRandom JavaDoc;
25 import java.util.Random JavaDoc;
26 import java.util.logging.Logger JavaDoc;
27
28 import junit.framework.*;
29
30 /**
31  * Tests compression of a data with about 1MB of highly compressible text.
32  *
33  * @author Christian Schlichtherle
34  */

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