Search in sources :

Example 6 with BundleHeader

use of info.ata4.junity.bundle.BundleHeader in project disunity by ata4.

the class BundleTest method headerValid.

@Test
public void headerValid() throws IOException {
    BundleHeader header = bundle.header();
    long fileSize = Files.size(file);
    assertTrue("Number of levels to download must be equal to number of levels or 1", header.numberOfLevelsToDownload() == header.numberOfLevels() || header.numberOfLevelsToDownload() == 1);
    assertTrue("Signatures should be valid", header.hasValidSignature());
    assertTrue("Minimum streamed bytes must be smaller than or equal to file size", header.minimumStreamedBytes() <= fileSize);
    assertTrue("Header size must be smaller than file size", header.headerSize() < fileSize);
    if (header.streamVersion() >= 2) {
        assertEquals("Header file size and actual file size must be equal", header.completeFileSize(), fileSize);
    }
    assertEquals("Number of levels must match number of level end offsets", header.numberOfLevelsToDownload(), header.levelByteEnd().size());
    header.levelByteEnd().forEach(lbe -> {
        assertTrue("Compressed offset must be smaller or equal to uncompressed offset", lbe.getLeft() <= lbe.getRight());
    });
}
Also used : BundleHeader(info.ata4.junity.bundle.BundleHeader) Test(org.junit.Test)

Aggregations

BundleHeader (info.ata4.junity.bundle.BundleHeader)3 Gson (com.google.gson.Gson)2 InputStream (java.io.InputStream)2 Path (java.nio.file.Path)2 GsonBuilder (com.google.gson.GsonBuilder)1 TableBuilder (info.ata4.disunity.cli.util.TableBuilder)1 DataReader (info.ata4.io.DataReader)1 DataWriter (info.ata4.io.DataWriter)1 DataWriters (info.ata4.io.DataWriters)1 LzmaEncoderProps (info.ata4.io.lzma.LzmaEncoderProps)1 UnityVersion (info.ata4.junity.UnityVersion)1 BundleExternalEntry (info.ata4.junity.bundle.BundleExternalEntry)1 Progress (info.ata4.junity.progress.Progress)1 BufferedOutputStream (java.io.BufferedOutputStream)1 Closeable (java.io.Closeable)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Reader (java.io.Reader)1 Writer (java.io.Writer)1 Files (java.nio.file.Files)1