|
| 1 | +package org.jsmart.zerocode.testhelp.tests; |
| 2 | + |
| 3 | +import java.io.File; |
| 4 | +import java.io.FileNotFoundException; |
| 5 | +import java.io.IOException; |
| 6 | +import java.io.InputStream; |
| 7 | +import java.nio.charset.StandardCharsets; |
| 8 | +import java.nio.file.Files; |
| 9 | +import java.nio.file.Path; |
| 10 | +import java.nio.file.Paths; |
| 11 | +import java.nio.file.StandardOpenOption; |
| 12 | + |
| 13 | +import org.jsmart.zerocode.core.domain.Scenario; |
| 14 | +import org.jsmart.zerocode.core.domain.TargetEnv; |
| 15 | +import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner; |
| 16 | +import org.junit.BeforeClass; |
| 17 | +import org.junit.Test; |
| 18 | +import org.junit.runner.RunWith; |
| 19 | + |
| 20 | +@TargetEnv("github_host.properties") |
| 21 | +@RunWith(ZeroCodeUnitRunner.class) |
| 22 | +public class ScenarioAbsolutePathTest { |
| 23 | + |
| 24 | + // Trying in target folder |
| 25 | + private static String folder1File1 = "target/temp/unit_test_files/cherry_pick_tests/folder_a/test_case_1.json"; |
| 26 | + private static String sourceResourceFile = "helloworld/hello_world_status_ok_assertions.json"; |
| 27 | + |
| 28 | + @BeforeClass |
| 29 | + public static void start() { |
| 30 | + System.out.println("INSIDE BEFORE"); |
| 31 | + Path path = Paths.get(folder1File1); |
| 32 | + try { |
| 33 | + Files.createDirectories(path.getParent()); |
| 34 | + String absolutePath = path.toFile().getAbsolutePath(); |
| 35 | + File f1 = new File(absolutePath); |
| 36 | + f1.createNewFile(); |
| 37 | + |
| 38 | + InputStream resourceStream = Thread.currentThread() |
| 39 | + .getContextClassLoader() |
| 40 | + .getResourceAsStream(sourceResourceFile); |
| 41 | + if (resourceStream == null) { |
| 42 | + throw new FileNotFoundException( |
| 43 | + "Resource file '" + sourceResourceFile + "' not found in test resources."); |
| 44 | + } |
| 45 | + |
| 46 | + String contents = new String(resourceStream.readAllBytes(), StandardCharsets.UTF_8); |
| 47 | + |
| 48 | + Files.writeString(path, contents, StandardCharsets.UTF_8, StandardOpenOption.TRUNCATE_EXISTING); |
| 49 | + |
| 50 | + } catch (IOException exx) { |
| 51 | + throw new RuntimeException("Create file '" + folder1File1 + "' Exception" + exx); |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + @Scenario("target/temp/unit_test_files/cherry_pick_tests/folder_a/test_case_1.json") |
| 57 | + public void testAbsolutePathGet() throws Exception { |
| 58 | + } |
| 59 | +} |
0 commit comments