forked from schemaspy/schemaspy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a synthetic argument hostOptionalPort, fixes schemaspy#109
* If host contains port uses it. * If host is missing port but -port is used it's by default separated by `:`. * If port is missing only host is used. * Host Port Separator can be customized with property in dbType `hostPortSeparator`.
- Loading branch information
Showing
24 changed files
with
147 additions
and
61 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
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
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
70 changes: 70 additions & 0 deletions
70
src/test/java/org/schemaspy/util/ConnectionURLBuilderTest.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,70 @@ | ||
package org.schemaspy.util; | ||
|
||
import org.junit.Test; | ||
import org.schemaspy.Config; | ||
|
||
import java.io.IOException; | ||
import java.util.Properties; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ConnectionURLBuilderTest { | ||
|
||
@Test | ||
public void shouldReplaceHostInConnectionSpec() throws IOException { | ||
Config config = new Config( | ||
"-t", "src/test/resources/dbtypes/onlyHost", | ||
"-host", "abc.com", | ||
"-u", "aUser"); | ||
Properties properties = config.determineDbProperties(config.getDbType()); | ||
ConnectionURLBuilder connectionURLBuilder = new ConnectionURLBuilder(config, properties); | ||
assertThat(connectionURLBuilder.getConnectionURL()).isEqualToIgnoringCase("abc.com"); | ||
} | ||
|
||
@Test | ||
public void shouldReplaceHostAndOrPortWithOnlyHost() throws IOException { | ||
Config config = new Config( | ||
"-t", "src/test/resources/dbtypes/hostOptionalPort", | ||
"-host", "abc.com", | ||
"-u", "aUser"); | ||
Properties properties = config.determineDbProperties(config.getDbType()); | ||
ConnectionURLBuilder connectionURLBuilder = new ConnectionURLBuilder(config, properties); | ||
assertThat(connectionURLBuilder.getConnectionURL()).isEqualToIgnoringCase("abc.com"); | ||
} | ||
|
||
@Test | ||
public void shouldReplaceHostAndOrPortWithHostAndPort() throws IOException { | ||
Config config = new Config( | ||
"-t", "src/test/resources/dbtypes/hostOptionalPort", | ||
"-host", "abc.com", | ||
"-port", "1234", | ||
"-u", "aUser"); | ||
Properties properties = config.determineDbProperties(config.getDbType()); | ||
ConnectionURLBuilder connectionURLBuilder = new ConnectionURLBuilder(config, properties); | ||
assertThat(connectionURLBuilder.getConnectionURL()).isEqualToIgnoringCase("abc.com:1234"); | ||
} | ||
|
||
@Test | ||
public void shouldReplaceHostAndOrPortWithHostAndPortOnlyOnce() throws IOException { | ||
Config config = new Config( | ||
"-t", "src/test/resources/dbtypes/hostOptionalPort", | ||
"-host", "abc.com:4321", | ||
"-port", "1234", | ||
"-u", "aUser"); | ||
Properties properties = config.determineDbProperties(config.getDbType()); | ||
ConnectionURLBuilder connectionURLBuilder = new ConnectionURLBuilder(config, properties); | ||
assertThat(connectionURLBuilder.getConnectionURL()).isEqualToIgnoringCase("abc.com:4321"); | ||
} | ||
|
||
@Test | ||
public void shouldReplaceHostAndOrPortWithCustomSeparator() throws IOException { | ||
Config config = new Config( | ||
"-t", "src/test/resources/dbtypes/hostOptionalPortCustomSeparator", | ||
"-host", "abc.com", | ||
"-port", "1234", | ||
"-u", "aUser"); | ||
Properties properties = config.determineDbProperties(config.getDbType()); | ||
ConnectionURLBuilder connectionURLBuilder = new ConnectionURLBuilder(config, properties); | ||
assertThat(connectionURLBuilder.getConnectionURL()).isEqualToIgnoringCase("abc.com|1234"); | ||
} | ||
} |
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,3 @@ | ||
connectionSpec=<hostOptionalPort> | ||
host=host where database resides with optional port | ||
port=database server listening port |
4 changes: 4 additions & 0 deletions
4
src/test/resources/dbtypes/hostOptionalPortCustomSeparator.properties
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,4 @@ | ||
connectionSpec=<hostOptionalPort> | ||
host=host where database resides with optional port | ||
port=database server listening port | ||
hostPortSeparator=| |
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,2 @@ | ||
connectionSpec=<host> | ||
host=hostname[:port] host where database resides with optional port |