コード例 #1
0
  @Before
  public void before() throws Exception {
    // force the xn field in the request
    Random random = mock(Random.class);
    Mockito.when(random.nextInt(0xffff)).thenReturn(65535);
    whenNew(Random.class).withNoArguments().thenReturn(random);

    mockStatic(System.class);
    when(System.currentTimeMillis()).thenReturn(144140678000L).thenReturn(144140678345L);
    when(System.nanoTime()).thenReturn(100000000L, 100000000L + 345123000L);

    mockStatic(Logger.class);
    when(Logger.getLogger("com.comcast.cdn.traffic_control.traffic_router.core.access"))
        .thenReturn(accessLogger);

    header = new Header();
    header.setID(65535);
    header.setFlag(Flags.QR);

    client = Inet4Address.getByAddress(new byte[] {(byte) 192, (byte) 168, 23, 45});
    nameServer = mock(NameServer.class);
  }