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

github.com/apache/directory-studio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Seelmann <mail@stefan-seelmann.de>2021-02-19 08:27:38 +0300
committerStefan Seelmann <mail@stefan-seelmann.de>2021-02-19 08:27:38 +0300
commit3b7c332dbb0662732c11f9d1052f3ea4a513fb63 (patch)
tree9b514a16571952e3c15b64cc4faadd33a7b127a5
parent41859746fcc53e8870d3cd0205fbfe0edac7150b (diff)
DIRSTUDIO-1265: Clear entry from all caches when deleted
-rw-r--r--plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/BrowserConnection.java14
-rw-r--r--tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java38
2 files changed, 41 insertions, 11 deletions
diff --git a/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/BrowserConnection.java b/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/BrowserConnection.java
index f1845d494..671771023 100644
--- a/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/BrowserConnection.java
+++ b/plugins/ldapbrowser.core/src/main/java/org/apache/directory/studio/ldapbrowser/core/model/impl/BrowserConnection.java
@@ -608,6 +608,9 @@ public class BrowserConnection implements IBrowserConnection, Serializable
protected synchronized void uncacheEntry( IEntry entry )
{
dnToEntryCache.remove( Utils.getNormalizedOidString( entry.getDn(), getSchema() ) );
+ setAttributeInfo( entry, null );
+ setChildrenInfo( entry, null );
+ setChildrenFilter(entry, null);
}
@@ -629,17 +632,6 @@ public class BrowserConnection implements IBrowserConnection, Serializable
/**
- * Removes the entry from the cache.
- *
- * @param dn the Dn of the entry to remove from cache
- */
- protected synchronized void uncacheEntry( Dn dn )
- {
- dnToEntryCache.remove( Utils.getNormalizedOidString( dn, getSchema() ) );
- }
-
-
- /**
* Gets the children filter of the entry.
*
* @param entry the entry
diff --git a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
index d3298d925..3a6c9adb6 100644
--- a/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
+++ b/tests/test.integration.ui/src/main/java/org/apache/directory/studio/test/integration/ui/BrowserTest.java
@@ -810,7 +810,45 @@ public class BrowserTest extends AbstractLdapTestUnit
assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users (13)" ) );
assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ) );
assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.8" ) );
+ }
+
+ @Test
+ public void testDeleteClearsEntryCache() throws Exception
+ {
+ browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
+ browserViewBot.expandEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
+
+ browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" );
+ EntryEditorBot entryEditorBot = studioBot.getEntryEditorBot( "uid=user.1,ou=users,ou=system" );
+ List<String> attributeValues = entryEditorBot.getAttributeValues();
+ assertEquals( 23, attributeValues.size() );
+ assertTrue( attributeValues.contains( "uid: user.1" ) );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "initials: AA" ) );
+ DeleteDialogBot deleteDialog = browserViewBot.openDeleteDialog();
+ deleteDialog.clickOkButton();
+ browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users" );
+ assertFalse( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ) );
+
+ Entry entry = new DefaultEntry( service.getSchemaManager() );
+ entry.setDn( new Dn( "uid=user.1,ou=users,ou=system" ) );
+ entry.add( "objectClass", "top", "person", "organizationalPerson", "inetOrgPerson" );
+ entry.add( "uid", "user.1" );
+ entry.add( "givenName", "Foo" );
+ entry.add( "sn", "Bar" );
+ entry.add( "cn", "Foo Bar" );
+ entry.add( "initials", "FB" );
+ service.getAdminSession().add( entry );
+
+ browserViewBot.refresh();
+ assertTrue( browserViewBot.existsEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" ) );
+
+ browserViewBot.selectEntry( "DIT", "Root DSE", "ou=system", "ou=users", "uid=user.1" );
+ entryEditorBot = studioBot.getEntryEditorBot( "uid=user.1,ou=users,ou=system" );
+ attributeValues = entryEditorBot.getAttributeValues();
+ assertEquals( 9, attributeValues.size() );
+ assertTrue( attributeValues.contains( "uid: user.1" ) );
+ assertTrue( entryEditorBot.getAttributeValues().contains( "initials: FB" ) );
}
}