@Override public Statement apply(Statement statement, Description description) { RetryOnFailure retryOnFailure = description.getAnnotation(RetryOnFailure.class); RetryOnException retryOnException = description.getAnnotation(RetryOnException.class); // sanity check that we don't use expected exceptions with the RetryOnX annotations if (retryOnFailure != null || retryOnException != null) { Test test = description.getAnnotation(Test.class); if (test.expected() != Test.None.class) { throw new IllegalArgumentException( "You cannot combine the RetryOnFailure " + "annotation with the Test(expected) annotation."); } } // sanity check that we don't use both annotations if (retryOnFailure != null && retryOnException != null) { throw new IllegalArgumentException( "You cannot combine the RetryOnFailure and RetryOnException annotations."); } if (retryOnFailure != null) { return new RetryOnFailureStatement(retryOnFailure.times(), statement); } else if (retryOnException != null) { return new RetryOnExceptionStatement( retryOnException.times(), retryOnException.exception(), statement); } else { return statement; } }
@Test public void testPrivate() { class Test { @AutoWire(name = "test") private DoubleNode mWriter; public DoubleNode getWriter() { return mWriter; } } Test t1 = new Test(); DatastreamManager.autowire(t1); Assert.assertNotNull(t1.getWriter()); }
/** Test the Test-Service for valid rest mapping. Important for development. */ @Test public void testDebugMapping() { Test cl = new Test(); String XML_LOCATION = "./restMapping.xml"; String xml = cl.getRESTMapping(); try { RESTMapper.writeFile(XML_LOCATION, xml); } catch (IOException e) { e.printStackTrace(); } XMLCheck validator = new XMLCheck(); ValidationResult result = validator.validate(xml); if (!result.isValid()) { fail(); } }
private long getTimeout(Test annotation) { if (annotation == null || annotation.timeout() == 0) { return TimeUnit.SECONDS.toMillis(DEFAULT_TEST_TIMEOUT_IN_SECONDS); } return annotation.timeout(); }