forked from CharlesSkelton/studio
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
config test which will be useful to test upgrades
- Loading branch information
Showing
3 changed files
with
169 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package studio.kdb; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import studio.core.DefaultAuthenticationMechanism; | ||
import studio.kdb.config.ActionOnExit; | ||
import studio.utils.LineEnding; | ||
|
||
import java.awt.*; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class ConfigUpgradeTest { | ||
|
||
@Test | ||
public void testLoadingConfig13() throws IOException, URISyntaxException { | ||
byte[] content = Files.readAllBytes(Paths.get(this.getClass().getClassLoader().getResource("studio13.properties").toURI())); | ||
|
||
File tmpFile = File.createTempFile("studioforkdb", ".tmp"); | ||
tmpFile.deleteOnExit(); | ||
Files.write(tmpFile.toPath(), content); | ||
Config config = new Config(tmpFile.getPath()); | ||
|
||
assertEquals(ActionOnExit.NOTHING, config.getEnum(Config.ACTION_ON_EXIT)); | ||
assertEquals("defU", config.getDefaultCredentials(DefaultAuthenticationMechanism.NAME).getUsername()); | ||
assertEquals("defP", config.getDefaultCredentials(DefaultAuthenticationMechanism.NAME).getPassword()); | ||
assertEquals(DefaultAuthenticationMechanism.NAME, config.getDefaultAuthMechanism()); | ||
assertTrue(config.getBoolean(Config.AUTO_REPLACE_TAB_ON_OPEN)); | ||
assertEquals(250, config.getInt(Config.CELL_MAX_WIDTH)); | ||
assertEquals(0.9, config.getDouble(Config.CELL_RIGHT_PADDING)); | ||
assertEquals(LineEnding.Windows, config.getEnum(Config.DEFAULT_LINE_ENDING)); | ||
assertTrue(config.getBoolean(Config.EDITOR_TAB_EMULATED)); | ||
assertEquals(15, config.getInt(Config.EDITOR_TAB_SIZE)); | ||
assertEquals(1500, config.getInt(Config.EMULATED_DOUBLE_CLICK_TIMEOUT)); | ||
assertEquals(Config.ExecAllOption.Ignore, config.getExecAllOption()); | ||
assertEquals(new Font("Times New Roman", Font.PLAIN, 18),config.getFont(Config.FONT_EDITOR)); | ||
assertEquals(new Font("Arial", Font.PLAIN, 14),config.getFont(Config.FONT_TABLE)); | ||
assertTrue(config.getBoolean(Config.AUTO_SAVE)); | ||
assertEquals("javax.swing.plaf.nimbus.NimbusLookAndFeel",config.getLookAndFeel()); | ||
assertEquals(500000, config.getMaxCharsInResult()); | ||
assertEquals(1024, config.getMaxCharsInTableCell()); | ||
assertEquals(9, config.getInt(Config.MAX_FRACTION_DIGITS)); | ||
assertEquals(20, config.getResultTabsCount()); | ||
assertFalse(config.getBoolean(Config.RSTA_ANIMATE_BRACKET_MATCHING)); | ||
assertFalse(config.getBoolean(Config.RSTA_HIGHLIGHT_CURRENT_LINE)); | ||
assertFalse(config.getBoolean(Config.RSTA_INSERT_PAIRED_CHAR)); | ||
assertTrue(config.getBoolean(Config.RSTA_WORD_WRAP)); | ||
assertTrue(config.getBoolean(Config.SESSION_INVALIDATION_ENABLED)); | ||
assertEquals(10, config.getInt(Config.SESSION_INVALIDATION_TIMEOUT_IN_HOURS)); | ||
assertFalse(config.getBoolean(Config.SESSION_REUSE)); | ||
assertFalse(config.getBoolean(Config.SHOW_SERVER_COMBOBOX)); | ||
|
||
|
||
ServerTreeNode serverTree = config.getServerTree(); | ||
assertEquals(4, serverTree.getChildCount()); | ||
|
||
ServerTreeNode folder = serverTree.getChild(1); | ||
assertEquals("Folder", folder.getFolder()); | ||
assertEquals(1, folder.getChildCount()); | ||
ServerTreeNode subFolder = folder.getChild(0); | ||
assertEquals("Sub-Folder", subFolder.getFolder()); | ||
assertEquals(1, subFolder.getChildCount()); | ||
ServerTreeNode root2 = serverTree.getChild(2); | ||
assertEquals("Root2", root2.getFolder()); | ||
assertEquals(1, root2.getChildCount()); | ||
|
||
Server server1 = serverTree.getChild(0).getServer(); | ||
Server inner = subFolder.getChild(0).getServer(); | ||
Server inner2 = root2.getChild(0).getServer(); | ||
Server last = serverTree.getChild(3).getServer(); | ||
|
||
String defAuth = DefaultAuthenticationMechanism.NAME; | ||
assertEquals(new Server("server1", "serverHost", 2000, | ||
"user", "password", new Color(0x99ffff), defAuth, true), server1); | ||
assertEquals(new Color(0x99ffff), server1.getBackgroundColor()); | ||
|
||
assertEquals(new Server("innerServer", "anotherHost", 3000, | ||
"", "", Color.WHITE, defAuth, false), | ||
inner); | ||
|
||
assertEquals(new Server("innerServer2", "host2", 4000, | ||
"", "", Color.WHITE, defAuth, false), | ||
inner2); | ||
|
||
assertEquals(new Server("The.Last.Server", "lastServer", 5000, | ||
"", "", Color.WHITE, "customAuth", false), | ||
last); | ||
|
||
} | ||
} |
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,74 @@ | ||
#Auto-generated by Studio for kdb+ | ||
#Fri Mar 22 15:53:03 CET 2024 | ||
actionOnExit=NOTHING | ||
auth.Username\ and\ password.password=defP | ||
auth.Username\ and\ password.user=defU | ||
auth=Username and password | ||
autoReplaceTabOnOpen=true | ||
cellMaxWidth=250 | ||
cellRightPadding=0.9 | ||
defaultLineEnding=Windows | ||
editorTabEmulated=true | ||
editorTabSize=15 | ||
emulatedDoubleClickTimeout=1500 | ||
execAllOption=Ignore | ||
font.name=Times New Roman | ||
font.size=18 | ||
font.style=Plain | ||
fontTable.name=Arial | ||
fontTable.size=14 | ||
fontTable.style=Plain | ||
isAutoSave=true | ||
kdbMessageSizeLimitAction=BLOCK | ||
kdbMessageSizeLimitMB=15 | ||
lookandfeel=javax.swing.plaf.nimbus.NimbusLookAndFeel | ||
maxCharsInResult=500000 | ||
maxCharsInTableCell=1024 | ||
maxFractionDigits=9 | ||
notesHash=5647032c4b5d377f9b55fbc0535ea772 | ||
resultTabsCount=20 | ||
rstaAnimateBracketMatching=false | ||
rstaHighlightCurrentLine=false | ||
rstaInsertPairedChar=false | ||
rstaWordWrap=true | ||
server.0.authenticationMechanism=Username and password | ||
server.0.backgroundColor=99ffff | ||
server.0.host=serverHost | ||
server.0.password=password | ||
server.0.port=2000 | ||
server.0.useTLS=true | ||
server.0.user=user | ||
server.1.authenticationMechanism=Username and password | ||
server.1.backgroundColor=ffffff | ||
server.1.host=anotherHost | ||
server.1.password= | ||
server.1.port=3000 | ||
server.1.useTLS=false | ||
server.1.user= | ||
server.2.authenticationMechanism=Username and password | ||
server.2.backgroundColor=ffffff | ||
server.2.host=host2 | ||
server.2.password= | ||
server.2.port=4000 | ||
server.2.useTLS=false | ||
server.2.user= | ||
server.3.authenticationMechanism=customAuth | ||
server.3.backgroundColor=ffffff | ||
server.3.host=lastServer | ||
server.3.password= | ||
server.3.port=5000 | ||
server.3.useTLS=false | ||
server.3.user= | ||
serverHistory.0=Root2/innerServer2 | ||
serverTree.0=server1 | ||
serverTree.1.0.0=innerServer | ||
serverTree.1.0folder=Sub-Folder | ||
serverTree.1folder=Folder | ||
serverTree.2.0=innerServer2 | ||
serverTree.2folder=Root2 | ||
serverTree.3=The.Last.Server | ||
sessionInvalidationEnabled=true | ||
sessionInvalidationTimeoutInHours=10 | ||
sessionsReuse=false | ||
showServerComboBox=false | ||
version=1.3 |