Skip to content

Commit

Permalink
Replace System.lineSeparator() with \n for cross-platform consistency…
Browse files Browse the repository at this point in the history
… in tests (apache#33972)
  • Loading branch information
omkar-shitole authored Dec 9, 2024
1 parent 9035f4c commit 4bb8ecc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void assertGenerate() throws SQLException {
Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
ResultSet getNodesResultSet = mockGetNodesResultSet();
when(connection.createStatement().executeQuery(
contains("SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as name," + System.lineSeparator() + "(SELECT (CASE WHEN count(i.inhrelid) > 0 THEN true ELSE false END)")))
contains("SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as name," + "\n" + "(SELECT (CASE WHEN count(i.inhrelid) > 0 THEN true ELSE false END)")))
.thenReturn(getNodesResultSet);
ResultSet getPropertiesResultSet = mockGetPropertiesResultSet();
when(connection.createStatement().executeQuery(contains("SELECT DISTINCT ON(cls.relname) cls.oid, cls.relname as name, indrelid, indkey, indisclustered"))).thenReturn(getPropertiesResultSet);
Expand All @@ -50,8 +50,8 @@ void assertGenerate() throws SQLException {
context.put("schema", "foo_schema");
context.put("name", "foo_tbl");
String actual = new PostgreSQLIndexSQLGenerator(connection, 10, 0).generate(context);
String expected = "CREATE INDEX IF NOT EXISTS foo_tbl" + System.lineSeparator() + "ON foo_schema.foo_tbl USING foo_am_name"
+ System.lineSeparator() + "()" + System.lineSeparator() + "WITH (FILLFACTOR=90)" + System.lineSeparator() + "TABLESPACE default" + System.lineSeparator() + "WHERE NULL;";
String expected = "CREATE INDEX IF NOT EXISTS foo_tbl" + "\n" + "ON foo_schema.foo_tbl USING foo_am_name"
+ "\n" + "()" + "\n" + "WITH (FILLFACTOR=90)" + "\n" + "TABLESPACE default" + "\n" + "WHERE NULL;";
assertThat(actual, is(expected));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ void assertLoad() throws SQLException {
Connection connection = mock(Connection.class, RETURNS_DEEP_STUBS);
when(connection.getCatalog()).thenReturn("foo_db");
ResultSet fetchDatabaseIdResultSet = mockFetchDatabaseIdResultSet();
when(connection.createStatement().executeQuery(System.lineSeparator() + "SELECT oid AS did, datlastsysoid FROM pg_catalog.pg_database WHERE datname = 'foo_db';" + System.lineSeparator()))
when(connection.createStatement().executeQuery("\n" + "SELECT oid AS did, datlastsysoid FROM pg_catalog.pg_database WHERE datname = 'foo_db';" + "\n"))
.thenReturn(fetchDatabaseIdResultSet);
ResultSet fetchSchemaIdResultSet = mockFetchSchemaIdResultSet();
when(connection.createStatement().executeQuery(System.lineSeparator() + "SELECT oid AS scid FROM pg_catalog.pg_namespace WHERE nspname = 'foo_schema';" + System.lineSeparator()))
when(connection.createStatement().executeQuery("\n" + "SELECT oid AS scid FROM pg_catalog.pg_namespace WHERE nspname = 'foo_schema';" + "\n"))
.thenReturn(fetchSchemaIdResultSet);
Map<String, Object> actual = new PostgreSQLTablePropertiesLoader(connection, "foo_tbl", "foo_schema", 12, 0).load();
assertThat(actual.size(), is(7));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PostgreSQLPipelineFreemarkerManagerTest {
@Test
void assertGetSQLByDefaultVersion() {
String actual = PostgreSQLPipelineFreemarkerManager.getSQLByVersion(Collections.singletonMap("databaseName", "foo_db"), "component/table/%s/get_database_id.ftl", 10, 0);
String expected = System.lineSeparator() + "SELECT oid AS did, datlastsysoid FROM pg_catalog.pg_database WHERE datname = 'foo_db';" + System.lineSeparator();
String expected = "\n" + "SELECT oid AS did, datlastsysoid FROM pg_catalog.pg_database WHERE datname = 'foo_db';" + "\n";
assertThat(actual, is(expected));
}

Expand Down

0 comments on commit 4bb8ecc

Please sign in to comment.