repo stringclasses 1k
values | file_url stringlengths 96 373 | file_path stringlengths 11 294 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 6
values | commit_sha stringclasses 1k
values | retrieved_at stringdate 2026-01-04 14:45:56 2026-01-04 18:30:23 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ApacheDSPluginTest.java | /*
* 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 org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.ConnectionFolder;
import org.apache.directory.studio.connection.core.ConnectionFolderManager;
import org.apache.directory.studio.connection.core.ConnectionManager;
import org.apache.directory.studio.ldapservers.LdapServersManager;
import org.apache.directory.studio.test.integration.ui.bots.ApacheDSConfigurationEditorBot;
import org.apache.directory.studio.test.integration.ui.bots.BotUtils;
import org.apache.directory.studio.test.integration.ui.bots.ConnectionFromServerDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.ConsoleViewBot;
import org.apache.directory.studio.test.integration.ui.bots.DeleteDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.ModificationLogsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.NewApacheDSServerWizardBot;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledForJreRange;
import org.junit.jupiter.api.condition.JRE;
/**
* Tests the Apache DS Plugin's UI.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
@DisabledForJreRange(min = JRE.JAVA_16)
public class ApacheDSPluginTest extends AbstractTestBase
{
protected ConsoleViewBot consoleViewBot;
@BeforeEach
void setUp() throws Exception
{
consoleViewBot = studioBot.getConsoleView();
}
/**
* Run the following tests:
* <ul>
* <li>Creates a new server</li>
* <li>Starts the server</li>
* <li>Creates and uses a connection</li>
* <li>Stops the server</li>
* <li>Deletes the server</li>
* </ul>
*/
@Test
public void serverCreationStartCreateConnectionStopAndDeletion()
{
String serverName = "ServerCreationStartCreateConnectionStopAndDeletion";
createServer( serverName );
setAvailablePorts( serverName );
// Starting the server
serversViewBot.runServer( serverName );
serversViewBot.waitForServerStart( serverName );
// DIRSTUDIO-1077: Check for log output in console to verify logging configuration still works
String consoleText = consoleViewBot.getConsoleText();
assertThat( consoleText, containsString( "You didn't change the admin password" ) );
// Verifying the connections count is 0
assertEquals( 0, getBrowserConnectionsCount() );
// Creating a connection associated with the server
ConnectionFromServerDialogBot connectionFromServerDialogBot = serversViewBot.createConnectionFromServer();
assertTrue( connectionFromServerDialogBot.isVisible() );
connectionFromServerDialogBot.clickOkButton();
// Verifying the connections count is now 1
assertEquals( 1, getBrowserConnectionsCount() );
// Opening the connection
connectionsViewBot.select( serverName );
connectionsViewBot.openSelectedConnection();
// Getting the associated connection object
Connection connection = getBrowserConnection();
// Checking if the connection is open
assertTrue( connection.getConnectionWrapper().isConnected() );
// Closing the connection
connectionsViewBot.select( serverName );
connectionsViewBot.closeSelectedConnections();
// Checking if the connection is closed
assertFalse( connection.getConnectionWrapper().isConnected() );
// Deleting the connection
connectionsViewBot.deleteTestConnections();
// Stopping the server
serversViewBot.stopServer( serverName );
serversViewBot.waitForServerStop( serverName );
// Deleting the server
DeleteDialogBot deleteDialogBot = serversViewBot.openDeleteServerDialog();
deleteDialogBot.clickOkButton();
// Verifying the servers count is back to 0
assertEquals( 0, getCoreServersCount() );
assertEquals( 0, serversViewBot.getServersCount() );
}
private void createServer( String serverName )
{
// Showing view
serversViewBot.show();
// Verifying the servers count is 0
assertEquals( 0, getCoreServersCount() );
assertEquals( 0, serversViewBot.getServersCount() );
// Opening wizard
NewApacheDSServerWizardBot wizardBot = serversViewBot.openNewServerWizard();
// Verifying the wizard can't be finished yet
assertFalse( wizardBot.isFinishButtonEnabled() );
// Filling fields of the wizard
wizardBot.selectApacheDS200();
wizardBot.typeServerName( serverName );
// Verifying the wizard can now be finished
assertTrue( wizardBot.isFinishButtonEnabled() );
// Closing wizard
wizardBot.clickFinishButton();
serversViewBot.waitForServer( serverName );
// Verifying the servers count is now 1
assertEquals( 1, getCoreServersCount() );
assertEquals( 1, serversViewBot.getServersCount() );
}
/**
* Verifies that the 'New Server' does not allow the creation of
* 2 servers with the same name.
*/
@Test
public void verifyServerNameCollisionInNewWizard()
{
// Showing view
serversViewBot.show();
// Verifying the servers count is 0
assertEquals( 0, getCoreServersCount() );
assertEquals( 0, serversViewBot.getServersCount() );
// Opening wizard
NewApacheDSServerWizardBot wizardBot = serversViewBot.openNewServerWizard();
// Verifying the wizard can't be finished yet
assertFalse( wizardBot.isFinishButtonEnabled() );
// Filling fields of the wizard
String serverName = "NewServerWizardTest";
wizardBot.selectApacheDS200();
wizardBot.typeServerName( serverName );
// Verifying the wizard can now be finished
assertTrue( wizardBot.isFinishButtonEnabled() );
// Closing wizard
wizardBot.clickFinishButton();
serversViewBot.waitForServer( serverName );
// Verifying the servers count is now 1
assertEquals( 1, getCoreServersCount() );
assertEquals( 1, serversViewBot.getServersCount() );
// Opening wizard
wizardBot = serversViewBot.openNewServerWizard();
// Verifying the wizard can't be finished yet
assertFalse( wizardBot.isFinishButtonEnabled() );
// Filling fields of the wizard
wizardBot.selectApacheDS200();
wizardBot.typeServerName( serverName );
// Verifying the wizard can't be finished (because a server with
// same name already exists)
assertFalse( wizardBot.isFinishButtonEnabled() );
// Canceling wizard
wizardBot.clickCancelButton();
// Selecting the server row
serversViewBot.selectServer( serverName );
// Deleting the server
DeleteDialogBot deleteDialogBot = serversViewBot.openDeleteServerDialog();
deleteDialogBot.clickOkButton();
// Verifying the servers count is back to 0
assertEquals( 0, getCoreServersCount() );
assertEquals( 0, serversViewBot.getServersCount() );
}
private void setAvailablePorts( String serverName )
{
ApacheDSConfigurationEditorBot editorBot = serversViewBot.openConfigurationEditor( serverName );
editorBot.setAvailablePorts();
editorBot.save();
editorBot.close();
}
/**
* Gets the servers count found in the core of the plugin.
*
* @return
* the servers count found in the core of the plugin
*/
private int getCoreServersCount()
{
LdapServersManager serversHandler = LdapServersManager.getDefault();
if ( serversHandler != null )
{
return serversHandler.getServersList().size();
}
return 0;
}
/**
* Get the connections count found in the LDAP Browser.
*
* @return
* the connections count found in the LDAP Browser
*/
private int getBrowserConnectionsCount()
{
ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
.getConnectionFolderManager();
if ( connectionFolderManager != null )
{
ConnectionFolder rootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
if ( rootConnectionFolder != null )
{
return rootConnectionFolder.getConnectionIds().size();
}
}
return 0;
}
/**
* Get the connections count found in the LDAP Browser.
*
* @return
* the connections count found in the LDAP Browser
*/
private Connection getBrowserConnection()
{
ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
.getConnectionFolderManager();
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
if ( connectionFolderManager != null )
{
ConnectionFolder rootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
if ( rootConnectionFolder != null )
{
return connectionManager.getConnectionById( rootConnectionFolder.getConnectionIds().get( 0 ) );
}
}
return null;
}
/**
* Test for DIRSTUDIO-1080: edit the server configuration via remote connection.
*/
@Test
public void editRemoteConfig()
{
String serverName = "EditRemoteConfig";
createServer( serverName );
setAvailablePorts( serverName );
// Start the server
serversViewBot.runServer( serverName );
serversViewBot.waitForServerStart( serverName );
// Create a connection associated with the server
ConnectionFromServerDialogBot connectionFromServerDialogBot = serversViewBot.createConnectionFromServer();
connectionFromServerDialogBot.clickOkButton();
// Open the connection
connectionsViewBot.select( serverName );
connectionsViewBot.openSelectedConnection();
// Open the config editor and load remote config
ApacheDSConfigurationEditorBot remoteEditorBot = connectionsViewBot.openApacheDSConfiguration();
// Remember old ports
int oldLdapPort = remoteEditorBot.getLdapPort();
int oldLdapsPort = remoteEditorBot.getLdapsPort();
// Set new ports
remoteEditorBot.setAvailablePorts();
int newLdapPort = remoteEditorBot.getLdapPort();
int newLdapsPort = remoteEditorBot.getLdapsPort();
// Save the config editor
remoteEditorBot.save();
remoteEditorBot.close();
// Verify new port settings went over the network
ModificationLogsViewBot modificationLogsViewBot = studioBot.getModificationLogsViewBot();
modificationLogsViewBot.waitForText( "add: ads-systemPort" );
String modificationLogsText = modificationLogsViewBot.getModificationLogsText();
assertThat( modificationLogsText,
containsString( "delete: ads-systemPort\nads-systemPort: " + oldLdapPort + "\n" ) );
assertThat( modificationLogsText,
containsString( "add: ads-systemPort\nads-systemPort: " + newLdapPort + "\n" ) );
assertThat( modificationLogsText,
containsString( "delete: ads-systemPort\nads-systemPort: " + oldLdapsPort + "\n" ) );
assertThat( modificationLogsText,
containsString( "add: ads-systemPort\nads-systemPort: " + newLdapsPort + "\n" ) );
// Verify new port settings are visible in local config editor
ApacheDSConfigurationEditorBot localEditorBot = serversViewBot.openConfigurationEditor( serverName );
assertEquals( newLdapPort, localEditorBot.getLdapPort() );
assertEquals( newLdapsPort, localEditorBot.getLdapsPort() );
localEditorBot.close();
// Close the connection
connectionsViewBot.select( serverName );
connectionsViewBot.closeSelectedConnections();
// Delete the connection
connectionsViewBot.deleteTestConnections();
// Stopping the server
serversViewBot.stopServer( serverName );
serversViewBot.waitForServerStop( serverName );
// Deleting the server
DeleteDialogBot deleteDialogBot = serversViewBot.openDeleteServerDialog();
deleteDialogBot.clickOkButton();
}
/**
* Test for DIRSTUDIO-1118: Run repair
*/
@Test
public void repairAndStartAndStop()
{
String serverName = "Repair";
createServer( serverName );
setAvailablePorts( serverName );
// Repair the server
serversViewBot.repairServer( serverName );
consoleViewBot.waitForConsoleText( "Database repaired" );
serversViewBot.waitForServerStop( serverName );
// Wait a bit more after repair, another weird race condition...
BotUtils.sleep( SWTBotPreferences.TIMEOUT );
// Start the server after repair
serversViewBot.runServer( serverName );
serversViewBot.waitForServerStart( serverName );
// TODO: newer version of ApacheDS may log to console
// Stopping the server
serversViewBot.stopServer( serverName );
serversViewBot.waitForServerStop( serverName );
// Deleting the server
DeleteDialogBot deleteDialogBot = serversViewBot.openDeleteServerDialog();
deleteDialogBot.clickOkButton();
}
/**
* Test for DIRSTUDIO-1120: Checkbox active protocols
*/
@Test
public void testSetEnabledProtocols() throws Exception
{
String serverName = "SetEnabledProtocols";
createServer( serverName );
ApacheDSConfigurationEditorBot editorBot = serversViewBot.openConfigurationEditor( serverName );
// assert not enabled yet
assertFalse( editorBot.isSSLv3Enabled() );
assertFalse( editorBot.isTLSv1Enabled() );
assertFalse( editorBot.isTLSv1_1Enabled() );
assertFalse( editorBot.isTLSv1_2Enabled() );
// enable
editorBot.enableSSLv3();
editorBot.enableTLSv1();
editorBot.enableTLSv1_1();
editorBot.enableTLSv1_2();
editorBot.save();
editorBot.close();
// re-open and assert enabled
editorBot = serversViewBot.openConfigurationEditor( serverName );
assertTrue( editorBot.isSSLv3Enabled() );
assertTrue( editorBot.isTLSv1Enabled() );
assertTrue( editorBot.isTLSv1_1Enabled() );
assertTrue( editorBot.isTLSv1_2Enabled() );
editorBot.close();
// Deleting the server
DeleteDialogBot deleteDialogBot = serversViewBot.openDeleteServerDialog();
deleteDialogBot.clickOkButton();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SchemaEditorTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SchemaEditorTest.java | /*
* 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 org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.test.integration.junit5.LdapServerType;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.AttributeTypeEditorBot;
import org.apache.directory.studio.test.integration.ui.bots.NewSchemaProjectWizardBot;
import org.apache.directory.studio.test.integration.ui.bots.ObjectClassEditorBot;
import org.apache.directory.studio.test.integration.ui.bots.SchemaEditorBot;
import org.apache.directory.studio.test.integration.ui.bots.SchemaProjectsViewBot;
import org.apache.directory.studio.test.integration.ui.bots.SchemaSearchViewBot;
import org.apache.directory.studio.test.integration.ui.bots.SchemaViewBot;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests search in the schema editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class SchemaEditorTest extends AbstractTestBase
{
private SchemaProjectsViewBot projectsView;
private SchemaViewBot schemaView;
@BeforeEach
public void setUp() throws Exception
{
studioBot.resetSchemaPerspective();
projectsView = studioBot.getSchemaProjectsView();
schemaView = studioBot.getSchemaView();
}
@AfterEach
public void tearDown() throws Exception
{
projectsView.deleteAllProjects();
}
/**
* DIRSTUDIO-1026: Searching for an AT or an OC using an alternate name does not find it
*/
@Test
public void testSearchForAliases() throws Exception
{
createProject( "Project Search For Aliases" );
SchemaSearchViewBot searchView = studioBot.getSchemaSearchView();
searchView.search( "cn" );
List<String> results = searchView.getResults();
assertThat( results.size(), equalTo( 1 ) );
assertThat( results.get( 0 ), containsString( "cn, commonName [2.5.4.3]" ) );
searchView.search( "doest not exist" );
results = searchView.getResults();
assertThat( results.size(), equalTo( 0 ) );
searchView.search( "cOmmOnnAmE" );
results = searchView.getResults();
assertThat( results.size(), equalTo( 1 ) );
assertThat( results.get( 0 ), containsString( "cn, commonName [2.5.4.3]" ) );
searchView.search( "doest not exist" );
results = searchView.getResults();
assertThat( results.size(), equalTo( 0 ) );
searchView.search( "2.5.4.3" );
results = searchView.getResults();
assertThat( results.size(), equalTo( 1 ) );
assertThat( results.get( 0 ), containsString( "cn, commonName [2.5.4.3]" ) );
}
@Test
public void testCreateSchemaOfflineApacheDS() throws Exception
{
SchemaProjectsViewBot projectsView = studioBot.getSchemaProjectsView();
NewSchemaProjectWizardBot wizard = projectsView.openNewSchemaProjectWizard();
wizard.typeProjectName( "Project Offline ApacheDS" );
wizard.selectOfflineSchema();
wizard.clickNextButton();
wizard.selectApacheDS();
wizard.selectAllSchemas();
wizard.clickFinishButton();
assertTrue( schemaView.existsSchema( "adsconfig" ) );
assertTrue( schemaView.existsSchema( "apache" ) );
assertTrue( schemaView.existsSchema( "apachedns" ) );
assertTrue( schemaView.existsSchema( "apachemeta" ) );
assertTrue( schemaView.existsSchema( "core" ) );
assertTrue( schemaView.existsSchema( "system" ) );
assertTrue( schemaView.existsObjectClass( "system", "top" ) );
assertTrue( schemaView.existsObjectClass( "adsconfig", "ads-ldapServer" ) );
assertTrue( schemaView.existsAttributeType( "system", "objectClass" ) );
assertTrue( schemaView.existsAttributeType( "adsconfig", "ads-maxTimeLimit" ) );
}
@Test
public void testCreateSchemaOfflineOpenLDAP() throws Exception
{
SchemaProjectsViewBot projectsView = studioBot.getSchemaProjectsView();
NewSchemaProjectWizardBot wizard = projectsView.openNewSchemaProjectWizard();
wizard.typeProjectName( "Project Offline OpenLDAP" );
wizard.selectOfflineSchema();
wizard.clickNextButton();
wizard.selectOpenLDAP();
wizard.selectAllSchemas();
wizard.clickFinishButton();
assertTrue( schemaView.existsSchema( "collective" ) );
assertTrue( schemaView.existsSchema( "dyngroup" ) );
assertTrue( schemaView.existsSchema( "core" ) );
assertTrue( schemaView.existsSchema( "system" ) );
assertTrue( schemaView.existsObjectClass( "system", "top" ) );
assertTrue( schemaView.existsObjectClass( "dyngroup", "groupOfURLs" ) );
assertTrue( schemaView.existsAttributeType( "system", "objectClass" ) );
assertTrue( schemaView.existsAttributeType( "dyngroup", "memberURL" ) );
}
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "ApacheDS specific test")
public void testCreateSchemaOnlineApacheDS( TestLdapServer server ) throws Exception
{
studioBot.resetLdapPerspective();
Connection connection = connectionsViewBot.createTestConnection( server );
studioBot.resetSchemaPerspective();
SchemaProjectsViewBot projectsView = studioBot.getSchemaProjectsView();
NewSchemaProjectWizardBot wizard = projectsView.openNewSchemaProjectWizard();
wizard.typeProjectName( "Project Online ApacheDS" );
wizard.selectOnlineSchema();
wizard.clickNextButton();
wizard.selectConnection( connection.getName() );
wizard.clickFinishButton();
assertTrue( schemaView.existsSchema( "adsconfig" ) );
assertTrue( schemaView.existsSchema( "apache" ) );
assertTrue( schemaView.existsSchema( "apachedns" ) );
assertTrue( schemaView.existsSchema( "apachemeta" ) );
assertTrue( schemaView.existsSchema( "core" ) );
assertTrue( schemaView.existsSchema( "system" ) );
assertTrue( schemaView.existsSchema( "rfc2307bis" ) );
assertTrue( schemaView.existsObjectClass( "system", "top" ) );
assertTrue( schemaView.existsObjectClass( "adsconfig", "ads-ldapServer" ) );
assertTrue( schemaView.existsAttributeType( "system", "objectClass" ) );
assertTrue( schemaView.existsAttributeType( "adsconfig", "ads-maxTimeLimit" ) );
}
@ParameterizedTest
@LdapServersSource(only = LdapServerType.OpenLdap, reason = "OpenLDAP specific test")
public void testCreateSchemaOnlineOpenLDAP( TestLdapServer server ) throws Exception
{
studioBot.resetLdapPerspective();
Connection connection = connectionsViewBot.createTestConnection( server );
studioBot.resetSchemaPerspective();
SchemaProjectsViewBot projectsView = studioBot.getSchemaProjectsView();
NewSchemaProjectWizardBot wizard = projectsView.openNewSchemaProjectWizard();
wizard.typeProjectName( "Project Online OpenLDAP" );
wizard.selectOnlineSchema();
wizard.clickNextButton();
wizard.selectConnection( connection.getName() );
wizard.clickFinishButton();
assertTrue( schemaView.existsSchema( "schema" ) );
assertTrue( schemaView.existsObjectClass( "schema", "top" ) );
assertTrue( schemaView.existsObjectClass( "schema", "olcGlobal" ) );
assertTrue( schemaView.existsAttributeType( "schema", "objectClass" ) );
assertTrue( schemaView.existsAttributeType( "schema", "olcBackend" ) );
}
@ParameterizedTest
@LdapServersSource(only = LdapServerType.Fedora389ds, reason = "389ds specific test")
public void testCreateSchemaOnline389ds( TestLdapServer server ) throws Exception
{
studioBot.resetLdapPerspective();
Connection connection = connectionsViewBot.createTestConnection( server );
studioBot.resetSchemaPerspective();
SchemaProjectsViewBot projectsView = studioBot.getSchemaProjectsView();
NewSchemaProjectWizardBot wizard = projectsView.openNewSchemaProjectWizard();
wizard.typeProjectName( "Project Online 389ds" );
wizard.selectOnlineSchema();
wizard.clickNextButton();
wizard.selectConnection( connection.getName() );
wizard.clickFinishButton();
assertTrue( schemaView.existsSchema( "schema" ) );
assertTrue( schemaView.existsObjectClass( "schema", "top" ) );
assertTrue( schemaView.existsObjectClass( "schema", "nsConfig" ) );
assertTrue( schemaView.existsAttributeType( "schema", "objectClass" ) );
assertTrue( schemaView.existsAttributeType( "schema", "nsBaseDN" ) );
}
@Test
public void testOpenObjectClassEditor() throws Exception
{
createProject( "Project Open Object Class Editor" );
ObjectClassEditorBot objectClassEditor = schemaView.openObjectClassEditor( "system", "top" );
assertNotNull( objectClassEditor );
objectClassEditor.activateSourceCodeTab();
String sourceCode = objectClassEditor.getSourceCode();
assertTrue( sourceCode.contains( "objectclass ( 2.5.6.0 NAME 'top'" ) );
}
@Test
public void testOpenAttributeTypEditor() throws Exception
{
createProject( "Project Open Attribute Type Editor" );
AttributeTypeEditorBot attributeTypeEditor = schemaView.openAttributeTypeEditor( "system", "objectClass" );
assertNotNull( attributeTypeEditor );
attributeTypeEditor.activateSourceCodeTab();
String sourceCode = attributeTypeEditor.getSourceCode();
assertTrue( sourceCode.contains( "attributetype ( 2.5.4.0 NAME 'objectClass'" ) );
}
@Test
public void testOpenSchemaEditor() throws Exception
{
createProject( "Project Open Schema Editor" );
SchemaEditorBot schemaEditor = schemaView.openSchemaEditor( "system" );
assertNotNull( schemaEditor );
schemaEditor.activateSourceCodeTab();
String sourceCode = schemaEditor.getSourceCode();
assertTrue( sourceCode.contains( "objectclass ( 2.5.6.0 NAME 'top'" ) );
assertTrue( sourceCode.contains( "attributetype ( 2.5.4.0 NAME 'objectClass'" ) );
}
private void createProject( String projectName )
{
SchemaProjectsViewBot projectsView = studioBot.getSchemaProjectsView();
NewSchemaProjectWizardBot wizard = projectsView.openNewSchemaProjectWizard();
wizard.typeProjectName( projectName );
wizard.selectOfflineSchema();
wizard.clickNextButton();
wizard.selectApacheDS();
wizard.selectAllSchemas();
wizard.clickFinishButton();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/EntryEditorTest.java | /*
* 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 org.apache.directory.studio.test.integration.junit5.TestFixture.BJENSEN_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.GROUP1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.HNELSON_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.MULTI_VALUED_RDN_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER1_DN;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.password.PasswordUtil;
import org.apache.directory.api.util.Strings;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection.ModifyMode;
import org.apache.directory.studio.ldifparser.LdifFormatParameters;
import org.apache.directory.studio.ldifparser.LdifParserConstants;
import org.apache.directory.studio.ldifparser.model.lines.LdifAttrValLine;
import org.apache.directory.studio.test.integration.junit5.LdapServerType;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource.Mode;
import org.apache.directory.studio.test.integration.ui.bots.AciItemEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.AddressEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.CertificateEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.DnEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.EditAttributeWizardBot;
import org.apache.directory.studio.test.integration.ui.bots.EntryEditorBot;
import org.apache.directory.studio.test.integration.ui.bots.HexEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.ImageEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.NewAttributeWizardBot;
import org.apache.directory.studio.test.integration.ui.bots.PasswordEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.SelectDnDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.SubtreeSpecificationEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.TextEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.utils.Characters;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.apache.directory.studio.test.integration.ui.utils.ResourceUtils;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests the entry editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class EntryEditorTest extends AbstractTestBase
{
/**
* Test adding, editing and deleting of attributes in the entry editor.
*/
@ParameterizedTest
@LdapServersSource
public void testAddEditDeleteAttribute( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( BJENSEN_DN ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( BJENSEN_DN.getName() );
entryEditorBot.activate();
String dn = entryEditorBot.getDnText();
assertEquals( "DN: " + BJENSEN_DN.getName(), dn );
assertEquals( 8, entryEditorBot.getAttributeValues().size() );
assertEquals( "", modificationLogsViewBot.getModificationLogsText() );
// add description attribute
entryEditorBot.activate();
NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
assertTrue( wizardBot.isVisible() );
wizardBot.typeAttributeType( "description" );
wizardBot.clickFinishButton();
entryEditorBot.typeValueAndFinish( "This is the 1st description." );
assertEquals( 9, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
modificationLogsViewBot.waitForText( "add: description\ndescription: This is the 1st description." );
// add second value
entryEditorBot.activate();
entryEditorBot.addValue( "description" );
entryEditorBot.typeValueAndFinish( "This is the 2nd description." );
assertEquals( 10, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 2nd description." ) );
modificationLogsViewBot.waitForText( "add: description\ndescription: This is the 2nd description." );
// edit second value
entryEditorBot.editValue( "description", "This is the 2nd description." );
entryEditorBot.typeValueAndFinish( "This is the 3rd description." );
assertEquals( 10, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is the 2nd description." ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 3rd description." ) );
modificationLogsViewBot.waitForText( "delete: description\ndescription: This is the 2nd description." );
modificationLogsViewBot.waitForText( "add: description\ndescription: This is the 3rd description." );
// delete second value
entryEditorBot.deleteValue( "description", "This is the 3rd description." );
assertEquals( 9, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is the 3rd description." ) );
modificationLogsViewBot.waitForText( "delete: description\ndescription: This is the 3rd description." );
// edit 1st value
entryEditorBot.editValue( "description", "This is the 1st description." );
entryEditorBot.typeValueAndFinish( "This is the final description." );
assertEquals( 9, entryEditorBot.getAttributeValues().size() );
assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is the 1st description." ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: This is the final description." ) );
modificationLogsViewBot.waitForText( "delete: description\ndescription: This is the 1st description." );
modificationLogsViewBot.waitForText( "add: description\ndescription: This is the final description." );
// delete 1st value/attribute
entryEditorBot.deleteValue( "description", "This is the final description." );
assertEquals( 8, entryEditorBot.getAttributeValues().size() );
assertFalse( entryEditorBot.getAttributeValues().contains( "description: This is the final description." ) );
modificationLogsViewBot.waitForText( "delete: description\ndescription: This is the final description.\n-" );
assertEquals( 6, StringUtils.countMatches( modificationLogsViewBot.getModificationLogsText(), "#!RESULT OK" ),
"Expected 6 modifications." );
}
/**
* Test adding, editing and deleting of attributes without equality matching rule in the entry editor.
*/
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testAddEditDeleteAttributeWithoutEqualityMatchingRule( TestLdapServer server ) throws Exception
{
Connection connection = connectionsViewBot.createTestConnection( server );
if ( server.getType() == LdapServerType.OpenLdap )
{
IBrowserConnection browserConnection = BrowserCorePlugin.getDefault().getConnectionManager()
.getBrowserConnection( connection );
browserConnection.setModifyModeNoEMR( ModifyMode.REPLACE );
}
browserViewBot.selectEntry( path( BJENSEN_DN ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( BJENSEN_DN.getName() );
entryEditorBot.activate();
String dn = entryEditorBot.getDnText();
assertEquals( "DN: " + BJENSEN_DN.getName(), dn );
assertEquals( 8, entryEditorBot.getAttributeValues().size() );
assertEquals( "", modificationLogsViewBot.getModificationLogsText() );
// add facsimileTelephoneNumber attribute
entryEditorBot.activate();
NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
assertTrue( wizardBot.isVisible() );
wizardBot.typeAttributeType( "facsimileTelephoneNumber" );
wizardBot.clickFinishButton();
entryEditorBot.typeValueAndFinish( "+1 234 567 890" );
assertEquals( 9, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "facsimileTelephoneNumber: +1 234 567 890" ) );
if ( server.getType() == LdapServerType.OpenLdap )
{
modificationLogsViewBot
.waitForText( "replace: facsimileTelephoneNumber\nfacsimileTelephoneNumber: +1 234 567 890" );
}
else
{
modificationLogsViewBot
.waitForText( "add: facsimileTelephoneNumber\nfacsimileTelephoneNumber: +1 234 567 890" );
}
// edit value
entryEditorBot.editValue( "facsimileTelephoneNumber", "+1 234 567 890" );
entryEditorBot.typeValueAndFinish( "000000000000" );
assertEquals( 9, entryEditorBot.getAttributeValues().size() );
assertFalse( entryEditorBot.getAttributeValues().contains( "facsimileTelephoneNumber: +1 234 567 890" ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "facsimileTelephoneNumber: 000000000000" ) );
if ( server.getType() == LdapServerType.OpenLdap )
{
modificationLogsViewBot
.waitForText( "replace: facsimileTelephoneNumber\nfacsimileTelephoneNumber: 000000000000" );
}
else
{
modificationLogsViewBot
.waitForText( "delete: facsimileTelephoneNumber\nfacsimileTelephoneNumber: +1 234 567 890" );
modificationLogsViewBot
.waitForText( "add: facsimileTelephoneNumber\nfacsimileTelephoneNumber: 000000000000" );
}
// delete 1st value/attribute
entryEditorBot.deleteValue( "facsimileTelephoneNumber", "000000000000" );
assertEquals( 8, entryEditorBot.getAttributeValues().size() );
assertFalse( entryEditorBot.getAttributeValues().contains( "facsimileTelephoneNumber: 000000000000" ) );
if ( server.getType() == LdapServerType.OpenLdap )
{
modificationLogsViewBot.waitForText( "replace: facsimileTelephoneNumber\n-" );
}
else
{
modificationLogsViewBot
.waitForText( "delete: facsimileTelephoneNumber\nfacsimileTelephoneNumber: 000000000000\n-" );
}
assertEquals( 3, StringUtils.countMatches( modificationLogsViewBot.getModificationLogsText(), "#!RESULT OK" ),
"Expected 3 modifications." );
}
/**
* DIRSTUDIO-1267:Test adding, editing and deleting of attributes with language tag in the entry editor.
*/
@ParameterizedTest
@LdapServersSource(except = LdapServerType.ApacheDS, reason = "Language tags not yet supported by ApacheDS")
public void testAddEditDeleteAttributeWithLanguageTag( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( USER1_DN ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() );
entryEditorBot.activate();
// add attribute description;lang-en
entryEditorBot.activate();
NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
assertTrue( wizardBot.isVisible() );
wizardBot.typeAttributeType( "description" );
wizardBot.clickNextButton();
wizardBot.setLanguageTag( "en", "" );
wizardBot.clickFinishButton();
entryEditorBot.typeValueAndFinish( "English" );
modificationLogsViewBot.waitForText( "add: description;lang-en\ndescription;lang-en: English\n-" );
assertTrue( entryEditorBot.getAttributeValues().contains( "description;lang-en: English" ) );
// edit the attribute to description;lang-en
EditAttributeWizardBot editWizardBot = entryEditorBot.editAttribute( "description;lang-en", "English" );
editWizardBot.clickNextButton();
editWizardBot.setLanguageTag( "en", "us" );
editWizardBot.clickFinishButton();
modificationLogsViewBot.waitForText( "delete: description;lang-en\ndescription;lang-en: English\n-" );
modificationLogsViewBot.waitForText( "add: description;lang-en-us\ndescription;lang-en-us: English\n-" );
assertFalse( entryEditorBot.getAttributeValues().contains( "description;lang-en: English" ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "description;lang-en-us: English" ) );
// edit the value
entryEditorBot.editValue( "description;lang-en-us", "English" );
entryEditorBot.typeValueAndFinish( "English US" );
modificationLogsViewBot.waitForText( "delete: description;lang-en-us\ndescription;lang-en-us: English\n-" );
modificationLogsViewBot.waitForText( "add: description;lang-en-us\ndescription;lang-en-us: English US\n-" );
assertFalse( entryEditorBot.getAttributeValues().contains( "description;lang-en-us: English" ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "description;lang-en-us: English US" ) );
// delete the attribute
entryEditorBot.deleteValue( "description;lang-en-us", "English US" );
modificationLogsViewBot.waitForText( "delete: description;lang-en-us\ndescription;lang-en-us: English US\n-" );
assertFalse( entryEditorBot.getAttributeValues().contains( "description;lang-en-us: English US" ) );
}
/**
* DIRSTUDIO-483: DN Editor escapes all non-ascii characters
*/
@ParameterizedTest
@LdapServersSource
public void testDnValueEditor( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( GROUP1_DN ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( GROUP1_DN.getName() );
entryEditorBot.activate();
String dn = entryEditorBot.getDnText();
assertEquals( "DN: " + GROUP1_DN.getName(), dn );
assertEquals( 12, entryEditorBot.getAttributeValues().size() );
// add member attribute
NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
assertTrue( wizardBot.isVisible() );
wizardBot.typeAttributeType( "member" );
DnEditorDialogBot dnEditorBot = wizardBot.clickFinishButtonExpectingDnEditor();
assertTrue( dnEditorBot.isVisible() );
SelectDnDialogBot selectDnBot = dnEditorBot.clickBrowseButtonExpectingSelectDnDialog();
assertTrue( selectDnBot.isVisible() );
selectDnBot.selectEntry( ArrayUtils.remove( path( MULTI_VALUED_RDN_DN ), 0 ) );
selectDnBot.clickOkButton();
assertEquals( MULTI_VALUED_RDN_DN.getName(), dnEditorBot.getDnText() );
dnEditorBot.clickOkButton();
// assert value after saved and reloaded from server
assertEquals( 13, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "member: " + MULTI_VALUED_RDN_DN.getName() ) );
dnEditorBot = entryEditorBot.editValueExpectingDnEditor( "member", MULTI_VALUED_RDN_DN.getName() );
assertEquals( MULTI_VALUED_RDN_DN.getName(), dnEditorBot.getDnText() );
dnEditorBot.clickCancelButton();
modificationLogsViewBot.waitForText( "#!RESULT OK" );
assertEquals( 1, StringUtils.countMatches( modificationLogsViewBot.getModificationLogsText(), "#!RESULT OK" ),
"Expected 1 modification." );
}
/**
* DIRSTUDIO-637: copy/paste of attributes no longer works.
* Test copy/paste within entry editor.
*/
@ParameterizedTest
@LdapServersSource
public void testCopyPasteStringValue( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( BJENSEN_DN ) );
// copy a value
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( BJENSEN_DN.getName() );
entryEditorBot.activate();
entryEditorBot.copyValue( "uid", "bjensen" );
// go to another entry
browserViewBot.selectEntry( path( USER1_DN ) );
entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() );
entryEditorBot.activate();
assertEquals( 23, entryEditorBot.getAttributeValues().size() );
// paste value, wait till job is done
JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__execute_ldif_name );
entryEditorBot.pasteValue();
watcher.waitUntilDone();
// assert pasted value visible in editor
assertEquals( 24, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "uid: bjensen" ),
"Should contain uid=bjensen: " + entryEditorBot.getAttributeValues() );
// assert pasted value was written to directory
server.withAdminConnection( conn -> {
Entry entry = conn.lookup( USER1_DN );
assertTrue( entry.contains( "uid", "bjensen" ), "Should contain uid=bjensen: " + entry );
} );
}
@ParameterizedTest
@LdapServersSource
public void testCopyPasteMultipleStringAndBinaryValues( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( HNELSON_DN ) );
// copy the values
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( HNELSON_DN.getName() );
entryEditorBot.activate();
entryEditorBot.copyValues( "userPassword", "uid", "description", "jpegPhoto" );
// go to another entry
browserViewBot.selectEntry( path( USER1_DN ) );
entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() );
entryEditorBot.activate();
assertEquals( 23, entryEditorBot.getAttributeValues().size() );
// paste values, wait till job is done
JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__execute_ldif_name );
entryEditorBot.pasteValues();
watcher.waitUntilDone();
// assert pasted values are visible in editor
assertEquals( 27, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "uid: hnelson" ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: " + Characters.ALL ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "jpegPhoto: JPEG-Image (1x1 Pixel, 631 Bytes)" ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "userPassword: SSHA-512 hashed password" ) );
// assert pasted values were written to directory
server.withAdminConnection( conn -> {
Entry entry = conn.lookup( USER1_DN );
assertTrue( entry.contains( "uid", "hnelson" ), "Should contain uid=hnelson: " + entry );
assertTrue( entry.contains( "description", Characters.ALL ), "Should contain description: " + entry );
assertTrue( entry.containsAttribute( "userPassword" ), "Should contain userPassword: " + entry );
assertTrue( entry.containsAttribute( "jpegPhoto" ), "Should contain jpegPhoto: " + entry );
} );
}
/**
* DIRSTUDIO-738: Add support for modular crypt format password
*/
@ParameterizedTest
@LdapServersSource(mode=Mode.All)
public void testPasswordValueEditor( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( BJENSEN_DN ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( BJENSEN_DN.getName() );
entryEditorBot.activate();
String dn = entryEditorBot.getDnText();
assertEquals( "DN: " + BJENSEN_DN.getName(), dn );
assertEquals( 8, entryEditorBot.getAttributeValues().size() );
assertEquals( "", modificationLogsViewBot.getModificationLogsText() );
// add userPassword attribute
entryEditorBot.activate();
NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
assertTrue( wizardBot.isVisible() );
wizardBot.typeAttributeType( "userPassword" );
PasswordEditorDialogBot pwdEditorBot = wizardBot.clickFinishButtonExpectingPasswordEditor();
assertTrue( pwdEditorBot.isVisible() );
String random = RandomStringUtils.random( 20 );
pwdEditorBot.setNewPassword1( random );
pwdEditorBot.setNewPassword2( random );
pwdEditorBot.setShowNewPasswordDetails( true );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_MD5, PasswordUtil.MD5_LENGTH, 0 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SMD5, PasswordUtil.MD5_LENGTH, 8 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SHA, PasswordUtil.SHA1_LENGTH, 0 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA, PasswordUtil.SHA1_LENGTH, 8 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SHA256, PasswordUtil.SHA256_LENGTH, 0 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA256, PasswordUtil.SHA256_LENGTH, 8 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SHA384, PasswordUtil.SHA384_LENGTH, 0 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA384, PasswordUtil.SHA384_LENGTH, 8 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SHA512, PasswordUtil.SHA512_LENGTH, 0 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA512, PasswordUtil.SHA512_LENGTH, 8 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_PKCS5S2, PasswordUtil.PKCS5S2_LENGTH, 16 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_CRYPT, PasswordUtil.CRYPT_LENGTH, 2 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_CRYPT_MD5, PasswordUtil.CRYPT_MD5_LENGTH, 8 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_CRYPT_SHA256,
PasswordUtil.CRYPT_SHA256_LENGTH, 8 );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_CRYPT_SHA512,
PasswordUtil.CRYPT_SHA512_LENGTH, 8 );
pwdEditorBot.clickOkButton();
// assert value after saved and reloaded from server
assertTrue( entryEditorBot.getAttributeValues().contains( "userPassword: CRYPT-SHA-512 hashed password" ) );
// verify and bind with the correct password
pwdEditorBot = entryEditorBot.editValueExpectingPasswordEditor( "userPassword",
"CRYPT-SHA-512 hashed password" );
pwdEditorBot.activateCurrentPasswordTab();
pwdEditorBot.setVerifyPassword( random );
assertNull( pwdEditorBot.clickVerifyButton() );
assertNull( pwdEditorBot.clickBindButton() );
// verify and bind with the wrong password
pwdEditorBot.activateCurrentPasswordTab();
pwdEditorBot.setVerifyPassword( "Wrong Password" );
assertEquals( "Password verification failed", pwdEditorBot.clickVerifyButton() );
assertThat( pwdEditorBot.clickBindButton(), startsWith( "The authentication failed" ) );
pwdEditorBot.clickCancelButton();
// set a new password
pwdEditorBot = entryEditorBot.editValueExpectingPasswordEditor( "userPassword",
"CRYPT-SHA-512 hashed password" );
pwdEditorBot.activateNewPasswordTab();
random = RandomStringUtils.random( 20 );
pwdEditorBot.setNewPassword1( random );
pwdEditorBot.setNewPassword2( random );
pwdEditorBot.setShowNewPasswordDetails( true );
assertHashMethod( pwdEditorBot, LdapSecurityConstants.HASH_METHOD_SSHA256, PasswordUtil.SHA256_LENGTH, 8 );
pwdEditorBot.clickOkButton();
assertTrue( entryEditorBot.getAttributeValues().contains( "userPassword: SSHA-256 hashed password" ) );
}
private void assertHashMethod( PasswordEditorDialogBot passwordEditorBot, LdapSecurityConstants hashMethod,
int passwordLength, int saltLength ) throws Exception
{
passwordEditorBot.selectHashMethod( hashMethod );
String preview = passwordEditorBot.getPasswordPreview();
assertThat( preview, startsWith( "{" + Strings.upperCase( hashMethod.getPrefix() ) + "}" ) );
String passwordHex = passwordEditorBot.getPasswordHex();
assertEquals( passwordLength * 2, passwordHex.length() );
assertTrue( passwordHex.matches( "[0-9a-f]{" + ( passwordLength * 2 ) + "}" ) );
String saltHex = passwordEditorBot.getSaltHex();
if ( saltLength > 0 )
{
assertEquals( saltLength * 2, saltHex.length() );
assertTrue( saltHex.matches( "[0-9a-f]{" + ( saltLength * 2 ) + "}" ) );
}
else
{
assertEquals( "-", saltHex );
}
}
/**
* DIRSTUDIO-1157: Values cannot be modified by text editor
*/
@ParameterizedTest
@LdapServersSource
public void testTextValueEditor( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( BJENSEN_DN ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( BJENSEN_DN.getName() );
entryEditorBot.activate();
String dn = entryEditorBot.getDnText();
assertEquals( "DN: " + BJENSEN_DN.getName(), dn );
assertEquals( 8, entryEditorBot.getAttributeValues().size() );
assertEquals( "", modificationLogsViewBot.getModificationLogsText() );
// add description attribute
entryEditorBot.activate();
NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
assertTrue( wizardBot.isVisible() );
wizardBot.typeAttributeType( "description" );
wizardBot.clickFinishButton();
entryEditorBot.typeValueAndFinish( "testTextValueEditor 1" );
assertEquals( 9, entryEditorBot.getAttributeValues().size() );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: testTextValueEditor 1" ) );
modificationLogsViewBot.waitForText( "add: description\ndescription: testTextValueEditor 1" );
// edit value with the text editor
TextEditorDialogBot textEditorBot = entryEditorBot.editValueWithTextEditor( "description",
"testTextValueEditor 1" );
assertTrue( textEditorBot.isVisible() );
String newValue = "testTextValueEditor 2 " + Characters.ALL;
textEditorBot.setText( newValue );
textEditorBot.clickOkButton();
assertEquals( 9, entryEditorBot.getAttributeValues().size() );
assertFalse( entryEditorBot.getAttributeValues().contains( "description: testTextValueEditor 1" ) );
assertTrue( entryEditorBot.getAttributeValues().contains( "description: " + newValue ) );
String description2Ldif = LdifAttrValLine.create( "description", newValue )
.toFormattedString( LdifFormatParameters.DEFAULT ).replace( LdifParserConstants.LINE_SEPARATOR, "\n" );
modificationLogsViewBot.waitForText( "delete: description\ndescription: testTextValueEditor 1" );
modificationLogsViewBot.waitForText( "add: description\n" + description2Ldif );
}
/**
* Test for the postal address value editor, with an example from DIRSTUDIO-1298 to verify encoding/decoding of special characters.
*/
@ParameterizedTest
@LdapServersSource
public void testAddressValueEditor( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( BJENSEN_DN ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( BJENSEN_DN.getName() );
entryEditorBot.activate();
String dn = entryEditorBot.getDnText();
assertEquals( "DN: " + BJENSEN_DN.getName(), dn );
assertEquals( 8, entryEditorBot.getAttributeValues().size() );
assertEquals( "", modificationLogsViewBot.getModificationLogsText() );
// add postalAddress attribute and verify value is correctly encoded
entryEditorBot.activate();
NewAttributeWizardBot wizardBot = entryEditorBot.openNewAttributeWizard();
assertTrue( wizardBot.isVisible() );
wizardBot.typeAttributeType( "postalAddress" );
AddressEditorDialogBot addressEditorDialogBot = wizardBot.clickFinishButtonExpectingAddressEditor();
assertTrue( addressEditorDialogBot.isVisible() );
addressEditorDialogBot.setText( "1234 Main St.\nAnytown, CA 12345\nUSA" );
addressEditorDialogBot.clickOkButton();
assertEquals( 9, entryEditorBot.getAttributeValues().size() );
assertTrue(
entryEditorBot.getAttributeValues().contains( "postalAddress: 1234 Main St., Anytown, CA 12345, USA" ) );
modificationLogsViewBot.waitForText( "add: postalAddress\npostalAddress: 1234 Main St.$Anytown, CA 12345$USA" );
// verify value is correctly decoded
addressEditorDialogBot = entryEditorBot.editValueExpectingAddressEditor( "postalAddress",
"1234 Main St., Anytown, CA 12345, USA" );
assertTrue( addressEditorDialogBot.isVisible() );
assertEquals( "1234 Main St.\nAnytown, CA 12345\nUSA", addressEditorDialogBot.getText() );
addressEditorDialogBot.clickCancelButton();
// edit value with a complex address and verify value is correctly encoded
addressEditorDialogBot = entryEditorBot.editValueExpectingAddressEditor( "postalAddress",
"1234 Main St., Anytown, CA 12345, USA" );
assertTrue( addressEditorDialogBot.isVisible() );
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | true |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ValueEditorTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ValueEditorTest.java | /*
* 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 java.nio.charset.StandardCharsets.ISO_8859_1;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.nio.charset.StandardCharsets;
import java.util.stream.Stream;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.ldapbrowser.core.model.IAttribute;
import org.apache.directory.studio.ldapbrowser.core.model.IEntry;
import org.apache.directory.studio.ldapbrowser.core.model.IValue;
import org.apache.directory.studio.ldapbrowser.core.model.impl.Attribute;
import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyConnection;
import org.apache.directory.studio.ldapbrowser.core.model.impl.DummyEntry;
import org.apache.directory.studio.ldapbrowser.core.model.impl.Value;
import org.apache.directory.studio.ldapbrowser.core.model.schema.Schema;
import org.apache.directory.studio.valueeditors.HexValueEditor;
import org.apache.directory.studio.valueeditors.IValueEditor;
import org.apache.directory.studio.valueeditors.InPlaceTextValueEditor;
import org.apache.directory.studio.valueeditors.TextValueEditor;
import org.apache.directory.studio.valueeditors.address.AddressValueEditor;
import org.apache.directory.studio.valueeditors.bool.InPlaceBooleanValueEditor;
import org.apache.directory.studio.valueeditors.oid.InPlaceOidValueEditor;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
/**
* Tests the value editors.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class ValueEditorTest extends AbstractTestBase
{
private static final String CN = "cn";
private static final String POSTAL = "postalAddress";
private static final String USER_PWD = "userPassword";
private static final String EMPTY_STRING = "";
private static final String ASCII = "a-zA+Z0.9";
private static final String UNICODE = "a-z\nA+Z\r0.9\t\u00e4\u00f6\u00fc\u00df \u2000\u3000\u5047";
private static final byte[] EMPTY_BYTES = new byte[0];
private static final byte[] ISO88591 = "\u00e4\u00f6\u00fc\u00df".getBytes( ISO_8859_1 );
private static final byte[] UTF8 = UNICODE.getBytes( UTF_8 );
private static final byte[] PNG = new byte[]
{ ( byte ) 0x89, 0x50, 0x4E, 0x47 };
private static final String TRUE = "TRUE";
private static final String FALSE = "FALSE";
private static final String NUMERIC_OID = "1.3.6.1.4.1.1466.20037";
private static final String DESCR_OID = "a-zA-Z0-9";
private static final String ADDRESS_DISPLAY = "$1,000,000 Sweepstakes, PO Box 1000000, Anytown, CA 12345, USA";
private static final String ADDRESS_RAW = "\\241,000,000 Sweepstakes$PO Box 1000000$Anytown, CA 12345$USA";
public static Stream<Arguments> data()
{
return Stream.of( new Object[][]
{
/*
* InPlaceTextValueEditor can handle string values and binary values that can be decoded as UTF-8.
*/
{
"InPlaceTextValueEditor - empty value",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( CN )
.rawValue( IValue.EMPTY_STRING_VALUE ).expectedRawValue( EMPTY_STRING )
.expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
{
"InPlaceTextValueEditor - empty string",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( CN )
.rawValue( EMPTY_STRING ).expectedRawValue( EMPTY_STRING ).expectedDisplayValue( EMPTY_STRING )
.expectedHasValue( true ).expectedStringOrBinaryValue( EMPTY_STRING ) },
{
"InPlaceTextValueEditor - ascii",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( CN ).rawValue( ASCII )
.expectedRawValue( ASCII ).expectedDisplayValue( ASCII ).expectedHasValue( true )
.expectedStringOrBinaryValue( ASCII ) },
{
"InPlaceTextValueEditor - unicode",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( CN ).rawValue( UNICODE )
.expectedRawValue( UNICODE ).expectedDisplayValue( UNICODE ).expectedHasValue( true )
.expectedStringOrBinaryValue( UNICODE ) },
{
"InPlaceTextValueEditor - bytearray UTF8",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( USER_PWD ).rawValue( UTF8 )
.expectedRawValue( UNICODE ).expectedDisplayValue( UNICODE ).expectedHasValue( true )
.expectedStringOrBinaryValue( UNICODE ) },
// text editor always tries to decode byte[] as UTF-8, so it can not handle ISO-8859-1 encoded byte[]
{
"InPlaceTextValueEditor - bytearray ISO-8859-1",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( USER_PWD )
.rawValue( ISO88591 ).expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL )
.expectedHasValue( true ).expectedStringOrBinaryValue( null ) },
// text editor always tries to decode byte[] as UTF-8, so it can not handle arbitrary byte[]
{
"InPlaceTextValueEditor - bytearray PNG",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( USER_PWD ).rawValue( PNG )
.expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
/*
* InPlaceBooleanValueEditor can only handle TRUE or FALSE values.
*/
{
"InPlaceBooleanValueEditor - TRUE",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( CN ).rawValue( TRUE )
.expectedRawValue( TRUE ).expectedDisplayValue( TRUE ).expectedHasValue( true )
.expectedStringOrBinaryValue( TRUE ) },
{
"InPlaceBooleanValueEditor - FALSE",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( CN ).rawValue( FALSE )
.expectedRawValue( FALSE ).expectedDisplayValue( FALSE ).expectedHasValue( true )
.expectedStringOrBinaryValue( FALSE ) },
{
"InPlaceBooleanValueEditor - INVALID",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( CN )
.rawValue( "invalid" ).expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL )
.expectedHasValue( true ).expectedStringOrBinaryValue( null ) },
{
"InPlaceBooleanValueEditor - bytearray TRUE",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( USER_PWD )
.rawValue( TRUE.getBytes( UTF_8 ) ).expectedRawValue( TRUE ).expectedDisplayValue( TRUE )
.expectedHasValue( true ).expectedStringOrBinaryValue( TRUE ) },
{
"InPlaceBooleanValueEditor - bytearray FALSE",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( USER_PWD )
.rawValue( FALSE.getBytes( UTF_8 ) ).expectedRawValue( FALSE ).expectedDisplayValue( FALSE )
.expectedHasValue( true ).expectedStringOrBinaryValue( FALSE ) },
{
"InPlaceBooleanValueEditor - bytearray INVALID",
Data.data().valueEditorClass( InPlaceBooleanValueEditor.class ).attribute( USER_PWD )
.rawValue( "invalid".getBytes( UTF_8 ) ).expectedRawValue( null )
.expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
/*
* InPlaceOidValueEditor can only handle OIDs
*/
{
"InPlaceOidValueEditor - numeric OID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( CN ).rawValue( NUMERIC_OID )
.expectedRawValue( NUMERIC_OID ).expectedDisplayValue( NUMERIC_OID + " (Start TLS)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( NUMERIC_OID ) },
{
"InPlaceOidValueEditor - descr OID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( CN ).rawValue( DESCR_OID )
.expectedRawValue( DESCR_OID ).expectedDisplayValue( DESCR_OID ).expectedHasValue( true )
.expectedStringOrBinaryValue( DESCR_OID ) },
{
"InPlaceOidValueEditor - relaxed descr OID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( CN )
.rawValue( "orclDBEnterpriseRole_82" ).expectedRawValue( "orclDBEnterpriseRole_82" )
.expectedDisplayValue( "orclDBEnterpriseRole_82" ).expectedHasValue( true )
.expectedStringOrBinaryValue( "orclDBEnterpriseRole_82" ) },
{
"InPlaceOidValueEditor - INVALID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( CN ).rawValue( "in valid" )
.expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
{
"InPlaceOidValueEditor - bytearray numeric OID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( USER_PWD )
.rawValue( NUMERIC_OID.getBytes( UTF_8 ) ).expectedRawValue( NUMERIC_OID )
.expectedDisplayValue( NUMERIC_OID + " (Start TLS)" ).expectedHasValue( true )
.expectedStringOrBinaryValue( NUMERIC_OID ) },
{
"InPlaceOidValueEditor - bytearray INVALID",
Data.data().valueEditorClass( InPlaceOidValueEditor.class ).attribute( USER_PWD )
.rawValue( "in valid".getBytes( UTF_8 ) ).expectedRawValue( null )
.expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
/*
* TextValueEditor can handle string values and binary values that can be decoded as UTF-8.
*/
{
"TextValueEditor - empty string value",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( CN )
.rawValue( IValue.EMPTY_STRING_VALUE ).expectedRawValue( EMPTY_STRING )
.expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
{
"TextValueEditor - empty string",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( CN ).rawValue( EMPTY_STRING )
.expectedRawValue( EMPTY_STRING ).expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
{
"TextValueEditor - ascii",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( CN ).rawValue( ASCII )
.expectedRawValue( ASCII ).expectedDisplayValue( ASCII ).expectedHasValue( true )
.expectedStringOrBinaryValue( ASCII ) },
{
"TextValueEditor - unicode",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( CN ).rawValue( UNICODE )
.expectedRawValue( UNICODE ).expectedDisplayValue( UNICODE ).expectedHasValue( true )
.expectedStringOrBinaryValue( UNICODE ) },
{
"TextValueEditor - empty binary value",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( USER_PWD )
.rawValue( IValue.EMPTY_BINARY_VALUE ).expectedRawValue( EMPTY_STRING )
.expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
{
"TextValueEditor - empty bytearray",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( USER_PWD ).rawValue( EMPTY_BYTES )
.expectedRawValue( EMPTY_STRING ).expectedDisplayValue( EMPTY_STRING ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_STRING ) },
{
"TextValueEditor - bytearray UTF8",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( USER_PWD ).rawValue( UTF8 )
.expectedRawValue( UNICODE ).expectedDisplayValue( UNICODE ).expectedHasValue( true )
.expectedStringOrBinaryValue( UNICODE ) },
// text editor always tries to decode byte[] as UTF-8, so it can not handle ISO-8859-1 encoded byte[]
{
"TextValueEditor - bytearray ISO-8859-1",
Data.data().valueEditorClass( TextValueEditor.class ).attribute( USER_PWD ).rawValue( ISO88591 )
.expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
// text editor always tries to decode byte[] as UTF-8, so it can not handle arbitrary byte[]
{
"TextValueEditor - bytearray PNG",
Data.data().valueEditorClass( InPlaceTextValueEditor.class ).attribute( USER_PWD ).rawValue( PNG )
.expectedRawValue( null ).expectedDisplayValue( IValueEditor.NULL ).expectedHasValue( true )
.expectedStringOrBinaryValue( null ) },
/*
* HexValueEditor can handle all string or binary values.
*/
{
"HexValueEditor - empty string value",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( CN )
.rawValue( IValue.EMPTY_STRING_VALUE ).expectedRawValue( EMPTY_BYTES )
.expectedDisplayValue( "Binary Data (0 Bytes)" ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_BYTES ) },
{
"HexValueEditor - empty string",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( CN ).rawValue( EMPTY_STRING )
.expectedRawValue( EMPTY_BYTES ).expectedDisplayValue( "Binary Data (0 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( EMPTY_BYTES ) },
{
"HexValueEditor - ascii",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( CN ).rawValue( ASCII )
.expectedRawValue( ASCII.getBytes( StandardCharsets.US_ASCII ) )
.expectedDisplayValue( "Binary Data (9 Bytes)" ).expectedHasValue( true )
.expectedStringOrBinaryValue( ASCII.getBytes( StandardCharsets.US_ASCII ) ) },
{
"HexValueEditor - empty binary value",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD )
.rawValue( IValue.EMPTY_BINARY_VALUE ).expectedRawValue( EMPTY_BYTES )
.expectedDisplayValue( "Binary Data (0 Bytes)" ).expectedHasValue( true )
.expectedStringOrBinaryValue( EMPTY_BYTES ) },
{
"HexValueEditor - empty bytearray",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD ).rawValue( EMPTY_BYTES )
.expectedRawValue( EMPTY_BYTES ).expectedDisplayValue( "Binary Data (0 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( EMPTY_BYTES ) },
{
"HexValueEditor - bytearray UTF8",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD ).rawValue( UTF8 )
.expectedRawValue( UTF8 ).expectedDisplayValue( "Binary Data (30 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( UTF8 ) },
{
"HexValueEditor - bytearray ISO-8859-1",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD ).rawValue( ISO88591 )
.expectedRawValue( ISO88591 ).expectedDisplayValue( "Binary Data (4 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( ISO88591 ) },
{
"HexValueEditor - bytearray PNG",
Data.data().valueEditorClass( HexValueEditor.class ).attribute( USER_PWD ).rawValue( PNG )
.expectedRawValue( PNG ).expectedDisplayValue( "Binary Data (4 Bytes)" )
.expectedHasValue( true ).expectedStringOrBinaryValue( PNG ) },
/*
* AddressValueEditor can handle a multi-line postal address with escaped characters.
*/
{
"AddressValueEditor - RFC example",
Data.data().valueEditorClass( AddressValueEditor.class ).attribute( POSTAL ).rawValue( ADDRESS_RAW )
.expectedRawValue( ADDRESS_RAW ).expectedDisplayValue( ADDRESS_DISPLAY )
.expectedHasValue( true ).expectedStringOrBinaryValue( ADDRESS_RAW ) },
} ).map( d -> Arguments.arguments( ( String ) d[0], ( Data ) d[1] ) );
}
private IValue value;
private IValueEditor editor;
public void setup( String name, Data data ) throws Exception
{
IEntry entry = new DummyEntry( new Dn(), new DummyConnection( Schema.DEFAULT_SCHEMA ) );
IAttribute attribute = new Attribute( entry, data.attribute );
value = new Value( attribute, data.rawValue );
editor = data.valueEditorClass.newInstance();
}
@ParameterizedTest
@MethodSource("data")
public void testGetRawValue( String name, Data data ) throws Exception
{
setup( name, data );
if ( data.expectedRawValue instanceof byte[] )
{
assertArrayEquals( ( byte[] ) data.expectedRawValue, ( byte[] ) editor.getRawValue( value ) );
}
else
{
assertEquals( data.expectedRawValue, editor.getRawValue( value ) );
}
}
@ParameterizedTest
@MethodSource("data")
public void testGetDisplayValue( String name, Data data ) throws Exception
{
setup( name, data );
assertEquals( data.expectedDisplayValue, editor.getDisplayValue( value ) );
}
@ParameterizedTest
@MethodSource("data")
public void testHasValue( String name, Data data ) throws Exception
{
setup( name, data );
assertEquals( data.expectedHasValue, editor.hasValue( value ) );
}
@ParameterizedTest
@MethodSource("data")
public void testGetStringOrBinaryValue( String name, Data data ) throws Exception
{
setup( name, data );
if ( data.expectedStringOrBinaryValue instanceof byte[] )
{
assertArrayEquals( ( byte[] ) data.expectedStringOrBinaryValue,
( byte[] ) editor.getStringOrBinaryValue( editor.getRawValue( value ) ) );
}
else
{
assertEquals( data.expectedStringOrBinaryValue,
editor.getStringOrBinaryValue( editor.getRawValue( value ) ) );
}
}
static class Data
{
public Class<? extends IValueEditor> valueEditorClass;
public String attribute;
public Object rawValue;
public Object expectedRawValue;
public String expectedDisplayValue;
public boolean expectedHasValue;
public Object expectedStringOrBinaryValue;
public static Data data()
{
return new Data();
}
public Data valueEditorClass( Class<? extends IValueEditor> valueEditorClass )
{
this.valueEditorClass = valueEditorClass;
return this;
}
public Data attribute( String attribute )
{
this.attribute = attribute;
return this;
}
public Data rawValue( Object rawValue )
{
this.rawValue = rawValue;
return this;
}
public Data expectedRawValue( Object expectedRawValue )
{
this.expectedRawValue = expectedRawValue;
return this;
}
public Data expectedDisplayValue( String expectedDisplayValue )
{
this.expectedDisplayValue = expectedDisplayValue;
return this;
}
public Data expectedHasValue( boolean expectedHasValue )
{
this.expectedHasValue = expectedHasValue;
return this;
}
public Data expectedStringOrBinaryValue( Object expectedStringOrBinaryValue )
{
this.expectedStringOrBinaryValue = expectedStringOrBinaryValue;
return this;
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/MoveEntryTest.java | /*
* 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 org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC111_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.test.integration.junit5.LdapServerType;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource.Mode;
import org.apache.directory.studio.test.integration.ui.bots.MoveEntriesDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.SelectDnDialogBot;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests entry move (moddn) and the move dialog.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class MoveEntryTest extends AbstractTestBase
{
@ParameterizedTest
@LdapServersSource
public void testMoveUp( TestLdapServer server ) throws Exception
{
Dn dnToMove = MISC111_DN;
Dn newParentDn = MISC_DN;
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( dnToMove ) );
MoveEntriesDialogBot moveEntryDialog = browserViewBot.openMoveEntryDialog();
assertTrue( moveEntryDialog.isVisible() );
moveEntryDialog.setParentText( newParentDn.getName() );
moveEntryDialog.clickOkButton();
assertTrue( browserViewBot.existsEntry( path( newParentDn, dnToMove.getRdn() ) ) );
browserViewBot.selectEntry( path( newParentDn, dnToMove.getRdn() ) );
assertFalse( browserViewBot.existsEntry( path( dnToMove ) ) );
}
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testMoveDown( TestLdapServer server ) throws Exception
{
Dn dnToMove = DN_WITH_ESCAPED_CHARACTERS_BACKSLASH_PREFIXED;
Dn newParentDn = DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED;
if ( server.getType() == LdapServerType.OpenLdap || server.getType() == LdapServerType.Fedora389ds )
{
// OpenLDAP and 389ds escape all characters with hex digits
dnToMove = DN_WITH_ESCAPED_CHARACTERS_HEX_PAIR_ESCAPED;
newParentDn = DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED;
}
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( dnToMove ) );
MoveEntriesDialogBot moveEntryDialog = browserViewBot.openMoveEntryDialog();
assertTrue( moveEntryDialog.isVisible() );
SelectDnDialogBot selectDnBot = moveEntryDialog.clickBrowseButtonExpectingSelectDnDialog();
assertTrue( selectDnBot.isVisible() );
selectDnBot.selectEntry( ArrayUtils.remove( path( newParentDn ), 0 ) );
selectDnBot.clickOkButton();
moveEntryDialog.activate();
assertEquals( newParentDn.getName(), moveEntryDialog.getParentText() );
moveEntryDialog.clickOkButton();
assertTrue( browserViewBot.existsEntry( path( newParentDn, dnToMove.getRdn() ) ) );
browserViewBot.selectEntry( path( newParentDn, dnToMove.getRdn() ) );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/CertificateValidationTest.java | /*
* 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 org.apache.directory.studio.test.integration.ui.utils.Constants.LOCALHOST;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.io.FileOutputStream;
import java.lang.reflect.Method;
import java.math.BigInteger;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Security;
import java.security.cert.Certificate;
import java.security.cert.X509Certificate;
import java.util.Date;
import javax.security.auth.x500.X500Principal;
import org.apache.directory.api.ldap.model.constants.SchemaConstants;
import org.apache.directory.api.ldap.model.entry.Attribute;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.exception.LdapException;
import org.apache.directory.server.core.security.TlsKeyGenerator;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.test.integration.junit5.ApacheDirectoryServer;
import org.apache.directory.studio.test.integration.junit5.LdapServerType;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.CertificateTrustDialogBot;
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.CheckAuthenticationDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.DialogBot.CheckResponse;
import org.apache.directory.studio.test.integration.ui.bots.ErrorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.NewConnectionWizardBot;
import org.apache.directory.studio.test.integration.ui.bots.PreferencesBot;
import org.bouncycastle.asn1.x509.BasicConstraints;
import org.bouncycastle.asn1.x509.ExtendedKeyUsage;
import org.bouncycastle.asn1.x509.Extension;
import org.bouncycastle.asn1.x509.KeyPurposeId;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.x509.X509V3CertificateGenerator;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests secure connection handling.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class CertificateValidationTest extends AbstractTestBase
{
static final long YEAR_MILLIS = 365L * 24L * 3600L * 1000L;
private TestInfo testInfo;
private static NewConnectionWizardBot wizardBot;
@BeforeEach
public void setUp( TestInfo testInfo ) throws Exception
{
this.testInfo = testInfo;
// let Java use the key store
System.setProperty( "javax.net.ssl.trustStore", ROOT_CA_KEYSTORE_PATH );
System.setProperty( "javax.net.ssl.trustStorePassword", KEYSTORE_PW );
System.setProperty( "javax.net.ssl.keyStore", ROOT_CA_KEYSTORE_PATH );
System.setProperty( "javax.net.ssl.keyStorePassword", KEYSTORE_PW );
}
@AfterEach
public void tearDown() throws Exception
{
// delete custom Java key store settings
System.clearProperty( "javax.net.ssl.trustStore" );
System.clearProperty( "javax.net.ssl.trustStorePassword" );
System.clearProperty( "javax.net.ssl.keyStore" );
System.clearProperty( "javax.net.ssl.keyStorePassword" );
}
private static final String KEYSTORE_PW = "changeit";
private static final String ROOT_CA_KEYSTORE_PATH = "target/classes/root-ca-keystore.ks";
private static KeyStore ROOT_CA_KEYSTORE;
private static final String VALID_KEYSTORE_PATH = "target/classes/valid-keystore.ks";
private static final String EXPIRED_KEYSTORE_PATH = "target/classes/expired-keystore.ks";
private static final String NOT_YET_VALID_KEYSTORE_PATH = "target/classes/not-yet-valid-keystore.ks";
private static final String WRONG_HOSTNAME_KEYSTORE_PATH = "target/classes/invalid-hostname-keystore.ks";
private static final String SMALL_KEYSIZE_KEYSTORE_PATH = "target/classes/small-keysize-keystore.ks";
private static final String SELF_SIGNED_KEYSTORE_PATH = "target/classes/self-signed-keystore.ks";
private static final String UNTRUSTED_ROOT_CA_KEYSTORE_PATH = "target/classes/untrusted-root-ca-keystore.ks";
private static final String UNTRUSTED_KEYSTORE_PATH = "target/classes/untrusted-keystore.ks";
private static final String MULTIPLE_ISSUES_KEYSTORE_PATH = "target/classes/multiple-issues-keystore.ks";
@BeforeAll
public static void installKeyStoreWithCertificate() throws Exception
{
String issuerDn = "CN=trusted-root-ca";
String subjectDn = "CN=" + LOCALHOST;
Date startDate = new Date();
Date expiryDate = new Date( System.currentTimeMillis() + TlsKeyGenerator.YEAR_MILLIS );
String keyAlgo = "RSA";
int keySize = 1024;
// generate root CA, self-signed
ROOT_CA_KEYSTORE = createKeyStore( issuerDn, issuerDn, startDate, expiryDate, keyAlgo, keySize, null,
ROOT_CA_KEYSTORE_PATH );
PrivateKey rootCaPrivateKey = ( PrivateKey ) ROOT_CA_KEYSTORE.getKey( "apacheds", KEYSTORE_PW.toCharArray() );
// generate a valid certificate, signed by root CA
createKeyStore( subjectDn, issuerDn, startDate, expiryDate, keyAlgo, keySize, rootCaPrivateKey,
VALID_KEYSTORE_PATH );
// generate an expired certificate, signed by root CA
Date expiredStartDate = new Date( System.currentTimeMillis() - TlsKeyGenerator.YEAR_MILLIS );
Date expiredExpiryDate = new Date( System.currentTimeMillis() - TlsKeyGenerator.YEAR_MILLIS / 365 );
createKeyStore( subjectDn, issuerDn, expiredStartDate, expiredExpiryDate, keyAlgo, keySize,
rootCaPrivateKey, EXPIRED_KEYSTORE_PATH );
// generate a not yet valid certificate, signed by root CA
Date notYetValidStartDate = new Date( System.currentTimeMillis() + TlsKeyGenerator.YEAR_MILLIS / 365 );
Date notYetValidExpiryDate = new Date( System.currentTimeMillis() + TlsKeyGenerator.YEAR_MILLIS );
createKeyStore( subjectDn, issuerDn, notYetValidStartDate, notYetValidExpiryDate, keyAlgo, keySize,
rootCaPrivateKey, NOT_YET_VALID_KEYSTORE_PATH );
// generate a certificate with small key size, signed by root CA
int smallKeySize = 512;
createKeyStore( subjectDn, issuerDn, startDate, expiryDate, keyAlgo, smallKeySize,
rootCaPrivateKey, SMALL_KEYSIZE_KEYSTORE_PATH );
// generate a certificate with an invalid hostname, signed by root CA
String wrongHostnameSubjectDn = "CN=foo.example.com";
createKeyStore( wrongHostnameSubjectDn, issuerDn, startDate, expiryDate, keyAlgo, keySize, rootCaPrivateKey,
WRONG_HOSTNAME_KEYSTORE_PATH );
// generate a self-signed certificate
createKeyStore( subjectDn, subjectDn, startDate, expiryDate, keyAlgo, keySize, null,
SELF_SIGNED_KEYSTORE_PATH );
// generate a certificate, signed by untrusted root CA
String untrustedRootCaIssuerDn = "CN=untrusted-root-ca";
createKeyStore( untrustedRootCaIssuerDn, untrustedRootCaIssuerDn, startDate, expiryDate, keyAlgo, keySize, null,
UNTRUSTED_ROOT_CA_KEYSTORE_PATH );
PrivateKey untrustedRootCaPrivateKey = ( PrivateKey ) ROOT_CA_KEYSTORE.getKey( "apacheds",
KEYSTORE_PW.toCharArray() );
createKeyStore( subjectDn, untrustedRootCaIssuerDn, startDate, expiryDate, keyAlgo, keySize,
untrustedRootCaPrivateKey,
UNTRUSTED_KEYSTORE_PATH );
// generate a certificate with multiple issues: expired, wrong hostname, self-signed
createKeyStore( wrongHostnameSubjectDn, wrongHostnameSubjectDn, expiredStartDate, expiredExpiryDate, keyAlgo,
keySize, null, MULTIPLE_ISSUES_KEYSTORE_PATH );
}
private static KeyStore createKeyStore( String subjectDn, String issuerDn, Date startDate, Date expiryDate,
String keyAlgo, int keySize, PrivateKey optionalSigningKey, String keystorePath )
throws Exception
{
File goodKeyStoreFile = new File( keystorePath );
if ( goodKeyStoreFile.exists() )
{
goodKeyStoreFile.delete();
}
Entry entry = new DefaultEntry();
addKeyPair( entry, issuerDn, subjectDn, startDate, expiryDate, keyAlgo, keySize,
optionalSigningKey );
KeyPair keyPair = TlsKeyGenerator.getKeyPair( entry );
X509Certificate cert = TlsKeyGenerator.getCertificate( entry );
//System.out.println( cert );
KeyStore keyStore = KeyStore.getInstance( KeyStore.getDefaultType() );
keyStore.load( null, null );
keyStore.setCertificateEntry( "apacheds", cert );
keyStore.setKeyEntry( "apacheds", keyPair.getPrivate(), KEYSTORE_PW.toCharArray(), new Certificate[]
{ cert } );
try ( FileOutputStream out = new FileOutputStream( goodKeyStoreFile ) )
{
keyStore.store( out, KEYSTORE_PW.toCharArray() );
}
return keyStore;
}
static
{
Security.addProvider( new BouncyCastleProvider() );
}
public static void addKeyPair( Entry entry, String issuerDN, String subjectDN, Date startDate, Date expiryDate,
String keyAlgo, int keySize, PrivateKey optionalSigningKey ) throws LdapException
{
Attribute objectClass = entry.get( SchemaConstants.OBJECT_CLASS_AT );
if ( objectClass == null )
{
entry.put( SchemaConstants.OBJECT_CLASS_AT, TlsKeyGenerator.TLS_KEY_INFO_OC,
SchemaConstants.INET_ORG_PERSON_OC );
}
else
{
objectClass.add( TlsKeyGenerator.TLS_KEY_INFO_OC, SchemaConstants.INET_ORG_PERSON_OC );
}
KeyPairGenerator generator = null;
try
{
generator = KeyPairGenerator.getInstance( keyAlgo );
}
catch ( NoSuchAlgorithmException e )
{
LdapException ne = new LdapException( "" );
ne.initCause( e );
throw ne;
}
generator.initialize( keySize );
KeyPair keypair = generator.genKeyPair();
entry.put( TlsKeyGenerator.KEY_ALGORITHM_AT, keyAlgo );
// Generate the private key attributes
PrivateKey privateKey = keypair.getPrivate();
entry.put( TlsKeyGenerator.PRIVATE_KEY_AT, privateKey.getEncoded() );
entry.put( TlsKeyGenerator.PRIVATE_KEY_FORMAT_AT, privateKey.getFormat() );
PublicKey publicKey = keypair.getPublic();
entry.put( TlsKeyGenerator.PUBLIC_KEY_AT, publicKey.getEncoded() );
entry.put( TlsKeyGenerator.PUBLIC_KEY_FORMAT_AT, publicKey.getFormat() );
// Generate the self-signed certificate
BigInteger serialNumber = BigInteger.valueOf( System.currentTimeMillis() );
X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
X500Principal issuerName = new X500Principal( issuerDN );
X500Principal subjectName = new X500Principal( subjectDN );
certGen.setSerialNumber( serialNumber );
certGen.setIssuerDN( issuerName );
certGen.setNotBefore( startDate );
certGen.setNotAfter( expiryDate );
certGen.setSubjectDN( subjectName );
certGen.setPublicKey( publicKey );
certGen.setSignatureAlgorithm( "SHA256With" + keyAlgo );
certGen.addExtension( Extension.basicConstraints, false, new BasicConstraints( true ) );
certGen.addExtension( Extension.extendedKeyUsage, true, new ExtendedKeyUsage(
new KeyPurposeId[]
{ KeyPurposeId.id_kp_clientAuth, KeyPurposeId.id_kp_serverAuth } ) );
try
{
PrivateKey signingKey = optionalSigningKey != null ? optionalSigningKey : privateKey;
X509Certificate cert = certGen.generate( signingKey, "BC" );
entry.put( TlsKeyGenerator.USER_CERTIFICATE_AT, cert.getEncoded() );
}
catch ( Exception e )
{
LdapException ne = new LdapException( "" );
ne.initCause( e );
throw ne;
}
}
private String getConnectionName()
{
return testInfo.getTestMethod().map( Method::getName ).orElse( "null" ) + " "
+ testInfo.getDisplayName();
}
/**
* Tests ldaps:// with a valid certificate.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testLdapsCertificateValidationOK( ApacheDirectoryServer server ) throws Exception
{
server.setKeystore( VALID_KEYSTORE_PATH );
wizardBotWithLdaps( server, false );
// check the certificate, should be OK
CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
assertFalse( checkResponse.isError(), "Expected OK, valid and trusted certificate" );
// view the certificate
CertificateViewerDialogBot certificateViewerBot = wizardBot.clickViewCertificateButton();
certificateViewerBot.clickCloseButton();
// enter correct authentication parameter
wizardBot.clickNextButton();
wizardBot.typeUser( "uid=admin,ou=system" );
wizardBot.typePassword( "secret" );
// check the certificate again, should be OK
String result2 = wizardBot.clickCheckAuthenticationButton();
assertNull( result2, "Expected OK, valid and trusted certificate" );
wizardBot.clickCancelButton();
}
/**
* Tests ldaps:// with an expired certificate.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testLdapsCertificateValidationExpired( ApacheDirectoryServer server ) throws Exception
{
server.setKeystore( EXPIRED_KEYSTORE_PATH );
wizardBotWithLdaps( server, false );
// check the certificate, expecting the trust dialog
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isExpired() );
assertFalse( trustDialogBot.isSelfSigned() );
assertFalse( trustDialogBot.isNotYetValid() );
assertFalse( trustDialogBot.isHostNameMismatch() );
assertFalse( trustDialogBot.isIssuerUnkown() );
trustDialogBot.selectDontTrust();
ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
assertTrue( errorBot.getErrorMessage().contains( "failed" ) );
errorBot.clickOkButton();
wizardBot.clickCancelButton();
}
/**
* Tests that when selecting "Don't trust" the certificate is not trusted
* and not added to any key store.
*/
@ParameterizedTest
@LdapServersSource
public void testLdapsCertificateDoNotTrust( TestLdapServer server ) throws Exception
{
wizardBotWithLdaps( server, true );
// check trust, expect trust dialog, select don't trust
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isVisible() );
trustDialogBot.selectDontTrust();
ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
errorBot.clickOkButton();
// check trust again, expect trust dialog, select don't trust
wizardBot.activate();
trustDialogBot = wizardBot.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isVisible() );
trustDialogBot.selectDontTrust();
errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
errorBot.clickOkButton();
// certificate must not be added to a trust store
assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
// click finish, that opens the connection
wizardBot.clickFinishButton( false );
// expecting trust dialog again.
trustDialogBot = new CertificateTrustDialogBot();
assertTrue( trustDialogBot.isVisible() );
trustDialogBot.selectDontTrust();
errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
errorBot.clickOkButton();
assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
}
/**
* Tests that when selecting "Trust temporary" the certificate is trusted
* and added to the session key store.
*/
@ParameterizedTest
@LdapServersSource
public void testLdapsCertificateTrustTemporary( TestLdapServer server ) throws Exception
{
wizardBotWithLdaps( server, true );
// check trust, expect trust dialog, select trust temporary
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isVisible() );
trustDialogBot.selectTrustTemporary();
trustDialogBot.clickOkButton();
// expect ok dialog
new CheckAuthenticationDialogBot().clickOkButton();
// certificate must be added to the temporary trust store
assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
assertEquals( 1, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
// check trust again, now the certificate is already trusted
wizardBot.activate();
String result = wizardBot.clickCheckAuthenticationButton();
assertNull( result, "Expected OK, valid and trusted certificate" );
wizardBot.clickCancelButton();
}
/**
* Tests that when selecting "Trust permanent" the certificate is trusted
* and added to the permanent key store.
*/
@ParameterizedTest
@LdapServersSource
public void testLdapsCertificateTrustPermanent( TestLdapServer server ) throws Exception
{
wizardBotWithLdaps( server, true );
// check trust, expect trust dialog, select trust temporary
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isVisible() );
trustDialogBot.selectTrustPermanent();
trustDialogBot.clickOkButton();
// expect ok dialog
new CheckAuthenticationDialogBot().clickOkButton();
// certificate must be added to the temporary trust store
assertEquals( 1, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
// check trust again, now the certificate is already trusted
wizardBot.activate();
String result = wizardBot.clickCheckAuthenticationButton();
assertNull( result, "Expected OK, valid and trusted certificate" );
wizardBot.clickCancelButton();
}
/**
* Tests StartTLS with an valid certificate. This is simulated
* by putting the root certificate into a temporary key store.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testStartTlsCertificateValidationOK( ApacheDirectoryServer server ) throws Exception
{
server.setKeystore( VALID_KEYSTORE_PATH );
// enter connection parameter
wizardBot = connectionsViewBot.openNewConnectionWizard();
wizardBot.typeConnectionName( getConnectionName() );
wizardBot.typeHost( LOCALHOST );
wizardBot.typePort( server.getPort() );
wizardBot.selectStartTlsEncryption();
// check the certificate, should be OK
CheckResponse checkResponse = wizardBot.clickCheckNetworkParameterButton();
assertFalse( checkResponse.isError(), "Expected OK, valid and trusted certificate" );
// view the certificate
CertificateViewerDialogBot certificateViewerBot = wizardBot.clickViewCertificateButton();
certificateViewerBot.clickCloseButton();
// enter correct authentication parameter
wizardBot.clickNextButton();
wizardBot.typeUser( "uid=admin,ou=system" );
wizardBot.typePassword( "secret" );
// check the certificate again, should be OK
String result2 = wizardBot.clickCheckAuthenticationButton();
assertNull( result2, "Expected OK, valid and trusted certificate" );
wizardBot.clickCancelButton();
}
/**
* DIRSTUDIO-1205: SSL/TLS with small key size is not working.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testStartTlsCertificateValidationSmallKeysizeError( ApacheDirectoryServer server ) throws Exception
{
server.setKeystore( SMALL_KEYSIZE_KEYSTORE_PATH );
wizardBotWithStartTls( server, false );
// check the certificate, expecting the trust dialog
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
assertFalse( trustDialogBot.isExpired() );
assertFalse( trustDialogBot.isSelfSigned() );
assertFalse( trustDialogBot.isNotYetValid() );
assertFalse( trustDialogBot.isHostNameMismatch() );
assertFalse( trustDialogBot.isIssuerUnkown() );
assertTrue( trustDialogBot.hasErrorMessage( "Algorithm constraints check failed on keysize limits" ) );
trustDialogBot.selectDontTrust();
clickOkButtonExpectingCertficateErrorDialog( trustDialogBot, "Failed to verify certification path",
"Algorithm constraints check failed on keysize limits", "RSA 512", "bit key used" );
wizardBot.clickCancelButton();
}
/**
* Tests StartTLS with an expired certificate.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testStartTlsCertificateValidationExpired( ApacheDirectoryServer server ) throws Exception
{
server.setKeystore( EXPIRED_KEYSTORE_PATH );
wizardBotWithStartTls( server, false );
// check the certificate, expecting the trust dialog
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckNetworkParameterButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isExpired() );
assertFalse( trustDialogBot.isSelfSigned() );
assertFalse( trustDialogBot.isNotYetValid() );
assertFalse( trustDialogBot.isHostNameMismatch() );
assertFalse( trustDialogBot.isIssuerUnkown() );
trustDialogBot.selectDontTrust();
clickOkButtonExpectingCertficateErrorDialog( trustDialogBot, "Certificate expired", "NotAfter" );
wizardBot.clickCancelButton();
}
/**
* Tests StartTLS with an not yet valid certificate.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testStartTlsCertificateValidationNotYetValid( ApacheDirectoryServer server ) throws Exception
{
server.setKeystore( NOT_YET_VALID_KEYSTORE_PATH );
wizardBotWithStartTls( server, true );
// check the certificate, expecting the trust dialog
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isNotYetValid() );
assertFalse( trustDialogBot.isSelfSigned() );
assertFalse( trustDialogBot.isExpired() );
assertFalse( trustDialogBot.isHostNameMismatch() );
assertFalse( trustDialogBot.isIssuerUnkown() );
trustDialogBot.selectDontTrust();
clickOkButtonExpectingCertficateErrorDialog( trustDialogBot, "Certificate not yet valid", "NotBefore" );
wizardBot.clickCancelButton();
}
/**
* Tests StartTLS with a certificate where the certificate's host name
* doesn't match the server's host name (localhost)
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testStartTlsCertificateValidationHostnameMismatch( ApacheDirectoryServer server ) throws Exception
{
server.setKeystore( WRONG_HOSTNAME_KEYSTORE_PATH );
wizardBotWithStartTls( server, true );
// check the certificate, expecting the trust dialog
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isHostNameMismatch() );
assertFalse( trustDialogBot.isIssuerUnkown() );
assertFalse( trustDialogBot.isSelfSigned() );
assertFalse( trustDialogBot.isNotYetValid() );
assertFalse( trustDialogBot.isExpired() );
trustDialogBot.selectDontTrust();
clickOkButtonExpectingCertficateErrorDialog( trustDialogBot, LOCALHOST, "foo.example.com" );
wizardBot.clickCancelButton();
}
/**
* Tests StartTLS with a certificate without valid certification path.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testStartTlsCertificateValidationNoValidCertificationPath( ApacheDirectoryServer server )
throws Exception
{
server.setKeystore( UNTRUSTED_KEYSTORE_PATH );
wizardBotWithStartTls( server, true );
// check the certificate, expecting the trust dialog
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isIssuerUnkown() );
assertFalse( trustDialogBot.isSelfSigned() );
assertFalse( trustDialogBot.isHostNameMismatch() );
assertFalse( trustDialogBot.isNotYetValid() );
assertFalse( trustDialogBot.isExpired() );
trustDialogBot.selectDontTrust();
clickOkButtonExpectingCertficateErrorDialog( trustDialogBot,
"unable to find valid certification path to requested target" );
wizardBot.clickCancelButton();
}
/**
* Tests StartTLS with a self-signed certificate.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testStartTlsCertificateValidationSelfSigned( ApacheDirectoryServer server ) throws Exception
{
server.setKeystore( SELF_SIGNED_KEYSTORE_PATH );
wizardBotWithStartTls( server, true );
// check the certificate, expecting the trust dialog
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isSelfSigned() );
assertFalse( trustDialogBot.isHostNameMismatch() );
assertFalse( trustDialogBot.isIssuerUnkown() );
assertFalse( trustDialogBot.isNotYetValid() );
assertFalse( trustDialogBot.isExpired() );
trustDialogBot.selectDontTrust();
clickOkButtonExpectingCertficateErrorDialog( trustDialogBot,
"unable to find valid certification path to requested target" );
wizardBot.clickCancelButton();
}
/**
* Tests StartTLS with a certificate with multiple issues.
*/
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "Update of keystore only implemented for ApacheDS")
public void testStartTlsCertificateValidationExpiredAndWrongHostnameAndSelfSigned( ApacheDirectoryServer server )
throws Exception
{
server.setKeystore( MULTIPLE_ISSUES_KEYSTORE_PATH );
wizardBotWithStartTls( server, true );
// check the certificate, expecting the trust dialog
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isSelfSigned() );
assertTrue( trustDialogBot.isHostNameMismatch() );
assertTrue( trustDialogBot.isExpired() );
assertFalse( trustDialogBot.isIssuerUnkown() );
assertFalse( trustDialogBot.isNotYetValid() );
trustDialogBot.selectDontTrust();
clickOkButtonExpectingCertficateErrorDialog( trustDialogBot );
wizardBot.clickCancelButton();
}
/**
* Tests that when selecting "Don't trust" the certificate is not trusted
* and not added to any key store.
*/
@ParameterizedTest
@LdapServersSource
public void testStartTlsCertificateDoNotTrust( TestLdapServer server ) throws Exception
{
wizardBotWithStartTls( server, true );
// check trust, expect trust dialog, select don't trust
CertificateTrustDialogBot trustDialogBot = wizardBot
.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isVisible() );
trustDialogBot.selectDontTrust();
ErrorDialogBot errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
errorBot.clickOkButton();
// check trust again, expect trust dialog, select don't trust
wizardBot.activate();
trustDialogBot = wizardBot.clickCheckAuthenticationButtonExpectingCertificateTrustDialog();
assertTrue( trustDialogBot.isVisible() );
trustDialogBot.selectDontTrust();
errorBot = trustDialogBot.clickOkButtonExpectingErrorDialog();
errorBot.clickOkButton();
// certificate must not be added to a trust store
assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
// click finish, that opens the connection
wizardBot.clickFinishButton( false );
// expecting trust dialog again.
trustDialogBot = new CertificateTrustDialogBot();
assertTrue( trustDialogBot.isVisible() );
trustDialogBot.selectDontTrust();
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | true |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LdifEditorTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LdifEditorTest.java | /*
* 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 org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.directory.studio.test.integration.ui.bots.LdifEditorBot;
import org.apache.directory.studio.test.integration.ui.bots.NewWizardBot;
import org.junit.jupiter.api.Test;
/**
* Tests the LDIF editor.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
public class LdifEditorTest extends AbstractTestBase
{
/**
* Test for DIRSTUDIO-1043 (First open of LDIF editor fails)
*/
@Test
public void testNewLdifEditor() throws Exception
{
// Open first LDIF editor
NewWizardBot newWizard = studioBot.openNewWizard();
newWizard.selectLdifFile();
assertTrue( newWizard.isFinishButtonEnabled() );
newWizard.clickFinishButton();
LdifEditorBot ldifEditorBot = new LdifEditorBot( "LDIF" );
ldifEditorBot.activate();
ldifEditorBot.typeText( "dn: dc=test\nobjectClass: domain\n\n" );
assertTrue( ldifEditorBot.isDirty() );
ldifEditorBot.close();
// Open second LDIF editor
NewWizardBot newWizard2 = studioBot.openNewWizard();
newWizard2.selectLdifFile();
assertTrue( newWizard2.isFinishButtonEnabled() );
newWizard2.clickFinishButton();
LdifEditorBot ldifEditorBot2 = new LdifEditorBot( "LDIF" );
ldifEditorBot2.activate();
ldifEditorBot2.typeText( "dn: dc=test\nobjectClass: domain\n\n" );
assertTrue( ldifEditorBot2.isDirty() );
ldifEditorBot2.close();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ReferralDialogTest.java | /*
* 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 org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRALS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_LOOP_1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_LOOP_2_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_MISC_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_REFERRALS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_REFERRAL_TO_USERS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_USER1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_USERS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USERS_DN;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.Connection.ReferralHandlingMethod;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource.Mode;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.ReferralDialogBot;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests the referral dialog.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class ReferralDialogTest extends AbstractTestBase
{
/**
* Test for DIRSTUDIO-343.
*
* Follows a continuation reference.
*/
@ParameterizedTest
@LdapServersSource
public void testBrowseAndFollowContinuationReference( TestLdapServer server ) throws Exception
{
// ensure that referrals handling method is FOLLOW
Connection connection = connectionsViewBot.createTestConnection( server );
connection.getConnectionParameter().setExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
ReferralHandlingMethod.FOLLOW.ordinal() );
int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
assertEquals( ReferralHandlingMethod.FOLLOW.ordinal(), referralsHandlingMethodOrdinal );
// expand ou=referrals, that reads the referrals and opens the referral dialog
ReferralDialogBot referralDialogBot = browserViewBot.expandEntryExpectingReferralDialog( path( REFERRALS_DN ) );
assertTrue( referralDialogBot.isVisible() );
assertEquals( connection.getName(), referralDialogBot.getSelectedConnection() );
referralDialogBot.clickOkButton();
// ensure that the continuation URLs are visible and can be expanded, but not the referrals entries
assertReferralEntriesAreNotVisible();
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, USER1_DN ) ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, USERS_DN ) ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, USERS_DN ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, MISC_DN ) ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, MISC_DN ) );
}
/**
* Test for DIRSTUDIO-343.
*
* Does not follow a continuation reference by clicking the cancel button in
* the referral dialog.
*/
@ParameterizedTest
@LdapServersSource
public void testBrowseAndCancelFollowingContinuationReference( TestLdapServer server ) throws Exception
{
// ensure that referrals handling method is FOLLOW
Connection connection = connectionsViewBot.createTestConnection( server );
connection.getConnectionParameter().setExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
ReferralHandlingMethod.FOLLOW.ordinal() );
int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
assertEquals( ReferralHandlingMethod.FOLLOW.ordinal(), referralsHandlingMethodOrdinal );
// expand ou=referrals, that reads the referral and opens the referral dialog
ReferralDialogBot referralDialogBot = browserViewBot.expandEntryExpectingReferralDialog( path( REFERRALS_DN ) );
assertTrue( referralDialogBot.isVisible() );
assertEquals( connection.getName(), referralDialogBot.getSelectedConnection() );
referralDialogBot.clickCancelButton();
// ensure that neither the continuation URLs, nor the referral entries are visible
assertReferralEntriesAreNotVisible();
assertRefLdapUrlsAreNotVisible( server );
}
/**
* Tests ignore referral by setting the connection property to IGNORE.
*/
@ParameterizedTest
@LdapServersSource
public void testBrowseAndIgnoreReferral( TestLdapServer server ) throws Exception
{
// ensure that referrals handling method is IGNORE
Connection connection = connectionsViewBot.createTestConnection( server );
connection.getConnectionParameter().setExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
ReferralHandlingMethod.IGNORE.ordinal() );
int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
assertEquals( ReferralHandlingMethod.IGNORE.ordinal(), referralsHandlingMethodOrdinal );
// expand ou=referrals, no referral dialog expected
browserViewBot.selectAndExpandEntry( path( REFERRALS_DN ) );
// ensure that neither the continuation URLs, nor the referral entries are visible
assertReferralEntriesAreNotVisible();
assertRefLdapUrlsAreNotVisible( server );
}
/**
* Tests manage referral entry by setting the ManageDsaIT control.
*/
@ParameterizedTest
@LdapServersSource
public void testBrowseAndManageReferralEntry( TestLdapServer server ) throws Exception
{
// ensure that ManageDsaIT is set
Connection connection = connectionsViewBot.createTestConnection( server );
connection.getConnectionParameter().setExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
ReferralHandlingMethod.IGNORE.ordinal() );
connection.getConnectionParameter().setExtendedBoolProperty(
IBrowserConnection.CONNECTION_PARAMETER_MANAGE_DSA_IT, true );
int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
boolean manageDsaIT = connection.getConnectionParameter().getExtendedBoolProperty(
IBrowserConnection.CONNECTION_PARAMETER_MANAGE_DSA_IT );
assertEquals( ReferralHandlingMethod.IGNORE.ordinal(), referralsHandlingMethodOrdinal );
assertTrue( manageDsaIT );
// expand ou=referrals, that reads the referral object
browserViewBot.selectAndExpandEntry( path( REFERRALS_DN ) );
// ensure that the referral entries are visible, but not the continuation URLs
assertRefLdapUrlsAreNotVisible( server );
assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_USER1_DN ) ) );
assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_USERS_DN ) ) );
assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRAL_TO_USERS_DN ) ) );
assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRALS_DN ) ) );
assertTrue( browserViewBot.existsEntry( path( REFERRAL_LOOP_1_DN ) ) );
assertTrue( browserViewBot.existsEntry( path( REFERRAL_LOOP_2_DN ) ) );
assertTrue( browserViewBot.existsEntry( path( REFERRAL_TO_MISC_DN ) ) );
}
/**
* Tests manual referral following.
*/
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testBrowseAndFollowManuallyContinuationReference( TestLdapServer server ) throws Exception
{
// ensure that referrals handling method is FOLLOW_MANUALLY
Connection connection = connectionsViewBot.createTestConnection( server );
connection.getConnectionParameter().setExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD,
ReferralHandlingMethod.FOLLOW_MANUALLY.ordinal() );
int referralsHandlingMethodOrdinal = connection.getConnectionParameter().getExtendedIntProperty(
IBrowserConnection.CONNECTION_PARAMETER_REFERRALS_HANDLING_METHOD );
assertEquals( ReferralHandlingMethod.FOLLOW_MANUALLY.ordinal(), referralsHandlingMethodOrdinal );
// expand ou=referrals, no referral dialog expected yet
browserViewBot.selectAndExpandEntry( path( REFERRALS_DN ) );
// ensure that only the referral targets are visible, not the referrals
assertReferralEntriesAreNotVisible();
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, USER1_DN ) ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, USERS_DN ) ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_TO_USERS_DN ) ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_1_DN ) ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_2_DN ) ) );
assertTrue( browserViewBot.existsEntry( pathWithRefLdapUrl( server, MISC_DN ) ) );
// select one target, that should popup the referral dialog
ReferralDialogBot referralDialogBot = browserViewBot
.selectEntryExpectingReferralDialog( pathWithRefLdapUrl( server, USER1_DN ) );
assertTrue( referralDialogBot.isVisible() );
assertEquals( connection.getName(), referralDialogBot.getSelectedConnection() );
referralDialogBot.clickOkButton();
// now all ref URLs can be expanded, no additional referral dialog is expected
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, USER1_DN ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, USERS_DN ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, REFERRAL_TO_USERS_DN ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_1_DN ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_2_DN ) );
browserViewBot.selectAndExpandEntry( pathWithRefLdapUrl( server, MISC_DN ) );
}
private void assertRefLdapUrlsAreNotVisible( TestLdapServer server )
{
assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, USER1_DN ) ) );
assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, USERS_DN ) ) );
assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_TO_USERS_DN ) ) );
assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRALS_DN ) ) );
assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_1_DN ) ) );
assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, REFERRAL_LOOP_2_DN ) ) );
assertFalse( browserViewBot.existsEntry( pathWithRefLdapUrl( server, MISC_DN ) ) );
}
private void assertReferralEntriesAreNotVisible()
{
assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_USER1_DN ) ) );
assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_USERS_DN ) ) );
assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRAL_TO_USERS_DN ) ) );
assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_REFERRALS_DN ) ) );
assertFalse( browserViewBot.existsEntry( path( REFERRAL_LOOP_1_DN ) ) );
assertFalse( browserViewBot.existsEntry( path( REFERRAL_LOOP_2_DN ) ) );
assertFalse( browserViewBot.existsEntry( path( REFERRAL_TO_MISC_DN ) ) );
}
} | java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/SearchTest.java | /*
* 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 org.apache.directory.studio.test.integration.junit5.TestFixture.ALIAS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.CONTEXT_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.GROUP1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.GROUPS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.MISC_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.REFERRAL_TO_USER1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.SUBENTRY_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER8_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USERS_DN;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.lang3.StringUtils;
import org.apache.directory.api.ldap.model.message.ModifyRequest;
import org.apache.directory.api.ldap.model.message.ModifyRequestImpl;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
import org.apache.directory.studio.connection.core.Utils;
import org.apache.directory.studio.ldapbrowser.core.BrowserConnectionManager;
import org.apache.directory.studio.ldapbrowser.core.BrowserCorePlugin;
import org.apache.directory.studio.ldapbrowser.core.events.EventRegistry;
import org.apache.directory.studio.ldapbrowser.core.model.IBrowserConnection;
import org.apache.directory.studio.test.integration.junit5.LdapServerType;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.FilterEditorDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.SearchDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.SearchPropertiesDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.SearchResultEditorBot;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests the Search dialog and Search category in the LDAP Browser view.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class SearchTest extends AbstractTestBase
{
/**
* Test for DIRSTUDIO-490.
*
* Copy/Paste a search between connections and verify that the associated browser connection is correct.
*/
@ParameterizedTest
@LdapServersSource
public void testCopyPasteSearchBetweenConnections( TestLdapServer server ) throws Exception
{
Connection connection1 = connectionsViewBot.createTestConnection( server );
Connection connection2 = connectionsViewBot.createTestConnection( server );
BrowserConnectionManager browserConnectionManager = BrowserCorePlugin.getDefault().getConnectionManager();
IBrowserConnection browserConnection1 = browserConnectionManager.getBrowserConnectionByName( connection1
.getName() );
IBrowserConnection browserConnection2 = browserConnectionManager.getBrowserConnectionByName( connection2
.getName() );
assertEquals( 0, browserConnection1.getSearchManager().getSearches().size() );
assertEquals( 0, browserConnection2.getSearchManager().getSearches().size() );
// create a search for in connection 1
connectionsViewBot.select( connection1.getName() );
browserViewBot.selectEntry( path( CONTEXT_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( "Search all persons" );
dialogBot.setFilter( "(objectClass=person)" );
dialogBot.clickSearchButton();
browserViewBot.selectEntry( "Searches", "Search all persons" );
// assert browser connection in searches
assertEquals( 1, browserConnection1.getSearchManager().getSearches().size() );
assertEquals( browserConnection1, browserConnection1.getSearchManager().getSearches().get( 0 )
.getBrowserConnection() );
assertEquals( 0, browserConnection2.getSearchManager().getSearches().size() );
// copy/paste the created search from connection 1 to connection 2
browserViewBot.copy();
connectionsViewBot.select( connection2.getName() );
browserViewBot.selectEntry( "Searches" );
SearchPropertiesDialogBot searchPropertiesDialogBot = browserViewBot.pasteSearch( "Search all persons" );
assertTrue( searchPropertiesDialogBot.isVisible() );
searchPropertiesDialogBot.clickCancelButton();
// assert browser connection in searches
assertEquals( 1, browserConnection1.getSearchManager().getSearches().size() );
assertEquals( browserConnection1, browserConnection1.getSearchManager().getSearches().get( 0 )
.getBrowserConnection() );
assertEquals( 1, browserConnection2.getSearchManager().getSearches().size() );
assertEquals( browserConnection2, browserConnection2.getSearchManager().getSearches().get( 0 )
.getBrowserConnection() );
}
/**
* Test for DIRSTUDIO-587 (UI flickers on quick search).
*
* When performing a quick search only one UI update should be fired.
*/
@ParameterizedTest
@LdapServersSource
public void testOnlyOneUiUpdateOnQuickSearch( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( CONTEXT_DN ) );
browserViewBot.expandEntry( path( CONTEXT_DN ) );
browserViewBot.typeQuickSearchAttributeType( "ou" );
browserViewBot.typeQuickSearchValue( "*" );
long fireCount0 = EventRegistry.getFireCount();
browserViewBot.clickRunQuickSearchButton();
browserViewBot.waitForEntry( path( CONTEXT_DN, "Quick Search" ) );
long fireCount1 = EventRegistry.getFireCount();
browserViewBot.selectEntry( path( CONTEXT_DN, "Quick Search" ) );
// verify that only one event was fired
long fireCount = fireCount1 - fireCount0;
assertEquals( 1, fireCount, "Only 1 event firings expected when running quick search." );
}
@ParameterizedTest
@LdapServersSource
public void testQuickSearch( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
// quick search on context entry
browserViewBot.selectEntry( path( CONTEXT_DN ) );
browserViewBot.expandEntry( path( CONTEXT_DN ) );
browserViewBot.typeQuickSearchAttributeType( "ou" );
browserViewBot.typeQuickSearchValue( "*" );
browserViewBot.clickRunQuickSearchButton();
browserViewBot.waitForEntry( path( CONTEXT_DN, "Quick Search (5)" ) );
browserViewBot.selectEntry( path( CONTEXT_DN, "Quick Search (5)" ) );
browserViewBot.expandEntry( path( CONTEXT_DN, "Quick Search (5)" ) );
browserViewBot.selectEntry( path( CONTEXT_DN, "Quick Search (5)", USERS_DN.getName() ) );
// quick search on non-leaf entry
browserViewBot.selectEntry( path( USERS_DN ) );
browserViewBot.expandEntry( path( USERS_DN ) );
browserViewBot.typeQuickSearchAttributeType( "uid" );
browserViewBot.typeQuickSearchValue( "user.1" );
browserViewBot.clickRunQuickSearchButton();
browserViewBot.waitForEntry( path( USERS_DN, "Quick Search (1)" ) );
browserViewBot.selectEntry( path( USERS_DN, "Quick Search (1)" ) );
browserViewBot.expandEntry( path( USERS_DN, "Quick Search (1)" ) );
browserViewBot.selectEntry( path( USERS_DN, "Quick Search (1)", USER1_DN.getName() ) );
// quick search on leaf entry
browserViewBot.selectEntry( path( USER1_DN ) );
browserViewBot.expandEntry( path( USER1_DN ) );
browserViewBot.typeQuickSearchAttributeType( "uid" );
browserViewBot.typeQuickSearchValue( "user.1" );
browserViewBot.clickRunQuickSearchButton();
browserViewBot.waitForEntry( path( USER1_DN, "Quick Search (0)" ) );
browserViewBot.selectEntry( path( USER1_DN, "Quick Search (0)" ) );
browserViewBot.expandEntry( path( USER1_DN, "Quick Search (0)" ) );
browserViewBot.selectEntry( path( USER1_DN, "Quick Search (0)", "No Results" ) );
}
/**
* Test for DIRSTUDIO-601.
* (The 'Perform Search/Search Again' button in the Search Result Editor does not work correctly)
*/
@ParameterizedTest
@LdapServersSource
public void testRefresh( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( GROUPS_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( "Search Group" );
dialogBot.setFilter( "(" + GROUP1_DN.getRdn().getName() + ")" );
dialogBot.setReturningAttributes( "objectClass, cn, description" );
dialogBot.clickSearchButton();
browserViewBot.selectEntry( "Searches", "Search Group" );
SearchResultEditorBot srEditorBot = studioBot.getSearchResultEditorBot( "Search Group" );
srEditorBot.activate();
assertTrue( srEditorBot.isEnabled() );
// assert that description attribute is empty
assertEquals( GROUP1_DN.getName(), srEditorBot.getContent( 1, 1 ) );
assertEquals( "", srEditorBot.getContent( 1, 4 ) );
// add description
ModifyRequest request = new ModifyRequestImpl();
request.setName( GROUP1_DN );
request.replace( "description", "The 1st description." );
server.withAdminConnection( conn -> {
conn.modify( request );
} );
// refresh the search, using the toolbar icon
srEditorBot.refresh();
SWTUtils.sleep( 1000 );
// assert the description attribute value is displayed now
assertEquals( GROUP1_DN.getName(), srEditorBot.getContent( 1, 1 ) );
assertEquals( "The 1st description.", srEditorBot.getContent( 1, 4 ) );
}
@ParameterizedTest
@LdapServersSource
public void testSearchAlias( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
String searchName = "Search Alias";
browserViewBot.selectEntry( path( CONTEXT_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( searchName );
dialogBot.setFilter( "(objectClass=alias)" );
dialogBot.setReturningAttributes( "cn,aliasedObjectName" );
dialogBot.setAliasDereferencingMode( AliasDereferencingMethod.NEVER );
dialogBot.clickSearchButton();
// assert search result exists in tree
browserViewBot.expandEntry( "Searches", "Search Alias" );
assertTrue( browserViewBot.existsEntry( "Searches", "Search Alias", ALIAS_DN.getName() ) );
// assert attributes in search result editor
browserViewBot.selectEntry( "Searches", "Search Alias" );
SearchResultEditorBot srEditorBot = studioBot.getSearchResultEditorBot( "Search Alias" );
srEditorBot.activate();
assertTrue( srEditorBot.isEnabled() );
assertEquals( ALIAS_DN.getName(), srEditorBot.getContent( 1, 1 ) );
assertEquals( "alias", srEditorBot.getContent( 1, 2 ) );
assertEquals( MISC_DN, srEditorBot.getContent( 1, 3 ) );
}
@ParameterizedTest
@LdapServersSource
public void testSearchReferral( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
String searchName = "Search Referral";
browserViewBot.selectEntry( path( CONTEXT_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( searchName );
dialogBot.setFilter( "(&(objectClass=referral)(" + REFERRAL_TO_USER1_DN.getRdn().getName() + "))" );
dialogBot.setReturningAttributes( "cn,ref" );
dialogBot.setControlManageDsaIT( true );
dialogBot.clickSearchButton();
// assert search result exists in tree
browserViewBot.expandEntry( "Searches", searchName );
assertTrue(
browserViewBot.existsEntry( "Searches", searchName, Utils.shorten( REFERRAL_TO_USER1_DN.getName(), 50 ) ) );
// assert attributes in search result editor
browserViewBot.selectEntry( "Searches", searchName );
SearchResultEditorBot srEditorBot = studioBot.getSearchResultEditorBot( searchName );
srEditorBot.activate();
assertTrue( srEditorBot.isEnabled() );
assertEquals( REFERRAL_TO_USER1_DN.getName(), srEditorBot.getContent( 1, 1 ) );
assertEquals( REFERRAL_TO_USER1_DN.getRdn().getValue(), srEditorBot.getContent( 1, 2 ) );
assertEquals( StringUtils.abbreviate( server.getLdapUrl() + "/" + USER1_DN.getName(), 50 ),
srEditorBot.getContent( 1, 3 ) );
}
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "ApacheDS specifc test")
public void testSearchSubentry( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
String searchName = "Search Subentry";
browserViewBot.selectEntry( path( CONTEXT_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( searchName );
dialogBot.setFilter( "(objectClass=subentry)" );
dialogBot.setReturningAttributes( "cn,subtreeSpecification" );
dialogBot.setControlSubentries( true );
dialogBot.clickSearchButton();
// assert search result exists in tree
browserViewBot.expandEntry( "Searches", searchName );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, SUBENTRY_DN.getName() ) );
// assert attributes in search result editor
browserViewBot.selectEntry( "Searches", searchName );
SearchResultEditorBot srEditorBot = studioBot.getSearchResultEditorBot( searchName );
srEditorBot.activate();
assertTrue( srEditorBot.isEnabled() );
assertEquals( SUBENTRY_DN.getName(), srEditorBot.getContent( 1, 1 ) );
assertEquals( SUBENTRY_DN.getRdn().getValue(), srEditorBot.getContent( 1, 2 ) );
assertEquals( "{}", srEditorBot.getContent( 1, 3 ) );
}
@ParameterizedTest
@LdapServersSource
public void testSearchWithPagingWithScrollMode( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
String searchName = "Paged search with scroll mode";
browserViewBot.selectEntry( path( USERS_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( searchName );
dialogBot.setFilter( "(objectClass=*)" );
dialogBot.setReturningAttributes( "objectClass,ou,cn,uid" );
dialogBot.setControlPagedSearch( true, 3, true );
dialogBot.clickSearchButton();
// 1st page
browserViewBot.expandEntry( "Searches", searchName );
assertFalse( browserViewBot.existsEntry( "Searches", searchName, "--- Top Page ---" ) );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, "--- Next Page ---" ) );
// next page
browserViewBot.selectEntry( "Searches", searchName, "--- Next Page ---" );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, "--- Top Page ---" ) );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, "--- Next Page ---" ) );
// last page
browserViewBot.selectEntry( "Searches", searchName, "--- Next Page ---" );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, "--- Top Page ---" ) );
assertFalse( browserViewBot.existsEntry( "Searches", searchName, "--- Next Page ---" ) );
// back to top
browserViewBot.selectEntry( "Searches", searchName, "--- Top Page ---" );
assertFalse( browserViewBot.existsEntry( "Searches", searchName, "--- Top Page ---" ) );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, "--- Next Page ---" ) );
}
@ParameterizedTest
@LdapServersSource
public void testSearchWithPagingWithoutScrollMode( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
String searchName = "Paged search without scroll mode";
browserViewBot.selectEntry( path( USERS_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( searchName );
dialogBot.setFilter( "(objectClass=*)" );
dialogBot.setReturningAttributes( "objectClass,ou,cn,uid" );
dialogBot.setControlPagedSearch( true, 3, false );
dialogBot.clickSearchButton();
browserViewBot.expandEntry( "Searches", searchName );
assertFalse( browserViewBot.existsEntry( "Searches", searchName, "--- Top Page ---" ) );
assertFalse( browserViewBot.existsEntry( "Searches", searchName, "--- Next Page ---" ) );
assertTrue( browserViewBot.existsEntry( "Searches", searchName + " (9+)" ) );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, USER1_DN.getName() ) );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, USER8_DN.getName() ) );
}
@ParameterizedTest
@LdapServersSource
public void testFilterEditor( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
String searchName = "Test filter editor";
browserViewBot.selectEntry( path( USERS_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( searchName );
dialogBot.setReturningAttributes( "objectClass,ou,cn,uid" );
FilterEditorDialogBot filterBot = dialogBot.openFilterEditor();
filterBot.setFilter( "(&(objectClass=*)(uid=user.1))" );
filterBot.clickFormatButton();
String formattetFilter = filterBot.getFilter();
filterBot.clickOkButton();
dialogBot.activate();
String filter = dialogBot.getFilter();
dialogBot.clickSearchButton();
browserViewBot.expandEntry( "Searches", searchName );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, USER1_DN.getName() ) );
assertEquals( "(&(objectClass=*)(uid=user.1))", filter );
assertEquals( "(&\n (objectClass=*)\n (uid=user.1)\n)", formattetFilter );
}
/**
* Test for DIRSTUDIO-1078/DIRAPI-365: unable to use # pound hash sign in LDAP filters
*/
@ParameterizedTest
@LdapServersSource
public void testFilterForDnWithLeadingHash( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
String searchName = "Test filter for DN with leading hash character";
browserViewBot.selectEntry( path( CONTEXT_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( searchName );
dialogBot.setReturningAttributes( "objectClass,ou,cn,uid" );
String filterValue = DN_WITH_LEADING_SHARP_BACKSLASH_PREFIXED.getName().replace( "\\#", "\\5c#" );
FilterEditorDialogBot filterBot = dialogBot.openFilterEditor();
filterBot.setFilter( "member=" + filterValue );
filterBot.clickFormatButton();
filterBot.clickOkButton();
dialogBot.activate();
String filter = dialogBot.getFilter();
dialogBot.clickSearchButton();
browserViewBot.expandEntry( "Searches", searchName );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, GROUP1_DN.getName() ) );
assertEquals( "(member=" + filterValue + ")", filter );
}
/**
* Test for DIRSTUDIO-1078/DIRAPI-365: unable to use # pound hash sign in LDAP filters
*/
@ParameterizedTest
@LdapServersSource
public void testFilterForDnWithLeadingHashHex( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
String searchName = "Test filter for DN with leading hash character";
browserViewBot.selectEntry( path( CONTEXT_DN ) );
SearchDialogBot dialogBot = browserViewBot.openSearchDialog();
assertTrue( dialogBot.isVisible() );
dialogBot.setSearchName( searchName );
dialogBot.setReturningAttributes( "objectClass,ou,cn,uid" );
String filterValue = DN_WITH_LEADING_SHARP_HEX_PAIR_ESCAPED.getName().replace( "\\23", "\\5C23" );
FilterEditorDialogBot filterBot = dialogBot.openFilterEditor();
filterBot.setFilter( "member=" + filterValue );
filterBot.clickFormatButton();
filterBot.clickOkButton();
dialogBot.activate();
String filter = dialogBot.getFilter();
dialogBot.clickSearchButton();
browserViewBot.expandEntry( "Searches", searchName );
assertTrue( browserViewBot.existsEntry( "Searches", searchName, GROUP1_DN.getName() ) );
assertEquals( "(member=" + filterValue + ")", filter );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/Activator.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/Activator.java | /*
* 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 org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends Plugin
{
/**
* @see org.eclipse.core.runtime.Plugin#start(org.osgi.framework.BundleContext)
*/
public void start( BundleContext context ) throws Exception
{
super.start( context );
// Nasty hack to get the API bundles started. DO NOT REMOVE
Platform.getBundle( "org.apache.directory.api.ldap.codec.core" ).start();
Platform.getBundle( "org.apache.directory.api.ldap.extras.codec" ).start();
Platform.getBundle( "org.apache.directory.api.ldap.net.mina" ).start();
}
/**
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/
public void stop( BundleContext context ) throws Exception
{
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PerformanceTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PerformanceTest.java | /*
* 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 org.apache.directory.studio.test.integration.junit5.TestFixture.GROUPS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.dn;
import java.util.ArrayList;
import java.util.List;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.ldapbrowser.common.BrowserCommonActivator;
import org.apache.directory.studio.ldapbrowser.common.BrowserCommonConstants;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.EntryEditorBot;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests performance.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class PerformanceTest extends AbstractTestBase
{
/**
* Test for DIRSTUDIO-1119 (Group with over 1000 members crashes)
*/
@ParameterizedTest
@LdapServersSource
public void testEditLargeGroup( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
BrowserCommonActivator.getDefault()
.getPluginPreferences().setValue( BrowserCommonConstants.PREFERENCE_ENTRYEDITOR_ENABLE_FOLDING, false );
Dn dn = dn( "cn=Large Group", GROUPS_DN );
int n = 5000;
String memberAt = "member";
List<String> memberDns = new ArrayList<>( n );
server.withAdminConnection( conn -> {
Entry entry = new DefaultEntry( conn.getSchemaManager() );
entry.setDn( dn );
entry.add( "objectClass", "top", "groupOfNames" );
entry.add( "cn", "Large Group" );
for ( int i = 0; i < n; i++ )
{
String memberDn = "cn=user." + String.format( "%04d", i );
memberDns.add( memberDn );
entry.add( memberAt, memberDn );
}
conn.add( entry );
} );
String first = memberDns.get( 0 );
String second = memberDns.get( 1 );
String middle = memberDns.get( n / 2 );
String secondToLast = memberDns.get( n - 2 );
String last = memberDns.get( n - 1 );
browserViewBot.selectEntry( path( dn ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( dn.getName() );
entryEditorBot.activate();
// edit some values
entryEditorBot.editValueExpectingDnEditor( memberAt, first ).clickCancelButton();
entryEditorBot.editValueExpectingDnEditor( memberAt, last ).clickCancelButton();
entryEditorBot.editValueExpectingDnEditor( memberAt, middle ).clickCancelButton();
entryEditorBot.editValueExpectingDnEditor( memberAt, second ).clickCancelButton();
entryEditorBot.editValueExpectingDnEditor( memberAt, secondToLast ).clickCancelButton();
// delete some values
entryEditorBot.deleteValue( memberAt, second );
entryEditorBot.deleteValue( memberAt, secondToLast );
// edit some value after deletion
entryEditorBot.editValueExpectingDnEditor( memberAt, first ).clickCancelButton();
entryEditorBot.editValueExpectingDnEditor( memberAt, last ).clickCancelButton();
entryEditorBot.editValueExpectingDnEditor( memberAt, middle ).clickCancelButton();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ErrorHandlingTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/ErrorHandlingTest.java | /*
* 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 org.apache.directory.studio.test.integration.junit5.TestFixture.USER1_DN;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import org.apache.directory.studio.test.integration.junit5.LdapServerType;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource.Mode;
import org.apache.directory.studio.test.integration.ui.bots.DeleteDialogBot;
import org.apache.directory.studio.test.integration.ui.bots.EntryEditorBot;
import org.apache.directory.studio.test.integration.ui.bots.ErrorDialogBot;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests error handling
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class ErrorHandlingTest extends AbstractTestBase
{
@ParameterizedTest
@LdapServersSource(only = LdapServerType.ApacheDS, reason = "ApacheDS specific test")
public void testDeleteObjectClassTopSchemaEntryShouldFail( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( "DIT", "Root DSE", "ou=schema", "cn=system", "ou=objectClasses", "m-oid=2.5.6.0" );
browserViewBot.expandEntry( "DIT", "Root DSE", "ou=schema", "cn=system", "ou=objectClasses", "m-oid=2.5.6.0" );
DeleteDialogBot deleteDialog = browserViewBot.openDeleteDialog();
ErrorDialogBot errorDialog = deleteDialog.clickOkButtonExpectingErrorDialog();
// verify message in error dialog
assertThat( errorDialog.getErrorDetails(), containsString( "[LDAP result code 53 - unwillingToPerform]" ) );
errorDialog.clickOkButton();
// verify in modification logs
modificationLogsViewBot.assertContainsError( "[LDAP result code 53 - unwillingToPerform]",
"dn: m-oid=2.5.6.0,ou=objectClasses,cn=system,ou=schema", "changetype: delete" );
}
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testDeleteObjectClassAttributeShouldFail( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( ( USER1_DN ) ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() );
entryEditorBot.activate();
ErrorDialogBot errorDialog = entryEditorBot.deleteValueExpectingErrorDialog( "objectClass",
"inetOrgPerson (structural)" );
String expectedError = "65 - objectClassViolation";
if ( server.getType() == LdapServerType.OpenLdap )
{
expectedError = "69 - objectClassModsProhibited";
}
// verify message in error dialog
assertThat( errorDialog.getErrorMessage(), containsString( "[LDAP result code " + expectedError + "]" ) );
errorDialog.clickOkButton();
modificationLogsViewBot.assertContainsError( "[LDAP result code " + expectedError + "]",
"dn: " + USER1_DN.getName(), "changetype: modify" );
}
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testDeleteRdnAttributeShouldFail( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( ( USER1_DN ) ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() );
entryEditorBot.activate();
ErrorDialogBot errorDialog = entryEditorBot.deleteValueExpectingErrorDialog( "uid", "user.1" );
String expectedError = "67 - notAllowedOnRDN";
if ( server.getType() == LdapServerType.OpenLdap )
{
expectedError = "64 - namingViolation";
}
// verify message in error dialog
assertThat( errorDialog.getErrorMessage(), containsString( "[LDAP result code " + expectedError + "]" ) );
errorDialog.clickOkButton();
// verify in modification logs
modificationLogsViewBot.assertContainsError( "[LDAP result code " + expectedError + "]",
"dn: " + USER1_DN.getName(), "changetype: modify", "delete: uid" );
}
@ParameterizedTest
@LdapServersSource
public void testDeleteMustAttributeShouldFail( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( ( USER1_DN ) ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() );
entryEditorBot.activate();
ErrorDialogBot errorDialog = entryEditorBot.deleteValueExpectingErrorDialog( "sn", "Amar" );
// verify message in error dialog
assertThat( errorDialog.getErrorMessage(), containsString( "[LDAP result code 65 - objectClassViolation]" ) );
errorDialog.clickOkButton();
// verify in modification logs
modificationLogsViewBot.assertContainsError( "[LDAP result code 65 - objectClassViolation]",
"dn: " + USER1_DN.getName(), "changetype: modify", "delete: sn" );
}
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testDeleteOperationalAttributeShouldFail( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( ( USER1_DN ) ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() );
entryEditorBot.activate();
entryEditorBot.fetchOperationalAttributes();
SWTUtils.sleep( 1000 );
entryEditorBot.activate();
ErrorDialogBot errorDialog = entryEditorBot.deleteValueExpectingErrorDialog( "creatorsName", null );
String expectedError = "50 - insufficientAccessRights";
if ( server.getType() == LdapServerType.OpenLdap )
{
expectedError = "19 - constraintViolation";
}
if ( server.getType() == LdapServerType.Fedora389ds )
{
expectedError = "53 - unwillingToPerform";
}
// verify message in error dialog
assertThat( errorDialog.getErrorMessage(),
containsString( "[LDAP result code " + expectedError + "]" ) );
errorDialog.clickOkButton();
// verify in modification logs
modificationLogsViewBot.assertContainsError( "[LDAP result code " + expectedError + "]",
"dn: " + USER1_DN.getName(), "changetype: modify", "delete: creatorsName" );
}
@ParameterizedTest
@LdapServersSource
public void testModifyInvalidSyntaxShouldFail( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
browserViewBot.selectEntry( path( ( USER1_DN ) ) );
EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( USER1_DN.getName() );
entryEditorBot.activate();
entryEditorBot.editValue( "mail", null );
ErrorDialogBot errorDialog = entryEditorBot.typeValueAndFinishAndExpectErrorDialog( "äöüß" );
// verify message in error dialog
assertThat( errorDialog.getErrorMessage(),
containsString( "[LDAP result code 21 - invalidAttributeSyntax]" ) );
errorDialog.clickOkButton();
// verify in modification logs
modificationLogsViewBot.assertContainsError( "[LDAP result code 21 - invalidAttributeSyntax]",
"dn: " + USER1_DN.getName(), "changetype: modify", "delete: mail" );
}
@Disabled("Until DIRSERVER-2308 is fixed")
@ParameterizedTest
@LdapServersSource
public void testRenameAlreadyExistingEntry( TestLdapServer server ) throws Exception
{
}
@Disabled("Until DIRSERVER-2308 is fixed")
@ParameterizedTest
@LdapServersSource
public void testMoveAlreadyExistingEntry( TestLdapServer server ) throws Exception
{
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LogsViewsTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/LogsViewsTest.java | /*
* 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 org.apache.directory.studio.test.integration.junit5.TestFixture.GROUPS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.TARGET_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER1_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER2_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER3_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER4_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USER5_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.USERS_DN;
import static org.apache.directory.studio.test.integration.junit5.TestFixture.dn;
import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.IntSummaryStatistics;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.directory.studio.connection.core.ConnectionCoreConstants;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource.Mode;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.bots.SelectCopyDepthDialogBot;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests the modification and search logs views.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class LogsViewsTest extends AbstractTestBase
{
@AfterEach
public void reset() throws Exception
{
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode( ConnectionCoreConstants.PLUGIN_ID );
prefs.remove( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT );
prefs.remove( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE );
prefs.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT );
prefs.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE );
prefs.remove( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES );
searchLogsViewBot.enableSearchRequestLogs( true );
searchLogsViewBot.enableSearchResultEntryLogs( false );
modificationLogsViewBot.enableModificationLogs( true );
}
@ParameterizedTest
@LdapServersSource
public void testSearchLogsViewDefault( TestLdapServer server ) throws Exception
{
// create and open connection
connectionsViewBot.createTestConnection( server );
searchLogsViewBot.clear();
// select groups entry
browserViewBot.selectAndExpandEntry( path( USERS_DN ) );
// assert content (ou=users)
String text = searchLogsViewBot.getSearchLogsText();
assertThat( text, containsString( "#!SEARCH REQUEST " ) );
assertThat( text, containsString( "#!CONNECTION " + server.getLdapUrl() ) );
assertThat( text, containsString( "#!DATE " ) );
assertThat( text, containsString( "# LDAP URL : " + server.getLdapUrl()
+ "/ou=users,dc=example,dc=org?hasSubordinates,objectClass?one?(objectClass=*)" ) );
assertThat( text, containsString( "# command line : ldapsearch -H " + server.getLdapUrl() + " -x -D \""
+ server.getAdminDn()
+ "\" -W -b \"ou=users,dc=example,dc=org\" -s one -a always -z 1000 \"(objectClass=*)\" \"hasSubordinates\" \"objectClass\"" ) );
assertThat( text, containsString( "# baseObject : ou=users,dc=example,dc=org" ) );
assertThat( text, containsString( "# scope : singleLevel (1)" ) );
assertThat( text, containsString( "# derefAliases : derefAlways (3)" ) );
assertThat( text, containsString( "# sizeLimit : 1000" ) );
assertThat( text, containsString( "# timeLimit : 0" ) );
assertThat( text, containsString( "# typesOnly : False" ) );
assertThat( text, containsString( "# filter : (objectClass=*)" ) );
assertThat( text, containsString( "# attributes : hasSubordinates objectClass" ) );
assertThat( text, not( containsString( "#!SEARCH RESULT ENTRY" ) ) );
assertThat( text, containsString( "#!SEARCH RESULT DONE " ) );
assertThat( text, containsString( "# numEntries : 8" ) );
}
@ParameterizedTest
@LdapServersSource
public void testSearchLogsViewWithSearchResultEntryLogsEnabled( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
searchLogsViewBot.clear();
// enable search result entry logs
searchLogsViewBot.enableSearchResultEntryLogs( true );
// select entry (ou=groups)
browserViewBot.selectEntry( path( GROUPS_DN ) );
// assert content
String text = searchLogsViewBot.getSearchLogsText();
assertThat( text, containsString( "#!SEARCH REQUEST " ) );
assertThat( text, containsString( "#!CONNECTION " + server.getLdapUrl() ) );
assertThat( text, containsString( "#!DATE " ) );
assertThat( text, containsString(
"# LDAP URL : " + server.getLdapUrl() + "/ou=groups,dc=example,dc=org?*??(objectClass=*)" ) );
assertThat( text, containsString( "# command line : ldapsearch -H " + server.getLdapUrl() + " -x -D \""
+ server.getAdminDn()
+ "\" -W -b \"ou=groups,dc=example,dc=org\" -s base -a always \"(objectClass=*)\" \"*\"" ) );
assertThat( text, containsString( "# baseObject : ou=groups,dc=example,dc=org" ) );
assertThat( text, containsString( "# scope : baseObject (0)" ) );
assertThat( text, containsString( "# derefAliases : derefAlways (3)" ) );
assertThat( text, containsString( "# sizeLimit : 0" ) );
assertThat( text, containsString( "# timeLimit : 0" ) );
assertThat( text, containsString( "# typesOnly : False" ) );
assertThat( text, containsString( "# filter : (objectClass=*)" ) );
assertThat( text, containsString( "# attributes : *" ) );
assertThat( text, containsString( "#!SEARCH RESULT ENTRY" ) );
assertThat( text, containsString( "dn: ou=groups,dc=example,dc=org" ) );
assertThat( text, containsString( "objectClass: top" ) );
assertThat( text, containsString( "objectClass: organizationalUnit" ) );
assertThat( text, containsString( "ou: groups" ) );
assertThat( text, containsString( "#!SEARCH RESULT DONE " ) );
assertThat( text, containsString( "# numEntries : 1" ) );
}
@ParameterizedTest
@LdapServersSource
public void testSearchLogsViewWithSearchResultLogsDisabled( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
searchLogsViewBot.clear();
// disable search request logs
searchLogsViewBot.enableSearchRequestLogs( false );
// select entry (ou=groups)
browserViewBot.selectEntry( path( GROUPS_DN ) );
// assert content
assertTrue( searchLogsViewBot.getSearchLogsText().isEmpty() );
}
@ParameterizedTest
@LdapServersSource
public void testSearchLogsViewClear( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
assertFalse( searchLogsViewBot.getSearchLogsText().isEmpty() );
searchLogsViewBot.clear();
assertTrue( searchLogsViewBot.getSearchLogsText().isEmpty() );
}
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testSearchLogsViewLogFileRotationAndNavigation( TestLdapServer server ) throws Exception
{
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode( ConnectionCoreConstants.PLUGIN_ID );
prefs.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT, 4 );
prefs.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_SIZE, 1 );
searchLogsViewBot.enableSearchResultEntryLogs( true );
connectionsViewBot.createTestConnection( server );
searchLogsViewBot.clear();
// initial state: empty log view and older/newer buttons are disabled
assertTrue( searchLogsViewBot.getSearchLogsText().isEmpty() );
assertFalse( searchLogsViewBot.isOlderButtonEnabled() );
assertFalse( searchLogsViewBot.isNewerButtonEnabled() );
// make some searches
browserViewBot.selectEntry( path( USER1_DN ) );
browserViewBot.selectEntry( path( USER2_DN ) );
browserViewBot.selectEntry( path( USER3_DN ) );
browserViewBot.selectEntry( path( USER4_DN ) );
browserViewBot.selectEntry( path( USER5_DN ) );
// assert status of newest page (1)
assertTrue( searchLogsViewBot.isOlderButtonEnabled() );
assertFalse( searchLogsViewBot.isNewerButtonEnabled() );
IntSummaryStatistics requestNumbers1 = getRequestStats( searchLogsViewBot.getSearchLogsText() );
// go to older page (2) and assert status
searchLogsViewBot.clickOlderButton();
assertTrue( searchLogsViewBot.isOlderButtonEnabled() );
assertTrue( searchLogsViewBot.isNewerButtonEnabled() );
IntSummaryStatistics requestNumbers2 = getRequestStats( searchLogsViewBot.getSearchLogsText() );
assertTrue( requestNumbers1.getMin() >= requestNumbers2.getMin() );
assertTrue( requestNumbers1.getMax() >= requestNumbers2.getMax() );
// go to older page (3) and assert status
searchLogsViewBot.clickOlderButton();
assertTrue( searchLogsViewBot.isOlderButtonEnabled() );
assertTrue( searchLogsViewBot.isNewerButtonEnabled() );
IntSummaryStatistics requestNumbers3 = getRequestStats( searchLogsViewBot.getSearchLogsText() );
assertTrue( requestNumbers2.getMin() >= requestNumbers3.getMin() );
assertTrue( requestNumbers2.getMax() >= requestNumbers3.getMax() );
// go to older page (4) and assert status
searchLogsViewBot.clickOlderButton();
assertFalse( searchLogsViewBot.isOlderButtonEnabled() );
assertTrue( searchLogsViewBot.isNewerButtonEnabled() );
IntSummaryStatistics requestNumbers4 = getRequestStats( searchLogsViewBot.getSearchLogsText() );
assertTrue( requestNumbers3.getMin() >= requestNumbers4.getMin() );
assertTrue( requestNumbers3.getMax() >= requestNumbers4.getMax() );
// go back to newest page (1) and assert status
searchLogsViewBot.clickNewerButton();
searchLogsViewBot.clickNewerButton();
searchLogsViewBot.clickNewerButton();
assertTrue( searchLogsViewBot.isOlderButtonEnabled() );
assertFalse( searchLogsViewBot.isNewerButtonEnabled() );
// reduce file count and assert extra files were deleted
prefs.putInt( ConnectionCoreConstants.PREFERENCE_SEARCHLOGS_FILE_COUNT, 2 );
assertTrue( searchLogsViewBot.isOlderButtonEnabled() );
assertFalse( searchLogsViewBot.isNewerButtonEnabled() );
searchLogsViewBot.clickOlderButton();
assertFalse( searchLogsViewBot.isOlderButtonEnabled() );
assertTrue( searchLogsViewBot.isNewerButtonEnabled() );
searchLogsViewBot.clickNewerButton();
}
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testSearchLogsViewLogMaskAttributes( TestLdapServer server ) throws Exception
{
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode( ConnectionCoreConstants.PLUGIN_ID );
prefs.put( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES,
"userPassword,employeeNumber" );
searchLogsViewBot.enableSearchResultEntryLogs( true );
connectionsViewBot.createTestConnection( server );
searchLogsViewBot.clear();
browserViewBot.selectEntry( path( USER1_DN ) );
String text = searchLogsViewBot.getSearchLogsText();
assertThat( text, containsString( "userPassword: **********" ) );
assertThat( text, not( containsString( "userPassword:: " ) ) );
assertThat( text, containsString( "employeeNumber: **********" ) );
}
@ParameterizedTest
@LdapServersSource
public void testModificationLogsViewModificationLogsDisabled( TestLdapServer server ) throws Exception
{
// create and open connection
connectionsViewBot.createTestConnection( server );
modificationLogsViewBot.clear();
// disable modification logs
modificationLogsViewBot.enableModificationLogs( false );
makeModifications();
// assert content
assertTrue( modificationLogsViewBot.getModificationLogsText().isEmpty() );
}
@ParameterizedTest
@LdapServersSource
public void testModificationLogsViewDefault( TestLdapServer server ) throws Exception
{
// create and open connection
connectionsViewBot.createTestConnection( server );
modificationLogsViewBot.clear();
makeModifications();
// assert content (ou=users)
String text = modificationLogsViewBot.getModificationLogsText();
assertThat( text, containsString( "#!RESULT OK" ) );
assertThat( text, containsString( "#!CONNECTION " + server.getLdapUrl() ) );
assertThat( text, containsString( "#!DATE " ) );
modificationLogsViewBot.assertContainsOk( "dn: " + dn( USERS_DN.getRdn(), TARGET_DN ), "changetype: add" );
modificationLogsViewBot.assertContainsOk( "dn: " + dn( USERS_DN.getRdn(), TARGET_DN ), "changetype: delete" );
}
@ParameterizedTest
@LdapServersSource
public void testModificationLogsViewClear( TestLdapServer server ) throws Exception
{
connectionsViewBot.createTestConnection( server );
assertTrue( modificationLogsViewBot.getModificationLogsText().isEmpty() );
makeModifications();
assertFalse( modificationLogsViewBot.getModificationLogsText().isEmpty() );
modificationLogsViewBot.clear();
assertTrue( modificationLogsViewBot.getModificationLogsText().isEmpty() );
}
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testModificationLogsViewLogFileRotationAndNavigation( TestLdapServer server ) throws Exception
{
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode( ConnectionCoreConstants.PLUGIN_ID );
prefs.putInt( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_COUNT, 3 );
prefs.putInt( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_FILE_SIZE, 2 );
connectionsViewBot.createTestConnection( server );
modificationLogsViewBot.clear();
// initial state: empty log view and older/newer buttons are disabled
assertTrue( modificationLogsViewBot.getModificationLogsText().isEmpty() );
assertFalse( modificationLogsViewBot.isOlderButtonEnabled() );
assertFalse( modificationLogsViewBot.isNewerButtonEnabled() );
makeModifications();
// assert status of newest page (1)
assertTrue( modificationLogsViewBot.isOlderButtonEnabled() );
assertFalse( modificationLogsViewBot.isNewerButtonEnabled() );
IntSummaryStatistics requestNumbers1 = getRequestStats( modificationLogsViewBot.getModificationLogsText() );
// go to older page (2) and assert status
modificationLogsViewBot.clickOlderButton();
assertTrue( modificationLogsViewBot.isOlderButtonEnabled() );
assertTrue( modificationLogsViewBot.isNewerButtonEnabled() );
IntSummaryStatistics requestNumbers2 = getRequestStats( modificationLogsViewBot.getModificationLogsText() );
assertTrue( requestNumbers1.getMin() >= requestNumbers2.getMin() );
assertTrue( requestNumbers1.getMax() >= requestNumbers2.getMax() );
// go to older page (3) and assert status
modificationLogsViewBot.clickOlderButton();
assertFalse( modificationLogsViewBot.isOlderButtonEnabled() );
assertTrue( modificationLogsViewBot.isNewerButtonEnabled() );
IntSummaryStatistics requestNumbers3 = getRequestStats( modificationLogsViewBot.getModificationLogsText() );
assertTrue( requestNumbers2.getMin() >= requestNumbers3.getMin() );
assertTrue( requestNumbers2.getMax() >= requestNumbers3.getMax() );
// go back to newest page (1) and assert status
modificationLogsViewBot.clickNewerButton();
modificationLogsViewBot.clickNewerButton();
assertTrue( modificationLogsViewBot.isOlderButtonEnabled() );
assertFalse( modificationLogsViewBot.isNewerButtonEnabled() );
}
@ParameterizedTest
@LdapServersSource(mode = Mode.All)
public void testModificationLogsViewMaskAttributes( TestLdapServer server ) throws Exception
{
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode( ConnectionCoreConstants.PLUGIN_ID );
prefs.put( ConnectionCoreConstants.PREFERENCE_MODIFICATIONLOGS_MASKED_ATTRIBUTES,
"userPassword,employeeNumber" );
searchLogsViewBot.enableSearchResultEntryLogs( true );
connectionsViewBot.createTestConnection( server );
modificationLogsViewBot.clear();
makeModifications();
String text = modificationLogsViewBot.getModificationLogsText();
assertThat( text, containsString( "userPassword: **********" ) );
assertThat( text, not( containsString( "userPassword:: " ) ) );
assertThat( text, containsString( "employeeNumber: **********" ) );
}
private void makeModifications()
{
browserViewBot.selectEntry( path( USERS_DN ) );
browserViewBot.copy();
browserViewBot.selectEntry( path( TARGET_DN ) );
SelectCopyDepthDialogBot dialog = browserViewBot.pasteEntriesExpectingSelectCopyDepthDialog( 1 );
dialog.selectSubTree();
dialog.clickOkButton();
browserViewBot.selectEntry( path( TARGET_DN, USERS_DN.getRdn() ) );
browserViewBot.openDeleteDialog().clickOkButton();
}
private static IntSummaryStatistics getRequestStats( String text )
{
Pattern requestNumberPattern = Pattern.compile( "^#!.+\\((\\d+)\\) OK$", Pattern.MULTILINE );
Matcher matcher = requestNumberPattern.matcher( text );
List<String> matches = new ArrayList<>();
while ( matcher.find() )
{
matches.add( matcher.group( 1 ) );
}
return matches.stream().mapToInt( Integer::parseInt ).summaryStatistics();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/PreferencesTest.java | /*
* 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 org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.File;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.security.cert.X509Certificate;
import java.util.Date;
import java.util.List;
import org.apache.directory.api.ldap.model.entry.DefaultEntry;
import org.apache.directory.api.ldap.model.entry.Entry;
import org.apache.directory.api.util.FileUtils;
import org.apache.directory.server.core.security.TlsKeyGenerator;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.PasswordsKeyStoreManager;
import org.apache.directory.studio.test.integration.junit5.LdapServersSource;
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;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
/**
* Tests the preferences.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class PreferencesTest extends AbstractTestBase
{
/**
* Test for DIRSTUDIO-580
* (Setting "Validate certificates for secure LDAP connections" is not saved).
*/
@Test
public void testCertificatValidationSettingsSaved() throws Exception
{
File file = getConnectionCorePreferencesFile();
// 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, StandardCharsets.UTF_8 );
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 or the whole file
preferencesBot.clickOkButton();
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;
}
/**
* Test for DIRSTUDIO-1095
* (NullPointerException on certificates preference page).
*/
@Test
public void testCertificatValidationPage() throws Exception
{
// verify there is no certificate yet.
PreferencesBot preferencesBot = studioBot.openPreferences();
CertificateValidationPreferencePageBot pageBot = preferencesBot.openCertificatValidationPage();
pageBot.activatePermanentTab();
assertEquals( 0, pageBot.getCertificateCount() );
pageBot.activateTemporaryTab();
assertEquals( 0, pageBot.getCertificateCount() );
preferencesBot.clickCancelButton();
// add a certificate (not possible via native file dialog)
Entry entry = new DefaultEntry();
String issuerDn = "cn=apacheds,ou=directory,o=apache,c=US";
Date startDate = new Date();
Date expiryDate = new Date( System.currentTimeMillis() + TlsKeyGenerator.YEAR_MILLIS );
String keyAlgo = "RSA";
int keySize = 1024;
CertificateValidationTest.addKeyPair( entry, issuerDn, issuerDn, startDate, expiryDate, keyAlgo, keySize,
null );
X509Certificate certificate = TlsKeyGenerator.getCertificate( entry );
ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().addCertificate( certificate );
// verify there is one certificate now
preferencesBot = studioBot.openPreferences();
pageBot = preferencesBot.openCertificatValidationPage();
pageBot.activatePermanentTab();
assertEquals( 1, pageBot.getCertificateCount() );
pageBot.activateTemporaryTab();
assertEquals( 0, pageBot.getCertificateCount() );
// view the certificate
pageBot.activatePermanentTab();
pageBot.selectCertificate( 0 );
CertificateViewerDialogBot certificateViewerDialogBot = pageBot.clickViewButton();
assertTrue( certificateViewerDialogBot.isVisible() );
certificateViewerDialogBot.clickCloseButton();
// delete the certificate
pageBot.clickRemoveButton();
// verify there is no certificate left
pageBot.activatePermanentTab();
assertEquals( 0, pageBot.getCertificateCount() );
pageBot.activateTemporaryTab();
assertEquals( 0, pageBot.getCertificateCount() );
assertEquals( 0, ConnectionCorePlugin.getDefault().getPermanentTrustStoreManager().getCertificates().length );
assertEquals( 0, ConnectionCorePlugin.getDefault().getSessionTrustStoreManager().getCertificates().length );
preferencesBot.clickCancelButton();
}
/**
* Test for DIRSTUDIO-1179
* (java.io.IOException: Invalid secret key format after Java update).
*/
@ParameterizedTest
@LdapServersSource
public void testConnectionPasswordsKeystore( TestLdapServer server ) throws Exception
{
Connection connection = connectionsViewBot.createTestConnection( server );
connectionsViewBot.closeSelectedConnections();
// the global password keystore manager
PasswordsKeyStoreManager passwordsKeyStoreManager = ConnectionCorePlugin.getDefault()
.getPasswordsKeyStoreManager();
URL url = Platform.getInstanceLocation().getURL();
File file = new File( url.getFile()
+ ".metadata/.plugins/org.apache.directory.studio.connection.core/passwords.jks" );
// verify usage of password keystore is disabled
assertFalse( file.exists() );
PreferencesBot preferencesBot = studioBot.openPreferences();
PasswordsKeystorePreferencePageBot pageBot = preferencesBot.openPasswordsKeystorePage();
assertFalse( pageBot.isPasswordsKeystoreEnabled() );
// enable password keystore
SetupMasterPasswordDialogBot setupMasterPasswordDialogBot = pageBot.enablePasswordsKeystore();
setupMasterPasswordDialogBot.setMasterPassword( "secret12" );
setupMasterPasswordDialogBot.clickOkButton();
// verify usage of password keystore is enabled
assertTrue( pageBot.isPasswordsKeystoreEnabled() );
// apply
preferencesBot.clickOkButton();
// verify passwords keystore file exists and is loaded
assertTrue( file.exists() );
assertTrue( passwordsKeyStoreManager.isLoaded() );
// verify connection can be opened because keystore is already loaded
connectionsViewBot.select( connection.getName() );
connectionsViewBot.openSelectedConnection();
connectionsViewBot.closeSelectedConnections();
// unload the keystore
passwordsKeyStoreManager.unload();
assertFalse( passwordsKeyStoreManager.isLoaded() );
// verify master password prompt when opening the connection
connectionsViewBot.select( connection.getName() );
connectionsViewBot.openSelectedConnectionExpectingVerifyMasterPasswordDialog( "secret12" );
connectionsViewBot.closeSelectedConnections();
// disable password keystore, keep connection password
preferencesBot = studioBot.openPreferences();
pageBot = preferencesBot.openPasswordsKeystorePage();
assertTrue( pageBot.isPasswordsKeystoreEnabled() );
KeepConnectionsPasswordsDialogBot keepConnectionsPasswordsDialogBot = pageBot.disablePasswordsKeystore();
VerifyMasterPasswordDialogBot verifyMasterPasswordDialog = keepConnectionsPasswordsDialogBot
.clickYesButtonExpectingVerifyMasterPasswordDialog();
verifyMasterPasswordDialog.enterMasterPassword( "secret12" );
verifyMasterPasswordDialog.clickOkButton();
assertFalse( pageBot.isPasswordsKeystoreEnabled() );
// apply
preferencesBot.clickOkButton();
// verify passwords keystore file was deleted
assertFalse( file.exists() );
assertFalse( passwordsKeyStoreManager.isLoaded() );
// verify connection can be opened and connections password was kept
connectionsViewBot.select( connection.getName() );
connectionsViewBot.openSelectedConnection();
connectionsViewBot.closeSelectedConnections();
}
@Test
public void testLdifEditorPreferencesPage() throws Exception
{
// open preferences dialog
PreferencesBot preferencesBot = studioBot.openPreferences();
assertTrue( preferencesBot.isVisible() );
// open LDIF editor syntax coloring page
preferencesBot.openLdifEditorSyntaxColoringPage();
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() );
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaProjectsViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaProjectsViewBot.java | /*
* 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;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
public class SchemaProjectsViewBot
{
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
public NewSchemaProjectWizardBot openNewSchemaProjectWizard()
{
getProjectsTable().contextMenu( "New Schema Project" ).click();
return new NewSchemaProjectWizardBot();
}
public void deleteAllProjects()
{
while ( getProjectsTable().rowCount() > 0 )
{
getProjectsTable().getTableItem( 0 ).contextMenu( "Delete Project" ).click();
new DeleteDialogBot( DeleteDialogBot.DELETE_PROJECT ).clickOkButton();
}
}
private SWTBotTable getProjectsTable()
{
SWTBotView view = bot.viewByTitle( "Projects" );
view.show();
SWTBotTable table = view.bot().table();
return table;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/GeneratedPasswordDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/GeneratedPasswordDialogBot.java | /*
* 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 GeneratedPasswordDialogBot extends DialogBot
{
public GeneratedPasswordDialogBot()
{
super( "Generated Password" );
}
public String getGeneratedPassword()
{
return bot.text( 0 ).getText();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConsoleViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConsoleViewBot.java | /*
* 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;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
public class ConsoleViewBot
{
private SWTWorkbenchBot bot;
private SWTBotView view;
public ConsoleViewBot()
{
bot = new SWTWorkbenchBot();
view = bot.viewByPartName( "Console" );
}
public String getConsoleText()
{
view.show();
return view.bot().styledText().getText();
}
public void waitForConsoleText( String text )
{
bot.waitUntil( new DefaultCondition()
{
@Override
public boolean test() throws Exception
{
return getConsoleText().contains( text );
}
@Override
public String getFailureMessage()
{
return "Text " + text + " was not found in console";
}
}, SWTBotPreferences.TIMEOUT * 20 );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AddressEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AddressEditorDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class AddressEditorDialogBot extends DialogBot
{
public AddressEditorDialogBot()
{
super( "Address Editor" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name );
}
public String getText()
{
return bot.text( 0 ).getText();
}
public void setText( String text )
{
bot.text( 0 ).setText( text );
}
public void deselectStripWhitespaceCheckbox()
{
bot.checkBox( "Strip trailing whitespace" ).deselect();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/StudioBot.java | /*
* 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;
import java.util.Random;
import org.eclipse.e4.ui.css.swt.theme.IThemeEngine;
import org.eclipse.e4.ui.css.swt.theme.IThemeManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
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.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.utils.SWTUtils;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
public class StudioBot
{
public StudioBot()
{
SWTBotPreferences.KEYBOARD_LAYOUT = "org.eclipse.swtbot.swt.finder.keyboard.EN_US";
}
public ConnectionsViewBot getConnectionView()
{
return new ConnectionsViewBot();
}
public BrowserViewBot getBrowserView()
{
return new BrowserViewBot();
}
public SearchLogsViewBot getSearchLogsViewBot()
{
return new SearchLogsViewBot();
}
public ModificationLogsViewBot getModificationLogsViewBot()
{
return new ModificationLogsViewBot();
}
public ApacheDSServersViewBot getApacheDSServersViewBot()
{
return new ApacheDSServersViewBot();
}
public ProgressViewBot getProgressView()
{
return new ProgressViewBot();
}
public EntryEditorBot getEntryEditorBot( String title )
{
return new EntryEditorBot( title );
}
public SearchResultEditorBot getSearchResultEditorBot( String title )
{
return new SearchResultEditorBot( title );
}
public ConsoleViewBot getConsoleView()
{
ShowViewsBot showViewsBot = openShowViews();
showViewsBot.openView( "General", "Console" );
return new ConsoleViewBot();
}
public SchemaProjectsViewBot getSchemaProjectsView()
{
return new SchemaProjectsViewBot();
}
public SchemaViewBot getSchemaView()
{
return new SchemaViewBot();
}
public SchemaSearchViewBot getSchemaSearchView()
{
return new SchemaSearchViewBot();
}
public void resetLdapPerspective()
{
resetPerspective( "org.apache.directory.studio.ldapbrowser.ui.perspective.BrowserPerspective" );
}
public void resetSchemaPerspective()
{
resetPerspective( "org.apache.directory.studio.schemaeditor.perspective" );
}
private void resetPerspective( final String perspectiveId )
{
UIThreadRunnable.syncExec( new VoidResult()
{
public void run()
{
try
{
// https://wiki.eclipse.org/SWTBot/Troubleshooting#No_active_Shell_when_running_SWTBot_tests_in_Xvfb
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().forceActive();
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
// set default/dark theme
/*
IThemeManager tm = workbench.getService( IThemeManager.class );
IThemeEngine te = tm.getEngineForDisplay( Display.getCurrent() );
int random = new Random().nextInt( 3 );
switch ( random )
{
case 0:
te.setTheme( "org.eclipse.e4.ui.css.theme.e4_dark", false );
break;
case 1:
te.setTheme( "org.eclipse.e4.ui.css.theme.e4_default", false );
break;
case 2:
te.setTheme( "org.eclipse.e4.ui.css.theme.high-contrast", false );
break;
}
*/
// close welcome view
IWorkbenchPage page = window.getActivePage();
for ( IViewReference viewref : page.getViewReferences() )
{
if ( "org.eclipse.ui.internal.introview".equals( viewref.getId() ) )
{
page.hideView( viewref );
}
}
// close shells (open dialogs)
Shell[] shells = Display.getCurrent().getShells();
for ( Shell shell : shells )
{
if ( shell != null && shell != window.getShell() )
{
shell.close();
}
}
Shell activeShell = Display.getCurrent().getActiveShell();
if ( activeShell != null && activeShell != window.getShell() )
{
activeShell.close();
}
// open LDAP perspective
workbench.showPerspective( perspectiveId, window );
// close "LDAP Browser view" as it sometimes does not respond, will be re-opened by the following reset
for ( IViewReference viewref : page.getViewReferences() )
{
if ( "org.apache.directory.studio.ldapbrowser.ui.views.browser.BrowserView".equals( viewref
.getId() ) )
{
page.hideView( viewref );
}
}
// reset LDAP perspective
page.closeAllEditors( false );
page.resetPerspective();
}
catch ( Exception e )
{
e.printStackTrace();
throw new RuntimeException( e );
}
}
} );
}
public PreferencesBot openPreferences()
{
if ( SWTUtils.isMac() )
{
// new SWTBot().activeShell().pressShortcut( SWT.COMMAND, ',' );
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec( new Runnable()
{
public void run()
{
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if ( window != null )
{
Menu appMenu = workbench.getDisplay().getSystemMenu();
for ( MenuItem item : appMenu.getItems() )
{
if ( item.getText().startsWith( "Preferences" ) )
{
Event event = new Event();
event.time = ( int ) System.currentTimeMillis();
event.widget = item;
event.display = workbench.getDisplay();
item.setSelection( true );
item.notifyListeners( SWT.Selection, event );
break;
}
}
}
}
} );
}
else
{
new SWTBot().menu( "Window" ).menu( "Preferences" ).click();
}
return new PreferencesBot();
}
public NewWizardBot openNewWizard()
{
SWTBotMenu file = new SWTBot().menu( "File" );
if ( file.menuItems().contains( "New" ) )
{
// In RCP application
file.menu( "New" ).menu( "Other..." ).click();
}
else
{
// In IDE
file.menu( "New..." ).click();
}
return new NewWizardBot();
}
public ExportWizardBot openExportWizard()
{
new SWTBot().menu( "File" ).menu( "Export..." ).click();
return new ExportWizardBot();
}
public ImportWizardBot openImportWizard()
{
new SWTBot().menu( "File" ).menu( "Import..." ).click();
return new ImportWizardBot();
}
public ShowViewsBot openShowViews()
{
new SWTBot().menu( "Window" ).menu( "Show View" ).menu( "Other..." ).click();
return new ShowViewsBot();
}
public void navigationHistoryBack()
{
SWTBotMenu backMenu = new SWTWorkbenchBot().menu( "Navigate" ).menu( "Back" );
String firstItem = backMenu.menuItems().get( 0 );
backMenu.menu( firstItem ).click();
}
public void navigationHistoryForward()
{
SWTBotMenu forwardMenu = new SWTWorkbenchBot().menu( "Navigate" ).menu( "Forward" );
String firstItem = forwardMenu.menuItems().get( 0 );
forwardMenu.menu( firstItem ).click();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DialogBot.java | /*
* 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;
import org.apache.commons.lang3.StringUtils;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
public abstract class DialogBot
{
protected SWTWorkbenchBot bot = new SWTWorkbenchBot();
protected String title;
protected String[] okButtonJobWatcherJobNames = null;
protected DialogBot( String title )
{
this.title = title;
}
public void setWaitAfterClickOkButton( boolean wait, String... jobNames )
{
if ( wait )
{
this.okButtonJobWatcherJobNames = jobNames;
}
else
{
this.okButtonJobWatcherJobNames = null;
}
}
public void activate()
{
bot.shell( title ).setFocus();
}
public boolean isVisible()
{
return bot.shell( title ).isVisible();
}
public boolean isOkButtonEnabled()
{
return isButtonEnabled( "OK" );
}
private boolean isButtonEnabled( String buttonTitle )
{
activate();
final SWTBotButton button = bot.button( buttonTitle );
return button.isEnabled();
}
public void clickOkButton()
{
if ( okButtonJobWatcherJobNames != null )
{
JobWatcher jobWatcher = new JobWatcher( okButtonJobWatcherJobNames );
clickButton( "OK" );
jobWatcher.waitUntilDone();
}
else
{
clickButton( "OK" );
}
}
public ErrorDialogBot clickOkButtonExpectingErrorDialog()
{
String shellText = BotUtils.shell( () -> clickButton( "OK" ), "Error", "Problem Occurred" ).getText();
return new ErrorDialogBot( shellText );
}
public void clickCancelButton()
{
clickButton( "Cancel" );
}
public void waitForDialog()
{
bot.waitUntil( new DefaultCondition()
{
@Override
public boolean test() throws Exception
{
return isVisible();
}
@Override
public String getFailureMessage()
{
return "Dialog did not appear: " + title;
}
}, SWTBotPreferences.TIMEOUT * 4 );
}
protected void clickButton( final String buttonTitle )
{
activate();
final SWTBotButton button = bot.button( buttonTitle );
button.click();
}
protected CheckResponse clickCheckButton( final String label, final String title )
{
SWTBotShell parentShell = bot.activeShell();
SWTBotShell shell = BotUtils.shell( new Runnable()
{
public void run()
{
bot.button( label ).click();
}
}, "Error", title );
String shellText = shell.getText();
// label(0) may be the image
String messageText = bot.label( 0 ).getText();
if ( StringUtils.isBlank( messageText ) )
{
messageText = bot.label( 1 ).getText();
}
bot.button( "OK" ).click();
parentShell.activate();
if ( shellText.equals( title ) )
{
return new CheckResponse( false, shellText, messageText );
}
else
{
return new CheckResponse( true, shellText, messageText );
}
}
public static class CheckResponse
{
boolean isError;
String title;
String message;
public CheckResponse( boolean isError, String title, String message )
{
this.isError = isError;
this.title = title;
this.message = message;
}
public boolean isError()
{
return isError;
}
public String getTitle()
{
return title;
}
public String getMessage()
{
return message;
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ImportConnectionsWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ImportConnectionsWizardBot.java | /*
* 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 ImportConnectionsWizardBot extends WizardBot
{
public ImportConnectionsWizardBot()
{
super( "Connections Import" );
}
public void typeFile( String file )
{
bot.comboBox().setText( file );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaSearchViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaSearchViewBot.java | /*
* 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;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarToggleButton;
public class SchemaSearchViewBot
{
private SWTBotView view;
public SchemaSearchViewBot()
{
view = new SWTWorkbenchBot().viewByTitle( "Search" );
}
public void search( String text )
{
view.show();
SWTBotToolbarToggleButton button = view.toolbarToggleButton( "Show Search Field" );
button.select();
view.bot().text().setText( text );
view.bot().buttonWithTooltip( "Search" ).click();
}
public List<String> getResults()
{
List<String> results = new ArrayList<String>();
SWTBotTable table = view.bot().table();
for ( int i = 0; i < table.rowCount(); i++ )
{
String text = table.getTableItem( i ).getText();
results.add( text );
}
return results;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionsViewBot.java | /*
* 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;
import static org.apache.directory.studio.test.integration.ui.utils.Constants.LOCALHOST;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.directory.studio.connection.core.Connection;
import org.apache.directory.studio.connection.core.ConnectionCorePlugin;
import org.apache.directory.studio.connection.core.ConnectionFolder;
import org.apache.directory.studio.connection.core.ConnectionFolderManager;
import org.apache.directory.studio.connection.core.ConnectionManager;
import org.apache.directory.studio.connection.core.ConnectionParameter;
import org.apache.directory.studio.connection.core.ConnectionParameter.AuthenticationMethod;
import org.apache.directory.studio.connection.core.ConnectionParameter.EncryptionMethod;
import org.apache.directory.studio.connection.core.Messages;
import org.apache.directory.studio.connection.core.jobs.OpenConnectionsRunnable;
import org.apache.directory.studio.connection.core.jobs.StudioConnectionJob;
import org.apache.directory.studio.test.integration.junit5.TestLdapServer;
import org.apache.directory.studio.test.integration.ui.utils.ContextMenuHelper;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.utils.TableCollection;
import org.eclipse.swtbot.swt.finder.utils.TableRow;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
public class ConnectionsViewBot
{
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
public NewConnectionWizardBot openNewConnectionWizard()
{
ContextMenuHelper.clickContextMenu( getConnectionsTree(), "New Connection..." );
NewConnectionWizardBot newConnectionWizardBot = new NewConnectionWizardBot();
return newConnectionWizardBot;
}
public NewConnectionFolderDialogBot openNewConnectionFolderDialog()
{
ContextMenuHelper.clickContextMenu( getConnectionsTree(), "New Connection Folder..." );
return new NewConnectionFolderDialogBot();
}
public void openSelectedConnection()
{
JobWatcher watcher = new JobWatcher( Messages.jobs__open_connections_name_1 );
getConnectionsTree().contextMenu( "Open Connection" ).click();
watcher.waitUntilDone();
}
public void openSelectedConnectionExpectingVerifyMasterPasswordDialog( String masterPassword )
{
JobWatcher watcher = new JobWatcher( Messages.jobs__open_connections_name_1 );
getConnectionsTree().contextMenu( "Open Connection" ).click();
VerifyMasterPasswordDialogBot verifyMasterPasswordDialogBot = new VerifyMasterPasswordDialogBot();
verifyMasterPasswordDialogBot.enterMasterPassword( masterPassword );
verifyMasterPasswordDialogBot.clickOkButton();
watcher.waitUntilDone();
}
public ErrorDialogBot openSelectedConnectionExpectingNoSchemaProvidedErrorDialog()
{
String shellText = BotUtils.shell( () -> {
JobWatcher watcher = new JobWatcher( Messages.jobs__open_connections_name_1 );
getConnectionsTree().contextMenu( "Open Connection" ).click();
watcher.waitUntilDone();
}, "Problem Occurred" ).getText();
return new ErrorDialogBot( shellText );
}
public void closeSelectedConnections()
{
JobWatcher watcher = new JobWatcher( Messages.jobs__close_connections_name_1 );
getConnectionsTree().contextMenu( "Close Connection" ).click();
watcher.waitUntilDone();
}
public SchemaBrowserBot openSchemaBrowser()
{
ContextMenuHelper.clickContextMenu( getConnectionsTree(), "Open Schema Browser" );
return new SchemaBrowserBot();
}
public DeleteDialogBot openDeleteConnectionDialog()
{
getConnectionsTree().contextMenu( "Delete Connection" ).click();
return new DeleteDialogBot( DeleteDialogBot.DELETE_CONNECTION );
}
public DeleteDialogBot openDeleteConnectionFolderDialog()
{
getConnectionsTree().contextMenu( DeleteDialogBot.DELETE_CONNECTION_FOLDER ).click();
return new DeleteDialogBot( DeleteDialogBot.DELETE_CONNECTION_FOLDER );
}
public ExportConnectionsWizardBot openExportConnectionsWizard()
{
getConnectionsTree().contextMenu( "Export" ).contextMenu( "Export Connections..." ).click();
return new ExportConnectionsWizardBot();
}
public ImportConnectionsWizardBot openImportConnectionsWizard()
{
getConnectionsTree().contextMenu( "Import" ).contextMenu( "Import Connections..." ).click();
return new ImportConnectionsWizardBot();
}
public ApacheDSConfigurationEditorBot openApacheDSConfiguration()
{
getConnectionsTree().contextMenu( "Open Configuration" ).click();
String title = getSelection() + " - Configuration";
return new ApacheDSConfigurationEditorBot( title );
}
public void select( String... path )
{
List<String> pathList = new ArrayList<String>( Arrays.asList( path ) );
SWTBotTreeItem item = getConnectionsTree().getTreeItem( pathList.remove( 0 ) );
while ( !pathList.isEmpty() )
{
item = item.getNode( pathList.remove( 0 ) );
}
item.select();
}
public String getSelection()
{
TableCollection selection = getConnectionsTree().selection();
if ( selection != null && selection.rowCount() == 1 )
{
TableRow row = selection.get( 0 );
return row.get( 0 );
}
return null;
}
public int getCount()
{
return getConnectionsTree().visibleRowCount();
}
private SWTBotTree getConnectionsTree()
{
SWTBotView view = bot.viewByTitle( "Connections" );
view.show();
SWTBotTree tree = view.bot().tree();
return tree;
}
public void waitForConnection( final String connectionName )
{
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
for ( SWTBotTreeItem item : getConnectionsTree().getAllItems() )
{
String text = item.getText();
if ( text.startsWith( connectionName ) )
{
return true;
}
}
return false;
}
public String getFailureMessage()
{
return "Connection " + connectionName + " not visible in connections view.";
}
} );
}
public Connection createTestConnection( TestLdapServer server ) throws Exception
{
return createTestConnection( server.getType().name(), server.getHost(),
server.getPort(), server.getAdminDn(),
server.getAdminPassword() );
}
/**
* Creates the test connection.
*
* @param name
* the name of the connection
* @param port
* the port to use
*
* @return the connection
*
*/
public Connection createTestConnection( String name, int port ) throws Exception
{
return createTestConnection( name, LOCALHOST, port, "uid=admin,ou=system", "secret" );
}
public Connection createTestConnection( String name, String host, int port, String bindDn, String bindPassword )
throws Exception
{
name = name + "_" + System.currentTimeMillis();
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
ConnectionParameter connectionParameter = new ConnectionParameter();
connectionParameter.setName( name );
connectionParameter.setHost( host );
connectionParameter.setPort( port );
connectionParameter.setEncryptionMethod( EncryptionMethod.NONE );
connectionParameter.setAuthMethod( AuthenticationMethod.SIMPLE );
connectionParameter.setBindPrincipal( bindDn );
connectionParameter.setBindPassword( bindPassword );
Connection connection = new Connection( connectionParameter );
connectionManager.addConnection( connection );
ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
.getConnectionFolderManager();
ConnectionFolder rootConnectionFolder = connectionFolderManager.getRootConnectionFolder();
rootConnectionFolder.addConnectionId( connection.getId() );
select( name );
StudioConnectionJob job = new StudioConnectionJob( new OpenConnectionsRunnable( connection ) );
job.execute();
job.join();
return connection;
}
/**
* Deletes the test connection.
*/
public void deleteTestConnections()
{
ConnectionManager connectionManager = ConnectionCorePlugin.getDefault().getConnectionManager();
for ( Connection connection : connectionManager.getConnections() )
{
connectionManager.removeConnection( connection );
}
ConnectionFolderManager connectionFolderManager = ConnectionCorePlugin.getDefault()
.getConnectionFolderManager();
for ( ConnectionFolder connectionFolder : connectionFolderManager.getConnectionFolders() )
{
connectionFolderManager.removeConnectionFolder( connectionFolder );
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewApacheDSServerWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewApacheDSServerWizardBot.java | /*
* 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;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
public class NewApacheDSServerWizardBot extends WizardBot
{
private static final String TITLE = "New LDAP Server";
private static final String TYPE = "Select the server type:";
private static final String NAME = "Server Name:";
public NewApacheDSServerWizardBot()
{
super(TITLE);
}
public void typeServerName( String serverName )
{
SWTBotText connText = bot.textWithLabel( NAME );
connText.setText( serverName );
}
public void selectApacheDS200()
{
SWTBotTree tree = bot.treeWithLabel( TYPE );
tree.expandNode( "Apache Software Foundation" ).select( "ApacheDS 2.0.0" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorBot.java | /*
* 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;
import java.util.List;
import org.apache.directory.studio.test.integration.ui.utils.ContextMenuHelper;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
public class EntryEditorBot
{
private SWTBotEditor editor;
private SWTBot bot;
private EntryEditorWidgetBot editorBot;
public EntryEditorBot( String title )
{
SWTWorkbenchBot bot = new SWTWorkbenchBot();
editor = bot.editorByTitle( title );
this.bot = editor.bot();
this.editorBot = new EntryEditorWidgetBot( editor.bot() );
}
public String getDnText()
{
String text = bot.text().getText();
return text;
}
public boolean isEnabled()
{
return bot.tree().isEnabled();
}
public List<String> getAttributeValues()
{
return editorBot.getAttributeValues();
}
public NewAttributeWizardBot openNewAttributeWizard()
{
return editorBot.openNewAttributeWizard();
}
public void activate()
{
editor.setFocus();
bot.tree().setFocus();
}
public void typeValueAndFinish( String value )
{
editorBot.typeValueAndFinish( value, true );
}
public ErrorDialogBot typeValueAndFinishAndExpectErrorDialog( String value )
{
return editorBot.typeValueAndFinishAndExpectErrorDialog( value );
}
public void addValue( String attributeType )
{
editorBot.addValue( attributeType );
}
public void editValue( String attributeType, String value )
{
editorBot.editValue( attributeType, value );
}
public EditAttributeWizardBot editAttribute( String attributeType, String value )
{
return editorBot.editAttribute( attributeType, value );
}
public DnEditorDialogBot editValueExpectingDnEditor( String attributeType, String value )
{
return editorBot.editValueExpectingDnEditor( attributeType, value );
}
public PasswordEditorDialogBot editValueExpectingPasswordEditor( String attributeType, String value )
{
return editorBot.editValueExpectingPasswordEditor( attributeType, value );
}
public AciItemEditorDialogBot editValueExpectingAciItemEditor( String attributeType, String value )
{
return editorBot.editValueExpectingAciItemEditor( attributeType, value );
}
public SubtreeSpecificationEditorDialogBot editValueExpectingSubtreeSpecificationEditor( String attributeType,
String value )
{
return editorBot.editValueExpectingSubtreeSpecificationEditor( attributeType, value );
}
public CertificateEditorDialogBot editValueExpectingCertificateEditor( String attributeType, String value )
{
return editorBot.editValueExpectingCertificateEditor( attributeType, value );
}
public HexEditorDialogBot editValueExpectingHexEditor( String attributeType, String value )
{
return editorBot.editValueExpectingHexEditor( attributeType, value );
}
public AddressEditorDialogBot editValueExpectingAddressEditor( String attributeType, String value )
{
return editorBot.editValueExpectingAddressEditor( attributeType, value );
}
public TextEditorDialogBot editValueWithTextEditor( String attributeType, String value )
{
return editorBot.editValueWithTextEditor( attributeType, value );
}
public void deleteValue( String attributeType, String value )
{
editorBot.deleteValue( attributeType, value );
}
public ErrorDialogBot deleteValueExpectingErrorDialog( String attributeType, String value )
{
return editorBot.deleteValueExpectingErrorDialog( attributeType, value );
}
public void copyValue( String attributeType, String value )
{
editorBot.copyValue( attributeType, value );
}
public void copyValues( String... attributeTypes )
{
editorBot.copyValues( attributeTypes );
}
public void pasteValue()
{
editorBot.pasteValue();
}
public void pasteValues()
{
editorBot.pasteValues();
}
public void fetchOperationalAttributes()
{
ContextMenuHelper.clickContextMenu( bot.tree(), "Fetch Operational Attributes" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ImageEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ImageEditorDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class ImageEditorDialogBot extends DialogBot
{
public ImageEditorDialogBot()
{
super( "Image Editor" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name );
}
public void typeFile( String file )
{
bot.text(4).setText( file );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencesBot.java | /*
* 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;
import org.apache.directory.studio.test.integration.ui.utils.TreeBot;
public class PreferencesBot extends DialogBot
{
public PreferencesBot()
{
super( "Preferences" );
}
public CertificateValidationPreferencePageBot openCertificatValidationPage()
{
bot.tree().getTreeItem( "Apache Directory Studio" ).select().expand().getNode( "Connections" ).select()
.expand().getNode( "Certificate Validation" ).select();
return new CertificateValidationPreferencePageBot();
}
public boolean pageExists( String... path )
{
TreeBot treeBot = new TreeBot( bot.tree() );
return treeBot.exists( path );
}
@Override
public void clickOkButton()
{
super.clickButton( "Apply and Close" );
}
public PasswordsKeystorePreferencePageBot openPasswordsKeystorePage()
{
bot.tree().getTreeItem( "Apache Directory Studio" ).select().expand().getNode( "Connections" ).select()
.expand().getNode( "Passwords Keystore" ).select();
return new PasswordsKeystorePreferencePageBot();
}
public void openLdifEditorSyntaxColoringPage()
{
bot.tree().getTreeItem( "Apache Directory Studio" ).select().expand().getNode( "LDIF Editor" ).select()
.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();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ReferralDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.eclipse.swtbot.swt.finder.utils.TableCollection;
import org.eclipse.swtbot.swt.finder.utils.TableRow;
public class ReferralDialogBot extends DialogBot
{
public ReferralDialogBot()
{
super( "Select Referral Connection" );
super.setWaitAfterClickOkButton( true,
BrowserCoreMessages.jobs__init_entries_title_subonly,
BrowserCoreMessages.jobs__init_entries_title_attonly, BrowserCoreMessages.jobs__create_entry_name_1 );
}
public void selectConnection( String connectionName )
{
activate();
bot.tree().select( connectionName );
}
public String getSelectedConnection()
{
activate();
TableCollection selection = bot.tree().selection();
if ( selection != null && selection.rowCount() == 1 )
{
TableRow row = selection.get( 0 );
return row.get( 0 );
}
return null;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectCopyStrategyBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectCopyStrategyBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class SelectCopyStrategyBot extends DialogBot
{
public SelectCopyStrategyBot()
{
super( "Select copy strategy" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__copy_entries_name_1 );
waitForDialog();
activate();
}
public void selectStopCopyProcess()
{
bot.radio( "Stop copy process" ).click();
}
public void selectIgnoreEntryAndContinue()
{
bot.radio( "Ignore entry and continue" ).click();
}
public void selectOverwriteEntryAndContinue()
{
bot.radio( "Overwrite entry and continue" ).click();
}
public void selectRenameEntryAndContinue()
{
bot.radio( "Rename entry and continue" ).click();
}
public void setRdnValue( int number, String text )
{
int index = number - 1;
bot.text( index ).setText( text );
}
public void setRdnType( int number, String text )
{
int index = number - 1;
bot.comboBox( index ).setText( text );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateViewerDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateViewerDialogBot.java | /*
* 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 CertificateViewerDialogBot extends DialogBot
{
public CertificateViewerDialogBot()
{
super( "Certificate Viewer" );
}
public void clickCloseButton()
{
clickButton( "Close" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ExportWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ExportWizardBot.java | /*
* 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;
import java.io.File;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
public class ExportWizardBot extends WizardBot
{
public static final String EXPORT_LDIF_TITLE = "LDIF Export";
public static final String EXPORT_DSML_TITLE = "DSML Export";
public static final String EXPORT_CSV_TITLE = "CSV Export";
private String title;
SearchPageWrapperBot searchPageWrapperBot;
public ExportWizardBot()
{
this( "Export" );
}
public ExportWizardBot( String title )
{
super( title );
this.title = title;
this.searchPageWrapperBot = new SearchPageWrapperBot( bot );
}
public void setFilter( String filter )
{
searchPageWrapperBot.setFilter( filter );
}
public void setReturningAttributes( String returningAttributes )
{
searchPageWrapperBot.setReturningAttributes( returningAttributes );
}
public void setScope( SearchScope scope )
{
searchPageWrapperBot.setScope( scope );
}
public void setCountLimit( int countLimit )
{
searchPageWrapperBot.setCountLimit( countLimit );
}
public void setControlManageDsaIT( boolean enabled )
{
searchPageWrapperBot.setControlManageDsaIT( enabled );
}
public void setControlSubentries( boolean enabled )
{
searchPageWrapperBot.setControlSubentries( enabled );
}
public void setControlPagedSearch( boolean enabled, int pageSize, boolean scrollMode )
{
searchPageWrapperBot.setControlPagedSearch( enabled, pageSize, scrollMode );
}
public void setAliasDereferencingMode( AliasDereferencingMethod mode )
{
searchPageWrapperBot.setAliasDereferencingMode( mode );
}
public void typeFile( String file )
{
bot.comboBox().setText( file );
}
@Override
public void clickFinishButton()
{
JobWatcher watcher = null;
if ( EXPORT_LDIF_TITLE.equals( title ) )
{
watcher = new JobWatcher( BrowserCoreMessages.jobs__export_ldif_name );
}
else if ( EXPORT_DSML_TITLE.equals( title ) )
{
watcher = new JobWatcher( BrowserCoreMessages.jobs__export_dsml_name );
}
super.clickFinishButton();
if ( watcher != null )
{
watcher.waitUntilDone();
}
}
public void waitTillExportFinished( final String file, final int expectedFileSize )
{
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
File f = new File( file );
return f.exists() && f.length() > expectedFileSize;
}
public String getFailureMessage()
{
return "LDIF File " + file + " not found.";
}
}, SWTBotPreferences.TIMEOUT * 2 );
}
public void selectDsmlRequest()
{
bot.radio( "DSML Request" ).click();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SetupMasterPasswordDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SetupMasterPasswordDialogBot.java | /*
* 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 SetupMasterPasswordDialogBot extends DialogBot
{
public SetupMasterPasswordDialogBot()
{
super( "Setup Master Password" );
}
public void setMasterPassword( String masterPassword )
{
bot.text( 0 ).setText( masterPassword );
bot.text( 1 ).setText( masterPassword );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BaseSchemaEditorBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BaseSchemaEditorBot.java | /*
* 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;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotMultiPageEditor;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
public class BaseSchemaEditorBot
{
protected SWTBotMultiPageEditor editor;
public BaseSchemaEditorBot( String title )
{
SWTWorkbenchBot bot = new SWTWorkbenchBot();
editor = bot.multipageEditorByTitle( title );
bot.waitUntil( new DefaultCondition()
{
@Override
public boolean test() throws Exception
{
return editor.getPageCount() >= 2;
}
@Override
public String getFailureMessage()
{
return "Schema editor not ready";
}
} );
}
public void activateSourceCodeTab()
{
editor.activatePage( "Source Code" );
}
public String getSourceCode()
{
activateSourceCodeTab();
return editor.bot().styledText().getText();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserWidgetBot.java | /*
* 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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
/**
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
class BrowserWidgetBot
{
private SWTBot bot;
BrowserWidgetBot( SWTBot bot )
{
this.bot = bot;
}
boolean existsEntry( String... path )
{
// ensure the parent exists
String[] parentPath = new String[path.length - 1];
System.arraycopy( path, 0, parentPath, 0, parentPath.length );
getEntry( false, parentPath );
// check if the child exists
try
{
getEntry( false, path );
return true;
}
catch ( WidgetNotFoundException e )
{
return false;
}
}
void selectEntry( boolean wait, String... path )
{
SWTBotTreeItem entry = getEntry( true, path );
select( entry, wait );
}
void selectChildrenOfEntry( String[] children, String... path )
{
SWTBotTreeItem entry = getEntry( true, path );
entry.select( children );
}
ReferralDialogBot selectEntryExpectingReferralDialog( String... path )
{
SWTBotTreeItem entry = getEntry( true, path );
select( entry, false );
return new ReferralDialogBot();
}
void expandEntry( String... path )
{
SWTBotTreeItem entry = getEntry( true, path );
expand( entry, true, null );
}
void waitForEntry( String... path )
{
getEntry( true, path );
}
ReferralDialogBot expandEntryExpectingReferralDialog( String... path )
{
SWTBotTreeItem entry = getEntry( false, path );
expand( entry, false, null );
return new ReferralDialogBot();
}
String getSelectedEntry()
{
return getTree().selection().get( 0 ).get( 0 );
}
private SWTBotTreeItem getEntry( boolean wait, String... path )
{
SWTBotTree browserTree = bot.tree();
List<String> pathList = new ArrayList<String>( Arrays.asList( path ) );
SWTBotTreeItem entry = null;
while ( !pathList.isEmpty() )
{
String node = pathList.remove( 0 );
if ( entry == null )
{
node = adjustNodeName( browserTree, node );
entry = browserTree.getTreeItem( node );
}
else
{
entry = getChild( entry, node, wait );
}
if ( !pathList.isEmpty() )
{
// expand entry and wait till
// - children are displayed
// - next child is visible
final String nextNode = !pathList.isEmpty() ? pathList.get( 0 ) : null;
expand( entry, true, nextNode );
}
}
return entry;
}
private void expand( final SWTBotTreeItem entry, boolean wait, final String nextNode )
{
UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
{
public void run()
{
if ( !entry.isExpanded() )
{
entry.expand();
}
}
} );
if ( wait )
{
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
return !entry.getNodes().contains( "Fetching Entries..." )
&& !entry.getNodes().contains( "Opening Connection..." );
}
public String getFailureMessage()
{
return "Could not find entry " + entry.getText() + " -> " + nextNode;
}
} );
}
}
private void select( final SWTBotTreeItem entry, boolean wait )
{
if ( !bot.tree().isEnabled() )
{
bot.waitUntil( Conditions.widgetIsEnabled( bot.tree() ) );
}
if ( wait )
{
JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__init_entries_title_attonly,
"Open Entry Editor" );
entry.click();
entry.select();
watcher.waitUntilDone();
}
else
{
entry.click();
entry.select();
}
}
private SWTBotTreeItem getChild( SWTBotTreeItem entry, String nodeName, boolean wait )
{
// adjust current path, because the label is decorated with the number of children
if ( wait )
{
bot.waitUntil( new DefaultCondition()
{
@Override
public boolean test() throws Exception
{
String adjustedNodeName = adjustNodeName( entry, nodeName );
return adjustedNodeName != null;
}
@Override
public String getFailureMessage()
{
return "Node " + nodeName + " not found";
}
} );
}
String adjustedNodeName = adjustNodeName( entry, nodeName );
return entry.getNode( adjustedNodeName );
}
private String adjustNodeName( SWTBotTreeItem entry, String nodeName )
{
List<String> nodes = entry.getNodes();
for ( String node : nodes )
{
if ( matches( node, nodeName ) )
{
return node;
}
}
return null;
}
private String adjustNodeName( SWTBotTree tree, String nodeName )
{
SWTBotTreeItem[] allItems = tree.getAllItems();
for ( SWTBotTreeItem item : allItems )
{
String node = item.getText();
if ( matches( node, nodeName ) )
{
return node;
}
}
return nodeName;
}
private boolean matches( String candidate, String needle )
{
Pattern pattern = Pattern.compile( "(.*) \\(\\d+\\+?\\)" );
Matcher candidateMatcher = pattern.matcher( candidate );
Matcher needleMatcher = pattern.matcher( needle );
if ( candidateMatcher.matches() && !needleMatcher.matches() )
{
candidate = candidateMatcher.group( 1 );
}
return candidate.toUpperCase().equals( needle.toUpperCase() );
}
SWTBotTree getTree()
{
return bot.tree();
}
public void waitUntilEntryIsSelected( String label )
{
bot.waitUntil( new DefaultCondition()
{
@Override
public boolean test() throws Exception
{
String selectedEntry = getSelectedEntry();
return selectedEntry.equals( label );
}
@Override
public String getFailureMessage()
{
return "Entry " + label + " was not selected, but " + getSelectedEntry();
}
} );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectDnDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectDnDialogBot.java | /*
* 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 SelectDnDialogBot extends DialogBot
{
private BrowserWidgetBot browserBot;
public SelectDnDialogBot()
{
super("Select DN");
browserBot = new BrowserWidgetBot( bot );
}
public void selectEntry( String... path )
{
browserBot.selectEntry( false, path );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchLogsViewPreferencePageBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchLogsViewPreferencePageBot.java | /*
* 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 );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ObjectClassEditorBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ObjectClassEditorBot.java | /*
* 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 ObjectClassEditorBot extends BaseSchemaEditorBot
{
public ObjectClassEditorBot( String title )
{
super( title );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPropertiesDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPropertiesDialogBot.java | /*
* 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 SearchPropertiesDialogBot extends DialogBot
{
SearchPageWrapperBot searchPageWrapperBot;
public SearchPropertiesDialogBot( String searchName)
{
super( "Properties for " + searchName );
this.searchPageWrapperBot = new SearchPageWrapperBot( bot );
}
public boolean isVisible()
{
// "Properties for Search ..."
return searchPageWrapperBot.isVisible();
}
public void setSearchName( String string )
{
searchPageWrapperBot.setSearchName( string );
}
public void setFilter( String string )
{
searchPageWrapperBot.setFilter( string );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ErrorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ErrorDialogBot.java | /*
* 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;
import org.apache.commons.lang3.StringUtils;
public class ErrorDialogBot extends DialogBot
{
public ErrorDialogBot()
{
this( "Error" );
}
public ErrorDialogBot( String title )
{
super( title );
}
public String getErrorMessage()
{
// label(0) may be the image
int index = StringUtils.isBlank( bot.label( 0 ).getText() ) ? 1 : 0;
return bot.label( index ).getText();
}
public String getErrorDetails()
{
// label(0) may be the image
int index = StringUtils.isBlank( bot.label( 0 ).getText() ) ? 2 : 1;
return bot.label( index ).getText();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchDialogBot.java | /*
* 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;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
public class SearchDialogBot extends DialogBot
{
private SearchPageWrapperBot searchPageWrapperBot;
public SearchDialogBot()
{
super( "Search" );
this.searchPageWrapperBot = new SearchPageWrapperBot( bot );
}
public boolean isVisible()
{
return super.isVisible() && searchPageWrapperBot.isVisible();
}
public void setSearchName( String string )
{
searchPageWrapperBot.setSearchName( string );
}
public void setFilter( String string )
{
searchPageWrapperBot.setFilter( string );
}
public String getFilter()
{
return searchPageWrapperBot.getFilter();
}
public void setReturningAttributes( String string )
{
searchPageWrapperBot.setReturningAttributes( string );
}
public void setScope( SearchScope scope )
{
searchPageWrapperBot.setScope( scope );
}
public void setCountLimit( int countLimit )
{
searchPageWrapperBot.setCountLimit( countLimit );
}
public void setControlManageDsaIT( boolean enabled )
{
searchPageWrapperBot.setControlManageDsaIT( enabled );
}
public void setControlSubentries( boolean enabled )
{
searchPageWrapperBot.setControlSubentries( enabled );
}
public void setControlPagedSearch( boolean enabled, int pageSize, boolean scrollMode )
{
searchPageWrapperBot.setControlPagedSearch( enabled, pageSize, scrollMode );
}
public void setAliasDereferencingMode( AliasDereferencingMethod mode )
{
searchPageWrapperBot.setAliasDereferencingMode( mode );
}
public void clickSearchButton()
{
super.clickButton( "Search" );
}
public FilterEditorDialogBot openFilterEditor()
{
return searchPageWrapperBot.openFilterEditor();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectCopyDepthDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SelectCopyDepthDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class SelectCopyDepthDialogBot extends DialogBot
{
private String objectText;
private String oneLevelText;
private String subTreeText;
public SelectCopyDepthDialogBot( int numEntries )
{
super( "Select Copy Depth" );
if ( numEntries > 1 )
{
objectText = "Object (Only the copied entries)";
oneLevelText = "One Level (Only copied entries and their direct children)";
subTreeText = "Subtree (The whole subtrees)";
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__copy_entries_name_n );
}
else
{
objectText = "Object (Only the copied entry)";
oneLevelText = "One Level (Only copied entry and its direct children)";
subTreeText = "Subtree (The whole subtree)";
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__copy_entries_name_1 );
}
activate();
}
public void selectObject()
{
bot.radio( objectText ).click();
}
public void selectOneLevel()
{
bot.radio( oneLevelText ).click();
}
public void selectSubTree()
{
bot.radio( subTreeText ).click();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchResultEditorBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchResultEditorBot.java | /*
* 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;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withStyle;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withTooltip;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarPushButton;
import org.hamcrest.Matcher;
public class SearchResultEditorBot
{
private SWTBotEditor editor;
private SWTBot bot;
public SearchResultEditorBot( String title )
{
SWTWorkbenchBot bot = new SWTWorkbenchBot();
editor = bot.editorByTitle( title );
this.bot = editor.bot();
}
public boolean isEnabled()
{
return bot.table().isEnabled();
}
public void activate()
{
editor.setFocus();
bot.table().setFocus();
}
public String getContent( int row, int column )
{
return bot.table().cell( row - 1, column - 1 );
}
public void refresh()
{
JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__search_name );
//bot.toolbarButton( "Search Again (F5)" ).click();
Matcher<Widget> matcher = allOf( widgetOfType( ToolItem.class ), withTooltip( "Search Again (F5)" ), withStyle(
SWT.PUSH, "SWT.PUSH" ) );
SWTBotToolbarPushButton button = new SWTBotToolbarPushButton( ( ToolItem ) bot.widget( matcher, 0 ), matcher );
button.click();
watcher.waitUntilDone();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSServersViewBot.java | /*
* 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;
import java.util.ArrayList;
import org.apache.directory.studio.ldapservers.LdapServersManager;
import org.apache.directory.studio.ldapservers.model.LdapServer;
import org.apache.directory.studio.ldapservers.model.LdapServerStatus;
import org.apache.directory.studio.test.integration.ui.utils.ContextMenuHelper;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
public class ApacheDSServersViewBot
{
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
private SWTBotView view;
public ApacheDSServersViewBot()
{
view = new SWTWorkbenchBot().viewByTitle( "LDAP Servers" );
}
/**
* Shows the view.
*/
public void show()
{
view.show();
}
/**
* Opens the 'New Server' wizard.
*
* @return
* a bot associated with the 'New Server' wizard
*/
public NewApacheDSServerWizardBot openNewServerWizard()
{
ContextMenuHelper.clickContextMenu( getServersTree(), "New", "New &Server" );
return new NewApacheDSServerWizardBot();
}
/**
* Opens the 'LDAP Browser' > 'Create a Connection' action of the context menu.
*
* @return
* a bot associated with the dialog
*/
public ConnectionFromServerDialogBot createConnectionFromServer()
{
ContextMenuHelper.clickContextMenu( getServersTree(), "Create a Connection" );
return new ConnectionFromServerDialogBot();
}
/**
* Opens the 'Delete' dialog.
*
* @return
* a bot associated with the 'Delete' dialog
*/
public DeleteDialogBot openDeleteServerDialog()
{
ContextMenuHelper.clickContextMenu( getServersTree(), "Delete" );
return new DeleteDialogBot( DeleteDialogBot.DELETE_SERVER );
}
public ApacheDSConfigurationEditorBot openConfigurationEditor( String serverName )
{
selectServer( serverName );
ContextMenuHelper.clickContextMenu( getServersTree(), "Open Configuration" );
return new ApacheDSConfigurationEditorBot( "ou=config.ldif" );
}
/**
* Gets the tree associated with the 'Servers' view.
*
* @return
* the tree associated with the 'Servers' view
*/
private SWTBotTree getServersTree()
{
view.show();
SWTBotTree tree = view.bot().tree();
return tree;
}
/**
* Selects the server associated with the given name.
*
* @param serverName
* the name of the server
*/
public void selectServer( String serverName )
{
getServersTree().select( serverName );
}
/**
* Starts the server associated with the given name.
*
* @param serverName
* the name of the server
*/
public void runServer( String serverName )
{
selectServer( serverName );
ContextMenuHelper.clickContextMenu( getServersTree(), "&Run" );
}
/**
* Repairs the server associated with the given name.
*
* @param serverName
* the name of the server
*/
public void repairServer( String serverName )
{
selectServer( serverName );
ContextMenuHelper.clickContextMenu( getServersTree(), "Repair" );
}
/**
* Stops the server associated with the given name.
*
* @param serverName
* the name of the server
*/
public void stopServer( String serverName )
{
selectServer( serverName );
ContextMenuHelper.clickContextMenu( getServersTree(), "S&top" );
}
/**
* Waits until the server associated with the given name appears in
* the 'servers' view.
*
* @param serverName
* the name of the server
*/
public void waitForServer( final String serverName )
{
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
for ( SWTBotTreeItem item : getServersTree().getAllItems() )
{
String text = item.getText();
if ( text.startsWith( serverName ) )
{
return true;
}
}
return false;
}
public String getFailureMessage()
{
return "Server " + serverName + " not visible in servers view.";
}
} );
}
/**
* Waits until the server associated with the given name is started.
*
* @param serverName
* the server name
*/
public void waitForServerStart( final String serverName )
{
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
LdapServer server = getServer( serverName );
if ( server != null )
{
return ( LdapServerStatus.STARTED == server.getStatus() );
}
return false;
}
public String getFailureMessage()
{
return "Server " + serverName + " not started in servers view.";
}
}, SWTBotPreferences.TIMEOUT * 20 );
}
/**
* Waits until the server associated with the given name is stopped.
*
* @param serverName
* the name of the server
*/
public void waitForServerStop( final String serverName )
{
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
LdapServer server = getServer( serverName );
if ( server != null )
{
return ( LdapServerStatus.STOPPED == server.getStatus() );
}
return false;
}
public String getFailureMessage()
{
return "Server " + serverName + " not stopped in servers view.";
}
}, SWTBotPreferences.TIMEOUT * 10 );
// Wait a bit more to avoid unknown race conditions...
BotUtils.sleep( 1000 );
}
/**
* Gets the server associated with the given name.
*
* @param serverName
* the name of the server
* @return
* the server associated with the given name,
* or <code>null</code> if none was found.
*/
private LdapServer getServer( String serverName )
{
for ( LdapServer server : LdapServersManager.getDefault().getServersList() )
{
if ( serverName.equals( server.getName() ) )
{
return server;
}
}
return null;
}
/**
* Gets the servers count found in the 'Servers' view.
*
* @return
* the servers count found in the 'Servers' view
*/
public int getServersCount()
{
SWTBotTree tree = getServersTree();
if ( tree != null )
{
return tree.rowCount();
}
return 0;
}
public void deleteTestServers()
{
LdapServersManager ldapServersManager = LdapServersManager.getDefault();
for ( LdapServer server : new ArrayList<>( ldapServersManager.getServersList() ) )
{
ldapServersManager.removeServer( server );
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ShowViewsBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ShowViewsBot.java | /*
* 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;
import org.apache.directory.studio.test.integration.ui.utils.TreeBot;
public class ShowViewsBot extends DialogBot
{
public ShowViewsBot()
{
super( "Show View" );
}
public boolean existsCategory( String category )
{
TreeBot treeBot = new TreeBot( bot.tree() );
return treeBot.exists( category );
}
public boolean existsView( String category, String view )
{
TreeBot treeBot = new TreeBot( bot.tree() );
return treeBot.exists( category, view );
}
public void openView( String category, String view )
{
bot.tree().expandNode( category ).select( view );
clickButton( "Open" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ProgressViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ProgressViewBot.java | /*
* 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;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
public class ProgressViewBot
{
private SWTWorkbenchBot bot;
private SWTBotView view;
public ProgressViewBot()
{
bot = new SWTWorkbenchBot();
view = bot.viewByTitle( "Progress" );
}
public void removeAllFinishedOperations()
{
view.toolbarPushButton( "Remove All Finished Operations" ).click();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSConfigurationEditorBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ApacheDSConfigurationEditorBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.apache.mina.util.AvailablePortFinder;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotMultiPageEditor;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCheckBox;
public class ApacheDSConfigurationEditorBot
{
private SWTBotMultiPageEditor editor;
public ApacheDSConfigurationEditorBot( String title )
{
SWTWorkbenchBot bot = new SWTWorkbenchBot();
editor = bot.multipageEditorByTitle( title );
bot.waitUntil( new DefaultCondition()
{
@Override
public boolean test() throws Exception
{
return editor.getPageCount() > 5;
}
@Override
public String getFailureMessage()
{
return "ApacheDS configuration editor not ready";
}
} );
}
public void setAvailablePorts()
{
int port = 1023;
if ( isLdapServerEnabled() )
{
port = AvailablePortFinder.getNextAvailable( port + 1 );
setLdapPort( port );
}
if ( isLdapsServerEnabled() )
{
port = AvailablePortFinder.getNextAvailable( port + 1 );
setLdapsPort( port );
}
if ( isKerberosServerEnabled() )
{
port = AvailablePortFinder.getNextAvailable( port + 1 );
setKerberosPort( port );
}
}
public boolean isLdapServerEnabled()
{
activateLdapLdapsServersPage();
return editor.bot().checkBox( 0 ).isChecked();
}
public void setLdapPort( int port )
{
activateLdapLdapsServersPage();
editor.bot().text( 0 ).setText( "" + port );
}
public int getLdapPort()
{
activateLdapLdapsServersPage();
return Integer.parseInt( editor.bot().text( 0 ).getText() );
}
public void setLdapAddress( String address )
{
activateLdapLdapsServersPage();
editor.bot().text( 1 ).setText( address );
}
public boolean isLdapsServerEnabled()
{
activateLdapLdapsServersPage();
return editor.bot().checkBox( 1 ).isChecked();
}
public void setLdapsPort( int port )
{
activateLdapLdapsServersPage();
editor.bot().text( 4 ).setText( "" + port );
}
public int getLdapsPort()
{
activateLdapLdapsServersPage();
return Integer.parseInt( editor.bot().text( 4 ).getText() );
}
public void setLdapsAddress( String address )
{
activateLdapLdapsServersPage();
editor.bot().text( 5 ).setText( address );
}
public void setKeystore( String keyStoreFilePath, String keyStorePassword )
{
activateLdapLdapsServersPage();
editor.bot().text( 11 ).setText( keyStoreFilePath );
editor.bot().text( 12 ).setText( keyStorePassword );
}
public void enableSSLv3()
{
activateLdapLdapsServersPage();
editor.bot().checkBox( 5 ).select();
}
public boolean isSSLv3Enabled()
{
activateLdapLdapsServersPage();
return editor.bot().checkBox( 5 ).isChecked();
}
public void enableTLSv1()
{
activateLdapLdapsServersPage();
editor.bot().checkBox( 6 ).select();
}
public boolean isTLSv1Enabled()
{
activateLdapLdapsServersPage();
return editor.bot().checkBox( 6 ).isChecked();
}
public void enableTLSv1_1()
{
activateLdapLdapsServersPage();
editor.bot().checkBox( 7 ).select();
}
public boolean isTLSv1_1Enabled()
{
activateLdapLdapsServersPage();
return editor.bot().checkBox( 7 ).isChecked();
}
public void enableTLSv1_2()
{
activateLdapLdapsServersPage();
editor.bot().checkBox( 8 ).select();
}
public boolean isTLSv1_2Enabled()
{
activateLdapLdapsServersPage();
return editor.bot().checkBox( 8 ).isChecked();
}
public void setSaslHost( String saslHost )
{
activateLdapLdapsServersPage();
editor.bot().text( 15 ).setText( saslHost );
}
public void setSaslPrincipal( String saslPrincipal )
{
activateLdapLdapsServersPage();
editor.bot().text( 16 ).setText( saslPrincipal );
}
public void setSaslSearchBase( String saslSearchBase )
{
activateLdapLdapsServersPage();
editor.bot().text( 17 ).setText( saslSearchBase );
}
public void enableKerberosServer()
{
activateKerberosServerPage();
editor.bot().checkBox( 0 ).select();
}
public boolean isKerberosServerEnabled()
{
activateKerberosServerPage();
return editor.bot().checkBox( 0 ).isChecked();
}
public void setKerberosPort( int port )
{
activateKerberosServerPage();
editor.bot().text( 0 ).setText( "" + port );
}
public void setKerberosAddress( String address )
{
activateKerberosServerPage();
editor.bot().text( 1 ).setText( address );
}
public int getKerberosPort()
{
activateKerberosServerPage();
return Integer.parseInt( editor.bot().text( 0 ).getText() );
}
public void setKdcRealm( String kdcRealm )
{
activateKerberosServerPage();
editor.bot().text( 4 ).setText( kdcRealm );
}
public void setKdcSearchBase( String kdcSearchBase )
{
activateKerberosServerPage();
editor.bot().text( 5 ).setText( kdcSearchBase );
}
public void setRequirePreAuthenticationByEncryptedTimestamp( boolean enable )
{
activateKerberosServerPage();
SWTBotCheckBox checkBox = editor.bot().checkBox( 5 );
if ( enable )
{
checkBox.select();
}
else
{
checkBox.deselect();
}
}
public void save()
{
JobWatcher watcher = new JobWatcher( "Save Configuration" );
editor.save();
watcher.waitUntilDone();
}
public void close()
{
editor.close();
}
private void activateLdapLdapsServersPage()
{
editor.activatePage( "LDAP/LDAPS Servers" );
}
private void activateKerberosServerPage()
{
editor.activatePage( "Kerberos Server" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewWizardBot.java | /*
* 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;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
public class NewWizardBot extends WizardBot
{
public NewWizardBot()
{
super( "Select a wizard" );
}
public void selectLdifFile()
{
select( "LDAP Browser", "LDIF File" );
}
public void select( String parent, String child )
{
SWTBotTree tree = bot.tree();
tree.expandNode( parent ).select( child );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordEditorDialogBot.java | /*
* 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;
import org.apache.directory.api.ldap.model.constants.LdapSecurityConstants;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class PasswordEditorDialogBot extends DialogBot
{
public PasswordEditorDialogBot()
{
super( "Password Editor" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name );
}
public void setNewPassword1( String password )
{
bot.text( 0 ).setText( password );
}
public void setNewPassword2( String password )
{
bot.text( 1 ).setText( password );
}
public String getPasswordPreview()
{
return bot.text( 2 ).getText();
}
public void selectHashMethod( LdapSecurityConstants hashMethod )
{
bot.comboBox().setSelection( hashMethod.getName() );
}
public String getPasswordHex()
{
return bot.text( 3 ).getText();
}
public String getSaltHex()
{
return bot.text( 4 ).getText();
}
public void setShowNewPasswordDetails( boolean selected )
{
if ( selected )
{
bot.checkBox().select();
}
else
{
bot.checkBox().deselect();
}
}
public void activateCurrentPasswordTab()
{
bot.tabItem( "Current Password" ).activate();
}
public void activateNewPasswordTab()
{
bot.tabItem( "New Password" ).activate();
}
public void setVerifyPassword( String password )
{
bot.text( 4 ).setText( password );
}
public String clickVerifyButton()
{
CheckResponse checkResponse = clickCheckButton( "Verify", "Password Verification" );
return checkResponse.isError() ? checkResponse.getMessage() : null;
}
public String clickBindButton()
{
CheckResponse checkResponse = clickCheckButton( "Bind", "Check Authentication" );
return checkResponse.isError() ? checkResponse.getMessage() : null;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ModificationLogsViewPreferencePageBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ModificationLogsViewPreferencePageBot.java | /*
* 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 );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateValidationPreferencePageBot.java | /*
* 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 PreferencePageBot
{
private static final String VALIDATE_CERTIFICATES_FOR_SECURE_LDAP_CONNECTIONS = "Validate certificates for secure LDAP connections";
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();
}
}
public void activatePermanentTab()
{
bot.tabItem( "Permanent Trusted" ).activate();
}
public void activateTemporaryTab()
{
bot.tabItem( "Temporary Trusted" ).activate();
}
public int getCertificateCount()
{
return bot.table().rowCount();
}
public void selectCertificate( int index )
{
bot.table().select( index );
}
public CertificateViewerDialogBot clickViewButton()
{
clickButton( "View..." );
return new CertificateViewerDialogBot();
}
public void clickRemoveButton()
{
clickButton( "Remove" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SubtreeSpecificationEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SubtreeSpecificationEditorDialogBot.java | /*
* 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 SubtreeSpecificationEditorDialogBot extends DialogBot
{
public SubtreeSpecificationEditorDialogBot()
{
super( "Subtree Editor" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionFromServerDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ConnectionFromServerDialogBot.java | /*
* 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 ConnectionFromServerDialogBot extends DialogBot
{
private static final String TITLE = "Connection created";
public ConnectionFromServerDialogBot()
{
super( TITLE );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/FilterEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/FilterEditorDialogBot.java | /*
* 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 FilterEditorDialogBot extends DialogBot
{
public FilterEditorDialogBot()
{
super( "Filter Editor" );
}
public void setFilter( String filter )
{
bot.styledText().setText( filter );
}
public String getFilter()
{
return bot.styledText().getText();
}
public void clickFormatButton()
{
super.clickButton( "Format" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EntryEditorWidgetBot.java | /*
* 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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.ContextMenuHelper;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.keyboard.Keystrokes;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
/**
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
*/
class EntryEditorWidgetBot
{
private SWTBot bot;
EntryEditorWidgetBot( SWTBot bot )
{
this.bot = bot;
}
boolean isVisisble()
{
return bot.tree() != null;
}
List<String> getAttributeValues()
{
SWTBotTree tree = bot.tree();
List<String> attributes = new ArrayList<String>();
int rowCount = tree.rowCount();
for ( int i = 0; i < rowCount; i++ )
{
String attribute = tree.cell( i, 0 );
String value = tree.cell( i, 1 );
attributes.add( attribute + ": " + value );
}
return attributes;
}
NewAttributeWizardBot openNewAttributeWizard()
{
ContextMenuHelper.clickContextMenu( bot.tree(), "New Attribute..." );
return new NewAttributeWizardBot();
}
void typeValueAndFinish( String value, boolean wait )
{
SWTBotText text = bot.text( 1 );
text.setText( value );
if ( wait )
{
JobWatcher jobWatcher = new JobWatcher( BrowserCoreMessages.jobs__execute_ldif_name );
bot.tree().pressShortcut( Keystrokes.LF );
jobWatcher.waitUntilDone();
}
else
{
bot.tree().pressShortcut( Keystrokes.LF );
}
}
public ErrorDialogBot typeValueAndFinishAndExpectErrorDialog( String value )
{
String shellText = BotUtils.shell( () -> typeValueAndFinish( value, false ), "Error" ).getText();
return new ErrorDialogBot( shellText );
}
void cancelEditValue()
{
SWTBotTree tree = bot.tree( 0 );
// TODO: Workaround for DIRAPI-228/DIRAPI-229
//tree.getTreeItem( "objectClass" ).click();
SWTBotTreeItem[] allItems = tree.getAllItems();
for ( SWTBotTreeItem item : allItems )
{
if ( "objectclass".equalsIgnoreCase( item.getText() ) )
{
item.click();
return;
}
}
}
void addValue( String attributeType )
{
SWTBotTree tree = bot.tree();
tree.getTreeItem( attributeType ).click();
ContextMenuHelper.clickContextMenu( bot.tree(), "New Value" );
}
EditAttributeWizardBot editAttribute( String attributeType, String value )
{
cancelEditValue();
SWTBotTreeItem treeItem = getTreeItem( attributeType, value );
treeItem.select();
ContextMenuHelper.clickContextMenu( bot.tree(), "Edit Attribute Description" );
return new EditAttributeWizardBot();
}
void editValue( String attributeType, String value )
{
cancelEditValue();
SWTBotTreeItem treeItem = getTreeItem( attributeType, value );
treeItem.doubleClick();
}
void editValueWith( String attributeType, String value, String valueEditorLabel )
{
cancelEditValue();
SWTBotTreeItem treeItem = getTreeItem( attributeType, value );
treeItem.select();
ContextMenuHelper.clickContextMenu( bot.tree(), "Edit Value With", valueEditorLabel );
}
DnEditorDialogBot editValueExpectingDnEditor( String attributeType, String value )
{
editValue( attributeType, value );
return new DnEditorDialogBot();
}
PasswordEditorDialogBot editValueExpectingPasswordEditor( String attributeType, String value )
{
editValue( attributeType, value );
return new PasswordEditorDialogBot();
}
AciItemEditorDialogBot editValueExpectingAciItemEditor( String attributeType, String value )
{
editValue( attributeType, value );
return new AciItemEditorDialogBot();
}
SubtreeSpecificationEditorDialogBot editValueExpectingSubtreeSpecificationEditor( String attributeType,
String value )
{
editValue( attributeType, value );
return new SubtreeSpecificationEditorDialogBot();
}
CertificateEditorDialogBot editValueExpectingCertificateEditor( String attributeType, String value )
{
editValue( attributeType, value );
return new CertificateEditorDialogBot();
}
HexEditorDialogBot editValueExpectingHexEditor( String attributeType, String value )
{
editValue( attributeType, value );
return new HexEditorDialogBot();
}
AddressEditorDialogBot editValueExpectingAddressEditor( String attributeType, String value )
{
editValue( attributeType, value );
return new AddressEditorDialogBot();
}
TextEditorDialogBot editValueWithTextEditor( String attributeType, String value )
{
editValueWith( attributeType, value, "^Text Editor$" );
return new TextEditorDialogBot();
}
private SWTBotTreeItem getTreeItem( String attributeType, String value )
{
SWTBotTree tree = bot.tree();
SWTBotTreeItem[] allItems = tree.getAllItems();
for ( SWTBotTreeItem item : allItems )
{
if ( item.cell( 0 ).equalsIgnoreCase( attributeType )
&& ( value == null || item.cell( 1 ).equals( value ) ) )
{
return item;
}
}
throw new WidgetNotFoundException( "Attribute " + attributeType + ":" + value + " not found." );
}
private List<SWTBotTreeItem> getTreeItems( String... attributeTypes )
{
List<String> attributeTypeList = Arrays.asList( attributeTypes );
List<SWTBotTreeItem> items = new ArrayList<>();
SWTBotTree tree = bot.tree();
SWTBotTreeItem[] allItems = tree.getAllItems();
for ( SWTBotTreeItem item : allItems )
{
if ( attributeTypeList.contains( item.cell( 0 ) ) )
{
items.add( item );
}
}
return items;
}
void deleteValue( String attributeType, String value )
{
SWTBotTreeItem treeItem = getTreeItem( attributeType, value );
treeItem.select();
ContextMenuHelper.clickContextMenu( bot.tree(), "Delete Value" );
DeleteDialogBot deleteDialogBot = new DeleteDialogBot( DeleteDialogBot.DELETE_VALUE_TITLE );
deleteDialogBot.clickOkButton();
}
public ErrorDialogBot deleteValueExpectingErrorDialog( String attributeType, String value )
{
SWTBotTreeItem treeItem = getTreeItem( attributeType, value );
treeItem.select();
ContextMenuHelper.clickContextMenu( bot.tree(), "Delete Value" );
DeleteDialogBot deleteDialogBot = new DeleteDialogBot( DeleteDialogBot.DELETE_VALUE_TITLE );
return deleteDialogBot.clickOkButtonExpectingErrorDialog();
}
public void copyValue( String attributeType, String value )
{
SWTBotTreeItem treeItem = getTreeItem( attributeType, value );
treeItem.select();
ContextMenuHelper.clickContextMenu( bot.tree(), "Copy Value" );
}
public void copyValues( String... attributeTypes )
{
List<SWTBotTreeItem> items = getTreeItems( attributeTypes );
bot.tree().select( items.toArray( new SWTBotTreeItem[0] ) );
ContextMenuHelper.clickContextMenu( bot.tree(), "Copy Values" );
}
public void pasteValue()
{
ContextMenuHelper.clickContextMenu( bot.tree(), "Paste Value" );
}
public void pasteValues()
{
ContextMenuHelper.clickContextMenu( bot.tree(), "Paste Values" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordModifyExtendedOperationDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordModifyExtendedOperationDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class PasswordModifyExtendedOperationDialogBot extends DialogBot
{
public PasswordModifyExtendedOperationDialogBot()
{
super( "Password Modify Extended Operation (RFC 3062)" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__extended_operation_name );
}
public String getUserIdentity()
{
return bot.comboBox().getText();
}
public void setUserIdentity( String text )
{
bot.comboBox().setText( text );
}
public boolean useBindUserIdentity()
{
return bot.checkBox( 0 ).isChecked();
}
public void useBindUserIdentity( boolean selected )
{
if ( selected )
{
bot.checkBox( 0 ).select();
}
else
{
bot.checkBox( 0 ).deselect();
}
}
public String getOldPassword()
{
return bot.text( 0 ).getText();
}
public void setOldPassword( String text )
{
bot.text( 0 ).setText( text );
}
public boolean noOldPassword()
{
return bot.checkBox( 1 ).isChecked();
}
public void noOldPassword( boolean selected )
{
if ( selected )
{
bot.checkBox( 1 ).select();
}
else
{
bot.checkBox( 1 ).deselect();
}
}
public String getNewPassword()
{
return bot.text( 1 ).getText();
}
public void setNewPassword( String text )
{
bot.text( 1 ).setText( text );
}
public boolean generateNewPassword()
{
return bot.checkBox( 2 ).isChecked();
}
public void generateNewPassword( boolean selected )
{
if ( selected )
{
bot.checkBox( 2 ).select();
}
else
{
bot.checkBox( 2 ).deselect();
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/TextEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/TextEditorDialogBot.java | /*
* 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 TextEditorDialogBot extends DialogBot
{
public TextEditorDialogBot()
{
super( "Text Editor" );
}
public void setText( String text )
{
bot.text( 0 ).setText( text );
}
} | java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaViewBot.java | /*
* 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;
import java.util.Arrays;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
public class SchemaViewBot
{
private static final String ATTRIBUTE_TYPES = "Attribute Types";
private static final String OBJECT_CLASSES = "Object Classes";
private SWTWorkbenchBot bot = new SWTWorkbenchBot();
public SchemaViewBot()
{
SWTBotView view = bot.viewByTitle( "Schema" );
view.show();
}
private SWTBotTree getSchemaTree()
{
SWTBotView view = bot.viewByTitle( "Schema" );
view.show();
SWTBotTree tree = view.bot().tree();
return tree;
}
public boolean existsSchema( String schema )
{
SWTBotTreeItem item = getSchemaTree().getTreeItem( schema );
return true;
}
public void selectObjectClass( String schema, String objectClass )
{
selectSchemaElement( schema, OBJECT_CLASSES, objectClass );
}
public void selectAttributeType( String schema, String attributeType )
{
selectSchemaElement( schema, ATTRIBUTE_TYPES, attributeType );
}
private void selectSchemaElement( String schema, String type, String schemaElement )
{
SWTBotTreeItem item = getSchemaElementTreeItem( schema, type, schemaElement );
item.select();
}
public boolean existsObjectClass( String schema, String objectClass )
{
return existsSchemaElement( schema, OBJECT_CLASSES, objectClass );
}
public boolean existsAttributeType( String schema, String attributeType )
{
return existsSchemaElement( schema, ATTRIBUTE_TYPES, attributeType );
}
private boolean existsSchemaElement( String schema, String type, String schemaElement )
{
SWTBotTreeItem item = getSchemaElementTreeItem( schema, type, schemaElement );
return item != null;
}
private SWTBotTreeItem getSchemaElementTreeItem( String schema, String type, String schemaElement )
{
SWTBotTreeItem schemaItem = getSchemaTree().getTreeItem( schema );
schemaItem.expand();
SWTBotTreeItem[] typeItems = schemaItem.getItems();
for ( SWTBotTreeItem typeItem : typeItems )
{
if ( typeItem.getText().startsWith( type ) )
{
typeItem.expand();
SWTBotTreeItem[] elementItems = typeItem.getItems();
for ( SWTBotTreeItem elementItem : elementItems )
{
if ( elementItem.getText().startsWith( schemaElement + " [" ) )
{
return elementItem;
}
}
}
}
return null;
}
public ObjectClassEditorBot openObjectClassEditor( String schema, String objectClass )
{
selectObjectClass( schema, objectClass );
getSchemaTree().contextMenu( "Open" ).click();
return new ObjectClassEditorBot( objectClass );
}
public AttributeTypeEditorBot openAttributeTypeEditor( String schema, String attributeType )
{
selectAttributeType( schema, attributeType );
getSchemaTree().contextMenu( "Open" ).click();
return new AttributeTypeEditorBot( attributeType );
}
public SchemaEditorBot openSchemaEditor( String schema )
{
getSchemaTree().select( schema ).contextMenu( "Open" ).click();
return new SchemaEditorBot( schema );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ModificationLogsViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ModificationLogsViewBot.java | /*
* 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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.directory.studio.ldifparser.LdifFormatParameters;
import org.apache.directory.studio.ldifparser.LdifParserConstants;
import org.apache.directory.studio.ldifparser.model.LdifFile;
import org.apache.directory.studio.ldifparser.model.container.LdifCommentContainer;
import org.apache.directory.studio.ldifparser.model.container.LdifContainer;
import org.apache.directory.studio.ldifparser.parser.LdifParser;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
public class ModificationLogsViewBot extends AbstractLogsViewBot
{
public ModificationLogsViewBot()
{
super( "Modification Logs" );
}
public String getModificationLogsText()
{
return super.getLogsText();
}
public void enableModificationLogs( boolean b )
{
view.show();
SWTBotMenu menuItem = view.viewMenu( "Enable Modification Logs" );
if ( menuItem.isChecked() != b )
{
menuItem.click();
}
}
public void assertContainsOk( String... lines )
{
List<String> parts = new ArrayList<>();
parts.add( "#!RESULT OK" );
parts.addAll( Arrays.asList( lines ) );
assertContains( parts );
}
public void assertContainsError( String... lines )
{
List<String> parts = new ArrayList<>();
parts.add( "#!RESULT ERROR" );
parts.addAll( Arrays.asList( lines ) );
assertContains( parts );
}
private void assertContains( List<String> parts )
{
String text = getModificationLogsText();
LdifFile ldif = new LdifParser().parse( text );
Iterator<LdifContainer> ldifContainers = ldif.getContainers().iterator();
while ( ldifContainers.hasNext() )
{
LdifContainer container = ldifContainers.next();
LdifFormatParameters ldifFormatParameters = new LdifFormatParameters( true, 1024,
LdifParserConstants.LINE_SEPARATOR );
String ldifRecordText = container.toFormattedString( ldifFormatParameters );
if ( container instanceof LdifCommentContainer )
{
LdifContainer record = ldifContainers.next();
ldifRecordText += record.toFormattedString( ldifFormatParameters );
}
if ( containsAll( ldifRecordText, parts ) )
{
return;
}
}
throw new AssertionError( "Expected to find all parts " + parts + " in\n" + text );
}
private boolean containsAll( String ldifRecordText, List<String> parts )
{
for ( String part : parts )
{
if ( !ldifRecordText.contains( part ) )
{
return false;
}
}
return true;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EditAttributeWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/EditAttributeWizardBot.java | /*
* 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 EditAttributeWizardBot extends WizardBot
{
public EditAttributeWizardBot()
{
super( "Edit Attribute Description" );
}
public void typeAttributeType( String text )
{
bot.comboBox().setText( text );
}
public void setLanguageTag( String lang, String country )
{
bot.comboBox( 0 ).setText( lang );
bot.comboBox( 1 ).setText( country );
}
public void selectBinaryOption()
{
bot.checkBox().select();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchLogsViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchLogsViewBot.java | /*
* 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;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
public class SearchLogsViewBot extends AbstractLogsViewBot
{
public SearchLogsViewBot()
{
super( "Search Logs" );
}
public String getSearchLogsText()
{
return super.getLogsText();
}
public void enableSearchRequestLogs( boolean b )
{
view.show();
SWTBotMenu menuItem = view.viewMenu( "Enable Search Request Logs" );
if ( menuItem.isChecked() != b )
{
menuItem.click();
}
}
public void enableSearchResultEntryLogs( boolean b )
{
view.show();
SWTBotMenu menuItem = view.viewMenu( "Enable Search Result Entry Logs (!)" );
if ( menuItem.isChecked() != b )
{
menuItem.click();
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BrowserViewBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.ContextMenuHelper;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
public class BrowserViewBot
{
private SWTWorkbenchBot bot;
private BrowserWidgetBot browserBot;
public BrowserViewBot()
{
bot = new SWTWorkbenchBot();
SWTBotView view = bot.viewByTitle( "LDAP Browser" );
view.show();
browserBot = new BrowserWidgetBot( view.bot() );
}
public String getSelectedEntry()
{
return browserBot.getSelectedEntry();
}
public boolean existsEntry( String... path )
{
return browserBot.existsEntry( path );
}
public void selectEntry( String... path )
{
boolean wait = !path[path.length - 1].startsWith( "Quick Search" )
&& !path[path.length - 1].equals( "No Results" )
&& !"Searches".equals( path[0] );
browserBot.selectEntry( wait, path );
}
public void selectChildrenOfEntry( String[] children, String... path )
{
browserBot.selectChildrenOfEntry( children, path );
}
public ReferralDialogBot selectEntryExpectingReferralDialog( String... path )
{
return browserBot.selectEntryExpectingReferralDialog( path );
}
public void selectAndExpandEntry( String... path )
{
selectEntry( path );
expandEntry( path );
}
public void expandEntry( String... path )
{
browserBot.expandEntry( path );
}
public void waitForEntry( String... path )
{
browserBot.waitForEntry( path );
}
public ReferralDialogBot expandEntryExpectingReferralDialog( String... path )
{
return browserBot.expandEntryExpectingReferralDialog( path );
}
public NewEntryWizardBot openNewEntryWizard()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "New", "New Entry..." );
return new NewEntryWizardBot();
}
public SearchDialogBot openSearchDialog()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "New", "New Search..." );
return new SearchDialogBot();
}
public RenameEntryDialogBot openRenameDialog()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Rename Entry..." );
return new RenameEntryDialogBot();
}
public MoveEntriesDialogBot openMoveEntryDialog()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Move Entry..." );
return new MoveEntriesDialogBot();
}
public DeleteDialogBot openDeleteDialog()
{
if ( browserBot.getTree().selectionCount() == 1 )
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Delete Entry" );
return new DeleteDialogBot( DeleteDialogBot.DELETE_ENTRY_TITLE );
}
else
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Delete Entries" );
return new DeleteDialogBot( DeleteDialogBot.DELETE_ENTRIES_TITLE );
}
}
public ExportWizardBot openExportLdifWizard()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Export", "LDIF Export..." );
return new ExportWizardBot( ExportWizardBot.EXPORT_LDIF_TITLE );
}
public ExportWizardBot openExportDsmlWizard()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Export", "DSML Export..." );
return new ExportWizardBot( ExportWizardBot.EXPORT_DSML_TITLE );
}
public ExportWizardBot openExportCsvWizard()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Export", "CSV Export..." );
return new ExportWizardBot( ExportWizardBot.EXPORT_CSV_TITLE );
}
public ImportWizardBot openImportLdifWizard()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Import", "LDIF Import..." );
return new ImportWizardBot( ImportWizardBot.IMPORT_LDIF_TITLE );
}
public ImportWizardBot openImportDsmlWizard()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Import", "DSML Import..." );
return new ImportWizardBot( ImportWizardBot.IMPORT_DSML_TITLE );
}
public void refresh()
{
JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__init_entries_title_subonly );
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Reload Entry" );
watcher.waitUntilDone();
}
public void copy()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Copy" );
}
public void paste()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Paste" );
}
public void pasteEntry()
{
pasteEntries( 1 );
}
public void pasteEntries( int numEntries )
{
if ( numEntries > 1 )
{
JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__copy_entries_name_n );
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Paste" );
watcher.waitUntilDone();
}
else
{
JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__copy_entries_name_1 );
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Paste" );
watcher.waitUntilDone();
}
}
public SelectCopyDepthDialogBot pasteEntriesExpectingSelectCopyDepthDialog( int numEntries )
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Paste" );
return new SelectCopyDepthDialogBot( numEntries );
}
public SelectCopyStrategyBot pasteEntriesExpectingSelectCopyStrategy()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Paste" );
return new SelectCopyStrategyBot();
}
public SearchPropertiesDialogBot pasteSearch( String searchName )
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Paste" );
return new SearchPropertiesDialogBot( searchName );
}
public PasswordModifyExtendedOperationDialogBot openPasswordModifyExtendedOperationDialog()
{
ContextMenuHelper.clickContextMenu( browserBot.getTree(), "Extended Operations", "Password Modify..." );
return new PasswordModifyExtendedOperationDialogBot();
}
public void typeQuickSearchAttributeType( String attributeType )
{
bot.comboBox( 0 ).setText( attributeType );
}
public void typeQuickSearchValue( String value )
{
bot.comboBox( 2 ).setText( value );
}
public void clickRunQuickSearchButton()
{
bot.buttonWithTooltip( "Run Quick Search" ).click();
}
public boolean isQuickSearchEnabled()
{
return bot.comboBox( 0 ).isEnabled();
}
public void waitUntilEntryIsSelected( String label )
{
browserBot.waitUntilEntryIsSelected( label );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewAttributeWizardBot.java | /*
* 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 NewAttributeWizardBot extends WizardBot
{
public NewAttributeWizardBot()
{
super( "New Attribute" );
}
public void typeAttributeType( String text )
{
bot.comboBox().setText( text );
}
public void setLanguageTag( String lang, String country )
{
bot.comboBox( 0 ).setText( lang );
bot.comboBox( 1 ).setText( country );
}
public void selectBinaryOption()
{
bot.checkBox().select();
}
public DnEditorDialogBot clickFinishButtonExpectingDnEditor()
{
clickFinishButton();
return new DnEditorDialogBot();
}
public PasswordEditorDialogBot clickFinishButtonExpectingPasswordEditor()
{
clickFinishButton();
return new PasswordEditorDialogBot();
}
public ImageEditorDialogBot clickFinishButtonExpectingImageEditor()
{
clickFinishButton();
return new ImageEditorDialogBot();
}
public CertificateEditorDialogBot clickFinishButtonExpectingCertificateEditor()
{
clickFinishButton();
return new CertificateEditorDialogBot();
}
public HexEditorDialogBot clickFinishButtonExpectingHexEditor()
{
clickFinishButton();
return new HexEditorDialogBot();
}
public AddressEditorDialogBot clickFinishButtonExpectingAddressEditor()
{
clickFinishButton();
return new AddressEditorDialogBot();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AttributeTypeEditorBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AttributeTypeEditorBot.java | /*
* 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 AttributeTypeEditorBot extends BaseSchemaEditorBot
{
public AttributeTypeEditorBot( String title )
{
super( title );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ImportWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ImportWizardBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
public class ImportWizardBot extends WizardBot
{
public static final String IMPORT_LDIF_TITLE = "LDIF Import";
public static final String IMPORT_DSML_TITLE = "DSML Import";
private String title;
public ImportWizardBot()
{
this( "Import" );
}
public ImportWizardBot( String title )
{
super( title );
this.title = title;
}
public void typeFile( String file )
{
bot.comboBox().setText( file );
}
@Override
public void clickFinishButton()
{
JobWatcher watcher = null;
if ( IMPORT_LDIF_TITLE.equals( title ) )
{
watcher = new JobWatcher( BrowserCoreMessages.jobs__import_ldif_name );
}
else if ( IMPORT_DSML_TITLE.equals( title ) )
{
watcher = new JobWatcher( BrowserCoreMessages.jobs__import_dsml_name );
}
super.clickFinishButton();
if ( watcher != null )
{
watcher.waitUntilDone();
}
}
public void setContinueOnError( boolean enabled )
{
if ( enabled )
{
bot.checkBox( "Continue on error" ).select();
}
else
{
bot.checkBox( "Continue on error" ).deselect();
}
}
public void setUpdateExistingEntries( boolean enabled )
{
if ( enabled )
{
bot.checkBox( "Update existing entries" ).select();
}
else
{
bot.checkBox( "Update existing entries" ).deselect();
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ExportConnectionsWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/ExportConnectionsWizardBot.java | /*
* 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 ExportConnectionsWizardBot extends WizardBot
{
public ExportConnectionsWizardBot()
{
super( "Connections Export" );
}
public void typeFile( String file )
{
bot.comboBox().setText( file );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/KeepConnectionsPasswordsDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/KeepConnectionsPasswordsDialogBot.java | /*
* 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 KeepConnectionsPasswordsDialogBot extends DialogBot
{
public KeepConnectionsPasswordsDialogBot()
{
super( "Keep Connections Passwords?" );
}
public VerifyMasterPasswordDialogBot clickYesButtonExpectingVerifyMasterPasswordDialog()
{
clickButton( "Yes" );
return new VerifyMasterPasswordDialogBot();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewEntryWizardBot.java | /*
* 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;
import org.apache.directory.api.ldap.model.name.Dn;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
public class NewEntryWizardBot extends WizardBot
{
private static final String TITLE = "New Entry";
private EntryEditorWidgetBot widgetBot;
public NewEntryWizardBot()
{
super( TITLE );
this.widgetBot = new EntryEditorWidgetBot( bot );
}
@Override
public void clickFinishButton()
{
JobWatcher watcher = new JobWatcher( BrowserCoreMessages.jobs__create_entry_name_1 );
super.clickFinishButton();
watcher.waitUntilDone();
}
public void selectCreateEntryFromScratch()
{
bot.radio( "Create entry from scratch" ).click();
}
public void addObjectClasses( String... objectClasses )
{
bot.table( 0 ).select( objectClasses );
bot.button( "Add" ).click();
}
public boolean isObjectClassSelected( String objectClass )
{
return bot.table( 1 ).containsItem( objectClass );
}
public void clickAddRdnButton( int number )
{
int index = number - 1;
bot.button( " + ", index ).click();
}
public void setRdnValue( int number, String text )
{
int index = number - 1;
bot.text( index ).setText( text );
}
public void setRdnType( int number, String text )
{
int index = number - 1 + 1; // the parent field is also an combo box
bot.comboBox( index ).setText( text );
}
public void typeValueAndFinish( String value )
{
widgetBot.isVisisble();
widgetBot.typeValueAndFinish( value, false );
}
public NewAttributeWizardBot openNewAttributeWizard()
{
widgetBot.isVisisble();
return widgetBot.openNewAttributeWizard();
}
public EditAttributeWizardBot editAttribute( String attributeType, String value )
{
widgetBot.isVisisble();
return widgetBot.editAttribute( attributeType, value );
}
public void editValue( String attributeType, String value )
{
widgetBot.isVisisble();
widgetBot.editValue( attributeType, value );
}
public void cancelEditValue()
{
widgetBot.isVisisble();
widgetBot.cancelEditValue();
}
public String getDnPreview()
{
while ( true )
{
String text = bot.text( 1 ).getText();
if ( Dn.isValid( text ) )
{
return text;
}
}
}
public ReferralDialogBot clickFinishButtonExpectingReferralDialog()
{
clickButton( "Finish" );
return new ReferralDialogBot();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SearchPageWrapperBot.java | /*
* 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;
import org.apache.directory.api.ldap.model.message.SearchScope;
import org.apache.directory.studio.connection.core.Connection.AliasDereferencingMethod;
import org.eclipse.swtbot.swt.finder.SWTBot;
class SearchPageWrapperBot
{
private SWTBot bot;
SearchPageWrapperBot( SWTBot bot )
{
this.bot = bot;
}
boolean isVisible()
{
return bot.textWithLabel( "Search Name:" ).isVisible();
}
void setSearchName( String string )
{
bot.textWithLabel( "Search Name:" ).setText( string );
}
void setFilter( String string )
{
bot.comboBoxWithLabel( "Filter:" ).setText( string );
}
String getFilter()
{
return bot.comboBoxWithLabel( "Filter:" ).getText();
}
void setReturningAttributes( String string )
{
bot.comboBoxWithLabel( "Returning Attributes:" ).setText( string );
}
void setControlManageDsaIT( boolean enabled )
{
if ( enabled )
{
bot.checkBox( "ManageDsaIT" ).select();
}
else
{
bot.checkBox( "ManageDsaIT" ).deselect();
}
}
void setControlSubentries( boolean enabled )
{
if ( enabled )
{
bot.checkBox( "Subentries" ).select();
}
else
{
bot.checkBox( "Subentries" ).deselect();
}
}
void setControlPagedSearch( boolean enabled, int pageSize, boolean scrollMode )
{
if ( enabled )
{
bot.checkBox( "Paged Search" ).select();
bot.textInGroup( "Controls" ).setText( "" + pageSize );
if ( scrollMode )
{
bot.checkBox( "Scroll Mode" ).select();
}
else
{
bot.checkBox( "Scroll Mode" ).deselect();
}
}
else
{
bot.checkBox( "Paged Search" ).deselect();
}
}
void setAliasDereferencingMode( AliasDereferencingMethod mode )
{
switch ( mode )
{
case ALWAYS:
bot.checkBox( "Finding Base DN" ).select();
bot.checkBox( "Search" ).select();
break;
case FINDING:
bot.checkBox( "Finding Base DN" ).select();
bot.checkBox( "Search" ).deselect();
break;
case SEARCH:
bot.checkBox( "Finding Base DN" ).deselect();
bot.checkBox( "Search" ).select();
break;
case NEVER:
bot.checkBox( "Finding Base DN" ).deselect();
bot.checkBox( "Search" ).deselect();
break;
}
}
void setScope( SearchScope scope )
{
switch ( scope )
{
case OBJECT:
bot.radio( "Object" ).click();
break;
case ONELEVEL:
bot.radio( "One Level" ).click();
break;
case SUBTREE:
bot.radio( "Subtree" ).click();
break;
}
}
void setCountLimit( int countLimit )
{
bot.textWithLabel( "Count Limit:" ).setText( "" + countLimit );
}
public FilterEditorDialogBot openFilterEditor()
{
bot.button( "Filter Editor..." ).click();
return new FilterEditorDialogBot();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/RenameEntryDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/RenameEntryDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class RenameEntryDialogBot extends DialogBot
{
public RenameEntryDialogBot()
{
super( "Rename Entry" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__rename_entry_name );
}
public void setRdnValue( int number, String text )
{
int index = number - 1;
bot.text( index ).setText( text );
}
public void setRdnType( int number, String text )
{
int index = number - 1;
bot.comboBox( index ).setText( text );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/LdifEditorBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/LdifEditorBot.java | /*
* 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;
import java.util.List;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEclipseEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
public class LdifEditorBot
{
private SWTBotEditor editor;
public LdifEditorBot( String title )
{
SWTWorkbenchBot bot = new SWTWorkbenchBot();
List<? extends SWTBotEditor> editors = bot.editors();
for ( SWTBotEditor editor : editors )
{
if ( editor.getTitle().startsWith( title ) )
{
this.editor = editor;
return;
}
}
editor = bot.editorByTitle( title );
}
public void typeText( String text )
{
SWTBotEclipseEditor textEditor = editor.toTextEditor();
// note: typeText() doesn't work on macOS
textEditor.setText( text );
}
public void activate()
{
editor.setFocus();
}
public void close()
{
editor.close();
}
public boolean isDirty()
{
return editor.isDirty();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CheckAuthenticationDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CheckAuthenticationDialogBot.java | /*
* 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 CheckAuthenticationDialogBot extends DialogBot
{
public CheckAuthenticationDialogBot()
{
super( "Check Authentication" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateEditorDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.valueeditors.certificate.CertificateDialog;
public class CertificateEditorDialogBot extends DialogBot
{
public CertificateEditorDialogBot()
{
super( "Certificate Editor" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name );
}
public void typeFile( String file )
{
bot.textWithTooltip( CertificateDialog.LOAD_FILE_NAME_TOOLTIP ).setText( file );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateTrustDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/CertificateTrustDialogBot.java | /*
* 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;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotLabel;
public class CertificateTrustDialogBot extends DialogBot
{
public CertificateTrustDialogBot()
{
super( "Certificate Trust" );
}
public boolean isSelfSigned()
{
return hasErrorMessage( "self-signed" );
}
public boolean isHostNameMismatch()
{
return hasErrorMessage( "host name" );
}
public boolean isExpired()
{
return hasErrorMessage( "expired" );
}
public boolean isNotYetValid()
{
return hasErrorMessage( "not yet valid" );
}
public boolean isIssuerUnkown()
{
return hasErrorMessage( "issuer certificate is unknown" );
}
public boolean hasErrorMessage( String needle )
{
List<String> errorMessages = getErrorMessages();
for ( String string : errorMessages )
{
if ( string.contains( needle ) )
{
return true;
}
}
return false;
}
private List<String> getErrorMessages()
{
List<String> messages = new ArrayList<String>();
for ( int i = 1;; i++ )
{
SWTBotLabel label = bot.label( i );
if ( label.getText().startsWith( "-" ) )
{
messages.add( label.getText() );
}
else
{
break;
}
}
return messages;
}
protected void clickViewCertificateButton()
{
super.clickButton( "View Certificate..." );
}
public void selectDontTrust()
{
bot.radio( "Don't trust this certificate." ).click();
}
public void selectTrustTemporary()
{
bot.radio( "Trust this certificate for this session." ).click();
}
public void selectTrustPermanent()
{
bot.radio( "Always trust this certificate." ).click();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewSchemaProjectWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewSchemaProjectWizardBot.java | /*
* 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;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
public class NewSchemaProjectWizardBot extends WizardBot
{
public NewSchemaProjectWizardBot()
{
super( "" );
}
public void typeProjectName( String projectName )
{
activate();
SWTBotText text = bot.textWithLabel( "Project name:" );
text.setText( projectName );
}
public void selectOfflineSchema()
{
activate();
bot.radio( "Offline Schema" ).click();
}
public void selectOnlineSchema()
{
activate();
bot.radio( "Online Schema from a Directory Server" ).click();
}
public void selectApacheDS()
{
activate();
bot.radio( "ApacheDS" ).click();
}
public void selectOpenLDAP()
{
activate();
bot.radio( "OpenLDAP" ).click();
}
public void selectAllSchemas()
{
activate();
clickButton( "Select All" );
}
public void selectConnection( String connectionName )
{
activate();
bot.tree().select( connectionName );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AciItemEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AciItemEditorDialogBot.java | /*
* 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;
import org.apache.directory.api.ldap.model.constants.AuthenticationLevel;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class AciItemEditorDialogBot extends DialogBot
{
public AciItemEditorDialogBot()
{
super( "ACI Item Editor" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name );
}
public void activateVisualEditorTab()
{
bot.tabItem( "Visual Editor" ).activate();
}
public void setIdentificationTag( String identificationTag )
{
bot.textWithLabel( "Identification Tag:" ).setText( identificationTag );
}
public void setPrecedence( int precedence )
{
bot.spinnerWithLabel( "Precedence:" ).setSelection( precedence );
}
public void setAuthenticationLevel( AuthenticationLevel authenticationLevel )
{
bot.comboBoxWithLabel( "Authentication Level:" ).setSelection( authenticationLevel.getName() );
}
public void setUserFirst()
{
bot.radio( "User First" ).click();
}
public void setItemFirst()
{
bot.radio( "Item First" ).click();
}
public void enableUserClassAllUsers()
{
bot.table().getTableItem( 0 ).check();
}
public void disableUserClassAllUsers()
{
bot.table().getTableItem( 0 ).uncheck();
}
public void enableUserClassThisEntry()
{
bot.table().getTableItem( 1 ).check();
}
public void disableUserClassThisEntry()
{
bot.table().getTableItem( 1 ).uncheck();
}
public void enableUserClassParentOfEntry()
{
bot.table().getTableItem( 2 ).check();
}
public void disableUserClassParentOfEntry()
{
bot.table().getTableItem( 2 ).uncheck();
}
public void enableUserClassName()
{
bot.table().getTableItem( 3 ).check();
}
public void disableUserClassName()
{
bot.table().getTableItem( 3 ).uncheck();
}
public void enableUserClassUserGroup()
{
bot.table().getTableItem( 4 ).check();
}
public void disableUserClassUserGroup()
{
bot.table().getTableItem( 4 ).uncheck();
}
public void enableUserClassSubtree()
{
bot.table().getTableItem( 5 ).check();
}
public void disableUserClassSubtree()
{
bot.table().getTableItem( 5 ).uncheck();
}
public void enableProtectedItemEntry()
{
bot.table().getTableItem( 0 ).check();
}
public void disableProtectedItemEntry()
{
bot.table().getTableItem( 0 ).uncheck();
}
public void enableProtectedItemAllUserAttributeTypes()
{
bot.table().getTableItem( 1 ).check();
}
public void disableProtectedItemAllUserAttributeTypes()
{
bot.table().getTableItem( 1 ).uncheck();
}
public void enableProtectedItemAttributeType()
{
bot.table().getTableItem( 2 ).check();
}
public void disableProtectedItemAttributeType()
{
bot.table().getTableItem( 2 ).uncheck();
}
public void enableProtectedItemAllAttributeValues()
{
bot.table().getTableItem( 3 ).check();
}
public void disableProtectedItemAllAttributeValues()
{
bot.table().getTableItem( 3 ).uncheck();
}
public void enableProtectedItemAllUserAttributeTypesAndValues()
{
bot.table().getTableItem( 4 ).check();
}
public void disableProtectedItemAllUserAttributeTypesAndValues()
{
bot.table().getTableItem( 4 ).uncheck();
}
public void enableProtectedItemAttributeValues()
{
bot.table().getTableItem( 5 ).check();
}
public void disableProtectedItemAttributeValues()
{
bot.table().getTableItem( 5 ).uncheck();
}
public void enableProtectedItemSelfValue()
{
bot.table().getTableItem( 6 ).check();
}
public void disableProtectedItemSelfValue()
{
bot.table().getTableItem( 6 ).uncheck();
}
public void enableProtectedItemRangeOfValues()
{
bot.table().getTableItem( 7 ).check();
}
public void disableProtectedItemRangeOfValues()
{
bot.table().getTableItem( 7 ).uncheck();
}
public void enableProtectedItemMaxValueCount()
{
bot.table().getTableItem( 8 ).check();
}
public void disableProtectedItemMaxValueCount()
{
bot.table().getTableItem( 8 ).uncheck();
}
public void enableProtectedItemMaxNumberOfImmediateSubordinates()
{
bot.table().getTableItem( 9 ).check();
}
public void disableProtectedItemMaxNumberOfImmediateSubordinates()
{
bot.table().getTableItem( 9 ).uncheck();
}
public void enableProtectedItemRestrictedBy()
{
bot.table().getTableItem( 10 ).check();
}
public void disableProtectedItemRestrictedBy()
{
bot.table().getTableItem( 10 ).uncheck();
}
public void enableProtectedItemClasses()
{
bot.table().getTableItem( 11 ).check();
}
public void disableProtectedItemClasses()
{
bot.table().getTableItem( 11 ).uncheck();
}
public void activateSourceTab()
{
bot.tabItem( "Source" ).activate();
}
public void setSource( String source )
{
bot.styledText().setText( source );
}
public String getSource()
{
return bot.styledText().getText();
}
public void clickFormatButton()
{
super.clickButton( "Format" );
}
public void clickCheckSyntaxButtonOk()
{
super.clickButton( "Check Syntax" );
new DialogBot( "Syntax ok" )
{
}.clickOkButton();
activate();
}
public void clickCheckSyntaxButtonError()
{
String shellText = BotUtils.shell( () -> super.clickButton( "Check Syntax" ), "Syntax Error" ).getText();
new DialogBot( shellText )
{
}.clickOkButton();
activate();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionWizardBot.java | /*
* 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;
import org.apache.directory.api.ldap.model.constants.SaslQoP;
import org.apache.directory.api.ldap.model.constants.SaslSecurityStrength;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
import org.apache.directory.studio.test.integration.ui.utils.JobWatcher;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotCombo;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
public class NewConnectionWizardBot extends WizardBot
{
private static final String TITLE = "New LDAP Connection";
private static final String CERTIFICATE_TRUST = "Certificate Trust";
private static final String CONNECTION_NAME = "Connection name:";
private static final String HOSTNAME = "Hostname:";
private static final String PORT = "Port:";
private static final String CHECK_AUTHENTICATION = "Check Authentication";
private static final String CHECK_NETWORK_PARAMETER = "Check Network Parameter";
private static final String VIEW_CERTIFICATE = "View Certificate...";
private static final String BASE_DN = "Base DN:";
private static final String GET_BASE_DNS_FROM_ROOT_DSE = "Get base DNs from Root DSE";
private static final String SAVE_PASSWORD = "Save password";
private static final String SASL_REALM = "SASL Realm:";
private static final String SASL_QUALITY_OF_PROTECTION = "Quality of Protection:";
private static final String SASL_PROTECTION_STRENGH = "Protection Strength:";
private static final String BIND_PASSWORD = "Bind password:";
private static final String BIND_DN_OR_USER = "Bind DN or user:";
private static final String CRAM_MD5_SASL = "CRAM-MD5 (SASL)";
private static final String DIGEST_MD5_SASL = "DIGEST-MD5 (SASL)";
private static final String GSS_API_SASL = "GSSAPI (Kerberos)";
private static final String NO_AUTHENTICATION = "No Authentication";
private static final String SIMPLE_AUTHENTICATION = "Simple Authentication";
private static final String AUTHENTICATION_METHOD = "Authentication Method";
private static final String ENCRYPTION_METHOD = "Encryption method:";
private static final String NO_ENCRYPTION = "No encryption";
private static final String START_TLS_ENCRYPTION = "Use StartTLS extension";
private static final String LDAPS_ENCRYPTION = "Use SSL encryption (ldaps://)";
private static final String USE_NATIVE_TGT = "Use native TGT";
private static final String OBTAIN_TGT_FROM_KDC = "Obtain TGT from KDC (provide username and password)";
private static final String USE_NATIVE_SYSTEM_CONFIG = "Use native system configuration";
private static final String USE_CONFIG_FILE = "Use configuration file:";
private static final String USE_MANUAL_CONFIG = "Use following configuration:";
private static final String KERBEROS_REALM = "Kerberos Realm:";
private static final String KDC_HOST = "KDC Host:";
private static final String KDC_PORT = "KDC Port:";
public NewConnectionWizardBot()
{
super( TITLE );
}
public void clickFinishButton( boolean waitTillConnectionOpened )
{
JobWatcher watcher = null;
if ( waitTillConnectionOpened )
{
watcher = new JobWatcher( BrowserCoreMessages.jobs__open_connections_name_1 );
}
super.clickFinishButton();
if ( waitTillConnectionOpened )
{
watcher.waitUntilDone();
}
}
public void typeConnectionName( String connectionName )
{
SWTBotText connText = bot.textWithLabel( CONNECTION_NAME );
connText.setText( connectionName );
}
public void typeHost( String host )
{
SWTBotCombo hostnameCombo = bot.comboBoxWithLabel( HOSTNAME );
hostnameCombo.setText( host );
}
public void typePort( int port )
{
SWTBotCombo portCombo = bot.comboBoxWithLabel( PORT );
portCombo.setText( Integer.toString( port ) );
}
public boolean isSimpleAuthenticationSelected()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
return SIMPLE_AUTHENTICATION.equals( authMethodCombo.selection() );
}
public void selectSimpleAuthentication()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
authMethodCombo.setSelection( SIMPLE_AUTHENTICATION );
}
public boolean isNoAuthenticationSelected()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
return NO_AUTHENTICATION.equals( authMethodCombo.selection() );
}
public void selectNoAuthentication()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
authMethodCombo.setSelection( NO_AUTHENTICATION );
}
public boolean isDigestMD5AuthenticationSelected()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
return DIGEST_MD5_SASL.equals( authMethodCombo.selection() );
}
public void selectDigestMD5Authentication()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
authMethodCombo.setSelection( DIGEST_MD5_SASL );
}
public boolean isCramMD5AuthenticationSelected()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
return CRAM_MD5_SASL.equals( authMethodCombo.selection() );
}
public void selectCramMD5Authentication()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
authMethodCombo.setSelection( CRAM_MD5_SASL );
}
public boolean isGssApiAuthenticationSelected()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
return GSS_API_SASL.equals( authMethodCombo.selection() );
}
public void selectGssApiAuthentication()
{
SWTBotCombo authMethodCombo = bot.comboBoxInGroup( AUTHENTICATION_METHOD );
authMethodCombo.setSelection( GSS_API_SASL );
}
public boolean isUserEnabled()
{
return bot.comboBoxWithLabel( BIND_DN_OR_USER ).isEnabled();
}
public void typeUser( String user )
{
SWTBotCombo dnCombo = bot.comboBoxWithLabel( BIND_DN_OR_USER );
dnCombo.setText( user );
}
public boolean isPasswordEnabled()
{
return bot.textWithLabel( BIND_PASSWORD ).isEnabled();
}
public void typePassword( String password )
{
SWTBotText passwordText = bot.textWithLabel( BIND_PASSWORD );
passwordText.setText( password );
}
public boolean isRealmEnabled()
{
return bot.comboBoxWithLabel( SASL_REALM ).isEnabled();
}
public void typeRealm( String realm )
{
SWTBotCombo combo = bot.comboBoxWithLabel( SASL_REALM );
combo.setText( realm );
}
public void selectQualityOfProtection( SaslQoP saslQoP )
{
SWTBotCombo combo = bot.comboBoxWithLabel( SASL_QUALITY_OF_PROTECTION );
switch ( saslQoP )
{
case AUTH:
combo.setSelection( 0 );
break;
case AUTH_INT:
combo.setSelection( 1 );
break;
case AUTH_CONF:
combo.setSelection( 2 );
break;
}
}
public void selectProtectionStrength( SaslSecurityStrength saslSecurityStrength )
{
SWTBotCombo combo = bot.comboBoxWithLabel( SASL_PROTECTION_STRENGH );
switch ( saslSecurityStrength )
{
case HIGH:
combo.setSelection( 0 );
break;
case MEDIUM:
combo.setSelection( 1 );
break;
case LOW:
combo.setSelection( 2 );
break;
}
}
public boolean isSavePasswordEnabled()
{
return bot.checkBox( SAVE_PASSWORD ).isEnabled();
}
public boolean isSavePasswordSelected()
{
return bot.checkBox( SAVE_PASSWORD ).isChecked();
}
public void selectSavePassword()
{
bot.checkBox( SAVE_PASSWORD ).select();
}
public void deselectSavePassword()
{
bot.checkBox( SAVE_PASSWORD ).deselect();
}
public boolean isUseNativeTgtSelected()
{
return bot.radio( USE_NATIVE_TGT ).isSelected();
}
public void selectUseNativeTgt()
{
bot.radio( USE_NATIVE_TGT ).click();
}
public boolean isObtainTgtFromKdcSelected()
{
return bot.radio( OBTAIN_TGT_FROM_KDC ).isSelected();
}
public void selectObtainTgtFromKdc()
{
bot.radio( OBTAIN_TGT_FROM_KDC ).click();
}
public boolean isUseNativeSystemConfigurationSelected()
{
return bot.radio( USE_NATIVE_SYSTEM_CONFIG ).isSelected();
}
public void selectUseNativeSystemConfiguration()
{
bot.radio( USE_NATIVE_SYSTEM_CONFIG ).click();
}
public boolean isUseConfigurationFileSelected()
{
return bot.radio( USE_CONFIG_FILE ).isSelected();
}
public void selectUseConfigurationFile()
{
bot.radio( USE_CONFIG_FILE ).click();
}
public boolean isUseManualConfigurationSelected()
{
return bot.radio( USE_MANUAL_CONFIG ).isSelected();
}
public void selectUseManualConfiguration()
{
bot.radio( USE_MANUAL_CONFIG ).click();
}
public boolean isKerberosRealmEnabled()
{
return bot.textWithLabel( KERBEROS_REALM ).isEnabled();
}
public void typeKerberosRealm( String realm )
{
bot.textWithLabel( KERBEROS_REALM ).setText( realm );
}
public boolean isKdcHostEnabled()
{
return bot.textWithLabel( KDC_HOST ).isEnabled();
}
public void typeKdcHost( String host )
{
bot.textWithLabel( KDC_HOST ).setText( host );
}
public boolean isKdcPortEnabled()
{
return bot.textWithLabel( KDC_PORT ).isEnabled();
}
public void typeKdcPort( int port )
{
bot.textWithLabel( KDC_PORT ).setText( Integer.toString( port ) );
}
public boolean isGetBaseDnsFromRootDseEnabled()
{
return bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).isEnabled();
}
public boolean isGetBaseDnsFromRootDseSelected()
{
return bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).isChecked();
}
public void selectGetBaseDnsFromRootDse()
{
bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).select();
}
public void deselectGetBaseDnsFromRootDse()
{
bot.checkBox( GET_BASE_DNS_FROM_ROOT_DSE ).deselect();
}
public boolean isBaseDnEnabled()
{
return bot.comboBoxWithLabel( BASE_DN ).isEnabled();
}
public void typeBaseDn( String baseDn )
{
SWTBotCombo dnCombo = bot.comboBoxWithLabel( BASE_DN );
dnCombo.setText( baseDn );
}
public boolean isViewCertificateButtonEnabled()
{
return bot.button( VIEW_CERTIFICATE ).isEnabled();
}
public CertificateViewerDialogBot clickViewCertificateButton()
{
bot.button( VIEW_CERTIFICATE ).click();
return new CertificateViewerDialogBot();
}
public boolean isCheckNetworkParameterButtonEnabled()
{
return bot.button( CHECK_NETWORK_PARAMETER ).isEnabled();
}
/**
* Clicks the "check network parameter" button.
*
* @return null if the OK dialog pops up, the error message if the error dialog pops up
*/
public CheckResponse clickCheckNetworkParameterButton()
{
activate();
return clickCheckButton( CHECK_NETWORK_PARAMETER, CHECK_NETWORK_PARAMETER );
}
/**
* Clicks the "check network parameter" button.
*/
public CertificateTrustDialogBot clickCheckNetworkParameterButtonExpectingCertificateTrustDialog()
{
bot.button( CHECK_NETWORK_PARAMETER ).click();
bot.shell( CERTIFICATE_TRUST );
return new CertificateTrustDialogBot();
}
/**
* Clicks the "check authentication" button.
*
* @return null if the OK dialog pops up, the error message if the error dialog pops up
*/
public String clickCheckAuthenticationButton()
{
CheckResponse checkResponse = clickCheckButton( CHECK_AUTHENTICATION, CHECK_AUTHENTICATION );
return checkResponse.isError() ? checkResponse.getMessage() : null;
}
/**
* Clicks the "check authentication" button.
*/
public CertificateTrustDialogBot clickCheckAuthenticationButtonExpectingCertificateTrustDialog()
{
bot.button( CHECK_AUTHENTICATION ).click();
bot.shell( CERTIFICATE_TRUST );
return new CertificateTrustDialogBot();
}
public boolean isNoEncryptionSelected()
{
SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
return NO_ENCRYPTION.equals( encMethodCombo.selection() );
}
public void selectNoEncryption()
{
SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
encMethodCombo.setSelection( NO_ENCRYPTION );
}
public boolean isStartTlsEncryptionSelected()
{
SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
return START_TLS_ENCRYPTION.equals( encMethodCombo.selection() );
}
public void selectStartTlsEncryption()
{
SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
encMethodCombo.setSelection( START_TLS_ENCRYPTION );
}
public boolean isLdapsEncryptionSelected()
{
SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
return LDAPS_ENCRYPTION.equals( encMethodCombo.selection() );
}
public void selectLdapsEncryption()
{
SWTBotCombo encMethodCombo = bot.comboBoxWithLabel( ENCRYPTION_METHOD );
encMethodCombo.setSelection( LDAPS_ENCRYPTION );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/VerifyMasterPasswordDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/VerifyMasterPasswordDialogBot.java | /*
* 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 VerifyMasterPasswordDialogBot extends DialogBot
{
public VerifyMasterPasswordDialogBot()
{
super( "Verify Master Password" );
}
public void enterMasterPassword( String masterPassword )
{
activate();
bot.text().setText( masterPassword );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordsKeystorePreferencePageBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PasswordsKeystorePreferencePageBot.java | /*
* 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 PasswordsKeystorePreferencePageBot extends PreferencePageBot
{
public boolean isPasswordsKeystoreEnabled()
{
activate();
return bot.checkBox().isChecked();
}
public SetupMasterPasswordDialogBot enablePasswordsKeystore()
{
activate();
bot.checkBox().click();
return new SetupMasterPasswordDialogBot();
}
public KeepConnectionsPasswordsDialogBot disablePasswordsKeystore()
{
activate();
bot.checkBox().click();
return new KeepConnectionsPasswordsDialogBot();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/MoveEntriesDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/MoveEntriesDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class MoveEntriesDialogBot extends DialogBot
{
public MoveEntriesDialogBot()
{
super( "Move Entries" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__move_entry_name_1 );
}
public void setParentText( String text )
{
bot.comboBox().setText( text );
}
public String getParentText()
{
return bot.comboBox().getText();
}
public SelectDnDialogBot clickBrowseButtonExpectingSelectDnDialog()
{
super.clickButton( "Browse..." );
return new SelectDnDialogBot();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BotUtils.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/BotUtils.java | /*
* 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;
import java.util.Arrays;
import java.util.List;
import org.apache.directory.ldap.client.api.LdapConnectionConfig;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
public class BotUtils
{
private static SWTBot bot = new SWTBot();
/**
* Waits for a shell with any of the given labels.
*
* @param labels
* @return
*/
static SWTBotShell shell( final Runnable runnable, final String... labels )
{
// we expect the error dialog here, so set flag to false
boolean errorDialogAutomatedMode = ErrorDialog.AUTOMATED_MODE;
ErrorDialog.AUTOMATED_MODE = false;
try
{
runnable.run();
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
return getShell( labels ) != null;
}
public String getFailureMessage()
{
List<String> asList = Arrays.asList( labels );
return "Expected a dialog with any label " + asList + " with an 'OK' button.";
}
}, SWTBotPreferences.TIMEOUT + LdapConnectionConfig.DEFAULT_TIMEOUT );
}
finally
{
// reset flag
ErrorDialog.AUTOMATED_MODE = errorDialogAutomatedMode;
}
return getShell( labels );
}
private static SWTBotShell getShell( final String... labels )
{
SWTBotShell[] shells = bot.shells();
for ( SWTBotShell shell : shells )
{
String shellText = shell.getText();
for ( String label : labels )
{
if ( shellText.equals( label ) )
{
shell.activate();
if( bot.button( "OK" ) != null) {
return shell;
}
}
}
}
return null;
}
public static void sleep( long millis )
{
bot.sleep( millis );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaEditorBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaEditorBot.java | /*
* 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 SchemaEditorBot extends BaseSchemaEditorBot
{
public SchemaEditorBot( String title )
{
super( title );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionFolderDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/NewConnectionFolderDialogBot.java | /*
* 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 NewConnectionFolderDialogBot extends DialogBot
{
public NewConnectionFolderDialogBot()
{
super( "New Connection Folder" );
}
public void setConnectionFoldername( String name )
{
bot.text().setText( name );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/WizardBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/WizardBot.java | /*
* 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;
import org.apache.directory.studio.test.integration.ui.utils.TreeBot;
import org.eclipse.swtbot.swt.finder.waits.Conditions;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
public abstract class WizardBot extends DialogBot
{
public WizardBot( String title )
{
super( title );
}
public boolean isBackButtonEnabled()
{
return isButtonEnabled( "< Back" );
}
public boolean isNextButtonEnabled()
{
return isButtonEnabled( "Next >" );
}
public boolean isFinishButtonEnabled()
{
return isButtonEnabled( "Finish" );
}
public boolean isCancelButtonEnabled()
{
return isButtonEnabled( "Cancel" );
}
protected boolean isButtonEnabled( String buttonTitle )
{
activate();
return bot.button( buttonTitle ).isEnabled();
}
public void clickBackButton()
{
clickButton( "< Back" );
}
public void clickNextButton()
{
clickButton( "Next >" );
}
public void clickFinishButton()
{
SWTBotShell shell = null;
if ( title != null )
{
shell = bot.shell( title );
}
clickButton( "Finish" );
if ( shell != null )
{
bot.waitUntil( Conditions.shellCloses( shell ) );
}
}
public ErrorDialogBot clickFinishButtonExpectingError()
{
String shellText = BotUtils.shell( () -> clickFinishButton(), "Error", "Problem Occurred" ).getText();
return new ErrorDialogBot( shellText );
}
public boolean existsCategory( String category )
{
TreeBot treeBot = new TreeBot( bot.tree() );
return treeBot.exists( category );
}
public boolean existsWizard( String category, String wizard )
{
TreeBot treeBot = new TreeBot( bot.tree() );
return treeBot.exists( category, wizard );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/HexEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/HexEditorDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.common.dialogs.HexDialog;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class HexEditorDialogBot extends DialogBot
{
public HexEditorDialogBot()
{
super( "Hex Editor" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name );
}
public void typeFile( String file )
{
bot.textWithTooltip( HexDialog.LOAD_FILE_NAME_TOOLTIP ).setText( file );
}
public String getHexText()
{
return bot.text().getText();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DnEditorDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DnEditorDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class DnEditorDialogBot extends DialogBot
{
public DnEditorDialogBot()
{
super( "DN Editor" );
super.setWaitAfterClickOkButton( true, BrowserCoreMessages.jobs__execute_ldif_name );
}
public SelectDnDialogBot clickBrowseButtonExpectingSelectDnDialog()
{
activate();
super.clickButton( "Browse..." );
return new SelectDnDialogBot();
}
public void setDnText( String dn )
{
activate();
bot.comboBox().setText( dn );
}
public String getDnText()
{
activate();
return bot.comboBox().getText();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaBrowserBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/SchemaBrowserBot.java | /*
* 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;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotMultiPageEditor;
import org.eclipse.swtbot.swt.finder.matchers.WithRegex;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
import org.hamcrest.Matcher;
public class SchemaBrowserBot
{
private SWTBotMultiPageEditor editor;
public SchemaBrowserBot()
{
SWTWorkbenchBot bot = new SWTWorkbenchBot();
editor = bot.multipageEditorByTitle( "Schema Browser" );
bot.waitUntil( new DefaultCondition()
{
@Override
public boolean test() throws Exception
{
return editor.getPageCount() >= 5;
}
@Override
public String getFailureMessage()
{
return "Schema Browser editor not ready";
}
} );
}
public void activateObjectClassesTab()
{
editor.activatePage( "Object Classes" );
}
public void selectObjectClass( String oc )
{
activateObjectClassesTab();
editor.bot().table().select( oc );
}
public String getRawSchemaDefinition()
{
Matcher matcher = allOf( widgetOfType( Text.class ), WithRegex.withRegex( ".*NAME.*" ) );
SWTBotText text = new SWTBotText( ( Text ) editor.bot().widget( matcher, 0 ), matcher );
return text.getText();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AbstractLogsViewBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/AbstractLogsViewBot.java | /*
* 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;
import org.apache.commons.lang3.StringUtils;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarPushButton;
public class AbstractLogsViewBot
{
protected SWTBotView view;
public AbstractLogsViewBot( String title )
{
view = new SWTWorkbenchBot().viewByTitle( title );
}
public String getLogsText()
{
view.show();
SWTBotToolbarPushButton refreshButton = view.toolbarPushButton( "Refresh" );
if ( refreshButton.isEnabled() )
{
refreshButton.click();
}
return view.bot().styledText().getText();
}
public void waitForText( final String text )
{
view.show();
view.bot().waitUntil( new DefaultCondition()
{
@Override
public boolean test() throws Exception
{
SWTBotToolbarPushButton refreshButton = view.toolbarPushButton( "Refresh" );
if ( refreshButton.isEnabled() )
{
refreshButton.click();
}
return StringUtils.containsIgnoreCase( view.bot().styledText().getText(), text );
}
@Override
public String getFailureMessage()
{
return "Text '" + text + "' not found.";
}
} );
}
public void clear()
{
view.show();
view.toolbarPushButton( "Clear" ).click();
new DialogBot( "Delete" )
{
}.clickOkButton();
}
public boolean isOlderButtonEnabled()
{
view.show();
return view.toolbarPushButton( "Older" ).isEnabled();
}
public void clickOlderButton()
{
view.show();
view.toolbarPushButton( "Older" ).click();
}
public boolean isNewerButtonEnabled()
{
view.show();
return view.toolbarPushButton( "Newer" ).isEnabled();
}
public void clickNewerButton()
{
view.show();
view.toolbarPushButton( "Newer" ).click();
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/DeleteDialogBot.java | /*
* 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;
import org.apache.directory.studio.ldapbrowser.core.BrowserCoreMessages;
public class DeleteDialogBot extends DialogBot
{
public static final String DELETE_CONNECTION = "Delete Connection";
public static final String DELETE_CONNECTION_FOLDER = "Delete Connection Folder";
public static final String DELETE_ENTRY_TITLE = "Delete Entry";
public static final String DELETE_ENTRIES_TITLE = "Delete Entries";
public static final String DELETE_VALUE_TITLE = "Delete Value";
public static final String DELETE_SERVER = "Delete Server";
public static final String DELETE_PROJECT = "Delete Project";
public DeleteDialogBot( String title )
{
super( title );
String jobName = getJobWatcherTitle( title );
super.setWaitAfterClickOkButton( jobName != null, jobName );
}
private String getJobWatcherTitle( String dialogTitle )
{
switch ( dialogTitle )
{
case DELETE_VALUE_TITLE:
return BrowserCoreMessages.jobs__execute_ldif_name;
case DELETE_CONNECTION:
case DELETE_CONNECTION_FOLDER:
case DELETE_PROJECT:
return null;
default:
return dialogTitle;
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencePageBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/bots/PreferencePageBot.java | /*
* 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" );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/TreeBot.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/TreeBot.java | /*
* 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.utils;
import java.util.Arrays;
import java.util.LinkedList;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
public class TreeBot
{
private SWTBotTree tree;
public TreeBot( SWTBotTree tree )
{
this.tree = tree;
}
public boolean exists( String... nodes )
{
SWTBotTreeItem[] items = tree.getAllItems();
return exists( items, new LinkedList<String>( Arrays.asList( nodes ) ) );
}
private boolean exists( SWTBotTreeItem[] items, LinkedList<String> nodes )
{
for ( SWTBotTreeItem item : items )
{
if ( item.getText().equals( nodes.getFirst() ) )
{
if ( nodes.size() == 1 )
{
return true;
}
else
{
if ( !item.isExpanded() )
{
item.expand();
}
nodes.removeFirst();
SWTBotTreeItem[] children = item.getItems();
return exists( children, nodes );
}
}
}
return false;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/Assertions.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/Assertions.java | /*
* 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.utils;
import static org.junit.jupiter.api.Assertions.fail;
import org.apache.directory.studio.connection.core.Messages;
import org.apache.directory.studio.test.integration.ui.bots.BotUtils;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
public class Assertions
{
public static void genericTearDownAssertions()
{
if ( isOpenConnectionJobRunning() )
{
BotUtils.sleep( 5000L );
if ( isOpenConnectionJobRunning() )
{
fail( "No 'Open Connection' job expected" );
}
}
}
private static boolean isOpenConnectionJobRunning()
{
IJobManager jobManager = Job.getJobManager();
Job[] jobs = jobManager.find( null );
for ( Job job : jobs )
{
if ( job.getName().equals( Messages.jobs__open_connections_name_1 ) )
{
return true;
}
}
return false;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/ResourceUtils.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/ResourceUtils.java | /*
* 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.utils;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.UUID;
import org.apache.directory.api.util.IOUtils;
import org.apache.directory.studio.test.integration.ui.Activator;
import org.eclipse.core.runtime.Platform;
public class ResourceUtils
{
public static String prepareInputFile( String inputFileName ) throws IOException
{
URL url = Platform.getInstanceLocation().getURL();
String destFile = url.getFile() + UUID.randomUUID().toString();
try ( InputStream is = Activator.class.getResourceAsStream( inputFileName );
FileOutputStream fos = new FileOutputStream( new File( destFile ) ); )
{
IOUtils.copy( is, fos );
}
return destFile;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/SWTBotUtils.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/SWTBotUtils.java | /*
* 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.utils;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.waits.ICondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.swtbot.swt.finder.widgets.TimeoutException;
/**
* Helpers for using SWTBot.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class SWTBotUtils
{
/**
* Gets the connections tree.
*
* @param bot
* the bot
*
* @return the connections tree
*
* @throws Exception
* the exception
*/
public static SWTBotTree getConnectionsTree( SWTWorkbenchBot bot ) throws Exception
{
SWTBotView view = bot.viewByTitle( "Connections" );
view.show();
Tree tree = ( Tree ) bot.widget( widgetOfType( Tree.class ), view.getWidget() );
return new SWTBotTree( tree );
}
/**
* Gets the ldap browser tree.
*
* @param bot
* the bot
*
* @return the ldap browser tree
*
* @throws Exception
* the exception
*/
public static SWTBotTree getLdapBrowserTree( SWTWorkbenchBot bot )
{
SWTBotView view = bot.viewByTitle( "LDAP Browser" );
view.show();
Tree tree = ( Tree ) bot.widget( widgetOfType( Tree.class ), view.getWidget() );
return new SWTBotTree( tree );
}
/**
* Gets the entry editor tree.
*
* @param bot
* the bot
*
* @return the entry editor tree
*
* @throws Exception
* the exception
*/
public static SWTBotTree getEntryEditorTree( final SWTWorkbenchBot bot, String title ) throws Exception
{
SWTBotEditor editor = bot.editorByTitle( title );
SWTBotTree tree = editor.bot().tree();
return tree;
}
/**
* Clicks a button asynchronously and waits till the given condition is
* fulfilled.
*
* @param bot
* the SWT bot
* @param button
* the button to click
* @param waitCondition
* the condition to wait for, may be null
*
* @throws TimeoutException
*/
public static void asyncClick( final SWTWorkbenchBot bot, final SWTBotButton button, final ICondition waitCondition )
throws TimeoutException
{
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
return button.isEnabled();
}
public String getFailureMessage()
{
return "Button isn't enabled.";
}
} );
UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
{
public void run()
{
button.click();
}
} );
if ( waitCondition != null )
{
bot.waitUntil( waitCondition );
}
}
/**
* Clicks a menu item asynchronously and waits till the given condition is
* fulfilled.
*
* @param bot
* the SWT bot
* @param button
* the button to click
* @param waitCondition
* the condition to wait for, may be null
*
* @throws TimeoutException
*/
public static void asyncClick( final SWTWorkbenchBot bot, final SWTBotMenu menu, final ICondition waitCondition )
throws TimeoutException
{
UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
{
public void run()
{
menu.click();
}
} );
if ( waitCondition != null )
{
bot.waitUntil( waitCondition );
}
}
/**
* Clicks a tree item asynchronously and waits till the given condition is
* fulfilled.
*
* @param bot
* the SWT bot
* @param item
* the tree item to click
* @param waitCondition
* the condition to wait for, may be null
*
* @throws TimeoutException
* the timeout exception
*/
public static void asyncClick( final SWTWorkbenchBot bot, final SWTBotTreeItem item, final ICondition waitCondition )
throws TimeoutException
{
UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
{
public void run()
{
item.click();
}
} );
if ( waitCondition != null )
{
bot.waitUntil( waitCondition );
}
}
/**
* Selects an entry in the browser tree and optionally expands the selected
* entry. Takes care that all attributes and child entries are initialized
* so that there are no pending background actions and event notifications.
* This is necessary to avoid race conditions.
*
* @param bot
* the SWT bot
* @param tree
* the browser tree
* @param expandChild
* true to expand the child entry
* @param path
* the path to the entry
*
* @return the selected entry as SWTBotTreeItem
*
* @throws Exception
* the exception
*/
public static SWTBotTreeItem selectEntry( final SWTWorkbenchBot bot, final SWTBotTree tree,
final boolean expandChild, final String... path )
{
List<String> pathList = new ArrayList<String>( Arrays.asList( path ) );
SWTBotTreeItem entry = null;
while ( !pathList.isEmpty() )
{
String currentPath = pathList.remove( 0 );
if ( entry == null )
{
currentPath = adjustNodeName( tree, currentPath );
entry = tree.getTreeItem( currentPath );
}
else
{
// adjust current path, because the label is decorated with the
// number of children
currentPath = adjustNodeName( entry, currentPath );
entry = entry.getNode( currentPath );
}
entry.click();
if ( !pathList.isEmpty() || expandChild )
{
// expand entry and wait till
// - children are displayed
// - next child is visible
final String nextName = !pathList.isEmpty() ? pathList.get( 0 ) : null;
expandEntry( bot, entry, nextName );
}
entry.select();
}
return entry;
}
/**
* Expands the entry. Takes care that all attributes and child entries are
* initialized so that there are no pending background actions and event
* notifications. This is necessary to avoid race conditions.
*
* @param bot
* the bot
* @param entry
* the entry to expand
* @param nextName
* the name of the entry that must become visible, may be null
*
* @throws Exception
* the exception
*/
public static void expandEntry( final SWTWorkbenchBot bot, final SWTBotTreeItem entry, final String nextName )
{
UIThreadRunnable.asyncExec( bot.getDisplay(), new VoidResult()
{
public void run()
{
if ( !entry.isExpanded() )
{
entry.expand();
}
}
} );
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
if ( nextName != null )
{
String adjustedNodeName = nextName != null ? adjustNodeName( entry, nextName ) : null;
SWTBotTreeItem node = entry.getNode( adjustedNodeName );
if ( node == null )
{
return false;
}
}
return !entry.getNodes().contains( "Fetching Entries..." );
}
public String getFailureMessage()
{
return "Could not find entry " + entry.getText() + " -> " + nextName;
}
} );
}
private static String adjustNodeName( SWTBotTreeItem child, String nodeName )
{
List<String> nodes = child.getNodes();
for ( String node : nodes )
{
if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
{
return node;
}
}
return null;
}
private static String adjustNodeName( SWTBotTree tree, String nodeName )
{
SWTBotTreeItem[] allItems = tree.getAllItems();
for ( SWTBotTreeItem item : allItems )
{
String node = item.getText();
if ( node.toUpperCase().startsWith( nodeName.toUpperCase() ) )
{
return node;
}
}
return null;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/ContextMenuHelper.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/ContextMenuHelper.java | /*
* 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.utils;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withRegex;
import static org.hamcrest.Matchers.allOf;
import static org.hamcrest.Matchers.instanceOf;
import java.util.Arrays;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
import org.eclipse.swtbot.swt.finder.results.VoidResult;
import org.eclipse.swtbot.swt.finder.results.WidgetResult;
import org.eclipse.swtbot.swt.finder.widgets.AbstractSWTBot;
import org.hamcrest.Matcher;
/**
* A helper to click context menus
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class ContextMenuHelper
{
/**
* Clicks the context menu matching the text.
*
* @param text
* the text on the context menu.
* @throws WidgetNotFoundException
* if the widget is not found.
*/
public static void clickContextMenu( final AbstractSWTBot<?> bot, final String... texts )
{
final Matcher<?>[] matchers = new Matcher<?>[texts.length];
for ( int i = 0; i < texts.length; i++ )
{
// matchers[i] = allOf( instanceOf( MenuItem.class ), withMnemonic( texts[i] ) );
matchers[i] = allOf( instanceOf( MenuItem.class ), withRegex( texts[i] ) );
}
// show
final MenuItem menuItem = UIThreadRunnable.syncExec( new WidgetResult<MenuItem>()
{
public MenuItem run()
{
MenuItem menuItem = null;
Control control = ( Control ) bot.widget;
Menu menu = control.getMenu();
for ( int i = 0; i < matchers.length; i++ )
{
menuItem = show( menu, matchers[i] );
if ( menuItem != null )
{
menu = menuItem.getMenu();
}
else
{
hide( menu );
break;
}
}
return menuItem;
}
} );
if ( menuItem == null )
{
throw new WidgetNotFoundException( "Could not find menu: " + Arrays.asList( texts ) );
}
// click
click( menuItem );
// hide
UIThreadRunnable.syncExec( new VoidResult()
{
public void run()
{
hide( menuItem.getParent() );
}
} );
}
private static MenuItem show( final Menu menu, final Matcher<?> matcher )
{
if ( menu != null )
{
menu.notifyListeners( SWT.Show, new Event() );
MenuItem[] items = menu.getItems();
for ( final MenuItem menuItem : items )
{
if ( matcher.matches( menuItem ) )
{
return menuItem;
}
}
menu.notifyListeners( SWT.Hide, new Event() );
}
return null;
}
private static void click( final MenuItem menuItem )
{
final Event event = new Event();
event.time = ( int ) System.currentTimeMillis();
event.widget = menuItem;
event.display = menuItem.getDisplay();
event.type = SWT.Selection;
UIThreadRunnable.asyncExec( menuItem.getDisplay(), new VoidResult()
{
public void run()
{
menuItem.notifyListeners( SWT.Selection, event );
}
} );
}
private static void hide( final Menu menu )
{
menu.notifyListeners( SWT.Hide, new Event() );
if ( menu.getParentMenu() != null )
{
hide( menu.getParentMenu() );
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/ApacheDsUtils.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/ApacheDsUtils.java | /*
* 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.utils;
import static org.apache.directory.studio.test.integration.ui.utils.Constants.LOCALHOST;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.directory.Attribute;
import javax.naming.directory.Attributes;
import javax.naming.directory.BasicAttribute;
import javax.naming.directory.DirContext;
import javax.naming.directory.ModificationItem;
import javax.naming.ldap.InitialLdapContext;
import org.apache.directory.server.ldap.LdapServer;
/**
* Utils for ApacheDS.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class ApacheDsUtils
{
public static void enableSchema( LdapServer ldapServer, String schema ) throws Exception
{
Hashtable<String, String> env = new Hashtable<String, String>();
env.put( Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory" );
env.put( Context.PROVIDER_URL, "ldap://" + LOCALHOST + ":" + ldapServer.getPort() );
env.put( Context.SECURITY_PRINCIPAL, "uid=admin,ou=system" );
env.put( Context.SECURITY_CREDENTIALS, "secret" );
env.put( Context.SECURITY_AUTHENTICATION, "simple" );
DirContext schemaRoot = ( DirContext ) new InitialLdapContext( env, null ).lookup( "ou=schema" );
Attributes krb5kdcAttrs = schemaRoot.getAttributes( "cn=" + schema );
boolean isKrb5KdcDisabled = false;
if ( krb5kdcAttrs.get( "m-disabled" ) != null )
{
isKrb5KdcDisabled = ( ( String ) krb5kdcAttrs.get( "m-disabled" ).get() ).equalsIgnoreCase( "TRUE" );
}
// if krb5kdc is disabled then enable it
if ( isKrb5KdcDisabled )
{
Attribute disabled = new BasicAttribute( "m-disabled" );
ModificationItem[] mods = new ModificationItem[]
{ new ModificationItem( DirContext.REMOVE_ATTRIBUTE, disabled ) };
schemaRoot.modifyAttributes( "cn=" + schema, mods );
}
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/Characters.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/Characters.java | /*
* 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.utils;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
public class Characters
{
public static final String LATIN_A = "A";
public static final String LATIN_E_ACUTE = "\u00E9";
public static final String EURO = "\u20AC";
public static final String CYRILLIC_YA = "\u042F";
public static final String GREEK_LAMBDA = "\u03BB";
public static final String HEBREW_SHIN = "\u05E9";
public static final String ARABIC_AIN = "\u0639";
public static final String CJK_RADICAL_HEAD = "\u2EE1";
public static final String SMILEY = "\uD83D\uDE08";
public static final String ALL = "" +
LATIN_A + " " +
LATIN_E_ACUTE + " " +
EURO + " " +
CYRILLIC_YA + " " +
GREEK_LAMBDA + " " +
HEBREW_SHIN + " " +
ARABIC_AIN + " " +
CJK_RADICAL_HEAD + " "
// SMILEY + " "
;
public static final String ALL_UTF8_BASE64 = toUtf8Base64( ALL );
public static final String toUtf8Base64( String s )
{
return Base64.getEncoder()
.encodeToString( s.getBytes( StandardCharsets.UTF_8 ) );
}
public void print()
{
System.out.println( LATIN_A );
System.out.println( LATIN_E_ACUTE );
System.out.println( EURO );
System.out.println( CYRILLIC_YA );
System.out.println( GREEK_LAMBDA );
System.out.println( HEBREW_SHIN );
System.out.println( ARABIC_AIN );
System.out.println( CJK_RADICAL_HEAD );
System.out.println( SMILEY );
System.out.println( ALL );
System.out.println( ALL_UTF8_BASE64 );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/JobWatcher.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/JobWatcher.java | /*
* 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.utils;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.directory.studio.common.core.jobs.StudioJob;
import org.apache.directory.studio.connection.core.jobs.StudioConnectionRunnableWithProgress;
import org.apache.directory.studio.connection.ui.RunnableContextRunner;
import org.apache.directory.studio.test.integration.ui.bots.BotUtils;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.swtbot.swt.finder.SWTBot;
import org.eclipse.swtbot.swt.finder.utils.SWTBotPreferences;
import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
/**
* Helper class that watches particular job. The job is identified by its name.
*
* @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
* @version $Rev$, $Date$
*/
public class JobWatcher
{
private final AtomicBoolean done = new AtomicBoolean();
private final IJobManager jobManager = StudioJob.getJobManager();
private final JobChangeAdapter jobChangeListener;
private final RunnableContextRunner.Listener runnnableContextRunnerListener;
private final List<String> jobNames;
private void removeListeners()
{
jobManager.removeJobChangeListener( jobChangeListener );
RunnableContextRunner.removeListener( runnnableContextRunnerListener );
}
/**
* Creates a new instance of JobWatcher.
*
* @param jobName the name of the watched job
*/
public JobWatcher( final String... jobNames )
{
this.jobNames = Arrays.asList( jobNames );
// System.out.println( "Init for jobs: " + this.jobNames );
// register a job listener that checks if the job is finished
jobChangeListener = new JobChangeAdapter()
{
public void done( IJobChangeEvent event )
{
// System.out.println( "Done called: event=" + event.getJob().getName() );
// if the done job has the expected name we are done
for ( String jobName : jobNames )
{
if ( event.getJob().getName().startsWith( jobName ) )
{
// System.out.println( "Done done: " + jobName );
done.set( true );
removeListeners();
}
}
}
};
jobManager.addJobChangeListener( jobChangeListener );
runnnableContextRunnerListener = new RunnableContextRunner.Listener()
{
@Override
public void done( StudioConnectionRunnableWithProgress runnable, IStatus status )
{
// System.out.println( "Done called: runnable=" + runnable.getName() );
for ( String jobName : jobNames )
{
if ( runnable.getName().startsWith( jobName ) )
{
// System.out.println( "Done done: " + jobName );
done.set( true );
removeListeners();
}
}
}
};
RunnableContextRunner.addListener( runnnableContextRunnerListener );
}
/**
* Waits until the watched job is done.
*/
public void waitUntilDone()
{
// System.out.println( "Wait for jobs: " + jobNames );
SWTBot bot = new SWTBot();
bot.waitUntil( new DefaultCondition()
{
public boolean test() throws Exception
{
if ( done.get() )
{
// System.out.println( "Done is true: " + jobNames );
removeListeners();
return true;
}
return false;
}
public String getFailureMessage()
{
removeListeners();
return "Waited for jobs " + jobNames + " to finish";
}
}, SWTBotPreferences.TIMEOUT * 4 );
// Wait a bit longer after job is done to allow UI update
BotUtils.sleep( 100L );
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/StudioSystemUtils.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/StudioSystemUtils.java | /*
* 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.utils;
import org.apache.commons.lang3.SystemUtils;
public class StudioSystemUtils extends SystemUtils
{
public static final boolean IS_OS_WINDOWS_SERVER = isOSNameMatch( SystemUtils.OS_NAME, "Windows Server");
static boolean isOSNameMatch(final String osName, final String osNamePrefix) {
if (osName == null) {
return false;
}
return osName.startsWith(osNamePrefix);
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/Constants.java | tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/utils/Constants.java | /*
* 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.utils;
import org.apache.directory.api.util.Network;
public final class Constants
{
public static final String LOCALHOST = Network.LOOPBACK_HOSTNAME;
public static final String LOCALHOST_ADDRESS = Network.LOOPBACK.getHostAddress();
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
apache/directory-studio | https://github.com/apache/directory-studio/blob/e55b93d729a60c986fc93e52f9519f4bbdf51252/tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestData.java | tests/test.integration.core/src/main/java/org/apache/directory/studio/test/integration/junit5/TestData.java | /*
* 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.junit5;
import java.nio.charset.StandardCharsets;
import org.apache.commons.lang3.RandomStringUtils;
/**
* Utility to generate test data.
*/
public class TestData
{
public static byte[] jpegImage( int size )
{
byte[] jpegImage = RandomStringUtils.randomAscii( size ).getBytes( StandardCharsets.UTF_8 );
System.arraycopy( new byte[]
{
( byte ) 0xFF,
( byte ) 0xD8,
( byte ) 0XFF,
( byte ) 0XE0,
( byte ) 0X00,
( byte ) 0X00,
'J',
'F',
'I',
'F',
( byte ) 0X00 },
0, jpegImage, 0, 11 );
return jpegImage;
}
}
| java | Apache-2.0 | e55b93d729a60c986fc93e52f9519f4bbdf51252 | 2026-01-05T02:32:00.866394Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.