Java 类com.google.inject.servlet.ServletSpiVisitor.Params 实例源码

项目:guice-old    文件:ExtensionSpiTest.java   
private void validateVisitor(ServletSpiVisitor visitor) {
  assertEquals(48, visitor.currentCount - visitor.otherCount);

  // This is the expected param list, in order..
  List<Params> expected = ImmutableList.of(
      new Params("/class", Key.get(DummyFilterImpl.class), ImmutableMap.of(), SERVLET),
      new Params("/class/2", Key.get(DummyFilterImpl.class), ImmutableMap.of(), SERVLET),
      new Params("/key", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), SERVLET),
      new Params("/key/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), SERVLET),
      new Params("/instance", dummyFilter1, ImmutableMap.of(), SERVLET),
      new Params("/instance/2", dummyFilter1, ImmutableMap.of(), SERVLET),
      new Params("/class/keyvalues", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/class/keyvalues/2", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/key/keyvalues", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/key/keyvalues/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/instance/keyvalues", dummyFilter2, ImmutableMap.of("key", "value"), SERVLET),
      new Params("/instance/keyvalues/2", dummyFilter2, ImmutableMap.of("key", "value"), SERVLET),

      new Params("/class[0-9]", Key.get(DummyFilterImpl.class), ImmutableMap.of(), REGEX),
      new Params("/class[0-9]/2", Key.get(DummyFilterImpl.class), ImmutableMap.of(), REGEX),
      new Params("/key[0-9]", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), REGEX),
      new Params("/key[0-9]/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), REGEX),
      new Params("/instance[0-9]", dummyFilter3, ImmutableMap.of(), REGEX),
      new Params("/instance[0-9]/2", dummyFilter3, ImmutableMap.of(), REGEX),
      new Params("/class[0-9]/keyvalues", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), REGEX),
      new Params("/class[0-9]/keyvalues/2", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), REGEX),
      new Params("/key[0-9]/keyvalues", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX),
      new Params("/key[0-9]/keyvalues/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX),
      new Params("/instance[0-9]/keyvalues", dummyFilter4, ImmutableMap.of("key", "value"), REGEX),
      new Params("/instance[0-9]/keyvalues/2", dummyFilter4, ImmutableMap.of("key", "value"), REGEX),

      new Params("/class", Key.get(DummyServlet.class), ImmutableMap.of(), SERVLET),
      new Params("/class/2", Key.get(DummyServlet.class), ImmutableMap.of(), SERVLET),
      new Params("/key", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), SERVLET),
      new Params("/key/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), SERVLET),
      new Params("/instance", dummyServlet1, ImmutableMap.of(), SERVLET),
      new Params("/instance/2", dummyServlet1, ImmutableMap.of(), SERVLET),
      new Params("/class/keyvalues", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/class/keyvalues/2", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/key/keyvalues", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/key/keyvalues/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/instance/keyvalues", dummyServlet2, ImmutableMap.of("key", "value"), SERVLET),
      new Params("/instance/keyvalues/2", dummyServlet2, ImmutableMap.of("key", "value"), SERVLET),

      new Params("/class[0-9]", Key.get(DummyServlet.class), ImmutableMap.of(), REGEX),
      new Params("/class[0-9]/2", Key.get(DummyServlet.class), ImmutableMap.of(), REGEX),
      new Params("/key[0-9]", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), REGEX),
      new Params("/key[0-9]/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), REGEX),
      new Params("/instance[0-9]", dummyServlet3, ImmutableMap.of(), REGEX),
      new Params("/instance[0-9]/2", dummyServlet3, ImmutableMap.of(), REGEX),
      new Params("/class[0-9]/keyvalues", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), REGEX),
      new Params("/class[0-9]/keyvalues/2", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), REGEX),
      new Params("/key[0-9]/keyvalues", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX),
      new Params("/key[0-9]/keyvalues/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX),
      new Params("/instance[0-9]/keyvalues", dummyServlet4, ImmutableMap.of("key", "value"), REGEX),
      new Params("/instance[0-9]/keyvalues/2", dummyServlet4, ImmutableMap.of("key", "value"), REGEX)
  );

  assertEquals(expected.size(), visitor.actual.size());
  Iterator<Params> actualIterator = visitor.actual.iterator();
  int i = 0;
  for(Params param : expected) {
    assertEquals("wrong " + i++ + "th param", param, actualIterator.next());
  }
}
项目:google-guice    文件:ExtensionSpiTest.java   
private void validateVisitor(ServletSpiVisitor visitor) {
  assertEquals(48, visitor.currentCount - visitor.otherCount);

  // This is the expected param list, in order..
  List<Params> expected = ImmutableList.of(
      new Params("/class", Key.get(DummyFilterImpl.class), ImmutableMap.of(), SERVLET),
      new Params("/class/2", Key.get(DummyFilterImpl.class), ImmutableMap.of(), SERVLET),
      new Params("/key", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), SERVLET),
      new Params("/key/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), SERVLET),
      new Params("/instance", dummyFilter1, ImmutableMap.of(), SERVLET),
      new Params("/instance/2", dummyFilter1, ImmutableMap.of(), SERVLET),
      new Params("/class/keyvalues", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/class/keyvalues/2", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/key/keyvalues", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/key/keyvalues/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/instance/keyvalues", dummyFilter2, ImmutableMap.of("key", "value"), SERVLET),
      new Params("/instance/keyvalues/2", dummyFilter2, ImmutableMap.of("key", "value"), SERVLET),

      new Params("/class[0-9]", Key.get(DummyFilterImpl.class), ImmutableMap.of(), REGEX),
      new Params("/class[0-9]/2", Key.get(DummyFilterImpl.class), ImmutableMap.of(), REGEX),
      new Params("/key[0-9]", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), REGEX),
      new Params("/key[0-9]/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of(), REGEX),
      new Params("/instance[0-9]", dummyFilter3, ImmutableMap.of(), REGEX),
      new Params("/instance[0-9]/2", dummyFilter3, ImmutableMap.of(), REGEX),
      new Params("/class[0-9]/keyvalues", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), REGEX),
      new Params("/class[0-9]/keyvalues/2", Key.get(DummyFilterImpl.class), ImmutableMap.of("key", "value"), REGEX),
      new Params("/key[0-9]/keyvalues", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX),
      new Params("/key[0-9]/keyvalues/2", Key.get(DummyFilterImpl.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX),
      new Params("/instance[0-9]/keyvalues", dummyFilter4, ImmutableMap.of("key", "value"), REGEX),
      new Params("/instance[0-9]/keyvalues/2", dummyFilter4, ImmutableMap.of("key", "value"), REGEX),

      new Params("/class", Key.get(DummyServlet.class), ImmutableMap.of(), SERVLET),
      new Params("/class/2", Key.get(DummyServlet.class), ImmutableMap.of(), SERVLET),
      new Params("/key", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), SERVLET),
      new Params("/key/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), SERVLET),
      new Params("/instance", dummyServlet1, ImmutableMap.of(), SERVLET),
      new Params("/instance/2", dummyServlet1, ImmutableMap.of(), SERVLET),
      new Params("/class/keyvalues", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/class/keyvalues/2", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/key/keyvalues", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/key/keyvalues/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), SERVLET),
      new Params("/instance/keyvalues", dummyServlet2, ImmutableMap.of("key", "value"), SERVLET),
      new Params("/instance/keyvalues/2", dummyServlet2, ImmutableMap.of("key", "value"), SERVLET),

      new Params("/class[0-9]", Key.get(DummyServlet.class), ImmutableMap.of(), REGEX),
      new Params("/class[0-9]/2", Key.get(DummyServlet.class), ImmutableMap.of(), REGEX),
      new Params("/key[0-9]", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), REGEX),
      new Params("/key[0-9]/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of(), REGEX),
      new Params("/instance[0-9]", dummyServlet3, ImmutableMap.of(), REGEX),
      new Params("/instance[0-9]/2", dummyServlet3, ImmutableMap.of(), REGEX),
      new Params("/class[0-9]/keyvalues", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), REGEX),
      new Params("/class[0-9]/keyvalues/2", Key.get(DummyServlet.class), ImmutableMap.of("key", "value"), REGEX),
      new Params("/key[0-9]/keyvalues", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX),
      new Params("/key[0-9]/keyvalues/2", Key.get(DummyServlet.class, Names.named("foo")), ImmutableMap.of("key", "value"), REGEX),
      new Params("/instance[0-9]/keyvalues", dummyServlet4, ImmutableMap.of("key", "value"), REGEX),
      new Params("/instance[0-9]/keyvalues/2", dummyServlet4, ImmutableMap.of("key", "value"), REGEX)
  );

  assertEquals(expected.size(), visitor.actual.size());
  Iterator<Params> actualIterator = visitor.actual.iterator();
  int i = 0;
  for(Params param : expected) {
    assertEquals("wrong " + i++ + "th param", param, actualIterator.next());
  }
}