Package java.util.logging

Examples of java.util.logging.SocketHandler


        "java.util.logging.SocketHandler.host"));
    assertNull(LOG_MANAGER.getProperty(
        "java.util.logging.SocketHandler.port"));

    try {
      h = new SocketHandler();
      fail("Should throw IllegalArgumentException!");
    } catch (IllegalArgumentException e) {
    }

    try {
      h = new SocketHandler(null, 0);
      fail("Should throw IllegalArgumentException!");
    } catch (IllegalArgumentException e) {
    }

    try {
      h = new SocketHandler("", 0);
      fail("Should throw IllegalArgumentException!");
    } catch (IllegalArgumentException e) {
    }

    try {
      h = new SocketHandler("127.0.0.1", -1);
      fail("Should throw IllegalArgumentException!");
    } catch (IllegalArgumentException e) {
    }

    try {
      h = new SocketHandler("127.0.0.1", Integer.MAX_VALUE);
      fail("Should throw IllegalArgumentException!");
    } catch (IllegalArgumentException e) {
    }

    try {
      h = new SocketHandler("127.0.0.1", 66666);
      fail("Should throw IllegalArgumentException!");
    } catch (IllegalArgumentException e) {
    }

    try {
      h = new SocketHandler("127.0.0.1", 0);
      fail("Should throw IllegalArgumentException!");
    } catch (IllegalArgumentException e) {
    }

    // start the server to be ready to accept log messages
    ServerThread thread = new ServerThread();
    thread.start();
    Thread.sleep(2000);

    h = new SocketHandler("127.0.0.1", 6666);
    assertSame(h.getLevel(), Level.ALL);
    assertTrue(h.getFormatter() instanceof XMLFormatter);
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    h.close();
View Full Code Here


    // start the server to be ready to accept log messages
    ServerThread thread = new ServerThread();
    thread.start();
    Thread.sleep(2000);

    h = new SocketHandler();
    assertSame(h.getLevel(), Level.ALL);
    assertTrue(h.getFormatter() instanceof XMLFormatter);
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    h.close();
    // ensure the thread exits and the port becomes available again
    thread.getReadString();

    try {
      h = new SocketHandler("127.0.sdfcdsfsa%%&&^0.1", 6665);
      fail("Should throw IOException!");
    } catch (IOException e) {
    }
  }
View Full Code Here

        EnvironmentHelper.PropertiesToInputStream(p));

    oldMan = System.getSecurityManager();
    System.setSecurityManager(new MockNoSocketSecurityManager());
    try {
      new SocketHandler();
      fail("Should throw SecurityException!");
    } catch (SecurityException e) {
    } finally {
      System.setSecurityManager(oldMan);
    }
    System.setSecurityManager(new MockNoSocketSecurityManager());
    try {
      new SocketHandler("127.0.0.1", 6666);
      fail("Should throw SecurityException!");
    } catch (SecurityException e) {
    } finally {
      System.setSecurityManager(oldMan);
    }
View Full Code Here

    // start the server to be ready to accept log messages
    ServerThread thread = new ServerThread();
    thread.start();
    Thread.sleep(2000);

    h = new SocketHandler();
    assertSame(h.getLevel(), Level.parse("FINE"));
    assertTrue(h.getFormatter() instanceof MockFormatter);
    assertTrue(h.getFilter() instanceof MockFilter);
    assertEquals(h.getEncoding(), "iso-8859-1");
    h.close();
    // ensure the thread exits and the port becomes available again
    thread.getReadString();

    // start the server to be ready to accept log messages
    thread = new ServerThread();
    thread.start();
    Thread.sleep(2000);

    h = new SocketHandler("127.0.0.1", 6666);
    assertSame(h.getLevel(), Level.parse("FINE"));
    assertTrue(h.getFormatter() instanceof MockFormatter);
    assertTrue(h.getFilter() instanceof MockFilter);
    assertEquals(h.getEncoding(), "iso-8859-1");
    h.close();
View Full Code Here

    // start the server to be ready to accept log messages
    ServerThread thread = new ServerThread();
    thread.start();
    Thread.sleep(2000);

    h = new SocketHandler();
    assertSame(h.getLevel(), Level.ALL);
    assertTrue(h.getFormatter() instanceof XMLFormatter);
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    h.publish(new LogRecord(Level.SEVERE, "test"));
    assertNull(h.getEncoding());
    h.close();
    // ensure the thread exits and the port becomes available again
    thread.getReadString();

    // start the server to be ready to accept log messages
    thread = new ServerThread();
    thread.start();
    Thread.sleep(2000);

    h = new SocketHandler("127.0.0.1", 6666);
    assertSame(h.getLevel(), Level.ALL);
    assertTrue(h.getFormatter() instanceof XMLFormatter);
    assertNull(h.getFilter());
    assertNull(h.getEncoding());
    h.publish(new LogRecord(Level.SEVERE, "test"));
View Full Code Here

    p.put("java.util.logging.SocketHandler.port", "6666i");
    LOG_MANAGER.readConfiguration(
        EnvironmentHelper.PropertiesToInputStream(p));

    try {
      h = new SocketHandler();
      fail("Should throw IllegalArgumentException!");
    } catch (IllegalArgumentException e) {

    }
  }
View Full Code Here

    p.put("java.util.logging.SocketHandler.port", "6665");
    LOG_MANAGER.readConfiguration(
        EnvironmentHelper.PropertiesToInputStream(p));

    try {
      h = new SocketHandler();
      fail("Should throw IOException!");
    } catch (IOException e) {

    }

    try {
      h = new SocketHandler("127.0.0.1", 6665);
      fail("Should throw IOException!");
    } catch (IOException e) {

    }
  }
View Full Code Here

    p.put("java.util.logging.SocketHandler.port", "6666");
    LOG_MANAGER.readConfiguration(
        EnvironmentHelper.PropertiesToInputStream(p));

    try {
      h = new SocketHandler();
      fail("Should throw IOException!");
    } catch (IOException e) {

    }

    try {
      h = new SocketHandler(" 34345 #$#%$%$", 6666);
      fail("Should throw IOException!");
    } catch (IOException e) {

    }
  }
View Full Code Here

    // start the server to be ready to accept log messages
    ServerThread thread = new ServerThread();
    thread.start();
    Thread.sleep(2000);

    h = new SocketHandler();
    h.publish(new LogRecord(Level.SEVERE,
        "testClose_SufficientPrivilege_NormalClose msg"));
    h.close();
    assertEquals("MockFormatter_Head"
        + "testClose_SufficientPrivilege_NormalClose msg"
View Full Code Here

    // start the server to be ready to accept log messages
    ServerThread thread = new ServerThread();
    thread.start();
    Thread.sleep(2000);

    h = new SocketHandler();
    h.setLevel(Level.INFO);

    h.close();
    assertEquals("MockFormatter_Head" + "MockFormatter_Tail", thread
        .getReadString());
View Full Code Here

TOP

Related Classes of java.util.logging.SocketHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.