workspaceInfo.setFullName(workspaceName);
workspaceInfo.setUserId(userInfo.getUniqueId());
metaStore.createWorkspace(workspaceInfo);
// create a invalid metadata file
IFileStore rootLocation = OrionConfiguration.getRootLocation();
String orgFolderName = "te";
IFileStore orgFolder = rootLocation.getChild(orgFolderName);
assertTrue(orgFolder.fetchInfo().exists());
assertTrue(orgFolder.fetchInfo().isDirectory());
String invalid = "delete.html";
IFileStore invalidFileInOrg = orgFolder.getChild(invalid);
try {
OutputStream outputStream = invalidFileInOrg.openOutputStream(EFS.NONE, null);
outputStream.write("<!doctype html>".getBytes());
outputStream.close();
} catch (IOException e) {
fail("Count not create a test file in the Orion Project:" + e.getLocalizedMessage());
}
assertTrue(invalidFileInOrg.fetchInfo().exists());
// read all the users which will trigger the archive
List<String> users = metaStore.readAllUsers();
assertNotNull(users);
// verify the invalid metadata file has moved to the archive
IFileStore archiveFolder = rootLocation.getChild(SimpleMetaStoreUtil.ARCHIVE);
assertTrue(archiveFolder.fetchInfo().exists());
assertTrue(archiveFolder.fetchInfo().isDirectory());
IFileStore archiveOrgFolder = archiveFolder.getChild(orgFolderName);
assertTrue(archiveOrgFolder.fetchInfo().exists());
assertTrue(archiveOrgFolder.fetchInfo().isDirectory());
IFileStore archivedFile = archiveOrgFolder.getChild(invalid);
assertTrue(archivedFile.fetchInfo().exists());
assertFalse(invalidFileInOrg.fetchInfo().exists());
}