/** * Adds a new node to the end of the link list. * <p> * @param ce The feature to be added to the First * @return MemoryElementDescriptor */ protected MemoryElementDescriptor<K, V> addLast( ICacheElement<K, V> ce ) { lock.lock(); try { MemoryElementDescriptor<K, V> me = new MemoryElementDescriptor<K, V>(ce); list.addLast(me); verifyCache(ce.getKey()); return me; } finally { lock.unlock(); } }
/** * Adds a new node to the end of the link list. * <p> * * @param ce * The feature to be added to the First * @return MemoryElementDescriptor */ protected MemoryElementDescriptor<K, V> addLast(ICacheElement<K, V> ce) { lock.lock(); try { MemoryElementDescriptor<K, V> me = new MemoryElementDescriptor<K, V>(ce); list.addLast(me); if ( log.isDebugEnabled() ) { verifyCache(ce.getKey()); } return me; } finally { lock.unlock(); } }
/** verify that the last is added when the list is empty. */ public void testAddLast_NotEmpty() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); // WO WORK list.addLast( node1 ); list.addLast( node2 ); // VERIFY assertEquals( "Wrong last", node2, list.getLast() ); }
/** verify that the last is added when the list is empty. */ public void testAddLast_NotEmpty() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); // WO WORK list.addLast( node1 ); list.addLast( node2 ); // VERIFY assertEquals( "Wrong last", node2, list.getLast() ); }
/** verify that the entries are dumped. */ public void testDumpEntries_DebugTrue() { // SETUP StringWriter stringWriter = new StringWriter(); TestLogConfigurationUtil.configureLogger( stringWriter, DoubleLinkedList.class.getName() ); DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); list.addLast( node1 ); list.addLast( node2 ); list.debugDumpEntries(); // WO WORK String result = stringWriter.toString(); // VERIFY assertTrue( "Missing node in log dump", result.indexOf( payload1 ) != -1 ); assertTrue( "Missing node in log dump", result.indexOf( payload2 ) != -1 ); } }
/** verify that the entries are dumped. */ public void testDumpEntries_DebugTrue() { // SETUP StringWriter stringWriter = new StringWriter(); TestLogConfigurationUtil.configureLogger( stringWriter, DoubleLinkedList.class.getName() ); DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); String payload2 = "payload2"; DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 ); list.addLast( node1 ); list.addLast( node2 ); list.debugDumpEntries(); // WO WORK String result = stringWriter.toString(); // VERIFY assertTrue( "Missing node in log dump", result.indexOf( payload1 ) != -1 ); assertTrue( "Missing node in log dump", result.indexOf( payload2 ) != -1 ); } }
/** verify that the last is added when the list is empty. */ public void testAddLast_Empty() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); // WO WORK list.addLast( node1 ); // VERIFY assertEquals( "Wrong last", node1, list.getLast() ); }
/** verify that the last is added when the list is empty. */ public void testAddLast_Empty() { // SETUP DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>(); String payload1 = "payload1"; DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 ); // WO WORK list.addLast( node1 ); // VERIFY assertEquals( "Wrong last", node1, list.getLast() ); }