-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #112: Quarkus Error while trying to build the image: Unexpected i…
…nternal error near index 1 Fix Windows specific path parsing error
- Loading branch information
1 parent
1f5a81d
commit d610d31
Showing
4 changed files
with
97 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
jkube-kit/common/src/test/java/org/eclipse/jkube/kit/common/util/FileUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/** | ||
* Copyright (c) 2019 Red Hat, Inc. | ||
* This program and the accompanying materials are made | ||
* available under the terms of the Eclipse Public License 2.0 | ||
* which is available at: | ||
* | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Red Hat, Inc. - initial API and implementation | ||
*/ | ||
package org.eclipse.jkube.kit.common.util; | ||
|
||
import org.junit.Rule; | ||
import org.junit.Test; | ||
import org.junit.rules.TemporaryFolder; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public class FileUtilTest { | ||
@Rule | ||
public TemporaryFolder folder = new TemporaryFolder(); | ||
|
||
@Test | ||
public void testCreateDirectory() throws IOException { | ||
File newDirectory = new File(folder.getRoot(), "firstdirectory"); | ||
FileUtil.createDirectory(newDirectory); | ||
assertTrue(newDirectory.exists()); | ||
} | ||
|
||
@Test | ||
public void testListFilesRecursively() throws IOException { | ||
prepareDirectory(); | ||
List<File> fileList = FileUtil.listFilesRecursivelyInDirectory(folder.getRoot()); | ||
assertNotNull(fileList); | ||
assertEquals(3, fileList.size()); | ||
} | ||
|
||
@Test | ||
public void testCleanDirectory() throws IOException { | ||
prepareDirectory(); | ||
List<File> fileList = FileUtil.listFilesRecursivelyInDirectory(folder.getRoot()); | ||
assertEquals(3, fileList.size()); | ||
FileUtil.cleanDirectory(folder.getRoot()); | ||
assertFalse(folder.getRoot().exists()); | ||
} | ||
|
||
@Test | ||
public void trimWildCardCharactersFromPath() { | ||
assertEquals("lib", FileUtil.trimWildcardCharactersFromPath("lib/**")); | ||
} | ||
|
||
@Test | ||
public void testCopyDir() throws IOException { | ||
prepareDirectory(); | ||
File copyTarget = new File(folder.getRoot(), "copyTarget"); | ||
FileUtil.copyDirectory(new File(folder.getRoot(), "foo"), copyTarget); | ||
|
||
assertTrue(copyTarget.exists()); | ||
assertEquals(1, FileUtil.listFilesRecursivelyInDirectory(copyTarget).size()); | ||
assertTrue(new File(copyTarget, "fileInfoo1").exists()); | ||
} | ||
|
||
@Test | ||
public void testGetRelativePath() throws IOException { | ||
prepareDirectory(); | ||
File relativeFile = FileUtil.getRelativePath(folder.getRoot(), new File(folder.getRoot(), "foo")); | ||
assertEquals("foo", relativeFile.getPath()); | ||
relativeFile = FileUtil.getRelativePath(folder.getRoot(), new File(folder.getRoot().getAbsolutePath() + File.separator + "foo" + File.separator + "fileInfoo1")); | ||
assertEquals("foo/fileInfoo1", relativeFile.getPath()); | ||
} | ||
|
||
private void prepareDirectory() throws IOException { | ||
File dir1 = folder.newFolder("foo"); | ||
File file1 = new File(dir1, "fileInfoo1"); | ||
folder.newFile("something"); | ||
File dir2 = folder.newFolder("bar"); | ||
File file2 = new File(dir2, "fileInfoo2"); | ||
file1.createNewFile(); | ||
file2.createNewFile(); | ||
} | ||
|
||
} |