org.kie.commons.java.nio.file.Path.getRoot()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(15.4k)|赞(0)|评价(0)|浏览(124)

本文整理了Java中org.kie.commons.java.nio.file.Path.getRoot()方法的一些代码示例,展示了Path.getRoot()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Path.getRoot()方法的具体详情如下:
包路径:org.kie.commons.java.nio.file.Path
类名称:Path
方法名:getRoot

Path.getRoot介绍

暂无

代码示例

代码示例来源:origin: org.kie.guvnor/guvnor-project-backend

private Path getFileSystemRoot( final Path activePath ) {
  return paths.convert( paths.convert( activePath ).getRoot(),
             false );
}

代码示例来源:origin: org.kie.guvnor/guvnor-core-services-backend

@Override
  public Categories getCategoriesFromResource( final Path resource ) {
    final org.kie.commons.java.nio.file.Path categoriesPath = paths.convert( resource ).getRoot().resolve( "categories.xml" );

    return getContent( paths.convert( categoriesPath ) );
  }
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testGetComplexPath() {
  final URI newRepo = URI.create( "git://new-complex-get-repo-name" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://origin/master@new-complex-get-repo-name/home" ) );
  assertThat( path ).isNotNull();
  assertThat( path.getRoot().toString() ).isEqualTo( "/" );
  assertThat( path.toString() ).isEqualTo( "/home" );
  final Path pathRelative = PROVIDER.getPath( URI.create( "git://origin/master@new-complex-get-repo-name/:home" ) );
  assertThat( pathRelative ).isNotNull();
  assertThat( pathRelative.getRoot().toString() ).isEqualTo( "" );
  assertThat( pathRelative.toString() ).isEqualTo( "home" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
  public void testGetComplexPath() {
    final URI newRepo = URI.create("default://default-new-complex-get-repo-name");

    PROVIDER.newFileSystem(newRepo, EMPTY_ENV);

    final Path path = PROVIDER.getPath(URI.create("default://origin/master@default-new-complex-get-repo-name/home"));

    assertThat(path).isNotNull();
    assertThat(path.getRoot().toString()).isEqualTo("/");
    assertThat(path.toString()).isEqualTo("/home");
    assertThat(path.toUri().getScheme()).isEqualTo("default");

    final Path pathRelative = PROVIDER.getPath(URI.create("default://origin/master@default-new-complex-get-repo-name/:home"));
    assertThat(pathRelative).isNotNull();
    assertThat(pathRelative.getRoot().toString()).isEqualTo("");
    assertThat(pathRelative.getRoot().toUri().toString()).isEqualTo("default://origin/master@default-new-complex-get-repo-name");
    assertThat(pathRelative.toString()).isEqualTo("home");
  }
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testGetPath() {
  final URI newRepo = URI.create( "git://new-get-repo-name" );
  PROVIDER.newFileSystem( newRepo, EMPTY_ENV );
  final Path path = PROVIDER.getPath( URI.create( "git://master@new-get-repo-name/home" ) );
  assertThat( path ).isNotNull();
  assertThat( path.getRoot().toString() ).isEqualTo( "/" );
  assertThat( path.getRoot().toRealPath().toUri().toString() ).isEqualTo( "git://master@new-get-repo-name/" );
  assertThat( path.toString() ).isEqualTo( "/home" );
  final Path pathRelative = PROVIDER.getPath( URI.create( "git://master@new-get-repo-name/:home" ) );
  assertThat( pathRelative ).isNotNull();
  assertThat( pathRelative.toRealPath().toUri().toString() ).isEqualTo( "git://master@new-get-repo-name/:home" );
  assertThat( pathRelative.getRoot().toString() ).isEqualTo( "" );
  assertThat( pathRelative.toString() ).isEqualTo( "home" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testGetPath() {
  final URI newRepo = URI.create("default://default-new-get-repo-name");
  PROVIDER.newFileSystem(newRepo, EMPTY_ENV);
  final Path path = PROVIDER.getPath(URI.create("default://master@default-new-get-repo-name/home"));
  assertThat(path).isNotNull();
  assertThat(path.getRoot().toString()).isEqualTo("/");
  assertThat(path.toString()).isEqualTo("/home");
  assertThat(path.toUri().getScheme()).isEqualTo("default");
  final Path pathRelative = PROVIDER.getPath(URI.create("default://master@default-new-get-repo-name/:home"));
  assertThat(pathRelative).isNotNull();
  assertThat(pathRelative.toUri().toString()).isEqualTo("default://master@default-new-get-repo-name/:home");
  assertThat(pathRelative.getRoot().toString()).isEqualTo("");
  assertThat(pathRelative.toString()).isEqualTo("home");
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleBranchedGitRelative() {
  when(fs.getSeparator()).thenReturn("/");
  final Path path = JGitPathImpl.create(fs, "home", "master@my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isFalse();
  assertThat(path.toString()).isEqualTo("home");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/:home");
  assertThat(path.getRoot().toString()).isEqualTo("");
  assertThat(path.getNameCount()).isEqualTo(1);
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleBranchedGitRoot() {
  when(fs.getSeparator()).thenReturn("/");
  final Path path = JGitPathImpl.create(fs, "/", "master@my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isTrue();
  assertThat(path.toString()).isEqualTo("/");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/");
  assertThat(path.getRoot().toString()).isEqualTo("/");
  assertThat(path.getNameCount()).isEqualTo(0);
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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) {
  }
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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("/");
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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( "/" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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( "/" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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( "" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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("/");
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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( "/" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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( "" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@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("/");
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testOnlyLocalRoot() throws IOException, GitAPIException {
  final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class );
  final Git git = setupGit();
  final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() );
  assertThat( fileSystem.isReadOnly() ).isFalse();
  assertThat( fileSystem.getSeparator() ).isEqualTo( "/" );
  assertThat( fileSystem.getName() ).isEqualTo( "my-repo" );
  assertThat( fileSystem.getRootDirectories() ).hasSize( 1 );
  final Path root = fileSystem.getRootDirectories().iterator().next();
  assertThat( root.toString() ).isEqualTo( "/" );
  assertThat( root.getRoot().toString() ).isEqualTo( "/" );
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testSimpleBranchedGit() {
  final Path path = JGitPathImpl.create(fs, "", "master@my-host", false);
  assertThat(path).isNotNull();
  assertThat(path.isAbsolute()).isTrue();
  assertThat(path.toString()).isEqualTo("/");
  assertThat(path.toUri().toString()).isEqualTo("git://master@my-host/");
  assertThat(path.getRoot()).isEqualTo(path);
  assertThat(path.getNameCount()).isEqualTo(0);
  assertThat(path.getRoot()).isNotNull().isEqualTo(path);
}

代码示例来源:origin: org.kie.commons/kie-nio2-jgit

@Test
public void testRemoteRoot() throws IOException, GitAPIException {
  final JGitFileSystemProvider fsProvider = mock( JGitFileSystemProvider.class );
  final File tempDir = createTempDirectory();
  final Git git = Git.cloneRepository().setNoCheckout( false ).setBare( true ).setCloneAllBranches( true ).setURI( setupGit().getRepository().getDirectory().toString() ).setDirectory( tempDir ).call();
  final JGitFileSystem fileSystem = new JGitFileSystem( fsProvider, null, git, "my-repo", CredentialsProvider.getDefault() );
  assertThat( fileSystem.isReadOnly() ).isFalse();
  assertThat( fileSystem.getSeparator() ).isEqualTo( "/" );
  assertThat( fileSystem.getName() ).isEqualTo( "my-repo" );
  assertThat( fileSystem.getRootDirectories() ).hasSize( 1 );
  final Path root = fileSystem.getRootDirectories().iterator().next();
  assertThat( root.toString() ).isEqualTo( "/" );
  assertThat( root.getRoot().toString() ).isEqualTo( "/" );
}

相关文章