[jboss-cvs] JBossAS SVN: r85226 - in trunk/system/src/tests/org/jboss/test/server/profileservice/persistence: remove and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Mar 4 09:56:03 EST 2009
Author: emuckenhuber
Date: 2009-03-04 09:56:01 -0500 (Wed, 04 Mar 2009)
New Revision: 85226
Added:
trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/
trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/
trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/RemoveGenericValueUnitTestCase.java
Log:
[JBAS-6227] basic remove generic value unit test case.
Added: trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/RemoveGenericValueUnitTestCase.java
===================================================================
--- trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/RemoveGenericValueUnitTestCase.java (rev 0)
+++ trunk/system/src/tests/org/jboss/test/server/profileservice/persistence/remove/test/RemoveGenericValueUnitTestCase.java 2009-03-04 14:56:01 UTC (rev 85226)
@@ -0,0 +1,111 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.server.profileservice.persistence.remove.test;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.managed.api.ManagedObject;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.CollectionValue;
+import org.jboss.system.server.profileservice.persistence.ManagedGenericOverrideHandler;
+import org.jboss.system.server.profileservice.persistence.ManagedObjectPeristenceHandler;
+import org.jboss.system.server.profileservice.persistence.xml.ModificationInfo;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedCollectionValue;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedManagedObject;
+import org.jboss.system.server.profileservice.persistence.xml.PersistedProperty;
+import org.jboss.test.server.profileservice.persistence.support.GenericSupportMetaData;
+import org.jboss.test.server.profileservice.persistence.support.SimpleGenericMetaData;
+import org.jboss.test.server.profileservice.persistence.test.AbstractPersistenceFormatTest;
+import org.jboss.test.server.profileservice.persistence.test.CollectionValueUnitTestCase;
+
+/**
+ * @author <a href="mailto:emuckenh at redhat.com">Emanuel Muckenhuber</a>
+ * @version $Revision$
+ */
+public class RemoveGenericValueUnitTestCase extends AbstractPersistenceFormatTest
+{
+
+ public RemoveGenericValueUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void test() throws Throwable
+ {
+
+ ManagedObject mo = createTestMO();
+
+ ManagedObjectPeristenceHandler persistence = new ManagedObjectPeristenceHandler();
+ PersistedManagedObject moElement = persistence.createPersistenceMetaData(mo);
+ assertNotNull(moElement);
+
+ // Remove
+ PersistedProperty p = moElement.getProperties().get(0);
+ PersistedCollectionValue collection = (PersistedCollectionValue) p.getValue();
+ assertNotNull(collection);
+ collection.getValue(0).setModificationInfo(ModificationInfo.REMOVED);
+
+ // Restore
+ ManagedGenericOverrideHandler handler = new ManagedGenericOverrideHandler();
+ ManagedObject restored = handler.update(createTestMetaData(), moElement);
+
+
+ // Check meta data
+ GenericSupportMetaData md = (GenericSupportMetaData) restored.getAttachment();
+ assertNotNull(md);
+ assertEquals(1, md.getList().size());
+ SimpleGenericMetaData parent2 = md.getList().get(0);
+ assertEquals("parent2", parent2.getString());
+ assertNotNull(parent2.getChild());
+ assertEquals("child2", parent2.getChild().getString());
+ }
+
+ private ManagedObject createTestMO()
+ {
+ return getMOF().initManagedObject(createTestMetaData(), null);
+ }
+
+ private GenericSupportMetaData createTestMetaData()
+ {
+ GenericSupportMetaData metaData = new GenericSupportMetaData();
+
+ List<SimpleGenericMetaData> list = new ArrayList<SimpleGenericMetaData>();
+
+ SimpleGenericMetaData child1 = createSImple("child1", 11, null);
+ SimpleGenericMetaData child2 = createSImple("child2", 21, null);
+
+ list.add(createSImple("parent1", 1, child1));
+ list.add(createSImple("parent2", 2, child2));
+
+ metaData.setList(list);
+
+ return metaData;
+ }
+
+ private SimpleGenericMetaData createSImple(String string, int integer, SimpleGenericMetaData child)
+ {
+ return new SimpleGenericMetaData(string, integer, child);
+ }
+
+}
+
More information about the jboss-cvs-commits
mailing list