DATAGEODE-121 - Do not allow eager init when getting beans by type to resolve Configurers for Annotation configuration.
This commit is contained in:
@@ -74,23 +74,19 @@ public class ClientServerIntegrationTestsSupport {
|
||||
protected static final String SYSTEM_PROPERTIES_LOG_FILE = "system-properties.log";
|
||||
protected static final String TEST_GEMFIRE_LOG_LEVEL = "error";
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String asApplicationName(Class<?> type) {
|
||||
return type.getSimpleName();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String asDirectoryName(Class<?> type) {
|
||||
return String.format("%1$s-%2$s", asApplicationName(type),
|
||||
LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd-hh-mm-ss")));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static File createDirectory(String pathname) {
|
||||
return createDirectory(new File(pathname));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static File createDirectory(File directory) {
|
||||
|
||||
assertThat(directory.isDirectory() || directory.mkdirs())
|
||||
@@ -103,7 +99,6 @@ public class ClientServerIntegrationTestsSupport {
|
||||
return directory;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static int findAvailablePort() throws IOException {
|
||||
|
||||
ServerSocket serverSocket = null;
|
||||
@@ -117,110 +112,89 @@ public class ClientServerIntegrationTestsSupport {
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getClassNameAsPath(Class type) {
|
||||
return type.getName().replaceAll("\\.", "/");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getClassNameAsPath(Object obj) {
|
||||
return getClassNameAsPath(obj.getClass());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getPackageNameAsPath(Class type) {
|
||||
return type.getPackage().getName().replaceAll("\\.", "/");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getPackageNameAsPath(Object obj) {
|
||||
return getPackageNameAsPath(obj.getClass());
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getContextXmlFileLocation(Class type) {
|
||||
return getClassNameAsPath(type).concat("-context.xml");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String getServerContextXmlFileLocation(Class type) {
|
||||
return getClassNameAsPath(type).concat("-server-context.xml");
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean isDeleteDirectoryOnExit() {
|
||||
return Boolean.valueOf(System.getProperty(DIRECTORY_DELETE_ON_EXIT_PROPERTY, Boolean.TRUE.toString()));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static int intValue(Number number) {
|
||||
return (number != null ? number.intValue() : 0);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String logFile() {
|
||||
return logFile(GEMFIRE_LOG_FILE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String logFile(String defaultLogFilePathname) {
|
||||
return System.getProperty(GEMFIRE_LOG_FILE_PROPERTY, defaultLogFilePathname);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String logLevel() {
|
||||
return logLevel(GEMFIRE_LOG_LEVEL);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static String logLevel(String defaultLogLevel) {
|
||||
return System.getProperty(GEMFIRE_LOG_LEVEL_PROPERTY, defaultLogLevel);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static void logSystemProperties() throws IOException {
|
||||
FileUtils.write(new File(SYSTEM_PROPERTIES_LOG_FILE),
|
||||
String.format("%s", CollectionUtils.toString(System.getProperties())));
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static ProcessWrapper run(Class<?> type, String... arguments) throws IOException {
|
||||
return run(createDirectory(asDirectoryName(type)), type, arguments);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static ProcessWrapper run(File workingDirectory, Class<?> type, String... arguments) throws IOException {
|
||||
return isProcessRunAuto() ? launch(createDirectory(workingDirectory), type, arguments) : null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static ProcessWrapper run(String classpath, Class<?> type, String... arguments) throws IOException {
|
||||
return run(createDirectory(asDirectoryName(type)), classpath, type, arguments);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static ProcessWrapper run(File workingDirectory, String classpath, Class<?> type, String... arguments)
|
||||
throws IOException {
|
||||
|
||||
return isProcessRunAuto() ? launch(createDirectory(workingDirectory), classpath, type, arguments) : null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean isProcessRunAuto() {
|
||||
return !isProcessRunManual();
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean isProcessRunManual() {
|
||||
return Boolean.getBoolean(PROCESS_RUN_MANUAL_PROPERTY);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static AnnotationConfigApplicationContext runSpringApplication(Class<?> annotatedClass, String... args) {
|
||||
return runSpringApplication(asArray(annotatedClass), args);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static AnnotationConfigApplicationContext runSpringApplication(Class<?>[] annotatedClasses,
|
||||
String... args) {
|
||||
|
||||
@@ -232,12 +206,10 @@ public class ClientServerIntegrationTestsSupport {
|
||||
return applicationContext;
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean stop(ProcessWrapper process) {
|
||||
return stop(process, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean stop(ProcessWrapper process, long duration) {
|
||||
|
||||
return Optional.ofNullable(process)
|
||||
@@ -254,22 +226,18 @@ public class ClientServerIntegrationTestsSupport {
|
||||
.orElse(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(CacheServer cacheServer) {
|
||||
return waitForServerToStart(cacheServer.getBindAddress(), cacheServer.getPort(), DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForCacheServerToStart(CacheServer cacheServer, long duration) {
|
||||
return waitForServerToStart(cacheServer.getBindAddress(), cacheServer.getPort(), duration);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForServerToStart(String host, int port) {
|
||||
return waitForServerToStart(host, port, DEFAULT_WAIT_DURATION);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
protected static boolean waitForServerToStart(final String host, final int port, long duration) {
|
||||
|
||||
return ThreadUtils.timedWait(duration, DEFAULT_WAIT_INTERVAL, new ThreadUtils.WaitCondition() {
|
||||
@@ -313,13 +281,14 @@ public class ClientServerIntegrationTestsSupport {
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InterruptedException e) {
|
||||
catch (InterruptedException cause) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
|
||||
return condition.evaluate();
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
protected interface Condition {
|
||||
boolean evaluate();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user