[jbosscache-commits] JBoss Cache SVN: r6566 - in core/trunk/src: test/java/org/jboss/cache and 1 other directories.
jbosscache-commits at lists.jboss.org
jbosscache-commits at lists.jboss.org
Sat Aug 16 14:22:45 EDT 2008
Author: mircea.markus
Date: 2008-08-16 14:22:44 -0400 (Sat, 16 Aug 2008)
New Revision: 6566
Added:
core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTest.java
Modified:
core/trunk/src/main/resources/config-samples/buddy-replication.xml
core/trunk/src/main/resources/config-samples/invalidation-async.xml
core/trunk/src/main/resources/config-samples/total-replication.xml
core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
Log:
added test to check corectness of the configuration files
Modified: core/trunk/src/main/resources/config-samples/buddy-replication.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008-08-15 22:49:24 UTC (rev 6565)
+++ core/trunk/src/main/resources/config-samples/buddy-replication.xml 2008-08-16 18:22:44 UTC (rev 6566)
@@ -45,11 +45,11 @@
<pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
use_mcast_xmit="false"/>
<pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
- <pbcast.GMS join_retry_timeout="2000" join_timeout="5000" print_local_addr="true" shun="false"
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false"
view_ack_collection_timeout="5000" view_bundling="true"/>
<FC max_credits="5000000" min_threshold="0.20"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
</transport>
Modified: core/trunk/src/main/resources/config-samples/invalidation-async.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/invalidation-async.xml 2008-08-15 22:49:24 UTC (rev 6565)
+++ core/trunk/src/main/resources/config-samples/invalidation-async.xml 2008-08-16 18:22:44 UTC (rev 6566)
@@ -46,11 +46,11 @@
<pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
use_mcast_xmit="false"/>
<pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
- <pbcast.GMS join_retry_timeout="2000" join_timeout="5000" print_local_addr="true" shun="false"
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false"
view_ack_collection_timeout="5000" view_bundling="true"/>
<FC max_credits="5000000" min_threshold="0.20"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
</transport>
Modified: core/trunk/src/main/resources/config-samples/total-replication.xml
===================================================================
--- core/trunk/src/main/resources/config-samples/total-replication.xml 2008-08-15 22:49:24 UTC (rev 6565)
+++ core/trunk/src/main/resources/config-samples/total-replication.xml 2008-08-16 18:22:44 UTC (rev 6566)
@@ -45,11 +45,11 @@
<pbcast.NAKACK discard_delivered_msgs="true" gc_lag="0" retransmit_timeout="300,600,1200,2400,4800"
use_mcast_xmit="false"/>
<pbcast.STABLE desired_avg_gossip="50000" max_bytes="400000" stability_delay="1000"/>
- <pbcast.GMS join_retry_timeout="2000" join_timeout="5000" print_local_addr="true" shun="false"
+ <pbcast.GMS join_timeout="5000" print_local_addr="true" shun="false"
view_ack_collection_timeout="5000" view_bundling="true"/>
<FC max_credits="5000000" min_threshold="0.20"/>
<FRAG2 frag_size="60000"/>
- <pbcast.STREAMING_STATE_TRANSFER use_reading_thread="true"/>
+ <pbcast.STREAMING_STATE_TRANSFER/>
<pbcast.FLUSH timeout="0"/>
</jgroupsConfig>
</transport>
Added: core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTest.java (rev 0)
+++ core/trunk/src/test/java/org/jboss/cache/SampleConfigFilesCorrectnessTest.java 2008-08-16 18:22:44 UTC (rev 6566)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.cache;
+
+import org.testng.annotations.Test;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.AfterTest;
+import org.apache.log4j.AppenderSkeleton;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.spi.LoggingEvent;
+import org.jboss.cache.config.parsing.XmlConfigurationSchemaTest;
+import org.jboss.cache.config.parsing.XmlConfigurationParser;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+/**
+ * The purpose of this test is to make sure that the config files we ship are correct both according to xml schema and
+ * according to the used JGroups/JBossCache version. For the latter, we start a cache instance and make sure that no
+ * configuration warnings are being logged by both JGroups and JBossCache.
+ *
+ * @author Mircea.Markus at jboss.com
+ * @since 3.0
+ */
+ at Test(groups = "functional")
+public class SampleConfigFilesCorrectnessTest
+{
+ public static final String CONFIG_ROOT = "src/main/resources/config-samples";
+ public static final String XSD_FILE = "src/main/resources/jbosscache-config-3.0.xsd";
+
+ private InMemoryAppender appender;
+ private Level oldLevel;
+
+
+ /**
+ * Will be called only once, before all test methods run.
+ */
+ @BeforeTest
+ public void setUpTest()
+ {
+ Logger log4jLogger = Logger.getRootLogger();
+ oldLevel = log4jLogger.getLevel();
+ log4jLogger.setLevel(Level.WARN);
+ appender = new InMemoryAppender();
+ log4jLogger.addAppender(appender);
+ File f = new File(".");
+ System.out.println("f = " + f.getAbsolutePath());
+ }
+
+ /**
+ * Will be called only once, after all test methods run.
+ */
+ @AfterTest
+ public void tearDownTest()
+ {
+ Logger log4jLogger = Logger.getRootLogger();
+ log4jLogger.setLevel(oldLevel);
+ log4jLogger.removeAppender(appender);
+ }
+
+ public void testSchemaValidity()
+ {
+ System.setProperty("jbosscache.config.schemaLocation", XSD_FILE);
+ XmlConfigurationSchemaTest.ExceptionCountingErrorHandler errorHandler = new XmlConfigurationSchemaTest.ExceptionCountingErrorHandler();
+ XmlConfigurationParser parser = new XmlConfigurationParser(errorHandler);
+ String[] configFiles = getConfigFileNames();
+ for (String aConfFile : configFiles)
+ {
+ System.out.println("Processing file: " + aConfFile);
+ parser.parseFile(CONFIG_ROOT + "/" + aConfFile);
+ }
+ assert errorHandler.noErrors();
+ }
+
+ public void testConfigWarnings()
+ {
+ DefaultCacheFactory dcf = new DefaultCacheFactory();
+ for (String aConfFile : getConfigFileNames())
+ {
+ System.out.println("Processing file: " + aConfFile);
+ assert !appender.isFoundUnknownWarning();
+ Cache cache = dcf.createCache(CONFIG_ROOT + "/" + aConfFile);
+ cache.stop();
+ assert !appender.isFoundUnknownWarning();
+ }
+ }
+
+ private String[] getConfigFileNames()
+ {
+ File file = new File(CONFIG_ROOT);
+ return file.list(new FilenameFilter()
+ {
+ public boolean accept(File dir, String name)
+ {
+ return name.indexOf("xml") > 0;
+ }
+ });
+ }
+
+
+ private static class InMemoryAppender extends AppenderSkeleton
+ {
+ String[] TOLERABLE_WARNINGS = {"Falling back to DummyTransactionManager"};
+ boolean foundUnknownWarning = false;
+
+ protected void append(LoggingEvent event)
+ {
+ if (event.getLevel().equals(Level.WARN))
+ {
+ boolean skipPrinting = false;
+ foundUnknownWarning = true;
+ for (String knownWarn : TOLERABLE_WARNINGS)
+ {
+ if (event.getMessage().toString().indexOf(knownWarn) >= 0)
+ {
+ skipPrinting = true;
+ foundUnknownWarning = false;
+ }
+ }
+ if (!skipPrinting)
+ {
+ System.out.println("Unaccepted warn message :" + event.getMessage());
+ }
+ }
+ }
+
+ public boolean requiresLayout()
+ {
+ return false;
+ }
+
+ public void close()
+ {
+ //do nothing
+ }
+
+ public boolean isFoundUnknownWarning()
+ {
+ return foundUnknownWarning;
+ }
+ }
+}
Modified: core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java
===================================================================
--- core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2008-08-15 22:49:24 UTC (rev 6565)
+++ core/trunk/src/test/java/org/jboss/cache/config/parsing/XmlConfigurationSchemaTest.java 2008-08-16 18:22:44 UTC (rev 6566)
@@ -69,7 +69,7 @@
assert parser.isValidating();
}
- private static class ExceptionCountingErrorHandler implements ErrorHandler
+ public static class ExceptionCountingErrorHandler implements ErrorHandler
{
List<SAXParseException> exceptionList = new ArrayList<SAXParseException>();
@@ -94,7 +94,7 @@
exceptionList.add(exception);
}
- boolean noErrors()
+ public boolean noErrors()
{
return exceptionList.isEmpty();
}
More information about the jbosscache-commits
mailing list