use of org.commonjava.maven.galley.io.checksum.testutil.TestDecoratorAdvisor in project galley by Commonjava.
the class ChecksummingTransferDecoratorTest method customChecksumReaderFilter.
@Test
public void customChecksumReaderFilter() throws Exception {
String path = "my-path.txt";
fixture.setDecorator(new ChecksummingTransferDecorator(new TestDecoratorAdvisor(), new DisabledChecksummingDecoratorAdvisor(), new SpecialPathManagerImpl(), metadataConsumer, new Md5GeneratorFactory()));
fixture.initMissingComponents();
fixture.getCache().startReporting();
final Transfer txfr = fixture.getCache().getTransfer(new ConcreteResource(new SimpleLocation("test:uri"), path));
File f = new File(temp.getRoot(), "cache/test:uri");
f = new File(f, path);
byte[] data = "This is a test with a bunch of data and some other stuff, in a big box sealed with chewing gum".getBytes();
FileUtils.writeByteArrayToFile(f, data);
EventMetadata em = new EventMetadata();
logger.debug("Reading stream with EventMetadata advice: {}", em.get(DO_CHECKSUMS));
assertRead(txfr, data, em, false, false);
em = new EventMetadata().set(DO_CHECKSUMS, ChecksummingDecoratorAdvisor.ChecksumAdvice.CALCULATE_NO_WRITE);
logger.debug("Reading stream with EventMetadata advice: {}", em.get(DO_CHECKSUMS));
assertRead(txfr, data, em, false, true);
logger.debug("Removing checksum metadata from consumer");
metadataConsumer.removeMetadata(txfr);
em = new EventMetadata().set(DO_CHECKSUMS, ChecksummingDecoratorAdvisor.ChecksumAdvice.CALCULATE_AND_WRITE);
logger.debug("Reading stream with EventMetadata advice: {}", em.get(DO_CHECKSUMS));
assertRead(txfr, data, em, true, true);
}
Aggregations