use of org.junit.jupiter.api.extension.ExtendWith in project junit5 by junit-team.
the class ClasspathScannerTests method doesNotLoopInfinitelyWithCircularSymlinks.
@Test
@ExtendWith(TempDirectory.class)
void doesNotLoopInfinitelyWithCircularSymlinks(@Root Path tempDir) throws Exception {
// Abort if running on Microsoft Windows since we are testing symbolic links
assumeFalse(System.getProperty("os.name").toLowerCase().contains("win"));
Path directory = Files.createDirectory(tempDir.resolve("directory"));
Path symlink1 = Files.createSymbolicLink(tempDir.resolve("symlink1"), directory);
Files.createSymbolicLink(directory.resolve("symlink2"), symlink1);
List<Class<?>> classes = classpathScanner.scanForClassesInClasspathRoot(symlink1.toUri(), allClasses);
assertThat(classes).isEmpty();
}
use of org.junit.jupiter.api.extension.ExtendWith in project hive by apache.
the class TestLlapDaemonLogging method testQueryRoutingNoLeakFileDescriptors.
@Test
@Log4jConfig("llap-daemon-routing-log4j2.properties")
@ExtendWith(LlapDaemonExtension.class)
@ExtendWith(DoNothingTCPServerExtension.class)
void testQueryRoutingNoLeakFileDescriptors(LlapDaemon daemon, DoNothingTCPServer amMockServer) throws IOException, InterruptedException {
final int amPort = amMockServer.port();
Credentials credentials = validSessionCredentials();
String appId = "application_1540489363818_0021";
for (int i = 0; i < 10; i++) {
String queryId = "query" + i;
int dagId = 1000 + i;
daemon.registerDag(LlapDaemonTestUtils.buildRegisterDagRequest(appId, dagId, credentials));
daemon.submitWork(LlapDaemonTestUtils.buildSubmitProtoRequest(appId, dagId, queryId, amPort, credentials));
daemon.queryComplete(LlapDaemonTestUtils.buildQueryCompleteRequest(appId, dagId));
}
// Busy wait till all daemon tasks are treated
while (!daemon.getExecutorsStatus().isEmpty()) {
Thread.sleep(100);
}
// The IdlePurgePolicy used should close appenders after 5 seconds of inactivity.
// Wait for 8 sec to give some margin.
Thread.sleep(8000);
Pattern pn = Pattern.compile("query\\d++-dag_1540489363818_0021_\\d{4}\\.log");
assertEquals(0, findOpenFileDescriptors(pn).count());
}
use of org.junit.jupiter.api.extension.ExtendWith in project junit5 by junit-team.
the class ReflectionUtilsTests method getAllClasspathRootDirectories.
@Test
@ExtendWith(TempDirectory.class)
void getAllClasspathRootDirectories(@Root Path tempDirectory) throws Exception {
Path root1 = tempDirectory.resolve("root1").toAbsolutePath();
Path root2 = tempDirectory.resolve("root2").toAbsolutePath();
String testClassPath = root1 + File.pathSeparator + root2;
String originalClassPath = System.setProperty("java.class.path", testClassPath);
try {
createDirectories(root1, root2);
assertThat(ReflectionUtils.getAllClasspathRootDirectories()).containsOnly(root1, root2);
} finally {
System.setProperty("java.class.path", originalClassPath);
}
}
use of org.junit.jupiter.api.extension.ExtendWith in project spring-boot by spring-projects.
the class JtaAutoConfigurationTests method transactionManagerFromJndi.
@ParameterizedTest
@ExtendWith(JndiExtension.class)
@MethodSource("transactionManagerJndiEntries")
void transactionManagerFromJndi(JndiEntry jndiEntry, InitialContext initialContext) throws NamingException {
jndiEntry.register(initialContext);
this.context = new AnnotationConfigApplicationContext(JtaAutoConfiguration.class);
JtaTransactionManager transactionManager = this.context.getBean(JtaTransactionManager.class);
if (jndiEntry.value instanceof UserTransaction) {
assertThat(transactionManager.getUserTransaction()).isEqualTo(jndiEntry.value);
assertThat(transactionManager.getTransactionManager()).isNull();
} else {
assertThat(transactionManager.getUserTransaction()).isInstanceOf(UserTransactionAdapter.class);
assertThat(transactionManager.getTransactionManager()).isEqualTo(jndiEntry.value);
}
}
use of org.junit.jupiter.api.extension.ExtendWith in project spring-boot by spring-projects.
the class JtaAutoConfigurationTests method disableJtaSupport.
@Test
@ExtendWith(JndiExtension.class)
void disableJtaSupport(InitialContext initialContext) throws NamingException {
new JndiEntry("java:comp/UserTransaction", UserTransaction.class).register(initialContext);
this.context = new AnnotationConfigApplicationContext();
TestPropertyValues.of("spring.jta.enabled:false").applyTo(this.context);
this.context.register(JtaAutoConfiguration.class);
this.context.refresh();
assertThat(this.context.getBeansOfType(JtaTransactionManager.class)).isEmpty();
}
Aggregations