@Override public void run() { Closer.closeSilently(LOCK); } });
public static void resetClocks() throws IllegalAccessException { resetClock(Log4jLogEvent.class); resetClock(AsyncLogger.class); }
@Override public void run() { final int pos = index * count; final long start = System.nanoTime(); for (int i=pos; i < pos + count; ++i) { uuids[i] = UuidUtil.getTimeBasedUuid(); } elapsed[index] = System.nanoTime() - start; } }
@Override public void run() { final Thread thread = Thread.currentThread(); try { writer(lock, logEventCount, thread.getName(), createOnDemand, true); } catch (final Exception e) { exceptionRef[0] = e; Throwables.rethrow(e); } } }
@Test public void testReturnsSystemNanoTime() { final NanoClock clock = new SystemNanoClock(); final long expected = System.nanoTime(); final long actual = clock.nanoTime(); assertTrue("smal difference", actual - expected < TimeUnit.SECONDS.toNanos(1)); }
@Test public void testCeilingNextPowerOfTwoReturnsNextPowerOfTwo() { final int powerOfTwo = Integers.ceilingNextPowerOfTwo(1000); assertEquals(1024, powerOfTwo); }
@Test(expected = IllegalArgumentException.class) public void testSizeNegative() { final CyclicBuffer<Integer> buffer = new CyclicBuffer<>(Integer.class, -1); }
@Test public void testReturnsConstructorValue() { assertEquals(123, new DummyNanoClock(123).nanoTime()); }
@AfterClass public static void afterClass() throws IllegalAccessException { ClockFactoryTest.resetClocks(); }
@BeforeClass public static void beforeClass() { Assume.assumeTrue(FileUtils.isFilePosixAttributeViewSupported()); }
@Test public void isEmpty() throws Exception { assertEquals(isEmpty, Assert.isEmpty(value)); }
public static void resetClock(final Class<?> clazz) throws IllegalAccessException { System.clearProperty(ClockFactory.PROPERTY_NAME); final Field field = FieldUtils.getField(clazz, "CLOCK", true); FieldUtils.removeFinalModifier(field, true); FieldUtils.writeStaticField(field, ClockFactory.getClock(), false); }
@Test(expected = NoSuchMethodException.class) public void testRethrowCheckedException() throws Exception { Throwables.rethrow(new NoSuchMethodException()); } }
@Test public void testCeilingNextPowerOfTwoReturnsExactPowerOfTwo() { final int powerOfTwo = Integers.ceilingNextPowerOfTwo(1024); assertEquals(1024, powerOfTwo); }
@Before public void setUp() throws Exception { resetClocks(); }
@Test(expected = NullPointerException.class) public void testRethrowRuntimeException() throws Exception { Throwables.rethrow(new NullPointerException()); }
@AfterClass public static void afterClass() throws IllegalAccessException { ClockFactoryTest.resetClocks(); }
@Test(expected = UnknownError.class) public void testRethrowError() throws Exception { Throwables.rethrow(new UnknownError()); }
@AfterClass public static void afterClass() throws IllegalAccessException { System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY); ClockFactoryTest.resetClocks(); }
@AfterClass public static void afterClass() throws IllegalAccessException { System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, Strings.EMPTY); ClockFactoryTest.resetClocks(); }