Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/apache/directory-studio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Seelmann <mail@stefan-seelmann.de>2021-05-25 20:47:59 +0300
committerStefan Seelmann <mail@stefan-seelmann.de>2021-05-25 20:47:59 +0300
commitb975d1fcf8c17121f191f53cfaaf108bfffdd27a (patch)
tree0ff2f438ef3c85e729777322abc2675869c760e7
parentaf6f20370145f1adde3fb187eeeee449f7150256 (diff)
Fix flaky test
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java106
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java21
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ModificationLogsViewPreferencePageBot.java56
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordsKeystorePreferencePageBot.java8
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencePageBot.java43
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java17
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchLogsViewPreferencePageBot.java65
7 files changed, 283 insertions, 33 deletions
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java
index 60c7bee37..046febaaa 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java
@@ -44,8 +44,10 @@ import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.CertificateValidationPreferencePageBot;
import org.apache.directory.studio.test.integration.ui.bots.CertificateViewerDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.KeepConnectionsPasswordsDialogBot;
+import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewPreferencePageBot;
import org.apache.directory.studio.test.integration.ui.bots.PasswordsKeystorePreferencePageBot;
import org.apache.directory.studio.test.integration.ui.bots.PreferencesBot;
+import org.apache.directory.studio.test.integration.ui.bots.SearchLogsViewPreferencePageBot;
import org.apache.directory.studio.test.integration.ui.bots.SetupMasterPasswordDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.VerifyMasterPasswordDialogBot;
import org.eclipse.core.runtime.Platform;
@@ -69,10 +71,7 @@ public class PreferencesTest extends AbstractTestBase
@Test
public void testCertificatValidationSettingsSaved() throws Exception
{
- URL url = Platform.getInstanceLocation().getURL();
- File file = new File( url.getFile()
- + ".metadata/.plugins/org.eclipse.core.runtime/.settings/org.apache.directory.studio.connection.core.prefs" );
- assertFalse( file.exists() );
+ File file = getConnectionCorePreferencesFile();
// open preferences dialog
PreferencesBot preferencesBot = studioBot.openPreferences();
@@ -101,9 +100,26 @@ public class PreferencesTest extends AbstractTestBase
pageBot.clickRestoreDefaultsButton();
assertTrue( pageBot.isValidateCertificatesSelected() );
- // click OK, this should remove the property file as only defaults are set
+ // click OK, this should remove the property or the whole file
preferencesBot.clickOkButton();
- assertFalse( file.exists() );
+ if ( file.exists() )
+ {
+ lines = FileUtils.readLines( file, StandardCharsets.UTF_8 );
+ assertFalse( lines.contains( "validateCertificates=false" ) );
+ }
+ else
+ {
+ assertFalse( file.exists() );
+ }
+ }
+
+
+ private File getConnectionCorePreferencesFile()
+ {
+ URL url = Platform.getInstanceLocation().getURL();
+ File file = new File( url.getFile()
+ + ".metadata/.plugins/org.eclipse.core.runtime/.settings/org.apache.directory.studio.connection.core.prefs" );
+ return file;
}
@@ -255,4 +271,82 @@ public class PreferencesTest extends AbstractTestBase
preferencesBot.clickCancelButton();
}
+
+ @Test
+ public void testSearchLogsViewPreferencesPage() throws Exception
+ {
+ File file = getConnectionCorePreferencesFile();
+
+ // open preferences dialog
+ PreferencesBot preferencesBot = studioBot.openPreferences();
+ SearchLogsViewPreferencePageBot page = preferencesBot.openSearchLogsViewPage();
+
+ page.setEnableSearchRequestLogs( false );
+ page.setEnableSearchResultEntryLogs( true );
+ page.setLogFileCount( 7 );
+ page.setLogFileSize( 77 );
+ page.clickApplyButton();
+
+ assertTrue( file.exists() );
+ List<String> lines = FileUtils.readLines( file, StandardCharsets.UTF_8 );
+ assertTrue( lines.contains( "searchRequestLogsEnable=false" ) );
+ assertTrue( lines.contains( "searchResultEntryLogsEnable=true" ) );
+ assertTrue( lines.contains( "searchLogsFileCount=7" ) );
+ assertTrue( lines.contains( "searchLogsFileSize=77" ) );
+
+ page.clickRestoreDefaultsButton();
+ preferencesBot.clickOkButton();
+ if ( file.exists() )
+ {
+ lines = FileUtils.readLines( file, StandardCharsets.UTF_8 );
+ assertFalse( lines.contains( "searchRequestLogsEnable=false" ) );
+ assertFalse( lines.contains( "searchResultEntryLogsEnable=true" ) );
+ assertFalse( lines.contains( "searchLogsFileCount=7" ) );
+ assertFalse( lines.contains( "searchLogsFileSize=77" ) );
+ }
+ else
+ {
+ assertFalse( file.exists() );
+ }
+ }
+
+
+ @Test
+ public void testModificationLogsViewPreferencesPage() throws Exception
+ {
+ File file = getConnectionCorePreferencesFile();
+
+ // open preferences dialog
+ PreferencesBot preferencesBot = studioBot.openPreferences();
+ ModificationLogsViewPreferencePageBot page = preferencesBot.openModificationLogsViewPage();
+
+ page.setEnableModificationLogs( false );
+ page.setMaskedAttributes( "userPassword" );
+ page.setLogFileCount( 2 );
+ page.setLogFileSize( 22 );
+ page.clickApplyButton();
+
+ assertTrue( file.exists() );
+ List<String> lines = FileUtils.readLines( file, StandardCharsets.UTF_8 );
+ assertTrue( lines.contains( "modificationLogsEnable=false" ) );
+ assertTrue( lines.contains( "modificationLogsMaskedAttributes=userPassword" ) );
+ assertTrue( lines.contains( "modificationLogsFileCount=2" ) );
+ assertTrue( lines.contains( "modificationLogsFileSize=22" ) );
+
+ page.clickRestoreDefaultsButton();
+ preferencesBot.clickOkButton();
+ if ( file.exists() )
+ {
+ lines = FileUtils.readLines( file, StandardCharsets.UTF_8 );
+ assertFalse( lines.contains( "modificationLogsEnable=false" ) );
+ assertFalse( lines.contains( "modificationLogsMaskedAttributes=userPassword" ) );
+ assertFalse( lines.contains( "modificationLogsFileCount=2" ) );
+ assertFalse( lines.contains( "modificationLogsFileSize=22" ) );
+ }
+ else
+ {
+ assertFalse( file.exists() );
+ }
+ }
+
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java
index a9a8c51f2..7beeae47c 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java
@@ -20,30 +20,11 @@
package org.apache.directory.studio.test.integration.ui.bots;
-public class CertificateValidationPreferencePageBot extends DialogBot
+public class CertificateValidationPreferencePageBot extends PreferencePageBot
{
private static final String VALIDATE_CERTIFICATES_FOR_SECURE_LDAP_CONNECTIONS = "Validate certificates for secure LDAP connections";
-
- public CertificateValidationPreferencePageBot()
- {
- super( "Preferences" );
- }
-
-
- public void clickApplyButton()
- {
- super.clickButton( "Apply" );
- }
-
-
- public void clickRestoreDefaultsButton()
- {
- super.clickButton( "Restore Defaults" );
- }
-
-
public boolean isValidateCertificatesSelected()
{
return bot.checkBox( VALIDATE_CERTIFICATES_FOR_SECURE_LDAP_CONNECTIONS ).isChecked();
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ModificationLogsViewPreferencePageBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ModificationLogsViewPreferencePageBot.java
new file mode 100644
index 000000000..c5a8b687a
--- /dev/null
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ModificationLogsViewPreferencePageBot.java
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+public class ModificationLogsViewPreferencePageBot extends PreferencePageBot
+{
+
+ public void setEnableModificationLogs( boolean b )
+ {
+ activate();
+ if ( b )
+ {
+ bot.checkBox( 0 ).select();
+ }
+ else
+ {
+ bot.checkBox( 0 ).deselect();
+ }
+ }
+
+
+ public void setMaskedAttributes( String s )
+ {
+ bot.text( 1 ).setText( s );
+ }
+
+
+ public void setLogFileCount( int i )
+ {
+ bot.text( 2 ).setText( "" + i );
+ }
+
+
+ public void setLogFileSize( int i )
+ {
+ bot.text( 3 ).setText( "" + i );
+ }
+}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordsKeystorePreferencePageBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordsKeystorePreferencePageBot.java
index 9d7fcd2fc..bd22e97ed 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordsKeystorePreferencePageBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordsKeystorePreferencePageBot.java
@@ -20,15 +20,9 @@
package org.apache.directory.studio.test.integration.ui.bots;
-public class PasswordsKeystorePreferencePageBot extends DialogBot
+public class PasswordsKeystorePreferencePageBot extends PreferencePageBot
{
- public PasswordsKeystorePreferencePageBot()
- {
- super( "Preferences" );
- }
-
-
public boolean isPasswordsKeystoreEnabled()
{
activate();
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencePageBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencePageBot.java
new file mode 100644
index 000000000..3438718cf
--- /dev/null
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencePageBot.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+public class PreferencePageBot extends DialogBot
+{
+
+ public PreferencePageBot()
+ {
+ super( "Preferences" );
+ }
+
+
+ public void clickApplyButton()
+ {
+ super.clickButton( "Apply" );
+ }
+
+
+ public void clickRestoreDefaultsButton()
+ {
+ super.clickButton( "Restore Defaults" );
+ }
+
+}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java
index 35788cb43..e2f717d4a 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java
@@ -19,6 +19,7 @@
*/
package org.apache.directory.studio.test.integration.ui.bots;
+
import org.apache.directory.studio.test.integration.ui.utils.TreeBot;
@@ -67,4 +68,20 @@ public class PreferencesBot extends DialogBot
.expand().getNode( "Syntax Coloring" ).select();
}
+
+ public SearchLogsViewPreferencePageBot openSearchLogsViewPage()
+ {
+ bot.tree().getTreeItem( "Apache Directory Studio" ).select().expand().getNode( "LDAP Browser" ).select()
+ .expand().getNode( "Views" ).expand().getNode( "Search Logs View" ).select();
+ return new SearchLogsViewPreferencePageBot();
+ }
+
+
+ public ModificationLogsViewPreferencePageBot openModificationLogsViewPage()
+ {
+ bot.tree().getTreeItem( "Apache Directory Studio" ).select().expand().getNode( "LDAP Browser" ).select()
+ .expand().getNode( "Views" ).expand().getNode( "Modification Logs View" ).select();
+ return new ModificationLogsViewPreferencePageBot();
+ }
+
}
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchLogsViewPreferencePageBot.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchLogsViewPreferencePageBot.java
new file mode 100644
index 000000000..eba102a78
--- /dev/null
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchLogsViewPreferencePageBot.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.directory.studio.test.integration.ui.bots;
+
+
+public class SearchLogsViewPreferencePageBot extends PreferencePageBot
+{
+
+ public void setEnableSearchRequestLogs( boolean b )
+ {
+ activate();
+ if ( b )
+ {
+ bot.checkBox( 0 ).select();
+ }
+ else
+ {
+ bot.checkBox( 0 ).deselect();
+ }
+ }
+
+
+ public void setEnableSearchResultEntryLogs( boolean b )
+ {
+ activate();
+ if ( b )
+ {
+ bot.checkBox( 1 ).select();
+ }
+ else
+ {
+ bot.checkBox( 1 ).deselect();
+ }
+ }
+
+
+ public void setLogFileCount( int i )
+ {
+ bot.text( 1 ).setText( "" + i );
+ }
+
+
+ public void setLogFileSize( int i )
+ {
+ bot.text( 2 ).setText( "" + i );
+ }
+
+}