DATAGEODE-180 - Set Framework and Geode log level in tests to error.

Remove out System.out and System.err println(..) statements.
This commit is contained in:
John Blum
2019-04-09 14:27:03 -07:00
parent c1d6a710c0
commit 4358b51f98
126 changed files with 176 additions and 320 deletions

View File

@@ -102,7 +102,7 @@ public class CacheClusterConfigurationIntegrationTest extends ClientServerIntegr
getLocatorProcessOutput(description));
}
catch (IOException cause) {
throw newRuntimeException(cause, "Failed the write the contents of the Locator process log to a file");
throw newRuntimeException(cause, "Failed to write the contents of the Locator process log to a file");
}
}
}

View File

@@ -29,7 +29,7 @@ import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.gemfire.test.GemfireTestApplicationContextInitializer;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.junit4.SpringRunner;
/**
* The DiskStoreBeanUsingPropertyPlaceholdersIntegrationTest class is a test suite of integration tests testing the use
@@ -46,9 +46,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
* @link https://jira.springsource.org/browse/SGF-249
* @since 1.3.4
*/
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = "diskstore-using-propertyplaceholders-config.xml",
initializers = GemfireTestApplicationContextInitializer.class)
@RunWith(SpringJUnit4ClassRunner.class)
@SuppressWarnings("unused")
public class DiskStoreBeanUsingPropertyPlaceholdersIntegrationTest {
@@ -65,7 +65,6 @@ public class DiskStoreBeanUsingPropertyPlaceholdersIntegrationTest {
@Test
public void testDiskStoreBeanWithPropertyPlaceholderConfiguration() {
System.out.printf("Disk Store Configuration: %1$s%n", diskStoreConfiguration);
assertNotNull("The Disk Store was not configured and initialized!", testDataStore);
assertEquals(getExpectedValue("allowForceCompaction"), testDataStore.getAllowForceCompaction());
assertEquals(getExpectedValue("autoCompact"), testDataStore.getAutoCompact());
@@ -76,5 +75,4 @@ public class DiskStoreBeanUsingPropertyPlaceholdersIntegrationTest {
assertEquals(getExpectedValue("timeInterval"), testDataStore.getTimeInterval());
assertEquals(getExpectedValue("writeBufferSize"), testDataStore.getWriteBufferSize());
}
}

View File

@@ -353,11 +353,12 @@ public class GemfireTemplateIntegrationTests {
static class GemfireTemplateConfiguration {
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", applicationName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("log-level", logLevel());
return gemfireProperties;
}

View File

@@ -259,7 +259,6 @@ public class GemfireTemplateQueriesOnGroupedPooledClientCacheRegionsIntegrationT
return PropertiesBuilder.create()
.setProperty("name", applicationName())
.setProperty("mcast-port", "0")
.setProperty("log-level", logLevel())
.setProperty("locators", "localhost[11235]")
.setProperty("enable-cluster-configuration", "false")

View File

@@ -56,10 +56,10 @@ public class GenericRegionFactoryBeanTest {
@BeforeClass
public static void setup() throws Exception {
Cache gemfireCache = new CacheFactory()
.set("name", GenericRegionFactoryBeanTest.class.getSimpleName())
.set("mcast-port", "0")
.set("log-level", "warning")
.set("log-level", "error")
.create();
PeerRegionFactoryBean<Object, Object> defaultRegionFactory = new GenericRegionFactoryBean<Object, Object>();

View File

@@ -270,8 +270,7 @@ public class IndexConflictsIntegrationTest {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", IndexConflictsIntegrationTest.class.getSimpleName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("log-level", "warning");
gemfireProperties.setProperty("log-level", "error");
return gemfireProperties;
}

View File

@@ -40,7 +40,6 @@ public class InvalidRegionDataPolicyShortcutsTest {
"/org/springframework/data/gemfire/invalid-region-shortcut-with-persistent-attribute.xml");
}
catch (BeanCreationException expected) {
//expected.printStackTrace(System.err);
assertTrue(expected.getMessage().contains("Error creating bean with name 'InvalidReplicate'"));
throw expected;
}
@@ -53,7 +52,6 @@ public class InvalidRegionDataPolicyShortcutsTest {
"/org/springframework/data/gemfire/invalid-use-of-region-datapolicy-and-shortcut.xml");
}
catch (BeanDefinitionParsingException expected) {
//expected.printStackTrace(System.err);
assertTrue(expected.getMessage().contains(
"Only one of [data-policy, shortcut] may be specified with element 'gfe:partitioned-region'"));
throw expected;

View File

@@ -97,10 +97,10 @@ public class PdxDiskStoreIntegrationTest {
@Before
public void setup() {
assertNotNull("The PdxData GemFire Region was not created successfully!", pdxDataRegion);
if (pdxDataRegion.size() == 0) {
System.out.printf("Creating entries for Region (%1$s)...%n", pdxDataRegion.getName());
for (int index = 1; index <= NUMBER_OF_REGION_ENTRIES; index++) {
pdxDataRegion.put(new KeyHolder<String>("key" + index), new ValueHolder<Integer>(index));
}

View File

@@ -198,13 +198,13 @@ public class CompoundCachePutCacheEvictIntegrationTests {
@Configuration
static class GemFireConfiguration {
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
static final String DEFAULT_GEMFIRE_LOG_LEVEL = "error";
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", applicationName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("locators", "");
gemfireProperties.setProperty("log-level", logLevel());

View File

@@ -60,12 +60,11 @@ public class GemfireCacheIntegrationTests extends AbstractNativeCacheTests<Regio
@Override
protected Region<Object, Object> newNativeCache() throws Exception {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", GemfireCacheIntegrationTests.class.getName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("locators", "");
gemfireProperties.setProperty("log-level", "warning");
gemfireProperties.setProperty("log-level", "error");
org.apache.geode.cache.Cache cache = GemfireUtils.getCache();

View File

@@ -92,8 +92,6 @@ public class ClientCacheIndexingTest {
arguments.toArray(new String[arguments.size()]));
waitForServerStart(TimeUnit.SECONDS.toMillis(20));
System.out.println("GemFire Cache Server Process for ClientCache Indexing should be running...");
}
private static void waitForServerStart(final long milliseconds) {

View File

@@ -84,8 +84,6 @@ public class ClientCacheSecurityTest {
arguments.toArray(new String[arguments.size()]));
waitForServerStart(TimeUnit.SECONDS.toMillis(20));
System.out.println("GemFire Cache Server Process for ClientCache Security should be running...");
}
private static void waitForServerStart(final long milliseconds) {

View File

@@ -69,6 +69,7 @@ public class ClientCacheVariableLocatorsTest {
@BeforeClass
public static void setup() throws IOException {
String serverName = ClientCacheVariableServersTest.class.getSimpleName().concat("Server");
File serverWorkingDirectory = new File(FileSystemUtils.WORKING_DIRECTORY, serverName.toLowerCase());
@@ -85,9 +86,6 @@ public class ClientCacheVariableLocatorsTest {
arguments.toArray(new String[arguments.size()]));
waitForServerToStart(TimeUnit.SECONDS.toMillis(20));
System.out.printf("Spring-based, GemFire Cache Server process for %1$s should be running...%n",
ClientCacheVariableLocatorsTest.class.getSimpleName());
}
private static void waitForServerToStart(final long milliseconds) {

View File

@@ -85,9 +85,6 @@ public class ClientCacheVariableServersTest {
arguments.toArray(new String[arguments.size()]));
waitForServerToStart(TimeUnit.SECONDS.toMillis(20));
System.out.printf("Spring-based, GemFire Cache Server process for %1$s should be running...%n",
ClientCacheVariableServersTest.class.getSimpleName());
}
private static void waitForServerToStart(final long milliseconds) {

View File

@@ -71,20 +71,22 @@ public class SpringJavaConfiguredClientCacheIntegrationTest {
@Bean
public Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", SpringJavaConfiguredClientCacheIntegrationTest.class.getSimpleName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("log-level", "warning");
gemfireProperties.setProperty("log-level", "error");
return gemfireProperties;
}
@Bean
public ClientCacheFactoryBean clientCache() {
ClientCacheFactoryBean clientCacheFactoryBean = new ClientCacheFactoryBean();
clientCacheFactoryBean.setUseBeanFactoryLocator(false);
clientCacheFactoryBean.setProperties(gemfireProperties());
return clientCacheFactoryBean;
}
}
}

View File

@@ -119,16 +119,11 @@ public class EnableContinuousQueriesConfigurationIntegrationTests extends Client
assertThat(temperatureReading).isNotNull();
assertThat(temperatureReading.getTemperature()).isEqualTo(99);
//System.err.printf("Number of Temperature Readings [%d] on Server [%d]%n",
// this.temperatureReadings.size(), this.temperatureReadings.sizeOnServer());
assertThat(this.temperatureReadings.sizeOnServer()).isEqualTo(10);
//waitOn(() -> totalTemperatureReadingsCounter.get() >= 5, 100L);
//assertThat(totalTemperatureReadingsCounter.get()).isNotZero();
//System.err.printf("Total Temperature Readings [%d]%n", totalTemperatureReadingsCounter.get());
}
@Test

View File

@@ -41,7 +41,7 @@ public class CqCacheServerProcess {
private static Region<String, Integer> testCqRegion;
private static final String CACHE_SERVER_PORT_PROPERTY = "spring.data.gemfire.cache.server.port";
private static final String GEMFIRE_LOG_LEVEL = "warning";
private static final String GEMFIRE_LOG_LEVEL = "error";
private static final String GEMFIRE_NAME = "CqServer";
@SuppressWarnings("deprecation")
@@ -51,9 +51,9 @@ public class CqCacheServerProcess {
}
private static Cache newGemFireCache(String name, String logLevel) {
return new CacheFactory()
.set("name", name)
.set("mcast-port", "0")
.set("log-level", logLevel)
.create();
}

View File

@@ -44,7 +44,7 @@ public class FunctionCacheServerProcess {
private static Region<Object,Object> testFunctionRegion;
private static final String CACHE_SERVER_PORT_PROPERTY = "spring.data.gemfire.cache.server.port";
private static final String GEMFIRE_LOG_LEVEL = "warning";
private static final String GEMFIRE_LOG_LEVEL = "error";
private static final String GEMFIRE_NAME = "FunctionServer";
public static void main(String[] args) throws Exception {
@@ -53,9 +53,9 @@ public class FunctionCacheServerProcess {
}
private static Cache newGemFireCache(String name, String logLevel) {
return new CacheFactory()
.set("name", name)
.set("mcast-port", "0")
.set("log-level", logLevel)
.set("groups", "g1,g2,g3")
.create();

View File

@@ -97,8 +97,6 @@ public class ExceptionThrowingFunctionExecutionIntegrationTest {
arguments.toArray(new String[arguments.size()]));
waitForServerStart(TimeUnit.SECONDS.toMillis(20));
System.out.println("GemFire Cache Server Process for ClientCache Indexing should be running...");
}
private static void waitForServerStart(final long milliseconds) {

View File

@@ -67,12 +67,12 @@ public class PdxFunctionArgumentResolverTest {
@BeforeClass
public static void setupGemFire() {
gemfireCache = new CacheFactory()
.setPdxSerializer(new PersonPdxSerializer())
.setPdxReadSerialized(true)
.set("name", PdxFunctionArgumentResolverTest.class.getSimpleName())
.set("mcast-port", "0")
.set("log-level", "warning")
.set("log-level", "error")
.create();
}

View File

@@ -27,15 +27,10 @@ import org.apache.geode.cache.query.CqQuery;
*/
public class GemfireMDP {
public void handleEvent(CqEvent event) {
System.out.println("Received event " + event);
}
public void handleEvent(CqEvent event) { }
public void handleQuery(CqQuery query) {
System.out.println("Received query " + query);
}
public void handleQuery(CqQuery query) { }
public void handleOperation(Operation op) { }
public void handleOperation(Operation op) {
System.out.println("Received operation " + op);
}
}

View File

@@ -72,12 +72,13 @@ public abstract class ProcessExecutor {
ProcessWrapper processWrapper = new ProcessWrapper(process, ProcessConfiguration.create(processBuilder));
processWrapper.register((input) -> System.err.printf("[FORK] - %s%n", input));
//processWrapper.register((input) -> System.err.printf("[FORK] - %s%n", input));
return processWrapper;
}
protected static String[] buildCommand(String classpath, Class<?> type, String... args) {
Assert.notNull(type, "The main Java class to launch must not be null");
List<String> command = new ArrayList<>();
@@ -102,10 +103,11 @@ public abstract class ProcessExecutor {
command.add(type.getName());
command.addAll(programArguments);
return command.toArray(new String[command.size()]);
return command.toArray(new String[0]);
}
protected static Collection<? extends String> getSpringGemFireSystemProperties() {
return System.getProperties().stringPropertyNames().stream()
.filter(property -> property.startsWith(SPRING_DATA_GEMFIRE_SYSTEM_PROPERTY_PREFIX)
|| property.startsWith(SPRING_GEMFIRE_SYSTEM_PROPERTY_PREFIX))
@@ -114,10 +116,11 @@ public abstract class ProcessExecutor {
}
protected static boolean isJvmOption(String option) {
return (StringUtils.hasText(option) && (option.startsWith("-D") || option.startsWith("-X")));
return StringUtils.hasText(option) && (option.startsWith("-D") || option.startsWith("-X"));
}
protected static File validateDirectory(File workingDirectory) {
Assert.isTrue(workingDirectory != null && (workingDirectory.isDirectory() || workingDirectory.mkdirs()),
String.format("Failed to create working directory [%s]", workingDirectory));

View File

@@ -89,11 +89,11 @@ public class GemFireRepositoryFactoryInformationIntegrationTests {
}
Properties gemfireProperties() {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", applicationName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("log-level", "warning");
gemfireProperties.setProperty("log-level", "error");
return gemfireProperties;
}

View File

@@ -47,10 +47,10 @@ public class GemfireCacheRegionProducer {
@Produces
@ApplicationScoped
public Region<Long, Person> createPeopleRegion() {
Cache gemfireCache = new CacheFactory()
.set("name", "SpringDataGemFireCdiTest")
.set("mcast-port", "0")
.set("log-level", "warning")
.set("log-level", "error")
.create();
RegionFactory<Long, Person> peopleRegionFactory = gemfireCache.createRegionFactory(RegionShortcut.REPLICATE);

View File

@@ -61,7 +61,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@SuppressWarnings("unused")
public class PersonRepositoryIntegrationTests {
private static final String DEFAULT_GEMFIRE_LOG_LEVEL = "warning";
private static final String DEFAULT_GEMFIRE_LOG_LEVEL = "error";
private static final String GEMFIRE_LOG_LEVEL = System.getProperty("gemfire.log-level", DEFAULT_GEMFIRE_LOG_LEVEL);
protected final AtomicLong ID_SEQUENCE = new AtomicLong(0L);
@@ -207,8 +207,6 @@ public class PersonRepositoryIntegrationTests {
Properties gemfireProperties = new Properties();
gemfireProperties.setProperty("name", applicationName());
gemfireProperties.setProperty("mcast-port", "0");
gemfireProperties.setProperty("locators", "");
gemfireProperties.setProperty("log-level", logLevel());
return gemfireProperties;

View File

@@ -123,8 +123,6 @@ public class JSONRegionAdviceIntegrationTests {
String json = String.valueOf(this.jsonRegion.get("dave"));
System.out.printf("JSON [%s]%n", json);
assertEquals(json, toJson(davidTuranski));
Object result = jsonRegion.put("dave", davidTuranski);

View File

@@ -42,24 +42,20 @@ public class GemfirePersistenceExceptionTranslationTest {
@Test
public void test() {
Map<String, BeanPostProcessor> bpps = ctx.getBeansOfType(BeanPostProcessor.class);
System.out.println(bpps.size());
for (BeanPostProcessor bpp: bpps.values()) {
System.out.println(bpp.getClass().getSimpleName());
}
try {
gemfireRepo1.doit(new QueryException());
fail("should throw a query exception");
} catch (GemfireQueryException e){
}
catch (GemfireQueryException ignore){ }
try {
gemfireRepo1.doit(new FunctionDomainException("test"));
fail("should throw a query exception");
} catch (GemfireQueryException e) {
}
catch (GemfireQueryException ignore) { }
try {
gemfireRepo1.doit(new QueryInvocationTargetException("test"));
@@ -71,8 +67,6 @@ public class GemfirePersistenceExceptionTranslationTest {
/**
* Wraps GemfireCheckedExceptions in RuntimeException
* @author David Turanski
*
*/
@Repository
public static class GemFireRepo1 {

View File

@@ -59,10 +59,10 @@ public class LazyWiringDeclarableSupportFunctionBasedIntegrationTests {
/*
@BeforeClass
public static void setupBeforeClass() {
Cache gemfireCache = new CacheFactory()
.set("name", LazyWiringDeclarableSupportFunctionBasedIntegrationTests.class.getSimpleName())
.set("mcast-port", "0")
.set("log-level", "config")
.set("log-level", "error")
.set("cache-xml-file", null)
.create();

View File

@@ -125,12 +125,13 @@ public class AsyncEventQueueWithListenerIntegrationTest {
public void init() {
getQueue();
System.out.printf("%1$s initialized!%n", this);
}
public AsyncEventQueue getQueue() {
Assert.state(queue != null, String.format("A reference to the Async Event Queue on which this listener"
+ " (%1$s) has been registered was not properly configured!", this));
Assert.state(queue != null, String.format("A reference to the AsyncEventQueue on which this listener"
+ " [%s] has been registered was not properly configured", this));
return queue;
}