use of org.eclipse.sw360.fossology.ssh.FossologyUploader.CapturerOutputStream in project sw360portal by sw360.
the class FossologyUploaderFunctionalTest method testRealUpload.
@Ignore
@Test
public void testRealUpload() {
doFirstConnectionAndTrust();
String test = "this is the content\n";
InputStream inputStream = new ByteArrayInputStream(test.getBytes());
final CapturerOutputStream outputStream = new CapturerOutputStream();
final String command = String.format(FossologyUploader.FOSSOLOGY_COMMAND_UPLOAD, "id", GROUP, "project");
final int exitCode = fossologySshConnector.runInFossologyViaSsh(command, inputStream, outputStream);
final long uploadId = FossologyUploader.parseResultUploadId(outputStream.getContent());
System.out.println("uploaded as " + uploadId);
assertThat("Send to fossology failed: " + outputStream.getContent(), exitCode, is(0));
assertThat("bad uploadId received: " + outputStream.getContent(), uploadId, is(greaterThan(0L)));
int i = 0;
while (++i < 60) {
ByteArrayOutputStream osget = new ByteArrayOutputStream();
final String commandGet = String.format(FossologyUploader.FOSSOLOGY_COMMAND_GET_STATUS, uploadId, GROUP);
final int exitCodeGet = fossologySshConnector.runInFossologyViaSsh(commandGet, osget);
if (exitCodeGet != 0) {
fail("check status script is broken");
break;
}
final String outputget = new String(osget.toByteArray());
final FossologyStatus status = fossologyUploader.parseResultStatus(outputget);
System.out.println("status is " + status + ", try changing it from FOSSology");
if (status.equals(FossologyStatus.CLOSED)) {
break;
}
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
fail("interrupted");
}
}
}
use of org.eclipse.sw360.fossology.ssh.FossologyUploader.CapturerOutputStream in project sw360portal by sw360.
the class FossologyUploaderFunctionalTest method testNotLosingBytes.
@Test
public void testNotLosingBytes() {
RealSshConnectionUtils.assumeCanOpenSshSessions();
final long count = 5000000L;
CapturerOutputStream capturer = new CapturerOutputStream();
InputStream inputStream = new RepeaterInputStream("\n", count);
doFirstConnectionAndTrust();
assertThat(fossologySshConnector.runInFossologyViaSsh("wc -l", inputStream, capturer), is(0));
assertThat(capturer.getContent(), startsWith("" + count));
}
Aggregations