private char getSeparator() { if (usesWindowsFormat) { return '\\'; } return fs.getSeparator().toCharArray()[0]; }
@Before public void setup() { when(fs.getSeparator()).thenReturn("/"); when(nfs.getSeparator()).thenReturn("/"); }
@Before public void setup() { when(fs.getSeparator()).thenReturn("/"); }
@Before public void setup() { when(fs.getSeparator()).thenReturn("/"); }
@Before public void setup() { when(fs.getSeparator()).thenReturn("/"); param = GeneralPathImpl.create(fs, "path", false); }
@Test public void checkResolveNull2() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("/"); final Path path = create(fs, "/path/to/", false); assertThatThrownBy(() -> path.resolve((Path) null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Parameter named 'other' should be not null!"); }
@Test public void checkResolveNull() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("/"); final Path path = create(fs, "/path/to/", false); assertThatThrownBy(() -> path.resolve((String) null)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Parameter named 'other' should be not null!"); }
private void mockIoService() { final String artifact = "existentModule"; final String uri = repository.getUri() + fileSystem.getSeparator() + artifact; final Path path = PathFactory.newPath(artifact, uri); doReturn(fileSystem).when(ioService).getFileSystem(any(URI.class)); doReturn(Paths.convert(path)).when(ioService).get(eq(uri)); doReturn(true).when(ioService).exists(eq(Paths.convert(path))); } }
@Test public void testRelativizeWindowsIllegal3() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("\\"); final Path path = create(fs, "", false); final Path other = create(fs, "c:\\path\\to", false); assertThatThrownBy(() -> path.relativize(other)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Could not relativize path 'otherx', 'isAbsolute()' for 'this' and 'otherx' should be equal."); }
@Test public void testRelativizeIlegal1() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("/"); final Path path = create(fs, "/path/to", false); final Path other = create(fs, "some/place", false); assertThatThrownBy(() -> path.relativize(other)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Could not relativize path 'otherx', 'isAbsolute()' for 'this' and 'otherx' should be equal."); }
@Test public void testRelativizeWindowsIllegal1() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("\\"); final Path path = create(fs, "c:\\path\\to", false); final Path other = create(fs, "some\\place", false); assertThatThrownBy(() -> path.relativize(other)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Could not relativize path 'otherx', 'isAbsolute()' for 'this' and 'otherx' should be equal."); }
@Test public void testRelativizeWindowsIllegal2() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("\\"); final Path path = create(fs, "some\\place", false); final Path other = create(fs, "c:\\path\\to", false); assertThatThrownBy(() -> path.relativize(other)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Could not relativize path 'otherx', 'isAbsolute()' for 'this' and 'otherx' should be equal."); }
@Test public void testToFile() throws Exception { when(fs.getSeparator()).thenReturn("/"); final File file = File.createTempFile("foo", "bar"); final Path path = GeneralPathImpl.newFromFile(fs, file); assertThat(path).isNotNull(); assertThat(path.toString()).isEqualTo(file.getAbsolutePath()); assertThat(path.toFile()).isEqualTo(file); }
@Test public void testRelativizeWindowsIllegal4() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("\\"); final Path path = create(fs, "d:\\path\\to", false); final Path other = create(fs, "c:\\path\\to", false); assertThatThrownBy(() -> path.relativize(other)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Could not relativize path 'otherx', 'getRoot()' for 'this' and 'otherx' should be equal."); }
@Test public void testRelativizeWindowsIllegal5() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("\\"); final Path path = create(fs, "/d:/path/to", false); final Path other = create(fs, "c:\\path\\to", false); assertThatThrownBy(() -> path.relativize(other)) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Could not relativize path 'otherx', 'getRoot()' for 'this' and 'otherx' should be equal."); }
public void createDeploymentDescriptor( @Observes NewProjectEvent newProjectEvent ) { KieProject project = (KieProject) newProjectEvent.getProject(); URI projectRootURI = URI.create( project.getRootPath().toURI() ); String repositoryAlias = projectRootURI.getHost(); String metaInfPath = Paths.convert( project.getKModuleXMLPath() ).getParent().toUri().toString(); String separator = Paths.convert( project.getRootPath() ).getFileSystem().getSeparator(); String deploymentDescriptorPath = metaInfPath + separator + "kie-deployment-descriptor.xml"; Path ddVFSPath = ioService.get( URI.create( deploymentDescriptorPath ) ); if ( !ioService.exists( ddVFSPath ) ) { DeploymentDescriptor dd = new DeploymentDescriptorManager( "org.jbpm.domain" ).getDefaultDescriptor(); Set<String> groups = new HashSet<String>( project.getGroups() ); Repository repo = repositoryService.getRepository( repositoryAlias ); if ( repo != null ) { groups.addAll( repo.getGroups() ); } dd.getBuilder().setRequiredRoles( new ArrayList<String>( groups ) ); String xmlDescriptor = dd.toXml(); ioService.write( ddVFSPath, xmlDescriptor ); } }
public void configurePackage(@Observes NewPackageEvent pkg) { if (isCaseProject(Paths.convert(pkg.getPackage().getModuleRootPath()))) { String resourcesPathStr = Paths.convert(pkg.getPackage().getPackageMainResourcesPath()).toUri().toString(); String separator = Paths.convert(pkg.getPackage().getModuleRootPath()).getFileSystem().getSeparator(); Path resourcesPath = ioService.get(URI.create(resourcesPathStr + separator + WORK_DEFINITION_FILE)); addWorkDefinitions(resourcesPath); } }
public void configurePackage(@Observes NewPackageEvent pkg) { if (isCaseProject(Paths.convert(pkg.getPackage().getModuleRootPath()))) { String resourcesPathStr = Paths.convert(pkg.getPackage().getPackageMainResourcesPath()).toUri().toString(); String separator = Paths.convert(pkg.getPackage().getModuleRootPath()).getFileSystem().getSeparator(); Path resourcesPath = ioService.get(URI.create(resourcesPathStr + separator + WORK_DEFINITION_FILE)); addWorkDefinitions(resourcesPath); } }
@Test public void testAbsloluteSimpleToURIUnix() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(false); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("/"); final Path path = create(fs, "/path/to/file.txt", false); final URI uri = path.toUri(); assertThat(path).isNotNull(); assertThat(uri).isNotNull(); assertThat(uri.toString()).isEqualTo("file:///path/to/file.txt"); }
@Test public void testRelativeToURIUnix() { final FileSystemProvider fsprovider = mock(FileSystemProvider.class); when(fsprovider.isDefault()).thenReturn(true); when(fsprovider.getScheme()).thenReturn("file"); when(fs.provider()).thenReturn(fsprovider); when(fs.getSeparator()).thenReturn("/"); final Path path = create(fs, "path/to/file.txt", false); final URI uri = path.toUri(); assertThat(path).isNotNull(); assertThat(uri).isNotNull(); assertThat(uri.toString()).isEqualTo("default://" + DEFAULT_PATH + "path/to/file.txt"); assertThat(path.toRealPath().toUri().toString()).isEqualTo("file://" + DEFAULT_PATH + "path/to/file.txt"); }