Fixed Rule for METADATA::COLLECTION
This commit is contained in:
parent
6b7feaee29
commit
58f9dc9cad
|
@ -164,51 +164,45 @@ public class TestRules extends ContextTest {
|
|||
}
|
||||
};
|
||||
|
||||
for(File dir : rulesDirectory.listFiles()) {
|
||||
if(!dir.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
File[] elaborationFilesNoMatch = dir.listFiles(filenameFilter);
|
||||
for(File elaborationFileNoMatch : rulesDirectory.listFiles(filenameFilter)) {
|
||||
logger.info("Comparing examples which must not match from file {}", elaborationFileNoMatch.getName());
|
||||
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFileNoMatch))) {
|
||||
for(String line; (line = br.readLine()) != null;) {
|
||||
String[] splittedLine = line.split(",");
|
||||
String serviceClass = splittedLine[0];
|
||||
String serviceName = splittedLine[1];
|
||||
String calledMethod = splittedLine[2];
|
||||
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
||||
if(replace != null) {
|
||||
logger.error("{} match {} but it should NOT. This MUST not occur.", line,
|
||||
matcherReplace.getMultiMatcher().toString());
|
||||
throw new Exception();
|
||||
} else {
|
||||
logger.trace("{} does NOT match as requested", line, replacementRegex.getServiceClass(),
|
||||
replacementRegex.getServiceName(), replacementRegex.getCalledMethod());
|
||||
}
|
||||
|
||||
for(File elaborationFileNoMatch : elaborationFilesNoMatch) {
|
||||
logger.info("Comparing examples which must not match from file {}", elaborationFileNoMatch.getName());
|
||||
try(BufferedReader br = new BufferedReader(new FileReader(elaborationFileNoMatch))) {
|
||||
for(String line; (line = br.readLine()) != null;) {
|
||||
String[] splittedLine = line.split(",");
|
||||
String serviceClass = splittedLine[0];
|
||||
String serviceName = splittedLine[1];
|
||||
String calledMethod = splittedLine[2];
|
||||
Replace replace = matcherReplace.check(serviceClass, serviceName, calledMethod);
|
||||
if(replace != null) {
|
||||
logger.error("{} match {} but it should NOT. This MUST not occur.", line,
|
||||
matcherReplace.getMultiMatcher().toString());
|
||||
throw new Exception();
|
||||
} else {
|
||||
logger.trace("{} does NOT match as requested", line, replacementRegex.getServiceClass(),
|
||||
replacementRegex.getServiceName(), replacementRegex.getCalledMethod());
|
||||
}
|
||||
ServiceUsageRecord sur = TestUsageRecord.createTestServiceUsageRecord();
|
||||
sur.setServiceClass(serviceClass);
|
||||
sur.setServiceName(serviceName);
|
||||
sur.setCalledMethod(calledMethod);
|
||||
sur.validate();
|
||||
//logger.trace("Should not be aggregated ServiceUsageRecord {}", sur);
|
||||
for(AggregatedServiceUsageRecord asur : aggregatedMap.values()) {
|
||||
try {
|
||||
asur.aggregate(sur);
|
||||
throw new Exception("The record has been aggregated and it should NOT");
|
||||
|
||||
ServiceUsageRecord sur = TestUsageRecord.createTestServiceUsageRecord();
|
||||
sur.setServiceClass(serviceClass);
|
||||
sur.setServiceName(serviceName);
|
||||
sur.setCalledMethod(calledMethod);
|
||||
sur.validate();
|
||||
//logger.trace("Should not be aggregated ServiceUsageRecord {}", sur);
|
||||
for(AggregatedServiceUsageRecord asur : aggregatedMap.values()) {
|
||||
try {
|
||||
asur.aggregate(sur);
|
||||
throw new Exception("The record has been aggregated and it should NOT");
|
||||
|
||||
} catch(NotAggregatableRecordsExceptions e) {
|
||||
//logger.trace("{} is not aggragable as expected", sur);
|
||||
}
|
||||
} catch(NotAggregatableRecordsExceptions e) {
|
||||
//logger.trace("{} is not aggragable as expected", sur);
|
||||
}
|
||||
}
|
||||
} catch(Exception e) {
|
||||
throw e;
|
||||
}
|
||||
} catch(Exception e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(
|
||||
"-----------------------------------------------------------------------------------------------------\n\n\n");
|
||||
}
|
||||
|
@ -218,7 +212,7 @@ public class TestRules extends ContextTest {
|
|||
allRules();
|
||||
File rulesDirectory = getRulesDirectory();
|
||||
File rulesDirFile = new File(rulesDirectory, "Thredds");
|
||||
File rulesFile = new File(rulesDirFile, "Thredds_METADATA::OTHER.json");
|
||||
File rulesFile = new File(rulesDirFile, "Thredds_METADATA::COLLECTION.json");
|
||||
testRule(rulesFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
"match": {
|
||||
"serviceClassRegex": "SDI",
|
||||
"serviceNameRegex": "Thredds",
|
||||
"calledMethodRegex": "^(\/){1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}(?<Collection>[a-zA-Z0-9_-]*)(\/){1}(.*\\.(nc|asc|tiff)).{1,}"
|
||||
"calledMethodRegex": "^(\/){1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}(?<Collection>[a-zA-Z0-9_-]*(?<!(..\\.nc)))(\/){1}.*(?<!(..\\.nc|.\\.asc|\\.tiff))$"
|
||||
},
|
||||
"replace": {
|
||||
"serviceClass": "SDI",
|
||||
"serviceName": "Thredds",
|
||||
"calledMethod": "${Protocol}::${Collection}"
|
||||
"calledMethod": "METADATA::${Collection}"
|
||||
}
|
||||
}
|
|
@ -2,11 +2,11 @@
|
|||
"match": {
|
||||
"serviceClassRegex": "SDI",
|
||||
"serviceNameRegex": "Thredds",
|
||||
"calledMethodRegex": "^(\/){1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}([^\/]*\\.(nc|asc|tiff)).{1,}"
|
||||
"calledMethodRegex": "^(\/){1}(?<Protocol>[a-zA-Z0-9]*){1}(\/public\/netcdf\/){1}((.*\\.(nc|asc|tiff)).{1,})"
|
||||
},
|
||||
"replace": {
|
||||
"serviceClass": "SDI",
|
||||
"serviceName": "Thredds",
|
||||
"calledMethod": "${Protocol}::OTHER"
|
||||
"calledMethod": "METADATA::OTHER"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
Service Class,Service Name,Called Method
|
||||
SDI,Thredds,/style/ncss/layout.css
|
||||
SDI,Thredds,/tds.css
|
||||
SDI,Thredds,/folder.gif
|
||||
SDI,Thredds,/godiva2/css/calendar-blue.css
|
||||
SDI,Thredds,/godiva2/css/godiva2.css
|
||||
SDI,Thredds,/style/ncss/main.css
|
||||
SDI,Thredds,/tdsCat.css
|
||||
SDI,Thredds,/tdsDap.css
|
||||
SDI,Thredds,/
|
||||
SDI,Thredds,/godiva2/theme/default/img/close.gif
|
||||
SDI,Thredds,/godiva2/images/ajax-loader.gif
|
||||
SDI,Thredds,/godiva2/img/blank.gif
|
||||
SDI,Thredds,/godiva2/theme/default/style.css
|
||||
SDI,Thredds,/js/lib/OpenLayers-2.12/theme/default/style.css
|
||||
SDI,Thredds,/style/ncss/form.css
|
||||
SDI,Thredds,/threddsIcon.gif
|
|
Loading…
Reference in New Issue