Refactor remaining SDG test classes to run on Java 16.
Resolves gh-497.
This commit is contained in:
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -27,20 +26,16 @@ import java.util.concurrent.TimeUnit;
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.client.ClientRegionShortcut;
|
||||
import org.apache.geode.cache.client.Pool;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -52,7 +47,6 @@ import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.client.PoolFactoryBean;
|
||||
import org.springframework.data.gemfire.mapping.annotation.Region;
|
||||
import org.springframework.data.gemfire.process.ProcessExecutor;
|
||||
import org.springframework.data.gemfire.process.ProcessWrapper;
|
||||
import org.springframework.data.gemfire.server.CacheServerFactoryBean;
|
||||
import org.springframework.data.gemfire.support.ConnectionEndpoint;
|
||||
@@ -62,10 +56,14 @@ import org.springframework.data.gemfire.util.PropertiesBuilder;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Integrations tests for {@link GemfireTemplate} testing proper function and behavior of executing (OQL) queries
|
||||
* Integrations Tests for {@link GemfireTemplate} testing the proper function and behavior of executing (OQL) queries
|
||||
* from a cache client application using the {@link GemfireTemplate} to a cluster of GemFire servers that have
|
||||
* been grouped according to business function and data access, primarily to distribute the load.
|
||||
* been grouped according to business function and data access in order to distribute the load.
|
||||
*
|
||||
* Each GemFire {@link Pool} is configured to target a specific server group. Each group of servers in the cluster
|
||||
* defines specific {@link Region Regions} to manage data independently and separately from other data that might
|
||||
@@ -73,7 +71,7 @@ import org.springframework.test.context.junit4.SpringRunner;
|
||||
*
|
||||
* Spring Data GemFire's {@link GemfireTemplate} should intelligently employ the right
|
||||
* {@link org.apache.geode.cache.query.QueryService} configured with the {@link Region Region's} {@link Pool}
|
||||
* meta-data when executing the query in order to ensure the right servers containing the {@link Region Region's}
|
||||
* metadata when executing the query in order to ensure the right servers containing the {@link Region Region's}
|
||||
* with the data of interest are targeted.
|
||||
*
|
||||
* @author John Blum
|
||||
@@ -104,21 +102,26 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
private GemfireTemplate dogsTemplate;
|
||||
|
||||
@BeforeClass
|
||||
public static void setupGemFireCluster() throws Exception {
|
||||
serverOne = ProcessExecutor.launch(createDirectory("serverOne"), GemFireCacheServerOneConfiguration.class);
|
||||
public static void runGemFireCluster() throws Exception {
|
||||
|
||||
serverOne = run(createDirectory("serverOne"), GemFireCacheServerOneConfiguration.class);
|
||||
|
||||
waitForServerToStart("localhost", 41414);
|
||||
serverTwo = ProcessExecutor.launch(createDirectory("serverTwo"), GemFireCacheServerTwoConfiguration.class);
|
||||
|
||||
serverTwo = run(createDirectory("serverTwo"), GemFireCacheServerTwoConfiguration.class);
|
||||
|
||||
waitForServerToStart("localhost", 42424);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void shutdownGemFireCluster() {
|
||||
serverOne.stop();
|
||||
serverTwo.stop();
|
||||
stop(serverOne);
|
||||
stop(serverTwo);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void findsAllCats() {
|
||||
|
||||
List<String> catNames = catsTemplate.<String>find("SELECT c.name FROM /Cats c").asList();
|
||||
|
||||
assertThat(catNames).isNotNull();
|
||||
@@ -128,6 +131,7 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
|
||||
@Test
|
||||
public void findsAllDogs() {
|
||||
|
||||
List<String> dogNames = dogsTemplate.<String>find("SELECT d.name FROM /Dogs d").asList();
|
||||
|
||||
assertThat(dogNames).isNotNull();
|
||||
@@ -161,7 +165,7 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
}
|
||||
|
||||
String applicationName() {
|
||||
return GemFireClientCacheConfiguration.class.getName();
|
||||
return GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationTests.class.getName();
|
||||
}
|
||||
|
||||
String logLevel() {
|
||||
@@ -217,7 +221,6 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
ClientRegionFactoryBean<String, Cat> catsRegion = new ClientRegionFactoryBean<>();
|
||||
|
||||
catsRegion.setCache(gemfireCache);
|
||||
catsRegion.setClose(false);
|
||||
catsRegion.setPoolName(serverOnePool.getName());
|
||||
catsRegion.setShortcut(ClientRegionShortcut.PROXY);
|
||||
|
||||
@@ -231,7 +234,6 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
ClientRegionFactoryBean<String, Cat> dogsRegion = new ClientRegionFactoryBean<>();
|
||||
|
||||
dogsRegion.setCache(gemfireCache);
|
||||
dogsRegion.setClose(false);
|
||||
dogsRegion.setPoolName(serverTwoPool.getName());
|
||||
dogsRegion.setShortcut(ClientRegionShortcut.PROXY);
|
||||
|
||||
@@ -263,7 +265,6 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
.setProperty("name", applicationName())
|
||||
.setProperty("log-level", logLevel())
|
||||
.setProperty("locators", "localhost[11235]")
|
||||
.setProperty("enable-cluster-configuration", "false")
|
||||
.setProperty("groups", groups())
|
||||
.setProperty("start-locator", startLocator())
|
||||
.build();
|
||||
@@ -315,6 +316,11 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
@SuppressWarnings("all")
|
||||
static class GemFireCacheServerOneConfiguration extends AbstractGemFireCacheServerConfiguration {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AnnotationConfigApplicationContext(GemFireCacheServerOneConfiguration.class)
|
||||
.registerShutdownHook();
|
||||
}
|
||||
|
||||
@Resource(name = "Cats")
|
||||
private org.apache.geode.cache.Region<String, Cat> cats;
|
||||
|
||||
@@ -353,22 +359,21 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
LocalRegionFactoryBean catsRegion = new LocalRegionFactoryBean();
|
||||
|
||||
catsRegion.setCache(gemfireCache);
|
||||
catsRegion.setClose(false);
|
||||
catsRegion.setPersistent(false);
|
||||
|
||||
return catsRegion;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AnnotationConfigApplicationContext(GemFireCacheServerOneConfiguration.class)
|
||||
.registerShutdownHook();
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@SuppressWarnings("all")
|
||||
static class GemFireCacheServerTwoConfiguration extends AbstractGemFireCacheServerConfiguration {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AnnotationConfigApplicationContext(GemFireCacheServerTwoConfiguration.class)
|
||||
.registerShutdownHook();
|
||||
}
|
||||
|
||||
@Resource(name = "Dogs")
|
||||
private org.apache.geode.cache.Region<String, Dog> dogs;
|
||||
|
||||
@@ -399,15 +404,9 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
|
||||
LocalRegionFactoryBean<String, Dog> dogsRegion = new LocalRegionFactoryBean<String, Dog>();
|
||||
|
||||
dogsRegion.setCache(gemfireCache);
|
||||
dogsRegion.setClose(false);
|
||||
dogsRegion.setPersistent(false);
|
||||
|
||||
return dogsRegion;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new AnnotationConfigApplicationContext(GemFireCacheServerTwoConfiguration.class)
|
||||
.registerShutdownHook();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.config.annotation;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -23,12 +22,12 @@ import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.Region;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
@@ -39,9 +38,10 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
/**
|
||||
* The EnableLuceneIndexingConfigurationIntegrationTests class...
|
||||
* Integration Tests for Lucene Indexing Configuration.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.process;
|
||||
|
||||
import static org.springframework.data.gemfire.util.ArrayUtils.nullSafeArray;
|
||||
@@ -26,6 +25,7 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.data.gemfire.test.support.FileSystemUtils;
|
||||
import org.springframework.data.gemfire.util.CollectionUtils;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -86,6 +86,12 @@ public abstract class ProcessExecutor {
|
||||
command.add(JAVA_EXE.getAbsolutePath());
|
||||
command.add("-server");
|
||||
command.add("-ea");
|
||||
command.add("--add-opens");
|
||||
command.add("java.base/java.lang=ALL-UNNAMED");
|
||||
command.add("--add-opens");
|
||||
command.add("java.base/java.nio=ALL-UNNAMED");
|
||||
command.add("--add-opens");
|
||||
command.add("java.base/java.util=ALL-UNNAMED");
|
||||
command.add("-classpath");
|
||||
command.add(StringUtils.hasText(classpath) ? classpath : JAVA_CLASSPATH);
|
||||
command.addAll(getSpringGemFireSystemProperties());
|
||||
@@ -94,7 +100,7 @@ public abstract class ProcessExecutor {
|
||||
if (isJvmOption(arg)) {
|
||||
command.add(arg);
|
||||
}
|
||||
else if (!StringUtils.isEmpty(arg)) {
|
||||
else if (StringUtils.hasText(arg)) {
|
||||
programArguments.add(arg);
|
||||
}
|
||||
}
|
||||
@@ -102,9 +108,23 @@ public abstract class ProcessExecutor {
|
||||
command.add(type.getName());
|
||||
command.addAll(programArguments);
|
||||
|
||||
//System.err.printf("JAVA COMMAND (%s)%n", toExecutableCommandString(command));
|
||||
//System.err.flush();
|
||||
|
||||
return command.toArray(new String[0]);
|
||||
}
|
||||
|
||||
private static String toExecutableCommandString(Iterable<String> command) {
|
||||
|
||||
StringBuilder commandString = new StringBuilder();
|
||||
|
||||
for (String commandPart : CollectionUtils.nullSafeIterable(command)) {
|
||||
commandString.append(" ").append(commandPart);
|
||||
}
|
||||
|
||||
return commandString.toString().trim();
|
||||
}
|
||||
|
||||
protected static Collection<? extends String> getSpringGemFireSystemProperties() {
|
||||
|
||||
return System.getProperties().stringPropertyNames().stream()
|
||||
|
||||
@@ -28,17 +28,13 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.Region;
|
||||
import org.apache.geode.cache.lucene.LuceneService;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
@@ -51,6 +47,10 @@ import org.springframework.data.gemfire.util.SpringUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Integration tests for the Spring Data Geode, Apache Geode and Apache Lucene Integration.
|
||||
*
|
||||
@@ -74,13 +74,13 @@ public class LuceneOperationsIntegrationTests {
|
||||
|
||||
protected static final String GEMFIRE_LOG_LEVEL = "none";
|
||||
|
||||
private static Person jonDoe = Person.newPerson(LocalDate.of(1969, Month.JULY, 4), "Jon", "Doe").with("Master of Science");
|
||||
private static Person janeDoe = Person.newPerson(LocalDate.of(1969, Month.AUGUST, 16), "Jane", "Doe").with("Doctor of Astrophysics");
|
||||
private static Person cookieDoe = Person.newPerson(LocalDate.of(1991, Month.APRIL, 2), "Cookie", "Doe").with("Bachelor of Physics");
|
||||
private static Person froDoe = Person.newPerson(LocalDate.of(1988, Month.MAY, 25), "Fro", "Doe").with("Doctor of Computer Science");
|
||||
private static Person hoDoe = Person.newPerson(LocalDate.of(1984, Month.NOVEMBER, 11), "Ho", "Doe").with("Doctor of Math");
|
||||
private static Person pieDoe = Person.newPerson(LocalDate.of(1996, Month.JUNE, 4), "Pie", "Doe").with("Master of Astronomy");
|
||||
private static Person sourDoe = Person.newPerson(LocalDate.of(1999, Month.DECEMBER, 1), "Sour", "Doe").with("Bachelor of Art");
|
||||
private static final Person jonDoe = Person.newPerson(LocalDate.of(1969, Month.JULY, 4), "Jon", "Doe").with("Master of Science");
|
||||
private static final Person janeDoe = Person.newPerson(LocalDate.of(1969, Month.AUGUST, 16), "Jane", "Doe").with("Doctor of Astrophysics");
|
||||
private static final Person cookieDoe = Person.newPerson(LocalDate.of(1991, Month.APRIL, 2), "Cookie", "Doe").with("Bachelor of Physics");
|
||||
private static final Person froDoe = Person.newPerson(LocalDate.of(1988, Month.MAY, 25), "Fro", "Doe").with("Doctor of Computer Science");
|
||||
private static final Person hoDoe = Person.newPerson(LocalDate.of(1984, Month.NOVEMBER, 11), "Ho", "Doe").with("Doctor of Math");
|
||||
private static final Person pieDoe = Person.newPerson(LocalDate.of(1996, Month.JUNE, 4), "Pie", "Doe").with("Master of Astronomy");
|
||||
private static final Person sourDoe = Person.newPerson(LocalDate.of(1999, Month.DECEMBER, 1), "Sour", "Doe").with("Bachelor of Art");
|
||||
|
||||
private static List<String> asNames(List<? extends Nameable> nameables) {
|
||||
|
||||
@@ -110,7 +110,6 @@ public class LuceneOperationsIntegrationTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("all")
|
||||
public void findsMasterDoesAsTypeUserSuccessfully() {
|
||||
|
||||
List<User> masterDoes = template.query("title: Master*", "title", User.class);
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.test.support;
|
||||
|
||||
import static org.springframework.data.gemfire.util.ArrayUtils.nullSafeArray;
|
||||
@@ -89,7 +88,7 @@ public abstract class FileSystemUtils extends FileUtils {
|
||||
Assert.isTrue(isDirectory(directory), String.format(
|
||||
"File [%s] does not refer to a valid directory", directory));
|
||||
|
||||
List<File> results = new ArrayList<File>();
|
||||
List<File> results = new ArrayList<>();
|
||||
|
||||
for (File file : safeListFiles(directory, fileFilter)) {
|
||||
if (isDirectory(file)) {
|
||||
@@ -100,15 +99,13 @@ public abstract class FileSystemUtils extends FileUtils {
|
||||
}
|
||||
}
|
||||
|
||||
return results.toArray(new File[results.size()]);
|
||||
return results.toArray(new File[0]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static File[] safeListFiles(File directory) {
|
||||
return safeListFiles(directory, AllFilesFilter.INSTANCE);
|
||||
}
|
||||
|
||||
/* (non-Javadoc) */
|
||||
public static File[] safeListFiles(File directory, FileFilter fileFilter) {
|
||||
FileFilter resolvedFileFilter = (fileFilter != null ? fileFilter : AllFilesFilter.INSTANCE);
|
||||
File[] files = (isDirectory(directory) ? directory.listFiles(resolvedFileFilter) : null);
|
||||
@@ -185,7 +182,8 @@ public abstract class FileSystemUtils extends FileUtils {
|
||||
}
|
||||
|
||||
enum LogicalOperator {
|
||||
AND, OR;
|
||||
AND,
|
||||
OR
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user