Example usage for org.springframework.ide.eclipse.boot.dash.test.mocks MockCFApplication getBits

List of usage examples for org.springframework.ide.eclipse.boot.dash.test.mocks MockCFApplication getBits

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.boot.dash.test.mocks MockCFApplication getBits.

Prototype

public ByteArrayInputStream getBits() 

Source Link

Usage

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java

private void assertDeployedBytes(File referenceJar, MockCFApplication app) throws IOException {
    try (InputStream actualBits = app.getBits()) {
        try (InputStream expectedBits = new BufferedInputStream(new FileInputStream(referenceJar))) {
            ZipDiff zipDiff = new ZipDiff(expectedBits);
            try {
                zipDiff.assertEqual(actualBits);
            } catch (Throwable e) {
                System.out.println("Failed: " + ExceptionUtil.getMessage(e));
                saveArtefacts(referenceJar, app);
                throw e;
            }//  w ww . j  a  v  a2  s.c  om
        }
    }
}

From source file:org.springframework.ide.eclipse.boot.dash.test.CloudFoundryBootDashModelMockingTest.java

private void saveArtefacts(File referenceJar, MockCFApplication app) throws IOException {
    System.out.println("Trying to save jars...");
    File targetDir = getSaveDir();
    System.out.println("targetDir = " + targetDir);
    if (targetDir != null) {
        int id = uniqueId++;
        File referenceJarCopy = new File(targetDir, "deployed-reference-" + id + ".jar");
        File faultyJarCopy = new File(targetDir, "deployed-faulty-" + id + ".jar");
        FileUtils.copyFile(referenceJar, referenceJarCopy);
        System.out.println("Reference jar saved: " + referenceJarCopy);
        IOUtil.pipe(app.getBits(), faultyJarCopy);
        System.out.println("Faulty jar saved: " + faultyJarCopy);
    }/*from   w  w  w .j  a v a  2s .c  o  m*/
}