You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jmeter.apache.org by pm...@apache.org on 2017/02/11 08:28:16 UTC
svn commit: r1782554 - in /jmeter/trunk/test/src/org/apache:
jmeter/assertions/ jmeter/control/ jmeter/engine/ jmeter/functions/
jmeter/junit/ jmeter/protocol/http/parser/ jmeter/protocol/http/sampler/
jmeter/testbeans/gui/ jmeter/timers/ jorphan/colle...
Author: pmouawad
Date: Sat Feb 11 08:28:16 2017
New Revision: 1782554
URL: http://svn.apache.org/viewvc?rev=1782554&view=rev
Log:
Bug 60564 - Migrating LogKit to SLF4J - components (1), functions, protocol, test (2/2)
Contributed by Woonsan Ko
This closes #274
Bugzilla Id: 60564
Modified:
jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java
jmeter/trunk/test/src/org/apache/jmeter/control/TestSwitchController.java
jmeter/trunk/test/src/org/apache/jmeter/control/TestWhileController.java
jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java
jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java
jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java
jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java
jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java
jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java
jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java
jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java
jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java
Modified: jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/assertions/XPathAssertionTest.java Sat Feb 11 08:28:16 2017
@@ -32,13 +32,13 @@ import org.apache.jmeter.samplers.Sample
import org.apache.jmeter.threads.JMeterContext;
import org.apache.jmeter.threads.JMeterContextService;
import org.apache.jmeter.threads.JMeterVariables;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class XPathAssertionTest extends JMeterTestCase {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(XPathAssertionTest.class);
private XPathAssertion assertion;
@@ -92,8 +92,8 @@ public class XPathAssertionTest extends
public void testAssertionOK() throws Exception {
assertion.setXPathString("/");
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertFalse("Should not be a failure", res.isFailure());
}
@@ -102,8 +102,8 @@ public class XPathAssertionTest extends
public void testAssertionFail() throws Exception {
assertion.setXPathString("//x");
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertTrue("Should be a failure",res.isFailure());
}
@@ -112,8 +112,8 @@ public class XPathAssertionTest extends
public void testAssertionPath1() throws Exception {
assertion.setXPathString("//*[code=1]");
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertFalse("Should not be a failure",res.isFailure());
}
@@ -122,8 +122,8 @@ public class XPathAssertionTest extends
public void testAssertionPath2() throws Exception {
assertion.setXPathString("//*[code=2]"); // Not present
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertTrue("Should be a failure",res.isFailure());
}
@@ -132,8 +132,8 @@ public class XPathAssertionTest extends
public void testAssertionBool1() throws Exception {
assertion.setXPathString("count(//error)=2");
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertFalse("Should not be a failure",res.isFailure());
}
@@ -142,8 +142,8 @@ public class XPathAssertionTest extends
public void testAssertionBool2() throws Exception {
assertion.setXPathString("count(//*[code=1])=1");
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertFalse("Should not be a failure",res.isFailure());
}
@@ -152,18 +152,18 @@ public class XPathAssertionTest extends
public void testAssertionBool3() throws Exception {
assertion.setXPathString("count(//error)=1"); // wrong
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
- assertTrue("Should be a failure",res.isFailure());
+ assertTrue("Should be a failure", res.isFailure());
}
@Test
public void testAssertionBool4() throws Exception {
assertion.setXPathString("count(//*[code=2])=1"); //Wrong
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertTrue("Should be a failure",res.isFailure());
}
@@ -172,8 +172,8 @@ public class XPathAssertionTest extends
public void testAssertionNumber() throws Exception {
assertion.setXPathString("count(//error)");// not yet handled
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertTrue("Should be a failure",res.isFailure());
}
@@ -183,8 +183,8 @@ public class XPathAssertionTest extends
// result.setResponseData - not set
result = new SampleResult();
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertEquals(AssertionResult.RESPONSE_WAS_NULL, res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertTrue("Should be a failure",res.isFailure());
@@ -194,8 +194,8 @@ public class XPathAssertionTest extends
public void testAssertionEmptyResult() throws Exception {
result.setResponseData("", null);
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertEquals(AssertionResult.RESPONSE_WAS_NULL, res.getFailureMessage());
assertFalse("Should not be an error", res.isError());
assertTrue("Should be a failure",res.isFailure());
@@ -205,8 +205,8 @@ public class XPathAssertionTest extends
public void testAssertionBlankResult() throws Exception {
result.setResponseData(" ", null);
AssertionResult res = assertion.getResult(result);
- testLog.debug("isError() " + res.isError() + " isFailure() " + res.isFailure());
- testLog.debug("failure message: " + res.getFailureMessage());
+ testLog.debug("isError() {} isFailure() {}", res.isError(), res.isFailure());
+ testLog.debug("failure message: {}", res.getFailureMessage());
assertTrue(res.getFailureMessage().indexOf("Premature end of file") > 0);
assertTrue("Should be an error",res.isError());
assertFalse("Should not be a failure", res.isFailure());
@@ -225,7 +225,7 @@ public class XPathAssertionTest extends
assertion.setValidating(false);
assertion.setTolerant(false);
AssertionResult res = assertion.getResult(result);
- log.debug("failureMessage: " + res.getFailureMessage());
+ log.debug("failureMessage: {}", res.getFailureMessage());
assertTrue(res.isError());
assertFalse(res.isFailure());
}
@@ -235,8 +235,8 @@ public class XPathAssertionTest extends
setAlternateResponseData();
assertion.setXPathString("//row/value[@field = 'alias']");
AssertionResult res = assertion.getResult(jmctx.getPreviousResult());
- log.debug(" res " + res.isError());
- log.debug(" failure " + res.getFailureMessage());
+ log.debug(" res {}", res.isError());
+ log.debug(" failure {}", res.getFailureMessage());
assertFalse(res.isError());
assertFalse(res.isFailure());
}
@@ -248,8 +248,8 @@ public class XPathAssertionTest extends
assertion.setNegated(true);
AssertionResult res = assertion.getResult(jmctx.getPreviousResult());
- log.debug(" res " + res.isError());
- log.debug(" failure " + res.getFailureMessage());
+ log.debug(" res {}", res.isError());
+ log.debug(" failure {}", res.getFailureMessage());
assertFalse(res.isError());
assertFalse(res.isFailure());
}
@@ -261,7 +261,7 @@ public class XPathAssertionTest extends
assertion.setNegated(false);
assertion.setValidating(true);
AssertionResult res = assertion.getResult(jmctx.getPreviousResult());
- log.debug(res.getFailureMessage() + " error: " + res.isError() + " failure: " + res.isFailure());
+ log.debug("{} error: {} failure: {}", res.getFailureMessage(), res.isError(), res.isFailure());
assertTrue(res.isError());
assertFalse(res.isFailure());
}
@@ -316,7 +316,7 @@ public class XPathAssertionTest extends
assertion.setXPathString("/");
assertion.setValidating(true);
AssertionResult res = assertion.getResult(result);
- log.debug("failureMessage: " + res.getFailureMessage());
+ log.debug("failureMessage: {}", res.getFailureMessage());
assertTrue(res.isError());
assertFalse(res.isFailure());
}
@@ -334,7 +334,7 @@ public class XPathAssertionTest extends
assertion.setValidating(true);
assertion.setTolerant(true);
AssertionResult res = assertion.getResult(result);
- log.debug("failureMessage: " + res.getFailureMessage());
+ log.debug("failureMessage: {}", res.getFailureMessage());
assertFalse(res.isFailure());
assertFalse(res.isError());
}
Modified: jmeter/trunk/test/src/org/apache/jmeter/control/TestSwitchController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/control/TestSwitchController.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/control/TestSwitchController.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/control/TestSwitchController.java Sat Feb 11 08:28:16 2017
@@ -37,10 +37,6 @@ import org.apache.jmeter.threads.JMeterV
import org.junit.Test;
public class TestSwitchController extends JMeterTestCase {
-// static {
-// LoggingManager.setPriority("DEBUG","jmeter");
-// LoggingManager.setTarget(new java.io.PrintWriter(System.out));
-// }
// Get next sample and its name
private String nextName(GenericController c) {
Modified: jmeter/trunk/test/src/org/apache/jmeter/control/TestWhileController.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/control/TestWhileController.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/control/TestWhileController.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/control/TestWhileController.java Sat Feb 11 08:28:16 2017
@@ -36,11 +36,6 @@ import org.junit.Before;
import org.junit.Test;
public class TestWhileController extends JMeterTestCase {
-// static {
-// LoggingManager.setPriority("DEBUG","jmeter");
-// LoggingManager.setTarget(new java.io.PrintWriter(System.out));
-// }
-
private JMeterContext jmctx;
private JMeterVariables jmvars;
Modified: jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/engine/DistributedRunnerTest.java Sat Feb 11 08:28:16 2017
@@ -35,9 +35,9 @@ import java.util.Properties;
import org.apache.jmeter.util.JMeterUtils;
import org.apache.jorphan.collections.HashTree;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class DistributedRunnerTest {
@@ -137,7 +137,7 @@ public class DistributedRunnerTest {
}
private static class EmulatorEngine implements JMeterEngine {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(EmulatorEngine.class);
private String host;
public EmulatorEngine() {
@@ -146,37 +146,37 @@ public class DistributedRunnerTest {
@Override
public void configure(HashTree testPlan) {
- log.debug("Configuring " + host);
+ log.debug("Configuring {}", host);
}
@Override
public void runTest() throws JMeterEngineException {
- log.debug("Running " + host);
+ log.debug("Running {}", host);
}
@Override
public void stopTest(boolean now) {
- log.debug("Stopping " + host);
+ log.debug("Stopping {}", host);
}
@Override
public void reset() {
- log.debug("Resetting " + host);
+ log.debug("Resetting {}", host);
}
@Override
public void setProperties(Properties p) {
- log.debug("Set properties " + host);
+ log.debug("Set properties {}", host);
}
@Override
public void exit() {
- log.debug("Exiting " + host);
+ log.debug("Exiting {}", host);
}
@Override
public boolean isActive() {
- log.debug("Check if active " + host);
+ log.debug("Check if active {}", host);
return false;
}
Modified: jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/CSVReadFunctionTest.java Sat Feb 11 08:28:16 2017
@@ -26,13 +26,13 @@ import java.util.LinkedList;
import org.apache.jmeter.engine.util.CompoundVariable;
import org.apache.jmeter.junit.JMeterTestCase;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class CSVReadFunctionTest extends JMeterTestCase {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(CSVReadFunctionTest.class);
// Create the CSVRead function and set its parameters.
private static CSVRead setCSVReadParams(String p1, String p2) throws Exception {
Modified: jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/functions/ComponentReferenceFunctionTest.java Sat Feb 11 08:28:16 2017
@@ -28,24 +28,24 @@ import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.engine.util.CompoundVariable;
import org.apache.jmeter.junit.JMeterTest;
import org.apache.jmeter.junit.JMeterTestCaseJUnit3;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
public class ComponentReferenceFunctionTest extends JMeterTestCaseJUnit3 {
- private static final Logger LOG = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(ComponentReferenceFunctionTest.class);
private static Map<String, Boolean> funcTitles;
@@ -134,7 +134,7 @@ public class ComponentReferenceFunctionT
// No, not a work in progress ...
String s = "function.xml needs '" + title + "' entry for " + funcItem.getClass().getName();
if (!ct) {
- LOG.warn(s); // Record in log as well
+ log.warn(s); // Record in log as well
}
assertTrue(s, ct);
}
Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTest.java Sat Feb 11 08:28:16 2017
@@ -44,9 +44,6 @@ import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
import org.apache.commons.lang3.StringUtils;
import org.apache.jmeter.config.gui.ObsoleteGui;
import org.apache.jmeter.gui.JMeterGUIComponent;
@@ -57,18 +54,21 @@ import org.apache.jmeter.testbeans.TestB
import org.apache.jmeter.testbeans.gui.TestBeanGUI;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.reflect.ClassFinder;
import org.apache.jorphan.util.JOrphanUtils;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
public class JMeterTest extends JMeterTestCaseJUnit3 {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(JMeterTest.class);
private static Map<String, Boolean> guiTitles;
@@ -339,7 +339,7 @@ public class JMeterTest extends JMeterTe
assertFalse("'" + label + "' should be in resource file for " + name, JMeterUtils.getResString(
label).startsWith(JMeterUtils.RES_KEY_PFX));
} catch (UnsupportedOperationException uoe) {
- log.warn("Class has not yet implemented getLabelResource " + name);
+ log.warn("Class has not yet implemented getLabelResource {}", name);
}
}
checkElementAlias(guiItem);
@@ -366,7 +366,7 @@ public class JMeterTest extends JMeterTe
if (!(guiItem instanceof UnsharedComponent)) {
assertEquals("SHARED: Failed on " + name, "", el2.getPropertyAsString("NOT"));
}
- log.debug("Saving element: " + el.getClass());
+ log.debug("Saving element: {}", el.getClass());
ByteArrayOutputStream bos = new ByteArrayOutputStream();
SaveService.saveElement(el, bos);
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
Modified: jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/junit/JMeterTestCase.java Sat Feb 11 08:28:16 2017
@@ -26,12 +26,13 @@ import java.util.Collection;
import java.util.LinkedList;
import java.util.Locale;
import java.util.MissingResourceException;
+
import org.apache.jmeter.engine.util.CompoundVariable;
import org.apache.jmeter.functions.AbstractFunction;
import org.apache.jmeter.functions.InvalidVariableException;
import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/*
* Common setup for JUnit4 test cases
@@ -120,7 +121,7 @@ public abstract class JMeterTestCase {
return file;
}
- protected static final Logger testLog = LoggingManager.getLoggerForClass();
+ protected static final Logger testLog = LoggerFactory.getLogger(JMeterTestCase.class);
protected void checkInvalidParameterCounts(AbstractFunction func, int minimum)
throws Exception {
Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/parser/TestHTMLParser.java Sat Feb 11 08:28:16 2017
@@ -36,13 +36,13 @@ import java.util.Vector;
import org.apache.commons.io.IOUtils;
import org.apache.jmeter.junit.JMeterTestCaseJUnit3;
import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import junit.framework.TestSuite;
public class TestHTMLParser extends JMeterTestCaseJUnit3 {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(TestHTMLParser.class);
private static final String DEFAULT_UA = "Apache-HttpClient/4.2.6";
private static final String UA_FF = "Mozilla/5.0 (Windows NT 5.1; rv:31.0) Gecko/20100101 Firefox/31.0";
@@ -372,7 +372,7 @@ public class TestHTMLParser extends JMet
throws Exception {
String parserName = p.getClass().getName().substring("org.apache.jmeter.protocol.http.parser.".length());
String fname = file.substring(file.indexOf('/')+1);
- log.debug("file " + file);
+ log.debug("file {}", file);
File f = findTestFile(file);
byte[] buffer = new byte[(int) f.length()];
InputStream is = null;
Modified: jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/protocol/http/sampler/PostWriterTest.java Sat Feb 11 08:28:16 2017
@@ -34,20 +34,21 @@ import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
+
import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.protocol.http.util.HTTPArgument;
import org.apache.jmeter.protocol.http.util.HTTPConstants;
import org.apache.jmeter.protocol.http.util.HTTPFileArg;
-import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.util.JOrphanUtils;
-import org.apache.log.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PostWriterTest {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(PostWriterTest.class);
private static final String UTF_8 = "UTF-8";
private static final String HTTP_ENCODING = "ISO-8859-1";
@@ -219,13 +220,13 @@ public class PostWriterTest {
String otherEncoding;
final String fileEncoding = System.getProperty( "file.encoding");// $NON-NLS-1$
- log.info("file.encoding: "+fileEncoding);
+ log.info("file.encoding: {}", fileEncoding);
if (UTF_8.equalsIgnoreCase(fileEncoding) || "UTF8".equalsIgnoreCase(fileEncoding)){// $NON-NLS-1$
otherEncoding="ISO-8859-1"; // $NON-NLS-1$
} else {
otherEncoding=UTF_8;
}
- log.info("Using other encoding: "+otherEncoding);
+ log.info("Using other encoding: {}", otherEncoding);
establishConnection();
sampler.setContentEncoding(otherEncoding);
// File content is sent as binary, so the content encoding should not change the file data
Modified: jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/testbeans/gui/PackageTest.java Sat Feb 11 08:28:16 2017
@@ -30,9 +30,9 @@ import org.apache.jmeter.junit.JMeterTes
import org.apache.jmeter.testbeans.TestBean;
import org.apache.jmeter.testelement.TestElement;
import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.reflect.ClassFinder;
-import org.apache.log.Logger;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -47,7 +47,7 @@ import junit.framework.TestSuite;
*
*/
public final class PackageTest extends JMeterTestCaseJUnit3 {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(PackageTest.class);
private static final Locale defaultLocale = new Locale("en","");
@@ -86,7 +86,7 @@ public final class PackageTest extends J
beanInfo = Introspector.getBeanInfo(testBeanClass);
bundle = (ResourceBundle) beanInfo.getBeanDescriptor().getValue(GenericTestBeanCustomizer.RESOURCE_BUNDLE);
} catch (IntrospectionException e) {
- log.error("Can't get beanInfo for " + testBeanClass.getName(), e);
+ log.error("Can't get beanInfo for {}", testBeanClass, e);
throw new Error(e.toString(), e); // Programming error. Don't continue.
}
if (bundle == null) {
@@ -174,17 +174,17 @@ public final class PackageTest extends J
defaultBundle = (ResourceBundle) Introspector.getBeanInfo(testBeanClass).getBeanDescriptor().getValue(
GenericTestBeanCustomizer.RESOURCE_BUNDLE);
} catch (IntrospectionException e) {
- log.error("Can't get beanInfo for " + testBeanClass.getName(), e);
+ log.error("Can't get beanInfo for {}", testBeanClass, e);
throw new Error(e.toString(), e); // Programming error. Don't continue.
}
if (defaultBundle == null) {
if (className.startsWith("org.apache.jmeter.examples.")) {
- log.info("No default bundle found for " + className);
+ log.info("No default bundle found for {}", className);
continue;
}
errorDetected=true;
- log.error("No default bundle found for " + className + " using " + defaultLocale.toString());
+ log.error("No default bundle found for {} using {}", className, defaultLocale);
continue;
}
Modified: jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jmeter/timers/ConstantThroughputTimerTest.java Sat Feb 11 08:28:16 2017
@@ -26,13 +26,13 @@ import org.apache.jmeter.threads.JMeterC
import org.apache.jmeter.threads.TestJMeterContextService;
import org.apache.jmeter.util.BeanShellInterpreter;
import org.apache.jmeter.util.ScriptingTestElement;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class ConstantThroughputTimerTest {
- private static final Logger LOG = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(ConstantThroughputTimerTest.class);
@Test
public void testTimer1() throws Exception {
@@ -84,7 +84,7 @@ public class ConstantThroughputTimerTest
public void testTimerBSH() throws Exception {
if (!BeanShellInterpreter.isInterpreterPresent()){
final String msg = "BeanShell jar not present, test ignored";
- LOG.warn(msg);
+ log.warn(msg);
return;
}
BeanShellTimer timer = new BeanShellTimer();
Modified: jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/collections/PackageTest.java Sat Feb 11 08:28:16 2017
@@ -26,21 +26,22 @@ import static org.junit.Assert.assertTru
import java.util.Arrays;
import java.util.Collection;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
+
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class PackageTest {
-
+
+ private static Logger log = LoggerFactory.getLogger(PackageTest.class);
+
@Test
public void testAdd1() throws Exception {
- Logger log = LoggingManager.getLoggerForClass();
Collection<String> treePath = Arrays.asList(new String[] { "1", "2", "3", "4" });
HashTree tree = new HashTree();
- log.debug("treePath = " + treePath);
+ log.debug("treePath = {}", treePath);
tree.add(treePath, "value");
- log.debug("Now treePath = " + treePath);
- log.debug(tree.toString());
+ log.debug("Now treePath = {}, tree = {}", treePath, tree);
assertEquals(1, tree.list(treePath).size());
assertEquals("value", tree.getArray(treePath)[0]);
}
Modified: jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java?rev=1782554&r1=1782553&r2=1782554&view=diff
==============================================================================
--- jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java (original)
+++ jmeter/trunk/test/src/org/apache/jorphan/test/AllTests.java Sat Feb 11 08:28:16 2017
@@ -20,9 +20,7 @@ package org.apache.jorphan.test;
import java.awt.GraphicsEnvironment;
import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@@ -30,18 +28,15 @@ import java.nio.charset.Charset;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import java.util.Locale;
-import java.util.Properties;
import javax.crypto.Cipher;
import org.apache.jmeter.junit.categories.ExcludeCategoryFilter;
import org.apache.jmeter.junit.categories.NeedGuiTests;
import org.apache.jmeter.util.JMeterUtils;
-import org.apache.jorphan.logging.LoggingManager;
import org.apache.jorphan.reflect.ClassFilter;
import org.apache.jorphan.reflect.ClassFinder;
import org.apache.jorphan.util.JOrphanUtils;
-import org.apache.log.Logger;
import org.junit.internal.RealSystem;
import org.junit.internal.TextListener;
import org.junit.runner.Computer;
@@ -49,6 +44,8 @@ import org.junit.runner.JUnitCore;
import org.junit.runner.Request;
import org.junit.runner.Result;
import org.junit.runner.notification.RunListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import junit.framework.TestCase;
@@ -107,7 +104,7 @@ import junit.framework.TestCase;
* @see UnitTestManager
*/
public final class AllTests {
- private static final Logger log = LoggingManager.getLoggerForClass();
+ private static final Logger log = LoggerFactory.getLogger(AllTests.class);
/**
* Private constructor to prevent instantiation.
@@ -117,7 +114,7 @@ public final class AllTests {
private static void logprop(String prop, boolean show) {
String value = System.getProperty(prop);
- log.info(prop + "=" + value);
+ log.info("{}={}", prop, value);
if (show) {
System.out.println(prop + "=" + value);
}
@@ -148,30 +145,26 @@ public final class AllTests {
String home = new File(System.getProperty("user.dir")).getParent();
System.out.println("Setting JMeterHome: "+home);
JMeterUtils.setJMeterHome(home);
- initializeLogging(args);
initializeManager(args);
- String version = "JMeterVersion="+JMeterUtils.getJMeterVersion();
- log.info(version);
- System.out.println(version);
+ log.info("JMeterVersion={}", JMeterUtils.getJMeterVersion());
+ System.out.println("JMeterVersion=" + JMeterUtils.getJMeterVersion());
logprop("java.version", true);
logprop("java.vm.name");
logprop("java.vendor");
logprop("java.home", true);
logprop("file.encoding", true);
// Display actual encoding used (will differ if file.encoding is not recognised)
- String msg = "default encoding="+Charset.defaultCharset();
- System.out.println(msg);
- log.info(msg);
+ System.out.println("default encoding="+Charset.defaultCharset());
+ log.info("default encoding={}", Charset.defaultCharset());
logprop("user.home");
logprop("user.dir", true);
logprop("user.language");
logprop("user.region");
logprop("user.country");
logprop("user.variant");
- final String showLocale = "Locale="+Locale.getDefault().toString();
- log.info(showLocale);
- System.out.println(showLocale);
+ log.info("Locale={}", Locale.getDefault());
+ System.out.println("Locale=" + Locale.getDefault());
logprop("os.name", true);
logprop("os.version", true);
logprop("os.arch");
@@ -239,29 +232,6 @@ public final class AllTests {
}
/**
- * An overridable method that initializes the logging for the unit test run,
- * using the properties file passed in as the second argument.
- *
- * @param args arguments to get the logging setup information from
- */
- protected static void initializeLogging(String[] args) {
- if (args.length >= 2) {
- Properties props = new Properties();
- InputStream inputStream = null;
- try {
- System.out.println("Setting up props using file: " + args[1]);
- inputStream = new FileInputStream(args[1]);
- props.load(inputStream);
- LoggingManager.initializeLogging(props);
- } catch (IOException e) {
- System.out.println(e.getLocalizedMessage());
- } finally {
- JOrphanUtils.closeQuietly(inputStream);
- }
- }
- }
-
- /**
* An overridable method that instantiates a UnitTestManager (if one
* was specified in the command-line arguments), and hands it the name of
* the properties file to use to configure the system.
@@ -320,7 +290,7 @@ public final class AllTests {
}
} catch (UnsupportedClassVersionError | ClassNotFoundException
| NoClassDefFoundError e) {
- log.debug(e.getLocalizedMessage());
+ log.debug("Exception while filtering class {}. {}", className, e.toString());
}
return isJunitTest;