use of com.opentext.ia.sdk.support.io.ByteArrayInputOutputStream in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenAssemblingSips method assertPackagingInformation.
private void assertPackagingInformation(ZipInputStream zip, Collection<Object> objects, EncodedHash pdiHash) throws IOException {
ZipEntry entry = zip.getNextEntry();
assertNotNull(entry, "Missing Packaging Information");
assertEquals("eas_sip.xml", entry.getName(), "Zip entry");
try (ByteArrayInputOutputStream packagingInformation = new ByteArrayInputOutputStream()) {
IOUtils.copy(zip, packagingInformation);
Element sipElement = assertValidXml(packagingInformation.getInputStream(), "PackagingInformation", "sip.xsd").getDocumentElement();
assertTrue(XmlUtil.namedElementsIn(sipElement, "pdi_hash").filter(e -> equals(pdiHash, e)).findAny().isPresent(), "Missing pdi_hash: " + pdiHash);
String aiuCount = XmlUtil.getFirstChildElement(sipElement, "aiu_count").getTextContent();
assertEquals(objects.size(), Integer.parseInt(aiuCount), "# AIUs");
}
zip.closeEntry();
}
use of com.opentext.ia.sdk.support.io.ByteArrayInputOutputStream in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class SipFileValidator method assertPackagingInformation.
public SipFileValidator assertPackagingInformation(int aiuCount) throws IOException {
ZipEntry entry = zipFile.getEntry("eas_sip.xml");
assertNotNull(entry, "Missing Packaging Information");
try (ByteArrayInputOutputStream packagingInformation = new ByteArrayInputOutputStream();
InputStream in = zipFile.getInputStream(entry)) {
IOUtils.copy(in, packagingInformation);
Element sipElement = assertValidXml(packagingInformation.getInputStream(), "PackagingInformation", "sip.xsd").getDocumentElement();
String actualAiuCount = XmlUtil.getFirstChildElement(sipElement, "aiu_count").getTextContent();
assertEquals(aiuCount, Integer.parseInt(actualAiuCount), "# AIUs");
}
return this;
}
use of com.opentext.ia.sdk.support.io.ByteArrayInputOutputStream in project infoarchive-sip-sdk by Enterprise-Content-Management.
the class WhenWorkingWithHttp method init.
@BeforeEach
public void init() throws IOException {
server = HttpServer.create(new InetSocketAddress(0), 0);
int port = server.getAddress().getPort();
uri = "http://localhost:" + port + PATH;
server.createContext(PATH, httpExchange -> {
ByteArrayInputOutputStream content = new ByteArrayInputOutputStream();
long size = IOUtils.copy(httpExchange.getRequestBody(), content);
httpExchange.sendResponseHeaders(200, size);
try (InputStream input = content.getInputStream()) {
IOUtils.copy(input, httpExchange.getResponseBody());
}
httpExchange.close();
});
server.setExecutor(null);
serverThread = new Thread(() -> server.start());
serverThread.start();
}
Aggregations