You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@directory.apache.org by se...@apache.org on 2009/11/16 23:31:31 UTC
svn commit: r881016 - in
/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui:
PreferencesTest.java bots/CertificateValidationPreferencePageBot.java
bots/PreferencesBot.java bots/StudioBot.java
Author: seelmann
Date: Mon Nov 16 22:31:30 2009
New Revision: 881016
URL: http://svn.apache.org/viewvc?rev=881016&view=rev
Log:
Test for DIRSTUDIO-580 (Setting "Validate certificates for secure LDAP connections" is not saved)
Added:
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java
Modified:
directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java?rev=881016&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java Mon Nov 16 22:31:30 2009
@@ -0,0 +1,121 @@
+/*
+ * 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;
+
+
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.directory.server.core.integ.Level;
+import org.apache.directory.server.core.integ.annotations.CleanupLevel;
+import org.apache.directory.server.integ.SiRunner;
+import org.apache.directory.server.ldap.LdapServer;
+import org.apache.directory.studio.test.integration.ui.bots.CertificateValidationPreferencePageBot;
+import org.apache.directory.studio.test.integration.ui.bots.PreferencesBot;
+import org.apache.directory.studio.test.integration.ui.bots.StudioBot;
+import org.eclipse.core.runtime.Platform;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Tests the preferences.
+ *
+ * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
+ * @version $Rev$, $Date$
+ */
+@RunWith(SiRunner.class)
+@CleanupLevel(Level.SUITE)
+public class PreferencesTest
+{
+ public static LdapServer ldapServer;
+
+ private StudioBot studioBot;
+
+
+ @Before
+ public void setUp() throws Exception
+ {
+ studioBot = new StudioBot();
+ studioBot.resetLdapPerspective();
+ }
+
+
+ @After
+ public void tearDown() throws Exception
+ {
+ }
+
+
+ /**
+ * Test for DIRSTUDIO-580
+ * (Setting "Validate certificates for secure LDAP connections" is not saved).
+ *
+ * @throws Exception
+ */
+ @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() );
+
+ // open preferences dialog
+ PreferencesBot preferencesBot = studioBot.openPreferences();
+ assertTrue( preferencesBot.isVisible() );
+
+ // open certificate validation page
+ CertificateValidationPreferencePageBot pageBot = preferencesBot.openCertificatValidationPage();
+ assertTrue( pageBot.isValidateCertificatesSelected() );
+
+ // deselect certificate validation
+ pageBot.setValidateCertificates( false );
+ assertFalse( pageBot.isValidateCertificatesSelected() );
+
+ // click OK, this should write the property to the file
+ preferencesBot.clickOkButton();
+ assertTrue( file.exists() );
+ List<String> lines = FileUtils.readLines( file );
+ assertTrue( lines.contains( "validateCertificates=false" ) );
+
+ // open dialog again, check that certificate validation checkbox is not selected
+ preferencesBot = studioBot.openPreferences();
+ pageBot = preferencesBot.openCertificatValidationPage();
+ assertFalse( pageBot.isValidateCertificatesSelected() );
+
+ // restore defaults, this should select the certificate validation
+ pageBot.clickRestoreDefaultsButton();
+ assertTrue( pageBot.isValidateCertificatesSelected() );
+
+ // click OK, this should remove the property file as only defaults are set
+ preferencesBot.clickOkButton();
+ assertFalse( file.exists() );
+ }
+
+}
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java?rev=881016&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java Mon Nov 16 22:31:30 2009
@@ -0,0 +1,59 @@
+/*
+ * 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 CertificateValidationPreferencePageBot extends DialogBot
+{
+
+ private static final String VALIDATE_CERTIFICATES_FOR_SECURE_LDAP_CONNECTIONS = "Validate certificates for secure LDAP connections";
+
+
+ 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();
+ }
+
+
+ public void setValidateCertificates( boolean b )
+ {
+ if ( b )
+ {
+ bot.checkBox( VALIDATE_CERTIFICATES_FOR_SECURE_LDAP_CONNECTIONS ).select();
+ }
+ else
+ {
+ bot.checkBox( VALIDATE_CERTIFICATES_FOR_SECURE_LDAP_CONNECTIONS ).deselect();
+ }
+ }
+
+}
Added: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java?rev=881016&view=auto
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java (added)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java Mon Nov 16 22:31:30 2009
@@ -0,0 +1,51 @@
+/*
+ * 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 PreferencesBot extends DialogBot
+{
+
+ public boolean isVisible()
+ {
+ return super.isVisible( "Preferences" );
+ }
+
+
+ public void clickOkButton()
+ {
+ super.clickButton( "OK" );
+ }
+
+
+ public void clickCancelButton()
+ {
+ super.clickButton( "Cancel" );
+ }
+
+
+ public CertificateValidationPreferencePageBot openCertificatValidationPage()
+ {
+ bot.tree().getTreeItem( "Apache Directory Studio" ).select().expand().getNode( "Connections" ).select()
+ .expand().getNode( "Certificate Validation" ).select();
+ return new CertificateValidationPreferencePageBot();
+ }
+
+}
Modified: directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java
URL: http://svn.apache.org/viewvc/directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java?rev=881016&r1=881015&r2=881016&view=diff
==============================================================================
--- directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java (original)
+++ directory/studio/trunk/test-integration-ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java Mon Nov 16 22:31:30 2009
@@ -22,6 +22,7 @@
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.ui.IViewReference;
@@ -111,4 +112,11 @@
}
+
+ public PreferencesBot openPreferences()
+ {
+ new SWTBot().menu( "Window" ).menu( "Preferences" ).click();
+ return new PreferencesBot();
+ }
+
}