modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
| 6
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdateTest.java
| 114 ++++++++++
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PluginConfigurationUpdateTest.java
| 67 +++++
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdateTest.java
| 67 +++++
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/TestUtil.java
| 45 +++
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupPluginConfigurationUpdateTest.java
| 51 ++++
modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupResourceConfigurationUpdateTest.java
| 51 ++++
7 files changed, 400 insertions(+), 1 deletion(-)
New commits:
commit c2f668eb47020a14173e897e02ef84b0e29fc6a4
Merge: 4743488... 6a2d6ad...
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Nov 25 22:31:11 2009 -0500
Merge branch 'raw-config' of
ssh://git.fedorahosted.org/git/rhq/rhq into
raw-config
commit 4743488a8b743afb2965cb9a242b5dc8c7fb37cd
Author: John Sanda <john(a)localhost.localdomain>
Date: Wed Nov 25 22:24:44 2009 -0500
[BZ 541486] Fixing serialization bug for configuration update objects
The fix involved nothing more than making AbstractConfigurationUpdate implement
Serializable. I have also
added unit tests for all implementing classes to verify correct serialization
behavior.
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
index 8fd3150..0231f78 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdate.java
@@ -24,6 +24,7 @@ package org.rhq.core.domain.configuration;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
+import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
@@ -44,7 +45,10 @@ import javax.xml.bind.annotation.XmlTransient;
* Base class for resource configuration and plugin configuration updates (i.e. history
items).
*/
@XmlAccessorType(XmlAccessType.FIELD)
-public abstract class AbstractConfigurationUpdate {
+public abstract class AbstractConfigurationUpdate implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
@JoinColumn(name = "CONFIGURATION_ID", referencedColumnName =
"ID", nullable = false)
@OneToOne(cascade = { CascadeType.ALL }, fetch = FetchType.EAGER)
@XmlTransient
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdateTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdateTest.java
new file mode 100644
index 0000000..7195cde
--- /dev/null
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/AbstractConfigurationUpdateTest.java
@@ -0,0 +1,114 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.configuration;
+
+import org.testng.annotations.Test;
+
+public abstract class AbstractConfigurationUpdateTest {
+
+
+ @Test
+ public void serializationShouldCopyConfiguration() throws Exception {
+ Configuration config = new Configuration();
+ config.put(new PropertySimple("x", "1"));
+
+ ResourceConfigurationUpdate update = new ResourceConfigurationUpdate();
+ update.setConfiguration(config);
+
+ ResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ org.testng.Assert.assertEquals(
+ serializedUpdate.getConfiguration(),
+ update.getConfiguration(),
+ "Failed to properly serialize the 'configuration'
property"
+ );
+ }
+
+ @Test
+ public void serializationShouldCopyErrorMessage() throws Exception {
+ ResourceConfigurationUpdate update = new ResourceConfigurationUpdate();
+ update.setErrorMessage("update error");
+
+ ResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ org.testng.Assert.assertEquals(
+ serializedUpdate.getErrorMessage(),
+ update.getErrorMessage(),
+ "Failed to properly serialize the 'errorMessage' property"
+ );
+ }
+
+ @Test
+ public void serializationShouldCopyStatus() throws Exception {
+ ResourceConfigurationUpdate update = new ResourceConfigurationUpdate();
+ update.setStatus(ConfigurationUpdateStatus.SUCCESS);
+
+ ResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ org.testng.Assert.assertEquals(
+ serializedUpdate.getStatus(),
+ update.getStatus(),
+ "Failed to properly serialize the 'status' property"
+ );
+ }
+
+ @Test
+ public void serializationShouldCopySubjectName() throws Exception {
+ ResourceConfigurationUpdate update = new ResourceConfigurationUpdate(null, new
Configuration(), "rhqadmin");
+
+ ResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ org.testng.Assert.assertEquals(
+ serializedUpdate.getSubjectName(),
+ update.getSubjectName(),
+ "Failed to properly serialize the 'subjectName' property"
+ );
+ }
+
+ @Test
+ public void serializationShouldCopyCreatedTime() throws Exception {
+ ResourceConfigurationUpdate update = new ResourceConfigurationUpdate();
+
+ ResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ org.testng.Assert.assertEquals(
+ serializedUpdate.getCreatedTime(),
+ update.getCreatedTime(),
+ "Failed to properly serialize the 'createdTime' property"
+ );
+ }
+
+ @Test
+ public void serializationShouldCopyModifiedTime() throws Exception {
+ ResourceConfigurationUpdate update = new ResourceConfigurationUpdate();
+
+ ResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ org.testng.Assert.assertEquals(
+ serializedUpdate.getModifiedTime(),
+ update.getModifiedTime(),
+ "Failed to properly serialize the 'modifiedTime' property"
+ );
+ }
+}
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PluginConfigurationUpdateTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PluginConfigurationUpdateTest.java
new file mode 100644
index 0000000..ee63afd
--- /dev/null
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/PluginConfigurationUpdateTest.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.configuration;
+
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.group.GroupPluginConfigurationUpdate;
+
+public class PluginConfigurationUpdateTest extends AbstractConfigurationUpdateTest {
+
+ @Test
+ public void serializationShouldCopyResource() throws Exception {
+ Resource resource = new Resource();
+ resource.setUuid("1234");
+
+ PluginConfigurationUpdate update = new PluginConfigurationUpdate();
+ update.setResource(resource);
+
+ PluginConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ assertEquals(
+ serializedUpdate.getResource(),
+ update.getResource(),
+ "Failed to properly serialize the 'resource' property"
+ );
+ }
+
+ @Test
+ public void serializationShouldCopyGroupConfigurationUpdate() throws Exception {
+ PluginConfigurationUpdate update = new PluginConfigurationUpdate();
+ update.setGroupConfigurationUpdate(new GroupPluginConfigurationUpdate(new
ResourceGroup("resourceGroup"),
+ "rhqadmin"));
+
+ PluginConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ assertEquals(
+ serializedUpdate.getGroupConfigurationUpdate(),
+ update.getGroupConfigurationUpdate(),
+ "Failed to properly serialize the 'groupConfigurationUpdate'
property"
+ );
+ }
+
+}
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdateTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdateTest.java
new file mode 100644
index 0000000..8a967a6
--- /dev/null
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/ResourceConfigurationUpdateTest.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.configuration;
+
+import static org.testng.Assert.*;
+
+import org.testng.annotations.Test;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.group.ResourceGroup;
+import org.rhq.core.domain.configuration.group.GroupResourceConfigurationUpdate;
+
+public class ResourceConfigurationUpdateTest extends AbstractConfigurationUpdateTest {
+
+ @Test
+ public void serializationShouldCopyResource() throws Exception {
+ Resource resource = new Resource();
+ resource.setUuid("1234");
+
+ ResourceConfigurationUpdate update = new ResourceConfigurationUpdate();
+ update.setResource(resource);
+
+ ResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ assertEquals(
+ serializedUpdate.getResource(),
+ update.getResource(),
+ "Failed to properly serialize the 'resource' property"
+ );
+ }
+
+ @Test
+ public void serializationShouldCopyGroupConfigurationUpdate() throws Exception {
+ ResourceConfigurationUpdate update = new ResourceConfigurationUpdate();
+ update.setGroupConfigurationUpdate(new GroupResourceConfigurationUpdate(new
ResourceGroup("resourceGroup"),
+ "rhqadmin"));
+
+ ResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ assertEquals(
+ serializedUpdate.getGroupConfigurationUpdate(),
+ update.getGroupConfigurationUpdate(),
+ "Failed to properly serialize the 'groupConfigurationUpdate'
property"
+ );
+ }
+
+}
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/TestUtil.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/TestUtil.java
new file mode 100644
index 0000000..c1fac86
--- /dev/null
+++ b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/TestUtil.java
@@ -0,0 +1,45 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.configuration;
+
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ObjectInputStream;
+
+public class TestUtil {
+
+ public static <T> T serializeAndDeserialize(T object) throws Exception {
+ ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();
+ ObjectOutputStream ostream = new ObjectOutputStream(byteOutputStream);
+
+ ostream.writeObject(object);
+
+ ByteArrayInputStream byteInputStream = new
ByteArrayInputStream(byteOutputStream.toByteArray());
+ ObjectInputStream istream = new ObjectInputStream(byteInputStream);
+
+ return (T) istream.readObject();
+ }
+
+}
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupPluginConfigurationUpdateTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupPluginConfigurationUpdateTest.java
new file mode 100644
index 0000000..0be4172
--- /dev/null
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupPluginConfigurationUpdateTest.java
@@ -0,0 +1,51 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.configuration.group;
+
+import org.rhq.core.domain.configuration.AbstractConfigurationUpdateTest;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.TestUtil;
+import org.rhq.core.domain.configuration.PluginConfigurationUpdate;
+import org.rhq.core.domain.resource.Resource;
+import org.testng.annotations.Test;
+import static org.testng.Assert.assertEquals;
+
+public class GroupPluginConfigurationUpdateTest extends AbstractConfigurationUpdateTest
{
+
+ @Test
+ public void serializationShouldCopyConfigurationUpdates() throws Exception {
+ GroupPluginConfigurationUpdate update = new GroupPluginConfigurationUpdate();
+ update.getConfigurationUpdates().add(new PluginConfigurationUpdate(new
Resource(), new Configuration(),
+ "rhqadmin"));
+
+ GroupPluginConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ assertEquals(
+ serializedUpdate.getConfigurationUpdates(),
+ update.getConfigurationUpdates(),
+ "Failed to properly serialize the 'configurationUpdate'
property"
+ );
+ }
+}
diff --git
a/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupResourceConfigurationUpdateTest.java
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupResourceConfigurationUpdateTest.java
new file mode 100644
index 0000000..ebb9008
--- /dev/null
+++
b/modules/core/domain/src/test/java/org/rhq/core/domain/configuration/group/GroupResourceConfigurationUpdateTest.java
@@ -0,0 +1,51 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2008 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package org.rhq.core.domain.configuration.group;
+
+import static org.testng.Assert.*;
+
+import org.rhq.core.domain.configuration.AbstractConfigurationUpdateTest;
+import org.rhq.core.domain.configuration.ResourceConfigurationUpdate;
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.TestUtil;
+import org.rhq.core.domain.resource.Resource;
+import org.testng.annotations.Test;
+
+public class GroupResourceConfigurationUpdateTest extends AbstractConfigurationUpdateTest
{
+
+ @Test
+ public void serializationShouldCopyConfigurationUpdates() throws Exception {
+ GroupResourceConfigurationUpdate update = new
GroupResourceConfigurationUpdate();
+ update.addConfigurationUpdate(new ResourceConfigurationUpdate(new Resource(), new
Configuration(), "rhqadmin"));
+
+ GroupResourceConfigurationUpdate serializedUpdate =
TestUtil.serializeAndDeserialize(update);
+
+ assertEquals(
+ serializedUpdate.getConfigurationUpdates(),
+ update.getConfigurationUpdates(),
+ "Failed to properly serialize the 'configurationUpdate'
property"
+ );
+ }
+
+}