You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@river.apache.org by dr...@apache.org on 2015/09/04 17:03:33 UTC
svn commit: r1701280 - in
/river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support:
./ FullLoggingFilter.java FullLoggingVerifier.java
MulticastOverrideProvider.java
Author: dreedy
Date: Fri Sep 4 15:03:33 2015
New Revision: 1701280
URL: http://svn.apache.org/r1701280
Log:
Recovered org.apache.river.test.support.*
Added:
river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/
river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingFilter.java
river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingVerifier.java
river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/MulticastOverrideProvider.java
Added: river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingFilter.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingFilter.java?rev=1701280&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingFilter.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingFilter.java Fri Sep 4 15:03:33 2015
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.river.test.support;
+
+import java.util.logging.Filter;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+
+public class FullLoggingFilter implements Filter {
+
+ public boolean isLoggable(LogRecord record) {
+ if (record.getLevel().intValue() < Level.INFO.intValue()) {
+ String name = record.getLoggerName();
+ if (name != null && ! name.startsWith("org.apache.river.qa")) {
+ if (name.startsWith("net.jini")
+ || name.startsWith("org.apache.river")) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+}
Added: river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingVerifier.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingVerifier.java?rev=1701280&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingVerifier.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/FullLoggingVerifier.java Fri Sep 4 15:03:33 2015
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.river.test.support;
+
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.apache.river.qa.harness.ConfigurationVerifier;
+import org.apache.river.qa.harness.TestDescription;
+import org.apache.river.qa.harness.TestException;
+import org.apache.river.qa.harness.QAConfig;
+
+/**
+ * A configuration verifier used by tests which should not be run
+ * when full logging is turned on
+ */
+public class FullLoggingVerifier implements ConfigurationVerifier {
+
+ private static Logger logger = Logger.getLogger("org.apache.river.qa.harness");
+
+ /**
+ * Return false if full logging is turned on. Full logging is assumed
+ * to be turned on if the logging properties file contains entries
+ * for <code>org.apache.river.level</code> and <code>net.jini.level</code>
+ * and both levels have the value <code>FINEST.</code>
+ *
+ * @param td the test description for the test
+ * @param config the configuration object
+ *
+ * @return <code>false</code> if full logging is turned on
+ */
+ public boolean canRun(TestDescription td, QAConfig config) {
+ boolean notFull = true;
+ String propFile = System.getProperty("java.util.logging.config.file");
+ if (propFile != null) {
+ try {
+ Properties props = config.loadProperties(propFile);
+ String level = props.getProperty("org.apache.river.level", "INFO");
+ if (level.equals("FINEST")) {
+ level = props.getProperty("net.jini.level", "INFO");
+ notFull = !level.equals("FINEST");
+ }
+ } catch (TestException e) {
+ logger.log(Level.SEVERE, "Could not load properties", e);
+ }
+ }
+ return notFull;
+ }
+}
Added: river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/MulticastOverrideProvider.java
URL: http://svn.apache.org/viewvc/river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/MulticastOverrideProvider.java?rev=1701280&view=auto
==============================================================================
--- river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/MulticastOverrideProvider.java (added)
+++ river/jtsk/skunk/qa-refactor-namespace/trunk/qa/src/org/apache/river/test/support/MulticastOverrideProvider.java Fri Sep 4 15:03:33 2015
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.river.test.support;
+
+import org.apache.river.qa.harness.OverrideProvider;
+import org.apache.river.qa.harness.QAConfig;
+import org.apache.river.qa.harness.TestException;
+import java.util.ArrayList;
+
+/**
+ * An <code>OverrideProvider</code> which generates an override string
+ * for the entries:
+ * <ul>
+ * <li><code>net.jini.discovery.LookupDiscovery.multicastAnnouncementInterval</code>
+ * <li><code>org.apache.river.reggie.multicastAnnouncementInterval</code>
+ * if the service name is <code>net.jini.core.lookup.ServiceRegistrar</code>
+ * <li><code>multicast.ttl</code> is the test run is non-distributed
+ * </ul>
+ */
+public class MulticastOverrideProvider implements OverrideProvider {
+
+ /**
+ * If the test property <code>"net.jini.discovery.announce"</code> is
+ * defined, use its value to generate the override strings. For all values
+ * of <code>serviceName</code> including <code>null</code>, an override for
+ * <code>net.jini.discovery.LookupDiscovery.multicastAnnouncementInterval</code>
+ * is generated. If <code>serviceName</code> is
+ * <code>net.jini.core.lookup.ServiceRegistrar</code> then an additional
+ * override is generated for
+ * <code>org.apache.river.reggie.multicastAnnouncementInterval.</code>
+ * If the test run is NOT distributed then an override is generated
+ * for <code>multicast.ttl</code> to set it to zero.
+ *
+ * @param config the test config
+ * @param serviceName the name of the service to generate overrides for
+ * @param index the service instance count
+ * @return an array of override strings, or a zero-length array if
+ * there are no overrides.
+ * @throws TestException if the value of the announce test property
+ * is non-numeric
+ */
+ public String[] getOverrides(QAConfig config, String serviceName, int index)
+ throws TestException
+ {
+ ArrayList list = new ArrayList();
+ String announce =
+ config.getStringConfigVal("net.jini.discovery.announce", null);
+
+ if (announce != null) {
+ try {
+ Long.parseLong(announce);
+ String annString = "multicastAnnouncementInterval";
+ String lusName = "net.jini.core.lookup.ServiceRegistrar";
+ list.add("net.jini.discovery.LookupDiscovery." + annString);
+ list.add(announce);
+ if (lusName.equals(serviceName)) {
+ list.add("org.apache.river.reggie." + annString);
+ list.add(announce);
+ }
+ } catch (NumberFormatException e) {
+ throw new TestException("net.jini.discovery.announce"
+ + " must be a number",
+ e);
+ }
+ }
+
+ if (! QAConfig.isDistributed()) {
+ list.add("multicast.ttl");
+ list.add("0");
+ }
+
+ return (String[]) list.toArray(new String[list.size()]);
+ }
+}