1   package com.generationjava.collections;
2   
3   import junit.framework.Test;
4   import junit.framework.TestCase;
5   import junit.framework.TestSuite;
6   import junit.textui.TestRunner;
7   
8   import com.generationjava.lang.ClassW;
9   import java.util.Map;
10  
11  public class MultiKeyedMapTest extends TestCase {
12  
13      public MultiKeyedMapTest(String name) {
14          super(name);
15      }
16  
17      //-----------------------------------------------------------------------
18      // To test: 
19  
20      public void testMultiKeyes() {
21          Map map = new MultiKeyedMap();
22          String[] strs = new String[] { "com", "generationjava" };
23          map.put(strs, "GJ!");
24          strs = new String[] { "com", "smallcogs" };
25          map.put(strs, "STEVE!");
26          strs = new String[] { "com", "flamefew", "www" };
27          map.put(strs, "Ff-www");
28          strs = new String[] { "com", "flamefew", "log" };
29          map.put(strs, "Ff-log");
30          map.put("fred", "foo");
31  
32          assertEquals("STEVE!", map.get(new String[] { "com", "smallcogs" } ) );
33          assertEquals("Ff-www", ((Map)map.get(new String[] { "com", "flamefew" } )).get("www") );
34          assertEquals("foo", map.get("fred"));
35          assertEquals("foo", map.get(new String[] { "fred" } ));
36          assertEquals(true, map.containsValue("Ff-log"));
37          assertEquals(false, map.containsValue("Ff-dns"));
38      }
39  }