< prev index next >

application/tests/org.openjdk.jmc.jdp.test/src/test/java/org/openjdk/jmc/jdp/client/TestToolkit.java

Print this page




  33 package org.openjdk.jmc.jdp.client;
  34 
  35 import java.io.UnsupportedEncodingException;
  36 import java.net.InetAddress;
  37 import java.net.MalformedURLException;
  38 import java.net.UnknownHostException;
  39 import java.security.SecureRandom;
  40 import java.util.logging.Level;
  41 
  42 import javax.management.remote.JMXServiceURL;
  43 
  44 import org.openjdk.jmc.jdp.common.Configuration;
  45 import org.openjdk.jmc.jdp.server.JDPServer;
  46 import org.openjdk.jmc.jdp.server.jmx.JMXJDPServer;
  47 
  48 @SuppressWarnings("nls")
  49 public final class TestToolkit {
  50         private static final String HEXES = "0123456789ABCDEF";
  51         private final static SecureRandom RND = new SecureRandom();
  52         public static final int TEST_MULTICAST_PORT = 7711;
  53         private static final String TEST_MULTICAST_ADDRESS_STRING = "224.0.23.177"; //$NON-NLS-1$
  54         public static final InetAddress TEST_MULTICAST_ADDRESS;
  55 
  56         static {
  57                 InetAddress tmp = null;
  58                 try {
  59                         tmp = InetAddress.getByName(TEST_MULTICAST_ADDRESS_STRING);
  60                 } catch (UnknownHostException e) {
  61                         // Multicast address by IP, should never happen!
  62                         JDPClientTest.LOGGER.log(Level.SEVERE, "Could not create test multicast address!", e); //$NON-NLS-1$ //$NON-NLS-2$
  63                 }
  64                 TEST_MULTICAST_ADDRESS = tmp;
  65         }
  66 
  67         private TestToolkit() {
  68                 throw new AssertionError("Nope!");
  69         }
  70 
  71         public static String toHexString(byte[] raw) {
  72                 if (raw == null) {
  73                         return null;
  74                 }
  75                 final StringBuilder hex = new StringBuilder(2 * raw.length);
  76                 for (final byte b : raw) {
  77                         hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F)));
  78                 }
  79                 return hex.toString();
  80         }
  81 
  82         public static long nextLong() {




  33 package org.openjdk.jmc.jdp.client;
  34 
  35 import java.io.UnsupportedEncodingException;
  36 import java.net.InetAddress;
  37 import java.net.MalformedURLException;
  38 import java.net.UnknownHostException;
  39 import java.security.SecureRandom;
  40 import java.util.logging.Level;
  41 
  42 import javax.management.remote.JMXServiceURL;
  43 
  44 import org.openjdk.jmc.jdp.common.Configuration;
  45 import org.openjdk.jmc.jdp.server.JDPServer;
  46 import org.openjdk.jmc.jdp.server.jmx.JMXJDPServer;
  47 
  48 @SuppressWarnings("nls")
  49 public final class TestToolkit {
  50         private static final String HEXES = "0123456789ABCDEF";
  51         private final static SecureRandom RND = new SecureRandom();
  52         public static final int TEST_MULTICAST_PORT = 7711;
  53         private static final String TEST_MULTICAST_ADDRESS_STRING = "224.0.23.177";
  54         public static final InetAddress TEST_MULTICAST_ADDRESS;
  55 
  56         static {
  57                 InetAddress tmp = null;
  58                 try {
  59                         tmp = InetAddress.getByName(TEST_MULTICAST_ADDRESS_STRING);
  60                 } catch (UnknownHostException e) {
  61                         // Multicast address by IP, should never happen!
  62                         JDPClientTest.LOGGER.log(Level.SEVERE, "Could not create test multicast address!", e);
  63                 }
  64                 TEST_MULTICAST_ADDRESS = tmp;
  65         }
  66 
  67         private TestToolkit() {
  68                 throw new AssertionError("Nope!");
  69         }
  70 
  71         public static String toHexString(byte[] raw) {
  72                 if (raw == null) {
  73                         return null;
  74                 }
  75                 final StringBuilder hex = new StringBuilder(2 * raw.length);
  76                 for (final byte b : raw) {
  77                         hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F)));
  78                 }
  79                 return hex.toString();
  80         }
  81 
  82         public static long nextLong() {


< prev index next >