<commit_before>/*
 * Copyright (C) The Apache Software Foundation. All rights reserved.
 *
 * This software is published under the terms of the Apache Software License
 * version 1.1, a copy of which has been included with this distribution in
 * the LICENSE.txt file.
 */
package org.apache.commons.compress.tar;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import junit.framework.TestCase;

/**
 * Test case for all tar resources.
 *
 * @todo Find V7 tar and do tests against it
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Revision: 1.1 $ $Date: 2003/11/23 20:07:47 $
 */
public final class TarTestCase
    extends TestCase
{
    private static final char SP = File.separatorChar;
    private static final String BASE_DATA_NAME = "data.txt";
    private static final String LFN_PART = "a-b-c-d-e-f-g-h-i-j/";
    private static final String LONG_FILE_NAME =
        LFN_PART + LFN_PART + LFN_PART + LFN_PART + LFN_PART + "a";

    private static final String BASEDIR = calcBaseDir();

    private static final File BASEDIR_FILE = new File( BASEDIR );
    private static final File POSIX_TAR_FILE =
        new File( BASEDIR_FILE, "posix.tar" );
    //    private static final File V7_TAR_FILE =
    //        new File( BASEDIR_FILE, "v7.tar" );
    private static final File GNU_TAR_FILE =
        new File( BASEDIR_FILE, "gnu.tar" );
    private static final File DATA_FILE1 =
        new File( BASEDIR_FILE, BASE_DATA_NAME );
    private static final String USER_NAME = "avalon";
    private static final String GROUP_NAME = "excalibur";
    private static final long SIZE = DATA_FILE1.length();
    private static final int GROUP_ID = 0;
    private static final int USER_ID = 0;
    private static final int MODE = 0100000;
    private static final int MOD_TIME = 0;

    public TarTestCase()
    {
        this( "Tar Test Case" );
    }

    public TarTestCase( String name )
    {
        super( name );
    }

    private static String calcBaseDir()
    {
        final String name = TarTestCase.class.getName();
        final int size = name.length();
        final String filename =
            name.substring( 0, size - 11 ).replace( '.', SP );
        return "target" + SP + "tests" + SP +
                SP + filename + SP;
    }

    public void testReadPosixTar()
        throws Exception
    {
        compareTar( BASE_DATA_NAME, POSIX_TAR_FILE );
    }

    public void testReadGnuTar()
        throws Exception
    {
        compareTar( LONG_FILE_NAME, GNU_TAR_FILE );
    }

    public void testWritePosixTar()
        throws Exception<commit_msg>fix tar testcase - correct path - update *.tar binary files<commit_after>/*
 * Copyright (C) The Apache Software Foundation. All rights reserved.
 *
 * This software is published under the terms of the Apache Software License
 * version 1.1, a copy of which has been included with this distribution in
 * the LICENSE.txt file.
 */
package org.apache.commons.compress.tar;

import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import junit.framework.TestCase;

/**
 * Test case for all tar resources.
 *
 * @todo Find V7 tar and do tests against it
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @version $Revision: 1.2 $ $Date: 2003/12/02 20:35:05 $
 */
public final class TarTestCase
    extends TestCase
{
    private static final char SP = File.separatorChar;
    private static final String BASE_DATA_NAME = "data.txt";
    private static final String LFN_PART = "a-b-c-d-e-f-g-h-i-j/";
    private static final String LONG_FILE_NAME =
        LFN_PART + LFN_PART + LFN_PART + LFN_PART + LFN_PART + "a";

    private static final String BASEDIR = calcBaseDir();

    private static final File BASEDIR_FILE = new File( BASEDIR );
    private static final File POSIX_TAR_FILE =
        new File( BASEDIR_FILE, "posix.tar" );
    //    private static final File V7_TAR_FILE =
    //        new File( BASEDIR_FILE, "v7.tar" );
    private static final File GNU_TAR_FILE =
        new File( BASEDIR_FILE, "gnu.tar" );
    private static final File DATA_FILE1 =
        new File( BASEDIR_FILE, BASE_DATA_NAME );
    private static final String USER_NAME = "avalon";
    private static final String GROUP_NAME = "excalibur";
    private static final long SIZE = DATA_FILE1.length();
    private static final int GROUP_ID = 0;
    private static final int USER_ID = 0;
    private static final int MODE = 0100000;
    private static final int MOD_TIME = 0;

    public TarTestCase()
    {
        this( "Tar Test Case" );
    }

    public TarTestCase( String name )
    {
        super( name );
    }

    private static String calcBaseDir()
    {
        final String name = TarTestCase.class.getName();
        final int size = name.length();
        final String filename =
            name.substring( 0, size - 11 ).replace( '.', SP );
        return "src" + SP + "test" + SP +
                SP + filename + SP;
    }

    public void testReadPosixTar()
        throws Exception
    {
        compareTar( BASE_DATA_NAME, POSIX_TAR_FILE );
    }

    public void testReadGnuTar()
        throws Exception
    {
        compareTar( LONG_FILE_NAME, GNU_TAR_FILE );
    }

    public void testWritePosixTar()
        throws Exception
{'fraction_non_alphanumeric': 0.09284682080924855, 'fraction_numerical': 0.01300578034682081, 'mean_word_length': 2.8028846153846154, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4438718', 'n_tokens_mistral': 1752, 'n_tokens_neox': 1664, 'n_words': 545}