deepdiff.unitprocessor.SortedZipCompareDiffUnitProcessor Maven / Gradle / Ivy
/*
* Copyright 2011 DeepDiff Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package deepdiff.unitprocessor;
import java.io.IOException;
import java.io.InputStream;
import org.apache.log4j.Logger;
import deepdiff.core.DiffPointProcessor;
import deepdiff.core.DiffScope;
import deepdiff.core.DiffUnit;
import deepdiff.core.ScopedDiffUnitProcessor;
import deepdiff.scope.SortedZipDiffScope;
/**
* A DiffUnitProcessor that performs deep comparisons on Zip-compressed archive DiffUnit.
*/
public class SortedZipCompareDiffUnitProcessor implements ScopedDiffUnitProcessor {
private static final Logger log = Logger.getLogger(SortedZipCompareDiffUnitProcessor.class);
/**
* Performs a deep Zip comparison on diffUnit
.
*
* @param diffUnit the unit to process
* @param processor ignored
*
* @return a {@link DiffScope} to process the archive
*/
public DiffScope processDiffUnit(DiffUnit diffUnit, DiffPointProcessor processor) {
DiffScope scope = null;
String scopedPath = diffUnit.getScopedPath();
try {
InputStream is1 = diffUnit.getLeftInputStream();
InputStream is2 = diffUnit.getRightInputStream();
scope = createScope(scopedPath, is1, is2);
} catch (IOException ioe) {
log.error("Failure processing " + diffUnit, ioe);
}
return scope;
}
@Override
public DiffScope createScope(String path, InputStream is1, InputStream is2) {
return new SortedZipDiffScope(path, is1, is2);
}
}