Package org.jwat.common

Examples of org.jwat.common.Diagnosis


     * @param type diagnosis type
     * @param entity entity examined
     * @param information optional extra information
     */
    protected void addWarningDiagnosis(DiagnosisType type, String entity, String... information) {
        diagnostics.addWarning(new Diagnosis(type, entity, information));
    }
View Full Code Here


                default:
                    break;
                }
                if (!bValidVersion) {
                    diagnostics.addError(
                            new Diagnosis(DiagnosisType.UNKNOWN,
                                    "Magic version number", versionStr));
                }
            } else {
                diagnostics.addError(
                        new Diagnosis(DiagnosisType.INVALID_DATA,
                                "Magic Version string", versionStr));
            }

            MaxLengthRecordingInputStream mrin = new MaxLengthRecordingInputStream(in, reader.recordHeaderMaxSize);
            ByteCountingPushBackInputStream pbin = new ByteCountingPushBackInputStream(mrin, reader.recordHeaderMaxSize);
View Full Code Here

                        if (record.httpHeader != null) {
                            if (record.httpHeader.isValid()) {
                                record.payload.setPayloadHeaderWrapped(record.httpHeader);
                            } else {
                                record.diagnostics.addError(
                                        new Diagnosis(DiagnosisType.ERROR,
                                                "http header",
                                                "Unable to parse http header!"));
                            }
                        }
                    }
                }
            }
            // Preliminary compliance status, will be updated when the
            // payload/record is closed.
            if (record.diagnostics.hasErrors() || record.diagnostics.hasWarnings()) {
                record.bIsCompliant = false;
            } else {
                record.bIsCompliant = true;
            }
            reader.bIsCompliant &= record.bIsCompliant;
        } else {
            // In case no record is found the errors/warnings in the record
            // object are transfered to the Reader.
            reader.diagnostics.addAll(record.diagnostics);
            if (record.diagnostics.hasErrors() || record.diagnostics.hasWarnings()) {
                reader.errors += record.diagnostics.getErrors().size();
                reader.warnings += record.diagnostics.getWarnings().size();
                reader.bIsCompliant = false;
            }
            // Require one or more records to be present.
            if (reader.records == 0) {
                reader.diagnostics.addError(new Diagnosis(DiagnosisType.ERROR_EXPECTED, "WARC file", "One or more records"));
                ++reader.errors;
                reader.bIsCompliant = false;
            }
            // EOF
            record = null;
View Full Code Here

     * @param type diagnosis type
     * @param entity entity examined
     * @param information optional extra information
     */
    protected void addErrorDiagnosis(DiagnosisType type, String entity, String... information) {
        diagnostics.addError(new Diagnosis(type, entity, information));
    }
View Full Code Here

public class GzipTestHelper {

    public static boolean containsError(Diagnostics<Diagnosis> diagnostics, DiagnosisType type, String entity, int infos) {
        Iterator<Diagnosis> iter = diagnostics.getErrors().iterator();
        Diagnosis diagnosis;
        while (iter.hasNext()) {
            diagnosis = iter.next();
            if (diagnosis.type == type && diagnosis.entity.equals(entity) && diagnosis.information.length == infos) {
                return true;
            }
View Full Code Here

        return false;
    }

    public static boolean containsWarning(Diagnostics<Diagnosis> diagnostics, DiagnosisType type, String entity, int infos) {
        Iterator<Diagnosis> iter = diagnostics.getWarnings().iterator();
        Diagnosis diagnosis;
        while (iter.hasNext()) {
            diagnosis = iter.next();
            if (diagnosis.type == type && diagnosis.entity.equals(entity) && diagnosis.information.length == infos) {
                return true;
            }
View Full Code Here

        }
        return false;
    }

    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

            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

    @Test
    public void test_empty_gzipfile() {
        ByteArrayInputStream in;
        GzipReader reader;
        GzipEntry record;
        Diagnosis d;
        try {
            in = new ByteArrayInputStream(new byte[0]);
            reader = new GzipReader(in);
            record = reader.getNextEntry();
            Assert.assertNull(record);
View Full Code Here

TOP

Related Classes of org.jwat.common.Diagnosis

Copyright © 2018 www.massapicom. 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.