fr.eoit.util.dumper.DumperTest.java Source code

Java tutorial

Introduction

Here is the source code for fr.eoit.util.dumper.DumperTest.java

Source

/*
 * Copyright (C) 2012 Picon software
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
package fr.eoit.util.dumper;

import java.util.Arrays;
import java.util.zip.Deflater;

import org.apache.commons.codec.binary.Hex;
import org.junit.Test;

public class DumperTest {

    private static final String COPYRIGHTS = "<font color=yellow>Subject:</font> True Sansha Archduke (ID: Modified Nightmare)<br>\n"
            + "<font color=yellow>Military Specifications:</font> Battleship-class vessel. Heavily modified for increased armor and weapon system performance. <br>\n"
            + "<font color=yellow>Additional Intelligence:</font> The Archduke Nightmare variant is favored by Sansha military outpost commanders. While perhaps not as advanced as the ships flown by Sansha incursion forces, the Archduke is clearly built with the lessons from capsuleer battles in mind: Molten salt coolant systems allow for overcharged energy turrets. Physical link cables connect key True Slave crew members directly to their ship commander, preventing any electronic interference from affecting the crew. Supplemental adaptive armor plates line the hull. <br><br>This is all in addition to several proprietary Nation modules and other experimental tech found exclusively, if inconsistently, among models of the Archduke variant.\n"
            + "<i>Analyst Atros, CDIA.</i><br><i>Authorized for capsuleer dissemination.</i>  ";

    @Test
    public void testCompression() {

        byte[] strBytes = COPYRIGHTS.getBytes();

        byte[] output = new byte[8096];
        Deflater compresser = new Deflater(Deflater.BEST_COMPRESSION, true);
        compresser.setInput(strBytes);
        compresser.finish();
        int compressedDataLength = compresser.deflate(output);
        compresser.end();

        String inputString = new String(Hex.encodeHex(strBytes));
        String hexString = new String(Arrays.copyOf(output, compressedDataLength));

        int i = 0;
        i++;
    }

}