-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Files.copy() such that parent dirs are created
Closes #2761 Also toggled the version back to a bug fix version
- Loading branch information
1 parent
d51fbab
commit b649672
Showing
14 changed files
with
204 additions
and
23 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
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
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
2 changes: 1 addition & 1 deletion
2
...a/org/testng/jarfileutils/JarCreator.java → .../src/test/java/testhelper/JarCreator.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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.testng.jarfileutils; | ||
package testhelper; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
|
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
38 changes: 38 additions & 0 deletions
38
testng-core/src/test/java/testhelper/TestClassGenerator.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,38 @@ | ||
package testhelper; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
public final class TestClassGenerator { | ||
private static final File projectDir = SimpleCompiler.createTempDir(); | ||
|
||
private TestClassGenerator() { | ||
// Utility class. Defeat instantiation. | ||
} | ||
|
||
public static File getProjectDir() { | ||
return projectDir; | ||
} | ||
|
||
public static SourceCode[] generate(String packageName, List<String> classNames) { | ||
return classNames.stream() | ||
.map(className -> generateCode(packageName, className)) | ||
.toArray(SourceCode[]::new); | ||
} | ||
|
||
private static SourceCode generateCode(String packageName, String className) { | ||
String source = "package " + packageName + ";\n\n"; | ||
source += "import org.testng.annotations.Test;\n"; | ||
source += "public class " + className + " {\n"; | ||
source += " @Test\n"; | ||
source += " public void testMethod() {\n"; | ||
source += " }\n"; | ||
source += "}\n"; | ||
try { | ||
return new SourceCode(packageName, className, source, projectDir, false); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
testng-core/src/test/java/testhelper/TestNGSimpleClassLoader.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,36 @@ | ||
package testhelper; | ||
|
||
import java.io.File; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
|
||
public final class TestNGSimpleClassLoader extends ClassLoader { | ||
|
||
private final File baseDir; | ||
|
||
public TestNGSimpleClassLoader() { | ||
this(null); | ||
} | ||
|
||
public TestNGSimpleClassLoader(File baseDir) { | ||
this.baseDir = baseDir; | ||
} | ||
|
||
public Class<?> injectByteCode(CompiledCode byteCode) throws ClassNotFoundException { | ||
Class<?> clazz = | ||
defineClass(byteCode.getName(), byteCode.getByteCode(), 0, byteCode.getByteCode().length); | ||
return loadClass(clazz.getName()); | ||
} | ||
|
||
@Override | ||
protected URL findResource(String name) { | ||
if (this.baseDir != null) { | ||
try { | ||
return new File(this.baseDir.getAbsolutePath() + "/" + name).toURI().toURL(); | ||
} catch (MalformedURLException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
return super.findResource(name); | ||
} | ||
} |