/** Test detection of the Chlorine dioxide API. */ public void testFlickrUserDetection() throws Throwable { String url = FlickrUser.detectService(Uri.parse("http://flickr.com/photos/128962151@N05")); assertThat(url).isNotNull(); assertThat(url).isEqualTo("https://flickr.com/photos/128962151@N05"); }
/** Test detection of the Chlorine dioxide API. */ public void testFlickrDetection() throws Throwable { String url = Flickr.detectService(Uri.parse("https://api.flickr.com")); assertThat(url).isNotNull(); assertThat(url).isEqualTo("https://api.flickr.com/services/rest"); }
/** Test detection of the Mono-sodium Glutamate API. */ public void testE621Detection() throws Throwable { String url = E621.detectService(Uri.parse("https://e621.net")); assertThat(url).isNotNull(); assertThat(url).isEqualTo("https://e621.net"); }
/** Test detection of the Chlorine dioxide API. */ public void testE926Detection() throws Throwable { String url = E621.detectService(Uri.parse("https://e926.net")); assertThat(url).isNotNull(); assertThat(url).isEqualTo("https://e926.net"); }
public void testGetDefaultQuery() throws Throwable { final SearchClient client = createSearchClient(); assertThat(client.getDefaultQuery()).isNotNull(); }
public void testRequiredAuthentication() throws Throwable { final SearchClient client = createSearchClient(); assertThat(client.getDefaultQuery()).isNotNull(); }
/** Test detection of the Danbooru 2.x API */ public void testDanbooruDetection() throws Throwable { String url = Danbooru.detectService(getInstrumentation().getContext(), Uri.parse("https://danbooru.donmai.us"), RESPONSE_TIMEOUT); assertThat(url).isNotNull(); assertThat(url).isEqualTo("https://danbooru.donmai.us"); }
/** Test detection of Moebooru (Danbooru 1.x fork) boards. */ public void testMoebooruDetection() throws Throwable { String url = DanbooruLegacy.detectService(getInstrumentation().getContext(), Uri.parse("https://yande.re"), RESPONSE_TIMEOUT); assertThat(url).isNotNull(); assertThat(url).isEqualTo("https://yande.re"); }
/** Test detection of the Danbooru 1.x API */ public void testDanbooruLegacyDetection() throws Throwable { String url = DanbooruLegacy.detectService(getInstrumentation().getContext(), Uri.parse("https://danbooru.donmai.us"), RESPONSE_TIMEOUT); assertThat(url).isNotNull(); assertThat(url).isEqualTo("https://danbooru.donmai.us"); }
/** Test detection of the Gelbooru API. */ public void testGelbooruDetection() throws Throwable { String url = Gelbooru.detectService(getInstrumentation().getContext(), Uri.parse("http://safebooru.org"), RESPONSE_TIMEOUT); assertThat(url).isNotNull(); assertThat(url).isEqualTo("http://safebooru.org"); }
@Test public void testSimpleImplicitBranchGit() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "/path/to/some/place.txt", "my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testSimpleBranchedGitRoot2() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "/path/to/some/place.txt", "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testSimpleBranchedGitRoot2Spaced() throws URIException { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, URIUtil.decode("/path/to/some/some%20place.txt"), "master@my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/path/to/some/some place.txt"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/path/to/some/some%20place.txt"); assertThat(path.getNameCount()).isEqualTo(4); assertThat(path.getName(0).toString()).isNotNull().isEqualTo("path"); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); }
@Test public void testPathBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); when( fsProvider.isDefault() ).thenReturn( false ); when( fsProvider.getScheme() ).thenReturn( "git" ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); final Path path = fileSystem.getPath( "test-branch", "/path/to/some/place.txt" ); assertThat( path ).isNotNull(); assertThat( path.isAbsolute() ).isTrue(); assertThat( path.toString() ).isEqualTo( "/path/to/some/place.txt" ); assertThat( path.toUri().toString() ).isEqualTo( "git://test-branch@my-repo/path/to/some/place.txt" ); assertThat( path.getNameCount() ).isEqualTo( 4 ); assertThat( path.getName( 0 ).toString() ).isNotNull().isEqualTo( "path" ); assertThat( path.getRoot().toString() ).isNotNull().isEqualTo( "/" ); }
@Test public void testPathBranchRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); when( fsProvider.isDefault() ).thenReturn( false ); when( fsProvider.getScheme() ).thenReturn( "git" ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); final Path path = fileSystem.getPath( "test-branch", "/path/to", "some/place.txt" ); assertThat( path ).isNotNull(); assertThat( path.isAbsolute() ).isTrue(); assertThat( path.toString() ).isEqualTo( "/path/to/some/place.txt" ); assertThat( path.toUri().toString() ).isEqualTo( "git://test-branch@my-repo/path/to/some/place.txt" ); assertThat( path.getNameCount() ).isEqualTo( 4 ); assertThat( path.getName( 0 ).toString() ).isNotNull().isEqualTo( "path" ); assertThat( path.getRoot().toString() ).isNotNull().isEqualTo( "/" ); }
@Test public void testPathBranchNonRooted2() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); when( fsProvider.isDefault() ).thenReturn( false ); when( fsProvider.getScheme() ).thenReturn( "git" ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); final Path path = fileSystem.getPath( "test-branch", "path/to", "some/place.txt" ); assertThat( path ).isNotNull(); assertThat( path.isAbsolute() ).isFalse(); assertThat( path.toString() ).isEqualTo( "path/to/some/place.txt" ); assertThat( path.toUri().toString() ).isEqualTo( "git://test-branch@my-repo/:path/to/some/place.txt" ); assertThat( path.getNameCount() ).isEqualTo( 4 ); assertThat( path.getName( 0 ).toString() ).isNotNull().isEqualTo( "path" ); assertThat( path.getRoot().toString() ).isNotNull().isEqualTo( "" ); }
@Test public void testPathNonBranchRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); when( fsProvider.isDefault() ).thenReturn( false ); when( fsProvider.getScheme() ).thenReturn( "git" ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); final Path path = fileSystem.getPath( "/path/to/some/place.txt" ); assertThat( path ).isNotNull(); assertThat( path.isAbsolute() ).isTrue(); assertThat( path.toString() ).isEqualTo( "/path/to/some/place.txt" ); assertThat( path.toUri().toString() ).isEqualTo( "git://master@my-repo/path/to/some/place.txt" ); assertThat( path.getNameCount() ).isEqualTo( 4 ); assertThat( path.getName( 0 ).toString() ).isNotNull().isEqualTo( "path" ); assertThat( path.getRoot().toString() ).isNotNull().isEqualTo( "/" ); }
@Test public void testPathBranchNonRooted() throws IOException, GitAPIException { final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class ); when( fsProvider.isDefault() ).thenReturn( false ); when( fsProvider.getScheme() ).thenReturn( "git" ); final Git git = setupGit(); final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() ); final Path path = fileSystem.getPath( "test-branch", "path/to/some/place.txt" ); assertThat( path ).isNotNull(); assertThat( path.isAbsolute() ).isFalse(); assertThat( path.toString() ).isEqualTo( "path/to/some/place.txt" ); assertThat( path.toUri().toString() ).isEqualTo( "git://test-branch@my-repo/:path/to/some/place.txt" ); assertThat( path.getNameCount() ).isEqualTo( 4 ); assertThat( path.getName( 0 ).toString() ).isNotNull().isEqualTo( "path" ); assertThat( path.getRoot().toString() ).isNotNull().isEqualTo( "" ); }
@Test public void testSimpleImplicitBranchGitRoot() { when(fs.getSeparator()).thenReturn("/"); final Path path = JGitPathImpl.create(fs, "/", "my-host", false); assertThat(path).isNotNull(); assertThat(path.isAbsolute()).isTrue(); assertThat(path.toString()).isEqualTo("/"); assertThat(path.getRoot().toString()).isEqualTo("/"); assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/"); assertThat(path.getNameCount()).isEqualTo(0); assertThat(path.getRoot().toString()).isNotNull().isEqualTo("/"); try { assertThat(path.getName(0).toString()).isNotNull().isEqualTo(""); failBecauseExceptionWasNotThrown(IllegalArgumentException.class); } catch (IllegalArgumentException ex) { } }
@Test public void checkGetFileStore() { final Path path = GeneralPathImpl.create( fsProvider.getFileSystem( URI.create( "file:///" ) ), "c:\\path\\to\\file.txt", false ); assertThat( fsProvider.getFileStore( path ) ).isNotNull().isInstanceOf( SimpleWindowsFileStore.class ); assertThat( fsProvider.getFileStore( path ).name() ).isNotNull().isEqualTo( "c:\\" ); }