예제 #1
1
 @Test
 public void testFlattenResult() {
   List<Integer> list = List.list(1, 2, 3, 4, 5, 0, 6, 7, 8, 9);
   List<Double> list2 = List.flattenResult(list.map(inverse));
   assertEquals(
       "[1.0, 0.5, 0.3333333333333333, 0.25, 0.2, 0.16666666666666666, 0.14285714285714285, 0.125, 0.1111111111111111, NIL]",
       list2.toString());
 }
 @Test
 public void testNetworkConfig() {
   NetworkConfig networkConfig = config.getNetworkConfig();
   assertNotNull(networkConfig);
   assertEquals(5700, networkConfig.getPort());
   assertFalse(networkConfig.isPortAutoIncrement());
   final Collection<String> allowedPorts = networkConfig.getOutboundPortDefinitions();
   assertEquals(2, allowedPorts.size());
   Iterator portIter = allowedPorts.iterator();
   assertEquals("35000-35100", portIter.next());
   assertEquals("36000,36100", portIter.next());
   assertFalse(networkConfig.getJoin().getMulticastConfig().isEnabled());
   assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeoutSeconds(), 8);
   assertEquals(networkConfig.getJoin().getMulticastConfig().getMulticastTimeToLive(), 16);
   assertFalse(networkConfig.getInterfaces().isEnabled());
   assertEquals(1, networkConfig.getInterfaces().getInterfaces().size());
   assertEquals("10.10.1.*", networkConfig.getInterfaces().getInterfaces().iterator().next());
   TcpIpConfig tcp = networkConfig.getJoin().getTcpIpConfig();
   assertNotNull(tcp);
   assertTrue(tcp.isEnabled());
   assertTrue(networkConfig.getSymmetricEncryptionConfig().isEnabled());
   final List<String> members = tcp.getMembers();
   assertEquals(members.toString(), 2, members.size());
   assertEquals("127.0.0.1:5700", members.get(0));
   assertEquals("127.0.0.1:5701", members.get(1));
   assertEquals("127.0.0.1:5700", tcp.getRequiredMember());
   AwsConfig aws = networkConfig.getJoin().getAwsConfig();
   assertFalse(aws.isEnabled());
   assertEquals("sample-access-key", aws.getAccessKey());
   assertEquals("sample-secret-key", aws.getSecretKey());
   assertEquals("sample-region", aws.getRegion());
   assertEquals("sample-group", aws.getSecurityGroupName());
   assertEquals("sample-tag-key", aws.getTagKey());
   assertEquals("sample-tag-value", aws.getTagValue());
 }
예제 #3
0
  @Test
  public void allExtensions() {
    ExtensionPoint ep1 = mockExtensionPoint("ep1", EP1);
    ExtensionDescriptor ed1 =
        mockExtensionDescriptor("ed1", new ExtensionPoint[] {ep1}, new Extension[] {});
    ExtensionDescriptor ed2 =
        mockExtensionDescriptor(
            "ed2", new ExtensionPoint[] {}, new Extension[] {mockExtension("e1", EP1)});
    ExtensionDescriptor ed3 =
        mockExtensionDescriptor(
            "ed3", new ExtensionPoint[] {}, new Extension[] {mockExtension("e2", EP1)});
    ExtensionRegistry.getInstance().registerExtensionDescriptor(ed3);
    ExtensionRegistry.getInstance().registerExtensionDescriptor(ed2);
    ExtensionRegistry.getInstance().registerExtensionDescriptor(ed1);

    Iterable<Extension<?>> extensions = ep1.getExtensions();
    List<Extension> extensionList = new ArrayList();
    for (Iterator<Extension> it = ExtensionRegistry.getInstance().getExtensions(ep1).iterator();
        it.hasNext(); ) {
      extensionList.add(it.next());
    }
    assertSame(2, extensionList.size());
    Collections.sort(
        extensionList,
        new Comparator<Extension>() {
          @Override
          public int compare(Extension o1, Extension o2) {
            return String.CASE_INSENSITIVE_ORDER.compare(String.valueOf(o1), String.valueOf(o2));
          }
        });
    assertEquals("[e1, e2]", extensionList.toString());

    ExtensionRegistry.getInstance().unregisterExtensionDescriptor(ed3);
    ExtensionRegistry.getInstance().unregisterExtensionDescriptor(ed2);
    ExtensionRegistry.getInstance().unregisterExtensionDescriptor(ed1);
  }