View Javadoc
1   package org.apache.commons.jcs3.utils.struct;
2   
3   import java.io.StringWriter;
4   
5   import org.apache.commons.jcs3.TestLogConfigurationUtil;
6   
7   
8   /*
9    * Licensed to the Apache Software Foundation (ASF) under one
10   * or more contributor license agreements.  See the NOTICE file
11   * distributed with this work for additional information
12   * regarding copyright ownership.  The ASF licenses this file
13   * to you under the Apache License, Version 2.0 (the
14   * "License"); you may not use this file except in compliance
15   * with the License.  You may obtain a copy of the License at
16   *
17   *   http://www.apache.org/licenses/LICENSE-2.0
18   *
19   * Unless required by applicable law or agreed to in writing,
20   * software distributed under the License is distributed on an
21   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22   * KIND, either express or implied.  See the License for the
23   * specific language governing permissions and limitations
24   * under the License.
25   */
26  
27  import junit.framework.TestCase;
28  
29  /** Unit tests for the double linked list. */
30  public class DoubleLinkedListDumpUnitTest
31      extends TestCase
32  {
33      /** verify that the entries are dumped. */
34      public void testDumpEntries_DebugTrue()
35      {
36          // SETUP
37          final StringWriter stringWriter = new StringWriter();
38          TestLogConfigurationUtil.configureLogger( stringWriter, DoubleLinkedList.class.getName() );
39  
40          final DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<>();
41  
42          final String payload1 = "payload1";
43          final DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<>( payload1 );
44  
45          final String payload2 = "payload2";
46          final DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<>( payload2 );
47  
48          list.addLast( node1 );
49          list.addLast( node2 );
50          list.debugDumpEntries();
51  
52          // WO WORK
53          final String result = stringWriter.toString();
54  
55          // VERIFY
56          assertTrue( "Missing node in log dump", result.indexOf( payload1 ) != -1 );
57          assertTrue( "Missing node in log dump", result.indexOf( payload2 ) != -1 );
58      }
59  }