modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReader.java
| 2
modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
| 17 +
modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java
| 10 -
modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
| 14 +
modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
| 28 ++
modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java
| 100 +++++++---
modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
| 95 ++++++++-
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
| 3
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
| 6
modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
| 5
modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
| 5
11 files changed, 234 insertions(+), 51 deletions(-)
New commits:
commit d6dad28b375c5c26e50a6eba841166cd919652ce
Author: John Sanda <jsanda(a)redhat.com>
Date: Mon Jun 27 12:57:31 2011 -0400
Adding support to read/write headers in changeset meta data file
The changeset meta data file now includes a header with three entries,
one per line. The headers are,
* drift configuration name
* drift configuration base dir
* flag indicating whether or not it is a coverage changeset
The changeset reader and writer classes, including tests, have been
updating to handle the headers.
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReader.java
b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReader.java
index 630b1a6..93fe553 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReader.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReader.java
@@ -4,6 +4,8 @@ import java.io.IOException;
public interface ChangeSetReader {
+ Headers getHeaders() throws IOException;
+
DirectoryEntry readDirectoryEntry() throws IOException;
void close() throws IOException;
diff --git
a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
index 7e557a2..9cb3392 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetReaderImpl.java
@@ -19,13 +19,30 @@ public class ChangeSetReaderImpl implements ChangeSetReader {
private File metaDataFile;
+ private Headers headers;
+
public ChangeSetReaderImpl(File metaDataFile) throws IOException {
this.metaDataFile = metaDataFile;
reader = new BufferedReader(new FileReader(this.metaDataFile));
+ readHeaders();
}
public ChangeSetReaderImpl(Reader metaDataFile) throws Exception {
reader = new BufferedReader(metaDataFile);
+ readHeaders();
+ }
+
+ private void readHeaders() throws IOException {
+ String name = reader.readLine();
+ String basedir = reader.readLine();
+ boolean coverageChangeSet = Boolean.valueOf(reader.readLine());
+
+ headers = new Headers(name, basedir, coverageChangeSet);
+ }
+
+ @Override
+ public Headers getHeaders() throws IOException {
+ return headers;
}
@Override
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java
b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java
index 782f9bf..bcf14da 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriter.java
@@ -13,11 +13,19 @@ import java.io.IOException;
* <br/>
* The current format of the change set file is:
* <pre>
+ * HEADER
* DRIFT_ENTRY
* FILE_ENTRY (1..N)
* EMPTY_LINE
* </pre>
- * where DRIFT_ENTRY has two field that are space delimited. The first is the directory
path
+ * where HEADER has three fields that are terminated by newline characters. Those fields
are:
+ * <ul>
+ * <li>drift configuration name</li>
+ * <li>drift configuration base directory</li>
+ * <li>flag indicating whether or not this is a coverage changeset</li>
+ * </ul>
+ * <br/>
+ * and where DRIFT_ENTRY has two field that are space delimited. The first is the
directory path
* and the second is the number of files included in DRIFT_ENTRY. Note that the last
FILE_ENTRY
* in DRIFT_ENTRY is followed by a new line.
* <br/>
diff --git
a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
index 21b819a..1b68506 100644
--- a/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/ChangeSetWriterImpl.java
@@ -6,15 +6,27 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
+import org.rhq.core.domain.drift.DriftConfiguration;
+
public class ChangeSetWriterImpl implements ChangeSetWriter {
private Writer writer;
private File changeSetFile;
- public ChangeSetWriterImpl(File changeSetFile) throws IOException {
+ public ChangeSetWriterImpl(File changeSetFile, DriftConfiguration driftConfig,
boolean coverageChangeSet)
+ throws IOException {
+
this.changeSetFile = changeSetFile;
writer = new BufferedWriter(new FileWriter(this.changeSetFile));
+
+ writeHeader(driftConfig, coverageChangeSet);
+ }
+
+ private void writeHeader(DriftConfiguration driftConfig, boolean initialChangeSet)
throws IOException {
+ writer.write(driftConfig.getName() + "\n");
+ writer.write(driftConfig.getBasedir() + "\n");
+ writer.write(initialChangeSet + "\n");
}
public void writeDirectoryEntry(DirectoryEntry dirEntry) throws IOException {
diff --git a/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
b/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
new file mode 100644
index 0000000..7263f96
--- /dev/null
+++ b/modules/common/drift/src/main/java/org/rhq/common/drift/Headers.java
@@ -0,0 +1,28 @@
+package org.rhq.common.drift;
+
+public class Headers {
+
+ private String driftConfigurationName;
+
+ private String basedir;
+
+ private boolean coverageChangeSet;
+
+ public Headers(String driftConfigurationName, String basedir, boolean
coverageChangeSet) {
+ this.driftConfigurationName = driftConfigurationName;
+ this.basedir = basedir;
+ this.coverageChangeSet = coverageChangeSet;
+ }
+
+ public String getDriftConfigurationName() {
+ return driftConfigurationName;
+ }
+
+ public String getBasedir() {
+ return basedir;
+ }
+
+ public boolean isCoverageChangeSet() {
+ return coverageChangeSet;
+ }
+}
diff --git
a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java
b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java
index a7c8d2e..e642063 100644
---
a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java
+++
b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetReaderImplTest.java
@@ -10,67 +10,113 @@ public class ChangeSetReaderImplTest {
@Test
@SuppressWarnings("unchecked")
public void readDirectoryEntryWithFileAdded() throws Exception {
- String changeset = "myresource/conf 1\n" +
+ String changeset = "file-added-test\n" +
+ "myresource\n" +
+ "true\n" +
+ "myresource/conf 1\n" +
"a34ef6 0 myconf.conf A";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new
StringReader(changeset));
+
+ Headers actualHeaders = reader.getHeaders();
+ Headers expectedHeaders = new Headers("file-added-test",
"myresource", true);
+
+ assertHeadersEquals(actualHeaders, expectedHeaders);
+
DirectoryEntry dirEntry = reader.readDirectoryEntry();
reader.close();
- assertNotNull(dirEntry, "Expected reader to return a directory
entry");
- assertEquals(dirEntry.getDirectory(), "myresource/conf", "The
directory name is wrong");
- assertEquals(dirEntry.getNumberOfFiles(), 1, "The number of files for the
directory entry is wrong");
+ assertDirectoryEntryEquals(dirEntry, "myresource/conf", 1);
- FileEntry fileEntry = dirEntry.iterator().next();
+ FileEntry actualFileEntry = dirEntry.iterator().next();
+ FileEntry expectedFileEntry = new FileEntry("a34ef6", "0",
"myconf.conf", "A");
- assertEquals(fileEntry.getNewSHA(), "a34ef6", "The first column,
the new SHA-256, is wrong");
- assertEquals(fileEntry.getOldSHA(), "0", "The second column, the
old SHA-256, is wrong");
- assertEquals(fileEntry.getFile(), "myconf.conf", "The third
column, the file name, is wrong");
- assertEquals(fileEntry.getType().code(), "A", "The fourth column,
the entry type, is wrong");
+ assertFileEntryEquals(actualFileEntry, expectedFileEntry);
}
@Test
@SuppressWarnings("unchecked")
public void readDirectoryEntryWithFileRemoved() throws Exception {
- String changeset = "myresource/conf 1\n" +
+ String changeset = "file-removed-test\n" +
+ "myresource\n" +
+ "true\n" +
+ "myresource/conf 1\n" +
"0 a34ef6 myconf.conf R";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new
StringReader(changeset));
+
+ Headers actualHeaders = reader.getHeaders();
+ Headers expectedHeaders = new Headers("file-removed-test",
"myresource", true);
+
+ assertHeadersEquals(actualHeaders, expectedHeaders);
+
DirectoryEntry dirEntry = reader.readDirectoryEntry();
reader.close();
- assertNotNull(dirEntry, "Expected reader to return a directory
entry");
- assertEquals(dirEntry.getDirectory(), "myresource/conf", "The
directory name is wrong");
- assertEquals(dirEntry.getNumberOfFiles(), 1, "The number of files for the
directory entry is wrong");
+ assertDirectoryEntryEquals(dirEntry, "myresource/conf", 1);
- FileEntry fileEntry = dirEntry.iterator().next();
+ FileEntry actualFileEntry = dirEntry.iterator().next();
+ FileEntry expectedFileEntry = new FileEntry("0", "a34ef6",
"myconf.conf", "R");
- assertEquals(fileEntry.getNewSHA(), "0", "The first column, the
new SHA-256, is wrong");
- assertEquals(fileEntry.getOldSHA(), "a34ef6", "The second column,
the old SHA-256, is wrong");
- assertEquals(fileEntry.getFile(), "myconf.conf", "The third
column, the file name, is wrong");
- assertEquals(fileEntry.getType().code(), "R", "The fourth column,
the entry type, is wrong");
+ assertFileEntryEquals(actualFileEntry, expectedFileEntry);
}
@Test
@SuppressWarnings("unchecked")
public void readDirectoryEntryWithFileChanged() throws Exception {
- String changeset = "myresource/conf 1\n" +
+ String changeset = "file-changed-test\n" +
+ "myresource\n" +
+ "true\n" +
+ "myresource/conf 1\n" +
"a34ef6 c41b8 myconf.conf C";
ChangeSetReaderImpl reader = new ChangeSetReaderImpl(new
StringReader(changeset));
+
+ Headers actualHeaders = reader.getHeaders();
+ Headers expectedHeaders = new Headers("file-changed-test",
"myresource", true);
+
+ assertHeadersEquals(actualHeaders, expectedHeaders);
+
DirectoryEntry dirEntry = reader.readDirectoryEntry();
reader.close();
- assertNotNull(dirEntry, "Expected reader to return a directory
entry");
- assertEquals(dirEntry.getDirectory(), "myresource/conf", "The
directory name is wrong");
- assertEquals(dirEntry.getNumberOfFiles(), 1, "The number of files for the
directory entry is wrong");
+ assertDirectoryEntryEquals(dirEntry, "myresource/conf", 1);
+
+ FileEntry actualFileEntry = dirEntry.iterator().next();
+ FileEntry expectedFileEntry = new FileEntry("a34ef6",
"c41b8", "myconf.conf", "C");
+
+ assertFileEntryEquals(actualFileEntry, expectedFileEntry);
+ }
- FileEntry fileEntry = dirEntry.iterator().next();
+ void assertHeadersEquals(Headers actual, Headers expected) {
+ assertEquals(actual.getDriftConfigurationName(),
expected.getDriftConfigurationName(),
+ "The drift configuration name, which should be the first header, is
wrong.");
+ assertEquals(actual.getBasedir(), expected.getBasedir(), "The drift
configuration base directory, which " +
+ "should be the second header, is wrong.");
+ assertEquals(actual.isCoverageChangeSet(), expected.isCoverageChangeSet(),
"The coverage change set flag, " +
+ "which should be the third header, is wrong.");
+ }
+
+ /**
+ * Verifies that the directory entry name (i.e., path) and number of files match the
+ * specified values.
+ *
+ * @param dirEntry
+ * @param path
+ * @param numberOfFiles
+ */
+ void assertDirectoryEntryEquals(DirectoryEntry dirEntry, String path, int
numberOfFiles) {
+ assertNotNull(dirEntry, "Expected non-null directory entry");
+ assertEquals(dirEntry.getDirectory(), path, "The directory name/path is
wrong");
+ assertEquals(dirEntry.getNumberOfFiles(), numberOfFiles, "The number of
files for the directory entry is " +
+ "wrong");
+ }
- assertEquals(fileEntry.getNewSHA(), "a34ef6", "The first column,
the new SHA-256, is wrong");
- assertEquals(fileEntry.getOldSHA(), "c41b8", "The second column,
the old SHA-256, is wrong");
- assertEquals(fileEntry.getFile(), "myconf.conf", "The third
column, the file name, is wrong");
- assertEquals(fileEntry.getType().code(), "C", "The fourth column,
the entry type, is wrong");
+ void assertFileEntryEquals(FileEntry actual, FileEntry expected) {
+ assertEquals(actual.getNewSHA(), expected.getNewSHA(), "The first column,
the new SHA-256, is wrong");
+ assertEquals(actual.getOldSHA(), expected.getOldSHA(), "The second column,
the old SHA-256, is wrong");
+ assertEquals(actual.getFile(), expected.getFile(), "The third column, the
file name, is wrong");
+ assertEquals(actual.getType(), expected.getType(), "The fourth column, the
entry type, is wrong");
}
}
diff --git
a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
index 3e21887..6c9a475 100644
---
a/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
+++
b/modules/common/drift/src/test/java/org/rhq/common/drift/ChangeSetWriterImplTest.java
@@ -7,6 +7,10 @@ import java.util.List;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.PropertySimple;
+import org.rhq.core.domain.drift.DriftConfiguration;
+
import static org.apache.commons.io.FileUtils.deleteDirectory;
import static org.apache.commons.io.IOUtils.lineIterator;
import static org.apache.commons.io.IOUtils.readLines;
@@ -18,18 +22,22 @@ import static org.testng.Assert.assertTrue;
public class ChangeSetWriterImplTest {
- File changesetsDir = new File("target", "changesets");
+ File changeSetsDir = new File("target", "changesets");
@BeforeClass
public void setupChangesetsDir() throws Exception {
- deleteDirectory(changesetsDir);
- assertTrue(changesetsDir.mkdirs(), "Failed to create " +
changesetsDir.getPath());
+ deleteDirectory(changeSetsDir);
+ assertTrue(changeSetsDir.mkdirs(), "Failed to create " +
changeSetsDir.getPath());
}
@Test
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithAddedFile() throws Exception {
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(new File(changesetsDir,
"added-file-test"));
+ File changeSetFile = new File(changeSetsDir, "added-file-test");
+ DriftConfiguration driftConfig = driftConfiguration("added-file-test",
"myresource");
+ boolean coverageChangeSet = true;
+
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig,
coverageChangeSet);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
addedFileEntry("myconf.conf", "a34ef6")));
@@ -38,17 +46,25 @@ public class ChangeSetWriterImplTest {
File metaDataFile = writer.getChangeSetFile();
List<String> lines = readLines(new FileInputStream(metaDataFile));
- assertEquals(lines.size(), 3, "Expected to find three lines in " +
metaDataFile.getPath());
- assertEquals(lines.get(0), "myresource/conf 1", "The first line
for a directory entry should specify the " +
+ assertEquals(lines.size(), 6, "Expected to find six lines in " +
metaDataFile.getPath() +
+ " - three for the header followed by three for a directory
entry.");
+
+ assertHeaderEquals(lines, "added-file-test", "myresource",
"true");
+
+ assertEquals(lines.get(3), "myresource/conf 1", "The first line
for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
- assertFileEntryEquals(lines.get(1), "a34ef6 0 myconf.conf A");
+ assertFileEntryEquals(lines.get(4), "a34ef6 0 myconf.conf A");
}
@Test
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithRemovedFile() throws Exception {
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(new File(changesetsDir,
"removed-file-test"));
+ File changeSetFile = new File(changeSetsDir, "removed-file-test");
+ DriftConfiguration driftConfig =
driftConfiguration("removed-file-test", "myresource");
+ boolean coverageChangeSet = true;
+
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig,
coverageChangeSet);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
removedFileEntry("myconf.conf", "a34ef6")));
@@ -57,17 +73,25 @@ public class ChangeSetWriterImplTest {
File metaDataFile = writer.getChangeSetFile();
List<String> lines = readLines(new FileInputStream(metaDataFile));
- assertEquals(lines.size(), 3, "Expected to find three lines in " +
metaDataFile.getPath());
- assertEquals(lines.get(0), "myresource/conf 1", "The first line
for a directory entry should specify the " +
+ assertEquals(lines.size(), 6, "Expected to find six lines in " +
metaDataFile.getPath() +
+ " - three for the header followed by three for a directory
entry.");
+
+ assertHeaderEquals(lines, "removed-file-test", "myresource",
"true");
+
+ assertEquals(lines.get(3), "myresource/conf 1", "The first line
for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
- assertFileEntryEquals(lines.get(1), "0 a34ef6 myconf.conf R");
+ assertFileEntryEquals(lines.get(4), "0 a34ef6 myconf.conf R");
}
@Test
@SuppressWarnings("unchecked")
public void writeDirectoryEntryWithChangedFile() throws Exception {
- ChangeSetWriterImpl writer = new ChangeSetWriterImpl(new File(changesetsDir,
"changed-file-test"));
+ File changeSetFile = new File(changeSetsDir, "changed-file-test");
+ DriftConfiguration driftConfig =
driftConfiguration("changed-file-test", "myresource");
+ boolean coverageChangeSet = true;
+
+ ChangeSetWriterImpl writer = new ChangeSetWriterImpl(changeSetFile, driftConfig,
coverageChangeSet);
writer.writeDirectoryEntry(new DirectoryEntry("myresource/conf").add(
changedFileEntry("myconf.conf", "a34ef6",
"c2d55f")));
@@ -76,13 +100,46 @@ public class ChangeSetWriterImplTest {
File metaDataFile = writer.getChangeSetFile();
List<String> lines = readLines(new FileInputStream(metaDataFile));
- assertEquals(lines.size(), 3, "Expected to find three lines in " +
metaDataFile.getPath());
- assertEquals(lines.get(0), "myresource/conf 1", "The first line
for a directory entry should specify the " +
+ assertEquals(lines.size(), 6, "Expected to find six lines in " +
metaDataFile.getPath() +
+ " - three for the header followed by three for a directory
entry.");
+
+ assertHeaderEquals(lines, "changed-file-test", "myresource",
"true");
+
+ assertEquals(lines.get(3), "myresource/conf 1", "The first line
for a directory entry should specify the " +
"directory path followed by the number of lines in the entry.");
- assertFileEntryEquals(lines.get(1), "c2d55f a34ef6 myconf.conf C");
+ assertFileEntryEquals(lines.get(4), "c2d55f a34ef6 myconf.conf C");
+ }
+
+ /**
+ * Verifies that <code>lines</code>, which is assumed to represent the
entire changeset
+ * file, contains the expected header. The header contains three entries which are
+ * written out one entry per line. The header is the first three lines of the
changeset
+ * file and contains the following entries:
+ *
+ * <ul>
+ * <li>drift configuration name</li>
+ * <li>drift configuration base directory</li>
+ * <li>boolean flag indicating whether or not this is an initial
changeset</li>
+ * </ul>
+ * @param lines
+ * @param expected
+ */
+ void assertHeaderEquals(List<String> lines, String... expected) {
+ assertEquals(lines.get(0), expected[0], "The first header entry should be
the drift configuration name.");
+ assertEquals(lines.get(1), expected[1], "The second header entry should be
the base directory.");
+ assertEquals(lines.get(2), expected[2], "The second header entry should be a
flag indicating whether or not " +
+ "this is a coverage change set");
}
+ /**
+ * Verifies that a file entry matches an expected value. A file entry consists of
+ * four, space-delimited fields and is terminated by a newline character. Those
fields
+ * are new_sha, old_sha, file_name, type.
+ *
+ * @param actual
+ * @param expected
+ */
void assertFileEntryEquals(String actual, String expected) {
String[] expectedFields = expected.split(" ");
String[] actualFields = actual.split(" ");
@@ -96,4 +153,12 @@ public class ChangeSetWriterImplTest {
assertEquals(actualFields[3], expectedFields[3], "The fourth column, the
type, is wrong");
}
+ DriftConfiguration driftConfiguration(String name, String basedir) {
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("name", name));
+ config.put(new PropertySimple("basedir", basedir));
+
+ return new DriftConfiguration(config);
+ }
+
}
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
index d001019..962299b 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManager.java
@@ -33,7 +33,8 @@ public interface ChangeSetManager {
*/
ChangeSetReader getChangeSetReader(int resourceId, DriftConfiguration
driftConfiguration) throws IOException;
- ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration
driftConfiguration) throws IOException;
+ ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration
driftConfiguration,
+ boolean coverageChangeSet) throws IOException;
void addFileToChangeSet(int resourceId, DriftConfiguration driftConfiguration, File
file);
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
index ef7db5c..baea20c 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/ChangeSetManagerImpl.java
@@ -46,8 +46,8 @@ public class ChangeSetManagerImpl implements ChangeSetManager {
}
@Override
- public ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration
driftConfiguration)
- throws IOException {
+ public ChangeSetWriter getChangeSetWriter(int resourceId, DriftConfiguration
driftConfiguration,
+ boolean coverageChangeSet) throws IOException {
File resourceDir = new File(changeSetsDir, Integer.toString(resourceId));
File changeSetDir = new File(resourceDir, driftConfiguration.getName());
@@ -55,7 +55,7 @@ public class ChangeSetManagerImpl implements ChangeSetManager {
changeSetDir.mkdirs();
}
- return new ChangeSetWriterImpl(new File(changeSetDir,
"changeset.txt"));
+ return new ChangeSetWriterImpl(new File(changeSetDir, "changeset.txt"),
driftConfiguration, coverageChangeSet);
}
@Override
diff --git
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
index 4519b06..ad8b0c1 100644
---
a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
+++
b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/drift/DriftDetector.java
@@ -50,8 +50,11 @@ public class DriftDetector implements Runnable {
}
try {
+ // TODO add logic to determine if there is an existing changeset
+ // if there is no previous changeset then we need to generate the initial
+ // coverage changeset
ChangeSetWriter writer =
changeSetMgr.getChangeSetWriter(schedule.getResourceId(),
- schedule.getDriftConfiguration());
+ schedule.getDriftConfiguration(), true);
DirectoryScanner scanner = new
DirectoryScanner(schedule.getDriftConfiguration(), writer);
scanner.scan();
diff --git
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
index 9cb3119..80f16b1 100644
---
a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
+++
b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/drift/DriftDetectorTest.java
@@ -80,8 +80,9 @@ public class DriftDetectorTest extends JMockTest {
allowing(changeSetMgr).getChangeSetReader(schedule.getResourceId(),
schedule.getDriftConfiguration());
will(returnValue(new DriftDetectionSchedule(1, driftConfig)));
- allowing(changeSetMgr).getChangeSetWriter(1,
schedule.getDriftConfiguration());
- will(returnValue(new ChangeSetWriterImpl(new File(changeSetDir,
"test"))));
+ allowing(changeSetMgr).getChangeSetWriter(1,
schedule.getDriftConfiguration(), true);
+ will(returnValue(new ChangeSetWriterImpl(new File(changeSetDir,
"test"),
+ schedule.getDriftConfiguration(), true)));
}});
DriftDetector driftDetector = new DriftDetector();