[jboss-cvs] JBossAS SVN: r83527 - projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/aspects/remoting.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jan 27 19:13:06 EST 2009
Author: bstansberry at jboss.com
Date: 2009-01-27 19:13:06 -0500 (Tue, 27 Jan 2009)
New Revision: 83527
Added:
projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/aspects/remoting/FamilyWrapperUnitTestCase.java
Log:
Add a unit test of FamilyWrapper
Added: projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/aspects/remoting/FamilyWrapperUnitTestCase.java
===================================================================
--- projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/aspects/remoting/FamilyWrapperUnitTestCase.java (rev 0)
+++ projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/aspects/remoting/FamilyWrapperUnitTestCase.java 2009-01-28 00:13:06 UTC (rev 83527)
@@ -0,0 +1,90 @@
+/*
+ * 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.aspects.remoting;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.Arrays;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.jboss.aspects.remoting.FamilyWrapper;
+import org.jboss.ha.framework.interfaces.ClusteringTargetsRepository;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+
+/**
+ * Unit tests of {@link FamilyWrapper}.
+ * @author Brian Stansberry
+ * @version $Revision:$
+ */
+public class FamilyWrapperUnitTestCase extends TestCase
+{
+
+ /**
+ * Create a new FamilyWrapperUnitTestCase.
+ *
+ * @param name
+ */
+ public FamilyWrapperUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testSerialization() throws IOException, ClassNotFoundException
+ {
+ List targets = Arrays.asList(new String[]{"A", "B"});
+ FamilyWrapper wrapper = new FamilyWrapper("testSerialization", targets);
+ FamilyClusterInfo fci = wrapper.get();
+ assertNotNull(fci);
+ assertEquals(targets, fci.getTargets());
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream oos = new ObjectOutputStream(baos);
+ oos.writeObject(wrapper);
+ oos.close();
+ byte[] bytes = baos.toByteArray();
+
+ List newTargets = Arrays.asList(new String[]{"C", "D"});
+
+ FamilyClusterInfo fci2 = ClusteringTargetsRepository.initTarget("testSerialization", newTargets, 1);
+
+ assertSame(fci, fci2);
+
+ assertEquals(newTargets, fci.getTargets());
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
+ ObjectInputStream ois = new ObjectInputStream(bais);
+ FamilyWrapper deserialized = (FamilyWrapper) ois.readObject();
+
+ FamilyClusterInfo fci3 = deserialized.get();
+
+ assertSame(fci, fci3);
+
+ assertEquals(targets, fci3.getTargets());
+ }
+
+}
Property changes on: projects/cluster/ha-client/trunk/src/test/java/org/jboss/test/aspects/remoting/FamilyWrapperUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+
More information about the jboss-cvs-commits
mailing list