Skip to content

Commit

Permalink
Configure rules cache from qacover.properties
Browse files Browse the repository at this point in the history
  • Loading branch information
javiertuya committed Aug 14, 2024
1 parent 510213f commit bd5880e
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 30 deletions.
26 changes: 13 additions & 13 deletions net/QACover/Translated/Giis.Qacover.Core.Services/Configuration.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion net/QACoverTest/Translated/Test4giis.Qacover/Base.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion net/QACoverTest/Translated/Test4giis.Qacover/TestFaults.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions net/qacover.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ qacover.rule.optimize.evaluation=false
qacover.rule.criterion=fpc
qacover.rule.url=
qacover.rule.options=
qacover.rule.cache=
4 changes: 4 additions & 0 deletions qacover-core/qacover.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ qacover.rule.url=
# and supress rules that can be automatically detected as a tautology
qacover.rule.options=

# A folder to use as a cache of the rules that are generated
# Default: empty
qacover.rule.cache=

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Configuration { // NOSONAR singleton allowed
private static Configuration instance;
private String name=QACOVER_NAME;
private String storeRulesLocation;
private String cacheRulesLocation;
private String ruleCache;
private String storeReportsLocation;
private String ruleCriterion;
private String ruleUrl;
Expand Down Expand Up @@ -69,6 +69,7 @@ public Configuration reset() {
}
ruleUrl = getProperty("qacover.rule.url", "https://in2test.lsi.uniovi.es/tdrules/api/v4");
ruleOptions = getProperty("qacover.rule.options", "");
ruleCache = getProperty("qacover.rule.cache", "");
optimizeRuleEvaluation = JavaCs.equalsIgnoreCase("true", getProperty("qacover.rule.optimize.evaluation", "false"));

inferQueryParameters = JavaCs.equalsIgnoreCase("true", getProperty("qacover.query.infer.parameters", "false"));
Expand Down Expand Up @@ -206,14 +207,6 @@ public String getStoreRulesLocation() {
public void setStoreRulesLocation(String location) {
storeRulesLocation = location;
}
public String getCacheRulesLocation() {
return cacheRulesLocation;
}
public Configuration setCacheRulesLocation(String location) {
// Ensures that location is relative to project root and not null
cacheRulesLocation = location != null && !"".equals(location) ? FileUtil.getPath(Parameters.getProjectRoot(), location) : "";
return this;
}
public String getStoreReportsLocation() {
return storeReportsLocation;
}
Expand Down Expand Up @@ -243,6 +236,14 @@ public Configuration setRuleServiceUrl(String ruleUrl) {
return this;
}

public String getRuleCacheFolder() {
return ruleCache;
}
public Configuration setRuleCacheFolder(String folder) {
ruleCache = folder;
return this;
}

public boolean getOptimizeRuleEvaluation() {
return optimizeRuleEvaluation;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public void setErrorContext(String message) {

private TdRulesApi getApi() {
String uri = Configuration.getInstance().getRuleServiceUrl();
String cacheLocation = Configuration.getInstance().getCacheRulesLocation();
log.debug("Call service: {}, cache: {}", uri, cacheLocation);
String cacheLocation = Configuration.getInstance().getRuleCacheFolder();
log.debug("Call service: {}, using cache: {}", uri, cacheLocation);
TdRulesApi api = new TdRulesApi(uri);
if (!"".equals(cacheLocation))
api.setCache(cacheLocation);
Expand Down
4 changes: 3 additions & 1 deletion qacover-core/src/test/java/test4giis/qacover/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import giis.portable.util.FileUtil;
import giis.portable.util.Parameters;
import giis.qacover.core.QueryStatement;
import giis.qacover.core.services.FaultInjector;
import giis.qacover.core.services.Configuration;
Expand Down Expand Up @@ -67,7 +69,7 @@ public void setUp() throws SQLException {
public static Configuration configureTestOptions() {
return Configuration.getInstance().reset()
.setName("qacovertest")
.setCacheRulesLocation(".tdrules-cache");
.setRuleCacheFolder(FileUtil.getPath(Parameters.getProjectRoot(), ".tdrules-cache"));
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private boolean contains(String text, String substring) {
@Test
public void testFaultConnectingService() throws SQLException {
options.setRuleServiceUrl("http://giis.uniovi.es/noexiste.xml")
.setCacheRulesLocation(""); // disable cache to run the actual service
.setRuleCacheFolder(""); // disable cache to run the actual service
rs=app.executeQuery("select id,num,text from test where num<9");
assertExceptionMessage(new Variability().isJava()
? "Error at Get query table names: ApiException"
Expand Down

0 comments on commit bd5880e

Please sign in to comment.