use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class Test_FileSystemFolder method getAllMetadataNoSuchEntity.
@Test
public void getAllMetadataNoSuchEntity() throws Exception {
// constructors
expectNew(SystemOperations.class, "localhost:0000").andReturn(systemOperations);
expectNew(FileSystemOperations.class, "localhost:0000").andReturn(fileSystemOperations);
// open()
expect(systemOperations.getOperatingSystemType()).andReturn(OperatingSystemType.SOLARIS);
// getAllMetaData()
expect(fileSystemOperations.findFiles("some.path/", ".*", true, true, false)).andReturn(new String[0]);
replayAll();
FileSystemFolder folder = new FileSystemFolder("localhost:0000", "some.path", null, true, false);
folder.open();
assertEquals(folder.getAllMetaData(), new ArrayList<MetaData>());
verifyAll();
}
use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class Test_FileSystemFolder method getAllMetadataExceptionExists.
@Test(expected = RbvException.class)
public void getAllMetadataExceptionExists() throws Exception {
// constructor
expectNew(FileSystemOperations.class, "localhost:0000").andThrow(new RbvException("Test"));
replayAll();
FileSystemFolder folder = new FileSystemFolder("localhost:0000", "some.path", null, true, false);
folder.open();
assertEquals(folder.getAllMetaData(), new ArrayList<MetaData>());
verifyAll();
}
use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class SnapshotExecutor method snapshotMatch.
// locate this piece of MetaData in the snapshot
private boolean snapshotMatch(MetaData newMeta, List<String> excludedKeys) throws RbvException {
// iterate over all of the entries of the snapshot
for (Iterator<MetaData> iterator = this.snapshot.iterator(); iterator.hasNext(); ) {
MetaData metaData = iterator.next();
boolean isMatch = true;
if (!checkPropertiesMapping(metaData, newMeta)) {
// properties then they should not be matched
continue;
}
// compare their values to the ones supplied by the new MetaData
for (String value : metaData.getKeys()) {
// check if this key should be evaluated at all
if (shouldEvaluateKey(value, excludedKeys)) {
if (!compare(metaData.getProperty(value), newMeta.getProperty(value))) {
isMatch = false;
}
}
}
// if the current snapshot entry matches the new MetaData
if (isMatch) {
iterator.remove();
log.debug("Matched meta data: " + metaData);
return true;
}
}
log.debug(UNSUCCESSFUL_SNAPSHOT_MATCH);
log.debug("--- Debug dump --- ");
log.debug("Metadata contents : " + newMeta);
return false;
}
use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class FileSystemFolder method getAllMetaData.
public List<MetaData> getAllMetaData() throws RbvException {
// first check if the folder is already open
if (!isOpen) {
throw new MatchableNotOpenException("File system folder is not open");
}
newMetaData.clear();
if (fileName == null) {
fileName = ".*";
isRegExp = true;
}
HashMap<String, MetaData> tempMetaData = new HashMap<String, MetaData>();
// fetch dir contents recursively
String[] fileList;
try {
fileList = this.fileSystemOperations.findFiles(path, fileName, isRegExp, true, includeSubDirs);
} catch (Exception e) {
final String notExistMessageSuffix = "does not exist or is not a folder";
if ((e.getMessage() != null && e.getMessage().endsWith(notExistMessageSuffix)) || (e.getCause() != null && e.getCause().getMessage() != null && e.getCause().getMessage().endsWith(notExistMessageSuffix))) {
log.warn(getDescription() + " does not exist, skipping to next poll attempt");
return new ArrayList<MetaData>();
}
throw new RbvException("Unable to list the contents of " + path, e);
}
if (fileList != null) {
for (String fileName : fileList) {
try {
FilePackage file = new FilePackage(atsAgent, fileName.trim(), osType);
MetaData metaData = new FileSystemMetaData(file);
// The way files are compared is by combining their name+path,
// modification time, user and group ID in a hash string
String hashKey = file.getUniqueIdentifier();
if (!allMetaData.containsKey(hashKey)) {
newMetaData.add(metaData);
}
tempMetaData.put(hashKey, metaData);
} catch (PackageException e) {
// the creation of the package somehow failed - a simple explanation would be that
// the filed was removed during the execution of this method or something similar;
log.warn("Unable to build up metadata for " + fileName, e);
// either way we need not throw an exception but only continue iterating
}
}
}
allMetaData.clear();
allMetaData.putAll(tempMetaData);
return new ArrayList<MetaData>(allMetaData.values());
}
use of com.axway.ats.rbv.MetaData in project ats-framework by Axway.
the class Test_MetaData method toStringNull.
@Test
public void toStringNull() throws RbvException {
MetaData metaData = new MetaData();
metaData.putProperty("test", null);
assertEquals("{ test : null }", metaData.toString());
}
Aggregations