modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
| 11 +++
modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy
| 29 ++++++++++
2 files changed, 40 insertions(+)
New commits:
commit 9f95406ea4af3a31c1635eaa5d401aa05ad1e652
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Nov 25 13:54:02 2009 -0500
[US 6] Updating raw config test plugin to support update operation for Raw Server
diff --git
a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
index c71f0fb..9acbbd8 100644
---
a/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
+++
b/modules/plugins/raw-config-test/src/main/groovy/org/rhq/plugins/test/rawconfig/RawServer.groovy
@@ -6,6 +6,7 @@ import org.rhq.core.domain.configuration.Configuration
import org.rhq.core.domain.configuration.RawConfiguration
import org.rhq.core.domain.measurement.AvailabilityType
import org.rhq.core.pluginapi.inventory.ResourceContext
+import groovy.util.AntBuilder
class RawServer implements ResourceComponent, ResourceConfigurationFacet {
@@ -13,7 +14,11 @@ class RawServer implements ResourceComponent,
ResourceConfigurationFacet {
File rawConfig1
+ def ant = new AntBuilder()
+
void start(ResourceContext context) {
+ ant = new AntBuilder()
+
rawConfigDir = new
File("${System.getProperty('java.io.tmpdir')}/raw-config-test")
rawConfig1 = new File(rawConfigDir, "raw-test-1.txt")
@@ -67,6 +72,12 @@ class RawServer implements ResourceComponent,
ResourceConfigurationFacet {
}
void persistRawConfiguration(RawConfiguration rawConfiguration) {
+ ant.copy(file: rawConfiguration.path, tofile:
"${rawConfiguration.path}.orig")
+ ant.delete(file: rawConfiguration.path)
+
+ def file = new File(rawConfiguration.path)
+ file.createNewFile()
+ file << rawConfiguration.contents
}
void validateStructuredConfiguration(Configuration configuration) {
diff --git
a/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy
b/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy
new file mode 100644
index 0000000..ebb84c2
--- /dev/null
+++
b/modules/plugins/raw-config-test/src/test/groovy/org/rhq/plugins/test/rawconfig/RawServerTest.groovy
@@ -0,0 +1,29 @@
+package org.rhq.plugins.test.rawconfig
+
+import org.testng.annotations.Test
+import org.rhq.core.domain.configuration.RawConfiguration
+
+class RawServerTest {
+
+ @Test
+ void testPersistRawConfiguration() {
+ def rawFileName = "raw-test.txt"
+ def rawFile = new File(confDir, rawFileName)
+
+ def contents = "hello world"
+
+ rawFile << contents
+
+ def updatedContents = "hello world from red hat"
+
+ def rawConfig = new RawConfiguration(path: rawFile.absolutePath, contents:
updatedContents.bytes)
+
+ def rawServer = new RawServer()
+ rawServer.persistRawConfiguration(rawConfig)
+ }
+
+ String getConfDir() {
+ getClass().getResource(".").toURI().path
+ }
+
+}
\ No newline at end of file
Show replies by date