Examples of Diagnosis


Examples of org.jwat.common.Diagnosis

            entry.isize = ((trailerBytes[7] & 255) << 24) | ((trailerBytes[6] & 255) << 16) | ((trailerBytes[5] & 255) << 8) | (trailerBytes[4] & 255);
            entry.comp_crc32 = (int)(crc.getValue() & 0xffffffff);
            entry.comp_isize = (int)(inf.getBytesWritten() & 0xffffffff);
            if (entry.comp_crc32 != entry.crc32) {
                entry.diagnostics.addError(
                        new Diagnosis(
                                DiagnosisType.INVALID_EXPECTED,
                                "CRC32",
                                Integer.toHexString(entry.crc32),
                                Integer.toHexString(entry.comp_crc32)
                            )
                        );
            }
            if (entry.comp_isize != entry.isize) {
                entry.diagnostics.addError(
                        new Diagnosis(
                                DiagnosisType.INVALID_EXPECTED,
                                "ISize",
                                Long.toString(entry.isize),
                                Long.toString(entry.comp_isize)
                            )
                        );
            }
        } else {
            gzipEntry.diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_DATA, "GZip file", "Unexpected EOF!"));
            bIsCompliant = false;
        }
        // Compliance
        if (gzipEntry.diagnostics.hasErrors() || gzipEntry.diagnostics.hasWarnings()) {
            gzipEntry.bIsCompliant = false;
View Full Code Here

Examples of org.jwat.common.Diagnosis

        int inflated = 0;
        while((inflated = inf.inflate(b, off, len)) == 0) {
            if (inf.finished()) {
                return -1;
            } else if (inf.needsDictionary()) {
                gzipEntry.diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_DATA, "GZip file", "Unexpected EOF!"));
                bIsCompliant = false;
                throw new DataFormatException("Dictionary needed!");
            } else if (inf.needsInput()) {
                lastInput = pbin.read(inputBytes, 0, inputBytes.length);
                if (lastInput == -1) {
                    gzipEntry.diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_DATA, "GZip file", "Unexpected EOF!"));
                    bIsCompliant = false;
                    throw new DataFormatException("Data missing!");
                }
                inf.setInput(inputBytes, 0, lastInput);
            } else {
                gzipEntry.diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_DATA, "GZip file", "Unexpected EOF!"));
                bIsCompliant = false;
                throw new DataFormatException("Inflater malfunction!");
            }
        }
        return inflated;
View Full Code Here

Examples of org.jwat.common.Diagnosis

            }
            int read;
            try {
                read = reader.readInflated(b, off, len);
            } catch (DataFormatException e) {
                gzipEntry.diagnostics.addError(new Diagnosis(DiagnosisType.INVALID_DATA, "GZip file", "Unexpected EOF!"));
                reader.bIsCompliant = false;
                throw new IOException(e);
            }
            if (read != -1) {
                reader.crc.update(b, off, read);
View Full Code Here

Examples of org.jwat.common.Diagnosis

        ArcWriter writer;
        ArcRecordBase record;
        byte[] recordHeader;
        ByteArrayInputStream in;
        byte[] payload;
        Diagnosis diagnosis;
        try {
            payload = "Welcome to dænemark!".getBytes("UTF-8");

            /*
             * Exceptions enabled.
View Full Code Here

Examples of org.jwat.common.Diagnosis

        TestBaseUtils.compareDiagnoses(expected_errors, header.diagnostics.getErrors());
        TestBaseUtils.compareDiagnoses(expected_warnings, header.diagnostics.getWarnings());
    }

    public static void compareDiagnoses(Object[][] expectedDiagnoses, List<Diagnosis> diagnosisList) {
        Diagnosis diagnosis;
        // debug
        /*
        System.out.println(diagnosisList.size());
        for (int i=0; i<diagnosisList.size(); ++i) {
            diagnosis = diagnosisList.get(i);
View Full Code Here

Examples of org.jwat.common.Diagnosis

    }

    public static void printRecordErrors(ArcRecordBase record) {
        List<Diagnosis> diagnosisList;
        Iterator<Diagnosis> diagnosisIterator;
        Diagnosis diagnosis;
        if (record.diagnostics.hasErrors()) {
            diagnosisList = record.diagnostics.getErrors();
            if (diagnosisList != null && diagnosisList.size() > 0) {
                diagnosisIterator = diagnosisList.iterator();
                while (diagnosisIterator.hasNext()) {
View Full Code Here

Examples of org.jwat.common.Diagnosis

            if (header != null) {
                diagnosticsUsed = header.diagnostics;
            } else {
                diagnosticsUsed = diagnostics;
            }
            diagnosticsUsed.addError(new Diagnosis(
                    DiagnosisType.ERROR_EXPECTED,
                    "'" + ArcConstants.FN_ARCHIVE_LENGTH + "' header",
                    "Mandatory!"));
            if (bExceptionOnContentLengthMismatch) {
                throw new IllegalStateException("Payload size does not match content-length!");
            }
        } else {
            if (headerContentLength != payloadWrittenTotal) {
                if (header != null) {
                    diagnosticsUsed = header.diagnostics;
                } else {
                    diagnosticsUsed = diagnostics;
                }
                diagnosticsUsed.addError(new Diagnosis(
                        DiagnosisType.INVALID_EXPECTED,
                        "'" + ArcConstants.FN_ARCHIVE_LENGTH + "' header",
                        Long.toString(payloadWrittenTotal),
                        headerContentLength.toString()));
                if (bExceptionOnContentLengthMismatch) {
View Full Code Here

Examples of org.jwat.common.Diagnosis

    private TestBaseUtils() {
    }

    public static void compareDiagnoses(Object[][] expectedDiagnoses, List<Diagnosis> diagnosisList) {
        Diagnosis diagnosis;
        // debug
        /*
        System.out.println(diagnosisList.size());
        for (int i=0; i<diagnosisList.size(); ++i) {
            diagnosis = diagnosisList.get(i);
View Full Code Here

Examples of org.jwat.common.Diagnosis

            Assert.assertEquals(expectedDiagnoses[i][2], diagnosis.information.length);
        }
    }

    public static void printDiagnoses(List<Diagnosis> diagnosisList) {
        Diagnosis diagnosis;
        for (int i=0; i<diagnosisList.size(); ++i) {
            diagnosis = diagnosisList.get(i);
            System.out.println("[" + i + "]: " + diagnosis.type + " - " + diagnosis.entity + " - " + diagnosis.information.length);
        }
    }
View Full Code Here

Examples of org.jwat.common.Diagnosis

    }

    public static void printRecordErrors(WarcRecord record) {
        List<Diagnosis> diagnosisList;
        Iterator<Diagnosis> diagnosisIterator;
        Diagnosis diagnosis;
        if (record.diagnostics.hasErrors()) {
            diagnosisList = record.diagnostics.getErrors();
            if (diagnosisList != null && diagnosisList.size() > 0) {
                diagnosisIterator = diagnosisList.iterator();
                while (diagnosisIterator.hasNext()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.