Java Collections.emptyEnumeration Examples

Java Collections.emptyEnumeration - 8 examples found. These are the top rated real world Java examples of java.util.Collections.emptyEnumeration extracted from open source projects. You can rate examples to help us improve the quality of examples.
 private <T> Enumeration<T> getEnumeration(int type) {
   if (count == 0) {
     return Collections.emptyEnumeration();
   } else {
     return new Enumerator<>(type, false);
   }
 }
  @Test
  @SuppressWarnings("unchecked")
  public void testWithOrdering() throws IOException {
    URL url1 = new URL("file://jar1.jar");
    URL sci1 = new URL("jar:file://jar1.jar!/" + CONFIG_FILE);
    URL url2 = new URL("file://dir/");
    URL sci2 = new URL("file://dir/" + CONFIG_FILE);
    loader =
        EasyMock.createMockBuilder(WebappServiceLoader.class)
            .addMockedMethod("parseConfigFile", LinkedHashSet.class, URL.class)
            .withConstructor(context)
            .createMock(control);
    List<String> jars = Arrays.asList("jar1.jar", "dir/");
    EasyMock.expect(servletContext.getAttribute(ServletContext.ORDERED_LIBS)).andReturn(jars);
    EasyMock.expect(servletContext.getResource("/WEB-INF/lib/jar1.jar")).andReturn(url1);
    loader.parseConfigFile(EasyMock.isA(LinkedHashSet.class), EasyMock.eq(sci1));
    EasyMock.expect(servletContext.getResource("/WEB-INF/lib/dir/")).andReturn(url2);
    loader.parseConfigFile(EasyMock.isA(LinkedHashSet.class), EasyMock.eq(sci2));
    EasyMock.expect(parent.getResources(CONFIG_FILE))
        .andReturn(Collections.<URL>emptyEnumeration());

    control.replay();
    Assert.assertTrue(loader.load(ServletContainerInitializer.class).isEmpty());
    control.verify();
  }
Example #3
0
  private InetAddress getWiFiIP() {
    Enumeration<NetworkInterface> interfaces;
    try {
      interfaces = NetworkInterface.getNetworkInterfaces();
    } catch (SocketException e) {
      interfaces = Collections.emptyEnumeration();
    }

    while (interfaces.hasMoreElements()) {
      NetworkInterface inter = interfaces.nextElement();
      if (inter.getDisplayName().equals("wlan0")) {
        List<InetAddress> addresses = Collections.list(inter.getInetAddresses());
        for (InetAddress address : addresses) {
          if (!address.isLoopbackAddress()
              && InetAddressUtils.isIPv4Address(address.getHostAddress())) {
            return address;
          }
        }
      }
    }

    InetAddress adr = null;
    try {
      adr = InetAddress.getByName("0.0.0.0");
    } catch (UnknownHostException e) {
      adr = null;
      e.printStackTrace();
    }
    return adr;
  }
 @Test
 public void testNoInitializersFound() throws IOException {
   loader = new WebappServiceLoader<>(context);
   EasyMock.expect(servletContext.getAttribute(ServletContext.ORDERED_LIBS)).andReturn(null);
   EasyMock.expect(cl.getResources(CONFIG_FILE)).andReturn(Collections.<URL>emptyEnumeration());
   control.replay();
   Assert.assertTrue(loader.load(ServletContainerInitializer.class).isEmpty());
   control.verify();
 }
 public Enumeration<String> getHeaders(String name) {
   String headerValue = headers.get(name);
   if (headerValue != null) {
     String[] multiValuedHeader = headerValue.split(",");
     return Collections.enumeration(Arrays.asList(multiValuedHeader));
   } else {
     return Collections.emptyEnumeration();
   }
 }
 public Enumeration<String> getInitParameterNames() {
   return Collections.emptyEnumeration();
 }