/** * Creates a new instance of <code>{@link InputStreamAssert}</code>. * @param actual the actual value. * @return the created assertion object. */ public static InputStreamAssert assertThat(InputStream actual) { return new InputStreamAssert(actual); }
assertThat(baisCaptor.getValue()).isNotNull(); baisCaptor.getValue().reset(); byte[] bytes = IOUtils.toByteArray(baisCaptor.getValue());
@Test public void checkNewInputStream() throws IOException { final File temp = File.createTempFile( "foo", "bar" ); final SimpleFileSystemProvider fsProvider = new SimpleFileSystemProvider(); final Path path = GeneralPathImpl.newFromFile( fsProvider.getFileSystem( URI.create( "file:///" ) ), temp ); final InputStream stream = fsProvider.newInputStream( path ); assertThat( stream ).isNotNull(); stream.close(); }
@Test public void testInputStream2() throws IOException { final File parentFolder = createTempDirectory(); final File gitFolder = new File( parentFolder, "mytest.git" ); final Git origin = JGitUtil.newRepository( gitFolder, true ); commit( origin, "master", "user", "user@example.com", "commit message", null, null, false, new HashMap<String, File>() {{ put( "path/to/file/myfile.txt", tempFile( "temp\n.origin\n.content" ) ); }} ); final URI newRepo = URI.create( "git://xinputstream-test-repo" ); final Map<String, Object> env = new HashMap<String, Object>() {{ put( JGitFileSystemProvider.GIT_DEFAULT_REMOTE_NAME, origin.getRepository().getDirectory().toString() ); }}; final FileSystem fs = PROVIDER.newFileSystem( newRepo, env ); assertThat( fs ).isNotNull(); final Path path = PROVIDER.getPath( URI.create( "git://origin/master@xinputstream-test-repo/path/to/file/myfile.txt" ) ); final InputStream inputStream = PROVIDER.newInputStream( path ); assertThat( inputStream ).isNotNull(); final String content = new Scanner( inputStream ).useDelimiter( "\\A" ).next(); inputStream.close(); assertThat( content ).isNotNull().isEqualTo( "temp\n.origin\n.content" ); }
@Test public void testInputStream() throws IOException { final File parentFolder = createTempDirectory(); final File gitFolder = new File( parentFolder, "mytest.git" ); final Git origin = JGitUtil.newRepository( gitFolder, true ); commit( origin, "master", "user", "user@example.com", "commit message", null, null, false, new HashMap<String, File>() {{ put( "myfile.txt", tempFile( "temp\n.origin\n.content" ) ); }} ); final URI newRepo = URI.create( "git://inputstream-test-repo" ); final Map<String, Object> env = new HashMap<String, Object>() {{ put( JGitFileSystemProvider.GIT_DEFAULT_REMOTE_NAME, origin.getRepository().getDirectory().toString() ); }}; final FileSystem fs = PROVIDER.newFileSystem( newRepo, env ); assertThat( fs ).isNotNull(); final Path path = PROVIDER.getPath( URI.create( "git://origin/master@inputstream-test-repo/myfile.txt" ) ); final InputStream inputStream = PROVIDER.newInputStream( path ); assertThat( inputStream ).isNotNull(); final String content = new Scanner( inputStream ).useDelimiter( "\\A" ).next(); inputStream.close(); assertThat( content ).isNotNull().isEqualTo( "temp\n.origin\n.content" ); }