Example usage for org.eclipse.jgit.util ProcessResult ProcessResult

List of usage examples for org.eclipse.jgit.util ProcessResult ProcessResult

Introduction

In this page you can find the example usage for org.eclipse.jgit.util ProcessResult ProcessResult.

Prototype

public ProcessResult(int exitCode, Status status) 

Source Link

Document

Constructor for ProcessResult.

Usage

From source file:org.uberfire.io.impl.BatchTest.java

License:Apache License

@Test
public void hooksShouldBeCalledOnBatch() throws IOException {

    final File hooksDir = CommonIOServiceDotFileTest.createTempDirectory();
    System.setProperty("org.uberfire.nio.git.hooks", hooksDir.getAbsolutePath());

    writeMockHook(hooksDir, "post-commit");

    JGitFileSystemProvider provider = (JGitFileSystemProvider) FileSystemProviders
            .resolveProvider(URI.create("git://hook-fs/"));

    final AtomicInteger postCommitHookCalled = new AtomicInteger();

    provider.setDetectedFS(new FS_POSIX() {
        @Override//  w w  w .  j a v a  2s.c o  m
        public ProcessResult runHookIfPresent(Repository repox, String hookName, String[] args)
                throws JGitInternalException {
            if (hookName.equals(PostCommitHook.NAME)) {
                postCommitHookCalled.incrementAndGet();
                return new ProcessResult(1, ProcessResult.Status.OK);
            }
            return new ProcessResult(ProcessResult.Status.NOT_PRESENT);
        }
    });

    ioService.newFileSystem(URI.create("git://hook-fs/"), new HashMap<>());

    Path init = ioService.get(URI.create("git://hook-fs/init.file"));

    ioService.write(init, "setupFS!");

    ioService.startBatch(init.getFileSystem());

    ioService.write(init, "onBatch!");

    ioService.endBatch();

    assertEquals(2, postCommitHookCalled.get());
}