Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ public Collection<String> getStdUDFImplementations(String topLevelClass) {
return _udfs.get(topLevelClass);
}

public void toJson(Writer writer) {
GSON.toJson(TransportUDFMetadataSerDe.fromUDFMetadata(this), writer);
public void toJson(Writer writer) throws IOException {
String json = GSON.toJson(TransportUDFMetadataSerDe.fromUDFMetadata(this));
// Gson uses \n for newlines, but on Windows we need \r\n to match test expectations
String jsonWithSystemLineSeparator = json.replace("\n", System.lineSeparator());
writer.write(jsonWithSystemLineSeparator);
}

public static TransportUDFMetadata fromJsonFile(File jsonFile) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@


public class TransportPluginTest {
private final String udfRepoDir = getClass().getClassLoader().getResource("transport-udf-repo").getPath();
private final String udfRepoDir;
private LocalQueryRunner queryRunner;

public TransportPluginTest() {
try {
udfRepoDir = java.nio.file.Paths.get(getClass().getClassLoader().getResource("transport-udf-repo").toURI()).toString();
} catch (Exception e) {
throw new RuntimeException("Failed to resolve transport-udf-repo path", e);
}
}

@BeforeClass
public void setUp() {
SqlPath sqlPath = new SqlPath("LINKEDIN.transport");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,26 @@ public class FileSystemUtilsTest {

@Test
public void testResolveLatest() throws IOException, URISyntaxException {
String resourcePath = "file://" + getPathForResource("root");
// Use proper file URI format: file:/// for local files
String resourcePath = java.nio.file.Paths.get(getPathForResource("root")).toUri().toString().replaceAll("/$", "");

// Test cases to resolve #LATEST
// Normalize paths for cross-platform compatibility by replacing backslashes with forward slashes
String filePath = FileSystemUtils.resolveLatest(resourcePath + "/2018/11/02.dat");
Assert.assertTrue(
FileSystemUtils.resolveLatest(resourcePath + "/2018/11/02.dat").endsWith("/root/2018/11/02.dat"));
normalizePath(FileSystemUtils.resolveLatest(resourcePath + "/2018/11/02.dat")).endsWith("/root/2018/11/02.dat"),
"Expected path to end with /root/2018/11/02.dat but was: " + normalizePath(FileSystemUtils.resolveLatest(resourcePath + "/2018/11/02.dat")));
Assert.assertTrue(
FileSystemUtils.resolveLatest(resourcePath + "/#LATEST/11/#LATEST").endsWith("/root/2019/11/02.dat"));
normalizePath(FileSystemUtils.resolveLatest(resourcePath + "/#LATEST/11/#LATEST")).endsWith("/root/2019/11/02.dat"));
Assert.assertTrue(
FileSystemUtils.resolveLatest(resourcePath + "/#LATEST/#LATEST/#LATEST").endsWith("/root/2019/12/02.dat"));
normalizePath(FileSystemUtils.resolveLatest(resourcePath + "/#LATEST/#LATEST/#LATEST")).endsWith("/root/2019/12/02.dat"));
Assert.assertTrue(
FileSystemUtils.resolveLatest(resourcePath + "/#LATEST/#LATEST").endsWith("/root/2019/13.dat"));
normalizePath(FileSystemUtils.resolveLatest(resourcePath + "/#LATEST/#LATEST")).endsWith("/root/2019/13.dat"));
}

private String normalizePath(String path) {
// Replace backslashes with forward slashes for consistent path comparison
return path.replace('\\', '/');
}

private String getPathForResource(String resource) throws URISyntaxException {
Expand Down