/** * Test method for {@link DatabaseConnectionInput#getValues()} and {@link * DatabaseConnectionInput#setValues(ConfigurationSettingDatabaseConnection)} * * <p>The getValue and setValue methods should set and retrieve settings. */ public void testGetSetValues() throws AlgorithmConfigurationException { // Set up TestHelper.resetDatabaseSync(); TabWrapper tabWrapper = new TabWrapper(); DatabaseConnection dbConnection = new DatabaseConnection(); dbConnection.setUrl("url"); dbConnection.setPassword("password"); dbConnection.setUsername("username"); dbConnection.setSystem(DbSystem.DB2); // Expected values ConfigurationSettingDatabaseConnection expectedSetting = new ConfigurationSettingDatabaseConnection("url", "username", "password", DbSystem.DB2); // Initialize DatabaseConnectionInput (waiting for fetching all current database connections) DatabaseConnectionInput databaseConnectionInput = new DatabaseConnectionInput(false, false, tabWrapper, new ArrayList<String>()); databaseConnectionInput.databaseConnections.put("url", dbConnection); databaseConnectionInput.listBox.addValue("--"); databaseConnectionInput.listBox.addValue("url"); // Execute functionality databaseConnectionInput.setValues(expectedSetting); ConfigurationSettingDatabaseConnection actualSetting = null; try { actualSetting = databaseConnectionInput.getValues(); } catch (InputValidationException e) { fail(); } // Check result assertEquals(expectedSetting.getDbUrl(), actualSetting.getDbUrl()); assertEquals(expectedSetting.getPassword(), actualSetting.getPassword()); assertEquals(expectedSetting.getUsername(), actualSetting.getUsername()); assertEquals(expectedSetting.getSystem(), actualSetting.getSystem()); // Cleanup TestHelper.resetDatabaseSync(); }
/** * Test method for {@link DatabaseConnectionInput#getValues()} and {@link * DatabaseConnectionInput#setValues(ConfigurationSettingDatabaseConnection)} * * <p>The getValue and setValue methods should set and retrieve settings. */ public void testGetSetRequirementValues() throws AlgorithmConfigurationException { // Set up TestHelper.resetDatabaseSync(); TabWrapper tabWrapper = new TabWrapper(); // Initialize DatabaseConnectionInput (waiting for fetching all current database connections) DatabaseConnectionInput databaseConnectionInput = new DatabaseConnectionInput(false, false, tabWrapper, new ArrayList<String>()); try { databaseConnectionInput.getValues(); } catch (InputValidationException e) { // should throw an exception } // Cleanup TestHelper.resetDatabaseSync(); }