Skip to content

Commit 5a41c89

Browse files
committed
fix IncludeActionTest
Signed-off-by: Ceki Gulcu <[email protected]>
1 parent af92be4 commit 5a41c89

File tree

11 files changed

+60
-37
lines changed

11 files changed

+60
-37
lines changed

logback-core/src/main/java/ch/qos/logback/core/model/processor/IncludeModelHandler.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ public void handle(ModelInterpretationContext mic, Model model) throws ModelHand
7171
}
7272

7373
InputStream in = getInputStream(mic, includeModel);
74+
if(in == null) {
75+
inError = true;
76+
return;
77+
}
78+
7479
SaxEventRecorder recorder = null;
7580

7681
try {

logback-core/src/test/input/joran/inclusion/intermediaryByFile.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE x>
2+
<!DOCTYPE included>
33

44
<included>
55
<stack name="a"/>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE x>
2+
<!DOCTYPE configuration>
33

4-
<x>
4+
<configuration>
55
<include file="${includeKey}" />
66
<include file="${secondFileKey}" />
7-
</x>
7+
</configuration>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE x [
2+
<!DOCTYPE configuration [
33
<!ENTITY includedEntity SYSTEM "includedEntity.xml">
44
]>
55

6-
<x>
6+
<configuration>
77

88
&includedEntity;
99

10-
</x>
10+
</configuration>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE x>
2+
<!DOCTYPE configuration>
33

4-
<x>
4+
<configuration>
55
<include file="${includeKey}" />
6-
</x>
6+
</configuration>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE x>
2+
<!DOCTYPE configuration>
33

4-
<x>
4+
<configuration>
55

66
<include resource="${includeKey}" />
77

8-
</x>
8+
</configuration>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE x>
2+
<!DOCTYPE configuration>
33

4-
<x>
4+
<configuration>
55
<include url="${includeKey}" />
6-
</x>
6+
</configuration>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE x>
2+
<!DOCTYPE configuration>
33

4-
<x>
4+
<configuration>
55
<include optional="true" file="nonExistentFile.xml" />
66

77
<stack name="IA"/>
88
<stack name="IB"/>
9-
</x>
9+
</configuration>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
2-
<!DOCTYPE x>
2+
<!DOCTYPE configuration>
33

4-
<x>
4+
<configuration>
55
<include optional="true" resource="nonExistentResource.xml" />
66

77
<stack name="IA"/>
88
<stack name="IB"/>
9-
</x>
9+
</configuration>

logback-core/src/test/java/ch/qos/logback/core/joran/TrivialConfigurator.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import java.util.function.Supplier;
1818

1919
import ch.qos.logback.core.joran.action.Action;
20+
import ch.qos.logback.core.joran.action.ImplicitModelAction;
2021
import ch.qos.logback.core.joran.spi.ElementSelector;
2122
import ch.qos.logback.core.joran.spi.SaxEventInterpreter;
2223
import ch.qos.logback.core.joran.spi.RuleStore;
@@ -29,15 +30,23 @@ public TrivialConfigurator(HashMap<ElementSelector, Supplier<Action>> rules) {
2930
this.rulesMap = rules;
3031
}
3132

33+
34+
public TrivialConfigurator makeAnotherInstance() {
35+
TrivialConfigurator tc = new TrivialConfigurator(rulesMap);
36+
tc.setContext(context);
37+
return tc;
38+
}
39+
3240
@Override
3341
protected void setImplicitRuleSupplier(SaxEventInterpreter interpreter) {
42+
interpreter.setImplicitActionSupplier(ImplicitModelAction::new);
3443
}
3544

3645
@Override
37-
protected void addElementSelectorAndActionAssociations(RuleStore rs) {
46+
protected void addElementSelectorAndActionAssociations(RuleStore aRuleStore) {
3847
for (ElementSelector elementSelector : rulesMap.keySet()) {
3948
Supplier<Action> actionSupplier = rulesMap.get(elementSelector);
40-
rs.addRule(elementSelector, actionSupplier);
49+
aRuleStore.addRule(elementSelector, actionSupplier);
4150
}
4251
}
4352

0 commit comments

Comments
 (0)