*/
@Test
public void testCopyPasteSearchBetweenConnections() throws Exception
{
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.selectConnection( connection1.getName() );
browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system" );
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.selectConnection( connection2.getName() );
browserViewBot.selectEntry( "Searches" );
SearchPropertiesDialogBot searchPropertiesDialogBot = browserViewBot.pasteSearch();
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() );
}