Skip to content

Commit

Permalink
update Mockito version to 4.3.0, make sure tests pass under Java 18, …
Browse files Browse the repository at this point in the history
…other minor costmetic changes

Signed-off-by: Ceki Gulcu <ceki@qos.ch>
  • Loading branch information
ceki committed Jan 31, 2022
1 parent e89a08e commit 0a83e1a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import ch.qos.logback.core.net.SyslogConstants;
import ch.qos.logback.core.pattern.DynamicConverter;
import ch.qos.logback.core.pattern.FormatInfo;
import ch.qos.logback.core.util.EnvUtil;

public class ConverterTest {

Expand Down Expand Up @@ -74,7 +75,7 @@ public void testLineOfCaller() {
StringBuilder buf = new StringBuilder();
converter.write(buf, le);
// the number below should be the line number of the previous line
assertEquals("75", buf.toString());
assertEquals("76", buf.toString());
}
}

Expand Down Expand Up @@ -305,15 +306,26 @@ public void testCallerData() {
{
DynamicConverter<ILoggingEvent> converter = new CallerDataConverter();
this.optionList.clear();
this.optionList.add("4..5");

boolean jdk18 = EnvUtil.isJDK18OrHigher();
// jdk 18EA creates a different stack trace
if(jdk18) {
this.optionList.add("2..3");
} else {
this.optionList.add("4..5");
}
converter.setOptionList(this.optionList);
converter.start();

StringBuilder buf = new StringBuilder();
converter.write(buf, le);
assertTrue("buf is too short", buf.length() >= 10);

String expectedRegex = "Caller\\+4\t at (java.base\\/)?java.lang.reflect.Method.invoke.*$";
String expectedRegex = "Caller\\+4";
if(jdk18) {
expectedRegex = "Caller\\+2";
}
expectedRegex+="\t at (java.base\\/)?java.lang.reflect.Method.invoke.*$";
String actual = buf.toString();
assertTrue("actual: " + actual, Pattern.compile(expectedRegex).matcher(actual).find());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,6 @@ public void handle(ModelInterpretationContext mic, Model model) throws ModelHand
return;
}

// //this.appenderAttachable = appenderRefBag.get(appenderName);
//
// if(this.appenderAttachable == null) {
// addWarn("Appender named ["+appenderName+"] not referenced. Skipping further processing.");
// skipped = true;
// return;
// }

addInfo("Processing appender named [" + appenderName + "]");

String originalClassName = appenderModel.getClassName();
Expand Down Expand Up @@ -104,8 +96,6 @@ public void postHandle(ModelInterpretationContext mic, Model model) throws Model
addWarn("The object at the of the stack is not the appender named [" + appender.getName()
+ "] pushed earlier.");
} else {
// addInfo("Attaching appender ["+appender.getName()+"] to "+appenderAttachable);
// appenderAttachable.addAppender(appender);
mic.popObject();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public List<DependencyDefinition> getDependencyDefinitions() {
return Collections.unmodifiableList(dependencyDefinitionList);
}

List<String> getDependencyNamesForModel(Model model) {
public List<String> getDependencyNamesForModel(Model model) {
for (DependencyDefinition dd : dependencyDefinitionList) {
if (dd.getDependee() == model) {
return Collections.unmodifiableList(dd.dependenciesList);
Expand All @@ -198,30 +198,8 @@ public boolean hasDependencies(String name) {
}

return false;

// Collection<List<String>> nameLists = dependenciesMap.values();
// if (nameLists == null || nameLists.isEmpty())
// return false;
//
// for (List<String> aList : nameLists) {
// if (aList.contains(name))
// return true;
// }
// return false;
}

// public void addDependency(Model model, String ref) {
// List<String> refList = dependenciesMap.get(model);
// if (refList == null) {
// refList = new ArrayList<>();
// }
// refList.add(ref);
// dependenciesMap.put(model, refList);
// }
//
// public List<String> getDependencies(Model model) {
// return dependenciesMap.get(model);
// }

public void markStartOfNamedDependency(String name) {
startedDependencies.add(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ static public boolean isJDK16OrHigher() {
return isJDK_N_OrHigher(16);
}

static public boolean isJDK18OrHigher() {
return isJDK_N_OrHigher(18);
}

static public boolean isJaninoAvailable() {
ClassLoader classLoader = EnvUtil.class.getClassLoader();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.anyInt;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.timeout;
Expand Down
9 changes: 8 additions & 1 deletion logback-site/src/site/pages/news.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,20 @@ <h2>Logback News</h2>
<h3>, Release of version 1.3.0-alpha13</h3>
<p>&bull;&nbsp; Once the <code>Model</code> is created from XML
confifuration file, <code>Model</code> processing is now
independent of any XML related code. This
fixes <a href="https://jira.qos.ch/browse/LOGBACK-1613">LOGBACK-1613</a>.
</p>
<p>&bull;&nbsp; Fixed incorrect <code>String</code> cast in
<code>JNDIUtil</code>. This corrects <a
href="https://jira.qos.ch/browse/LOGBACK-1604">LOGBACK-1604</a>
reported by Chris Cheshire.</p>
<p>&bull;&nbsp; In <code>SMTPAppenderBase</code> empty username
parameter is now treatede the same <code>null</code>. This fixes
parameter is now treated same as <code>null</code>. This fixes
<a href="https://jira.qos.ch/browse/LOGBACK-1594">LOGBACK-1594</a>
reported by Mark Woon who also provided the relevant PR.</p>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.11.2</version>
<version>4.3.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down

0 comments on commit 0a83e1a

Please sign in to comment.