[jboss-cvs] JBossAS SVN: r89767 - trunk/varia/src/tests/org/jboss/test/services/binding/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jun 3 16:26:16 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-06-03 16:26:16 -0400 (Wed, 03 Jun 2009)
New Revision: 89767
Added:
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java
Removed:
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagmentObjectUnitTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataTestCase.java
trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperTestCase.java
Log:
Fix class names
Copied: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java (from rev 89766, trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagmentObjectUnitTestCase.java)
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java 2009-06-03 20:26:16 UTC (rev 89767)
@@ -0,0 +1,550 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.services.binding.test;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.services.binding.ServiceBinding;
+import org.jboss.services.binding.ServiceBindingMetadata;
+import org.jboss.services.binding.impl.ServiceBindingSet;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
+import org.jboss.services.binding.managed.ServiceBindingManagementObject;
+
+/**
+ * Unit tests for {@link ServiceBindingManagementObject}.
+ *
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class ServiceBindingManagmentObjectUnitTestCase extends TestCase
+{
+ private static final String A = "A";
+ private static final String B = "B";
+ private static final String C = "C";
+
+ private static ServiceBindingMetadata AA;
+ private static ServiceBindingMetadata AB;
+ private static ServiceBindingMetadata Anull;
+ private static ServiceBindingMetadata BA;
+
+ private static ServiceBindingSet SET_A;
+ private static ServiceBindingSet SET_B;
+ private static ServiceBindingSet SET_C;
+
+ private Set<ServiceBindingMetadata> bindings = new HashSet<ServiceBindingMetadata>();
+ private Set<ServiceBindingSet> bindingSets = new HashSet<ServiceBindingSet>();
+
+ /**
+ * Create a new ServiceBindingManagmentObjectUnitTestCase.
+ *
+ * @param name
+ */
+ public ServiceBindingManagmentObjectUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+
+ AA = new ServiceBindingMetadata(A, A, null, 1, false, false);
+ bindings.add(AA);
+ AB = new ServiceBindingMetadata(A, B, null, 1, false, false);
+ bindings.add(AB);
+ Anull = new ServiceBindingMetadata(A, null, null, 1, false, false);
+ bindings.add(Anull);
+
+ // This one doesn't go in the standard bindings set
+ BA = new ServiceBindingMetadata(B, A, null, 1, false, false);
+
+ SET_A = new ServiceBindingSet(A);
+ SET_A.setDefaultHostName("localhost");
+ bindingSets.add(SET_A);
+ SET_B = new ServiceBindingSet(B);
+ SET_B.setDefaultHostName("localhost");
+ bindingSets.add(SET_B);
+ SET_C = new ServiceBindingSet(C);
+ SET_C.setDefaultHostName("localhost");
+ bindingSets.add(SET_C);
+ }
+
+ protected void tearDown() throws Exception
+ {
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.managed.ServiceBindingManagementObject#setActiveBindingSetName(java.lang.String)}.
+ */
+ public void testSetActiveBindingSetName() throws Exception
+ {
+ ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", bindingSets, bindings);
+ testee.start();
+ assertEquals("test", testee.getActiveBindingSetName());
+ assertEquals("test", testee.getServiceBindingManager().getServerName());
+ testee.setActiveBindingSetName("changed");
+ assertEquals("changed", testee.getActiveBindingSetName());
+ assertEquals("changed", testee.getServiceBindingManager().getServerName());
+
+ try
+ {
+ testee.setActiveBindingSetName(null);
+ fail("Null activeBindingSetName allowed");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link ServiceBindingManagementObject#setBindingSets(java.util.Set)}.
+ *
+ * This is basically a duplicate of the same test in PojoServiceBindingStoreUnitTestCase.
+ */
+ public void testSetBindingSets() throws Exception
+ {
+ // THIS IS BAS
+ Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
+ set.addAll(Arrays.asList(AA, AB, Anull));
+
+ Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
+ ServiceBindingSet setA = new ServiceBindingSet(A, null, 10);
+ sbs.add(setA);
+ ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 20);
+ sbs.add(setB);
+
+ ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", sbs, set);
+ testee.start();
+
+ Set<ServiceBindingSet> updated = new HashSet<ServiceBindingSet>(testee.getBindingSets());
+
+ Set<ServiceBindingMetadata> overrides = new HashSet<ServiceBindingMetadata>();
+ overrides.add(BA);
+ ServiceBindingSet newSet = new ServiceBindingSet(C, "192.168.0.10", 30, overrides);
+ updated.add(newSet);
+ ServiceBindingSet replaced = new ServiceBindingSet(B, "localhost", 50);
+ updated.remove(setB);
+ updated.add(replaced);
+ assertEquals(3, updated.size());
+
+ testee.setBindingSets(updated);
+
+ Set<ServiceBindingSet> result = testee.getBindingSets();
+ assertNotNull(result);
+ assertTrue("has setA", result.contains(setA));
+ assertTrue("has setB", result.contains(replaced));
+ assertTrue("has newSet", result.contains(newSet));
+
+ Set<ServiceBinding> bindings = testee.getServiceBindings().get(C);
+ assertNotNull(bindings);
+ Map<String, ServiceBinding> byFQN = new HashMap<String, ServiceBinding>();
+ for (ServiceBinding binding : bindings)
+ {
+ byFQN.put(binding.getFullyQualifiedName(), binding);
+ }
+
+ ServiceBinding aa = byFQN.get(AA.getFullyQualifiedName());
+ assertNotNull(aa);
+ assertEquals(AA.getServiceName(), aa.getServiceName());
+ assertEquals(AA.getBindingName(), aa.getBindingName());
+ assertEquals(AA.getDescription(), aa.getDescription());
+ assertEquals("192.168.0.10", aa.getHostName());
+ assertEquals(AA.getPort() + 30, aa.getPort());
+
+ ServiceBinding ab = byFQN.get(AB.getFullyQualifiedName());
+ assertNotNull(aa);
+ assertEquals(AB.getServiceName(), ab.getServiceName());
+ assertEquals(AB.getBindingName(), ab.getBindingName());
+ assertEquals(AB.getDescription(), ab.getDescription());
+ assertEquals("192.168.0.10", ab.getHostName());
+ assertEquals(AB.getPort() + 30, ab.getPort());
+
+ ServiceBinding anull = byFQN.get(Anull.getFullyQualifiedName());
+ assertNotNull(anull);
+ assertEquals(Anull.getServiceName(), anull.getServiceName());
+ assertEquals(Anull.getBindingName(), anull.getBindingName());
+ assertEquals(Anull.getDescription(), anull.getDescription());
+ assertEquals("192.168.0.10", anull.getHostName());
+ assertEquals(Anull.getPort() + 30, anull.getPort());
+
+ ServiceBinding newOne = byFQN.get(BA.getFullyQualifiedName());
+ assertNotNull(newOne);
+ assertEquals(BA.getServiceName(), newOne.getServiceName());
+ assertEquals(BA.getBindingName(), newOne.getBindingName());
+ assertEquals(BA.getDescription(), newOne.getDescription());
+ assertEquals("192.168.0.10", newOne.getHostName());
+ assertEquals(BA.getPort() + 30, newOne.getPort());
+
+ bindings = testee.getServiceBindings().get(B);
+ assertNotNull(bindings);
+ byFQN = new HashMap<String, ServiceBinding>();
+ for (ServiceBinding binding : bindings)
+ {
+ byFQN.put(binding.getFullyQualifiedName(), binding);
+ }
+
+ aa = byFQN.get(AA.getFullyQualifiedName());
+ assertNotNull(aa);
+ assertEquals(AA.getServiceName(), aa.getServiceName());
+ assertEquals(AA.getBindingName(), aa.getBindingName());
+ assertEquals(AA.getDescription(), aa.getDescription());
+ assertEquals("localhost", aa.getHostName());
+ assertEquals(AA.getPort() + 50, aa.getPort());
+
+ ab = byFQN.get(AB.getFullyQualifiedName());
+ assertNotNull(aa);
+ assertEquals(AB.getServiceName(), ab.getServiceName());
+ assertEquals(AB.getBindingName(), ab.getBindingName());
+ assertEquals(AB.getDescription(), ab.getDescription());
+ assertEquals("localhost", ab.getHostName());
+ assertEquals(AB.getPort() + 50, ab.getPort());
+
+ anull = byFQN.get(Anull.getFullyQualifiedName());
+ assertNotNull(anull);
+ assertEquals(Anull.getServiceName(), anull.getServiceName());
+ assertEquals(Anull.getBindingName(), anull.getBindingName());
+ assertEquals(Anull.getDescription(), anull.getDescription());
+ assertEquals("localhost", anull.getHostName());
+ assertEquals(Anull.getPort() + 50, anull.getPort());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.managed.ServiceBindingManagementObject#setStandardBindings(java.util.Set)}.
+ *
+ * This is basically a duplicate of the same test in PojoServiceBindingStoreUnitTestCase.
+ */
+ public void testSetStandardBindings() throws Exception
+ {
+ Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
+ set.addAll(Arrays.asList(AA, AB, Anull));
+
+ Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
+ ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 20);
+ sbs.add(setB);
+ ServiceBindingSet setC = new ServiceBindingSet(C, "192.168.0.10", 30);
+ sbs.add(setC);
+
+ ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", sbs, set);
+ testee.start();
+
+ Set<ServiceBindingMetadata> updatedSet =
+ new HashSet<ServiceBindingMetadata>(testee.getStandardBindings());
+ assertEquals(3, updatedSet.size());
+ ServiceBindingMetadata updated = new ServiceBindingMetadata(AA);
+ updated.setPort(9999);
+ updated.setDescription("updated");
+ updatedSet.remove(AA);
+ updatedSet.add(updated);
+ updatedSet.add(BA);
+ assertEquals(4, updatedSet.size());
+
+ testee.setStandardBindings(updatedSet);
+
+ Set<ServiceBindingMetadata> result = testee.getStandardBindings();
+ assertNotNull(result);
+ assertTrue("has updated", result.contains(updated));
+ assertTrue("has AB", result.contains(AB));
+ assertTrue("has Anull", result.contains(Anull));
+ assertTrue("has BA", result.contains(BA));
+
+ for (ServiceBindingSet bindingSet : sbs)
+ {
+ String setName = bindingSet.getName();
+ Set<ServiceBinding> bindings = testee.getServiceBindings().get(setName);
+ assertNotNull(bindings);
+ assertEquals(4, bindings.size());
+ Map<String, ServiceBinding> byFQN = new HashMap<String, ServiceBinding>();
+ for (ServiceBinding binding : bindings)
+ {
+ byFQN.put(binding.getFullyQualifiedName(), binding);
+ }
+
+ ServiceBinding aa = byFQN.get(updated.getFullyQualifiedName());
+ assertNotNull(aa);
+ assertEquals(setName + "/updated/serviceName", updated.getServiceName(), aa.getServiceName());
+ assertEquals(setName + "/updated/bindingName", updated.getBindingName(), aa.getBindingName());
+ assertEquals(setName + "/updated/description", updated.getDescription(), aa.getDescription());
+ assertEquals(setName + "/updated/hostName", bindingSet.getDefaultHostName(), aa.getHostName());
+ assertEquals(setName + "/updated/port", updated.getPort() + bindingSet.getPortOffset(), aa.getPort());
+
+ ServiceBinding ab = byFQN.get(AB.getFullyQualifiedName());
+ assertNotNull(aa);
+ assertEquals(setName + "/AB/serviceName", AB.getServiceName(), ab.getServiceName());
+ assertEquals(setName + "/AB/bindingName", AB.getBindingName(), ab.getBindingName());
+ assertEquals(setName + "/AB/description", AB.getDescription(), ab.getDescription());
+ assertEquals(setName + "/AB/hostName", bindingSet.getDefaultHostName(), ab.getHostName());
+ assertEquals(setName + "/AB/port", AB.getPort() + bindingSet.getPortOffset(), ab.getPort());
+
+ ServiceBinding anull = byFQN.get(Anull.getFullyQualifiedName());
+ assertNotNull(anull);
+ assertEquals(setName + "/Anull/serviceName", Anull.getServiceName(), anull.getServiceName());
+ assertEquals(setName + "/Anull/bindingName", Anull.getBindingName(), anull.getBindingName());
+ assertEquals(setName + "/Anull/description", Anull.getDescription(), anull.getDescription());
+ assertEquals(setName + "/Anull/hostName", bindingSet.getDefaultHostName(), anull.getHostName());
+ assertEquals(setName + "/Anull/port", Anull.getPort() + bindingSet.getPortOffset(), anull.getPort());
+
+ ServiceBinding newOne = byFQN.get(BA.getFullyQualifiedName());
+ assertNotNull(newOne);
+ assertEquals(setName + "/BA/serviceName", BA.getServiceName(), newOne.getServiceName());
+ assertEquals(setName + "/BA/bindingName", BA.getBindingName(), newOne.getBindingName());
+ assertEquals(setName + "/BA/description", BA.getDescription(), newOne.getDescription());
+ assertEquals(setName + "/BA/hostName", bindingSet.getDefaultHostName(), newOne.getHostName());
+ assertEquals(setName + "/BA/port", BA.getPort() + bindingSet.getPortOffset(), newOne.getPort());
+ }
+ }
+
+ /**
+ * The objects returned via a management console don't include the
+ * value source class or config; the ServiceBindingManagementObject is
+ * responsible for preserving objects associated with the existing configs.
+ * This is a test of that for the standard bindings.
+ *
+ * @throws Exception
+ */
+ public void testPreserveValueSourceStandardBinding() throws Exception
+ {
+
+ Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
+ set.addAll(Arrays.asList(AA, AB));
+ ServiceBindingMetadata value = new ServiceBindingMetadata("value-source", null, null, 25);
+ // Add value-source configs we expect to retain!
+ value.setServiceBindingValueSourceClassName(XSLTServiceBindingValueSourceImpl.class.getName());
+ value.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
+ set.add(value);
+
+ Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
+ ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 0);
+ sbs.add(setB);
+
+ ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", sbs, set);
+ testee.start();
+
+ set = testee.getStandardBindings();
+ assertEquals(3, set.size());
+ boolean found = false;
+ for (ServiceBindingMetadata md : set)
+ {
+ if ("value-source".equals(md.getFullyQualifiedName()))
+ {
+ found = true;
+ assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
+ Object config = md.getServiceBindingValueSourceConfig();
+ assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
+ assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
+ break;
+ }
+ }
+ assertTrue(found);
+
+ Map<String, Set<ServiceBinding>> bindingsMap = testee.getServiceBindings();
+ assertNotNull(bindingsMap);
+ Set<ServiceBinding> bindings = bindingsMap.get(B);
+ assertNotNull(bindings);
+ found = false;
+ for (ServiceBinding md : bindings)
+ {
+ if ("value-source".equals(md.getFullyQualifiedName()))
+ {
+ found = true;
+ assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
+ Object config = md.getServiceBindingValueSourceConfig();
+ assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
+ assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
+ break;
+ }
+ }
+ assertTrue(found);
+
+
+ set = new HashSet<ServiceBindingMetadata>();
+ set.addAll(Arrays.asList(AA, AB));
+ set.add(new ServiceBindingMetadata("value-source", null, null, 25));
+ // KEY POINT IN THE WHOLE TEST: we don't configure the value source stuff
+
+ testee.setStandardBindings(set);
+
+ set = testee.getStandardBindings();
+ assertEquals(3, set.size());
+ found = false;
+ for (ServiceBindingMetadata md : set)
+ {
+ if ("value-source".equals(md.getFullyQualifiedName()))
+ {
+ found = true;
+ assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
+ Object config = md.getServiceBindingValueSourceConfig();
+ assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
+ assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
+ break;
+ }
+ }
+ assertTrue(found);
+
+ bindingsMap = testee.getServiceBindings();
+ assertNotNull(bindingsMap);
+ bindings = bindingsMap.get(B);
+ assertNotNull(bindings);
+ found = false;
+ for (ServiceBinding md : bindings)
+ {
+ if ("value-source".equals(md.getFullyQualifiedName()))
+ {
+ found = true;
+ assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
+ Object config = md.getServiceBindingValueSourceConfig();
+ assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
+ assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
+ /**
+ * The objects returned via a management console don't include the
+ * value source class or config; the ServiceBindingManagementObject is
+ * responsible for preserving objects associated with the existing configs.
+ * This is a test of that for ServiceBindingMetadata in a ServiceBindingSet's
+ * override set.
+ *
+ * @throws Exception
+ */
+ public void testPreserveValueSourceOverrideBinding() throws Exception
+ {
+
+ Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
+ set.addAll(Arrays.asList(AA, AB));
+
+ ServiceBindingMetadata value = new ServiceBindingMetadata("value-source", null, null, 25);
+ // Add value-source configs we expect to retain!
+ value.setServiceBindingValueSourceClassName(XSLTServiceBindingValueSourceImpl.class.getName());
+ value.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
+ Set<ServiceBindingMetadata> overrides = new HashSet<ServiceBindingMetadata>();
+ overrides.add(value);
+
+ Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
+ ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 0, overrides);
+ sbs.add(setB);
+
+ ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", sbs, set);
+ testee.start();
+
+ sbs = testee.getBindingSets();
+ assertEquals(1, sbs.size());
+
+ boolean found = false;
+ for (ServiceBindingSet sb : sbs)
+ {
+ for (ServiceBindingMetadata md : sb.getOverrideBindings())
+ {
+ if ("value-source".equals(md.getFullyQualifiedName()))
+ {
+ found = true;
+ assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
+ Object config = md.getServiceBindingValueSourceConfig();
+ assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
+ assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
+ Map<String, Set<ServiceBinding>> bindingsMap = testee.getServiceBindings();
+ assertNotNull(bindingsMap);
+ Set<ServiceBinding> bindings = bindingsMap.get(B);
+ assertNotNull(bindings);
+ found = false;
+ for (ServiceBinding md : bindings)
+ {
+ if ("value-source".equals(md.getFullyQualifiedName()))
+ {
+ found = true;
+ assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
+ Object config = md.getServiceBindingValueSourceConfig();
+ assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
+ assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
+ break;
+ }
+ }
+ assertTrue(found);
+
+
+ overrides = new HashSet<ServiceBindingMetadata>();
+ overrides.add(new ServiceBindingMetadata("value-source", null, null, 25));
+ // KEY POINT IN THE WHOLE TEST: we don't configure the value source stuff
+
+ setB = new ServiceBindingSet(B, "localhost", 0, overrides);
+ sbs = new HashSet<ServiceBindingSet>();
+ sbs.add(setB);
+ testee.setBindingSets(sbs);
+
+ sbs = testee.getBindingSets();
+ assertEquals(1, sbs.size());
+
+ found = false;
+ for (ServiceBindingSet sb : sbs)
+ {
+ for (ServiceBindingMetadata md : sb.getOverrideBindings())
+ {
+ if ("value-source".equals(md.getFullyQualifiedName()))
+ {
+ found = true;
+ assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
+ Object config = md.getServiceBindingValueSourceConfig();
+ assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
+ assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
+ bindingsMap = testee.getServiceBindings();
+ assertNotNull(bindingsMap);
+ bindings = bindingsMap.get(B);
+ assertNotNull(bindings);
+ found = false;
+ for (ServiceBinding md : bindings)
+ {
+ if ("value-source".equals(md.getFullyQualifiedName()))
+ {
+ found = true;
+ assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
+ Object config = md.getServiceBindingValueSourceConfig();
+ assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
+ assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
+ break;
+ }
+ }
+ assertTrue(found);
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+
Name: svn:mergeinfo
+
Deleted: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagmentObjectUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagmentObjectUnitTestCase.java 2009-06-03 20:24:30 UTC (rev 89766)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagmentObjectUnitTestCase.java 2009-06-03 20:26:16 UTC (rev 89767)
@@ -1,550 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.services.binding.test;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.jboss.services.binding.impl.ServiceBindingSet;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
-import org.jboss.services.binding.managed.ServiceBindingManagementObject;
-
-/**
- * Unit tests for {@link ServiceBindingManagementObject}.
- *
- * @author Brian Stansberry
- *
- * @version $Revision: $
- */
-public class ServiceBindingManagmentObjectUnitTestCase extends TestCase
-{
- private static final String A = "A";
- private static final String B = "B";
- private static final String C = "C";
-
- private static ServiceBindingMetadata AA;
- private static ServiceBindingMetadata AB;
- private static ServiceBindingMetadata Anull;
- private static ServiceBindingMetadata BA;
-
- private static ServiceBindingSet SET_A;
- private static ServiceBindingSet SET_B;
- private static ServiceBindingSet SET_C;
-
- private Set<ServiceBindingMetadata> bindings = new HashSet<ServiceBindingMetadata>();
- private Set<ServiceBindingSet> bindingSets = new HashSet<ServiceBindingSet>();
-
- /**
- * Create a new ServiceBindingManagmentObjectUnitTestCase.
- *
- * @param name
- */
- public ServiceBindingManagmentObjectUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- AA = new ServiceBindingMetadata(A, A, null, 1, false, false);
- bindings.add(AA);
- AB = new ServiceBindingMetadata(A, B, null, 1, false, false);
- bindings.add(AB);
- Anull = new ServiceBindingMetadata(A, null, null, 1, false, false);
- bindings.add(Anull);
-
- // This one doesn't go in the standard bindings set
- BA = new ServiceBindingMetadata(B, A, null, 1, false, false);
-
- SET_A = new ServiceBindingSet(A);
- SET_A.setDefaultHostName("localhost");
- bindingSets.add(SET_A);
- SET_B = new ServiceBindingSet(B);
- SET_B.setDefaultHostName("localhost");
- bindingSets.add(SET_B);
- SET_C = new ServiceBindingSet(C);
- SET_C.setDefaultHostName("localhost");
- bindingSets.add(SET_C);
- }
-
- protected void tearDown() throws Exception
- {
- super.tearDown();
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.managed.ServiceBindingManagementObject#setActiveBindingSetName(java.lang.String)}.
- */
- public void testSetActiveBindingSetName() throws Exception
- {
- ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", bindingSets, bindings);
- testee.start();
- assertEquals("test", testee.getActiveBindingSetName());
- assertEquals("test", testee.getServiceBindingManager().getServerName());
- testee.setActiveBindingSetName("changed");
- assertEquals("changed", testee.getActiveBindingSetName());
- assertEquals("changed", testee.getServiceBindingManager().getServerName());
-
- try
- {
- testee.setActiveBindingSetName(null);
- fail("Null activeBindingSetName allowed");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link ServiceBindingManagementObject#setBindingSets(java.util.Set)}.
- *
- * This is basically a duplicate of the same test in PojoServiceBindingStoreUnitTestCase.
- */
- public void testSetBindingSets() throws Exception
- {
- // THIS IS BAS
- Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
- set.addAll(Arrays.asList(AA, AB, Anull));
-
- Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
- ServiceBindingSet setA = new ServiceBindingSet(A, null, 10);
- sbs.add(setA);
- ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 20);
- sbs.add(setB);
-
- ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", sbs, set);
- testee.start();
-
- Set<ServiceBindingSet> updated = new HashSet<ServiceBindingSet>(testee.getBindingSets());
-
- Set<ServiceBindingMetadata> overrides = new HashSet<ServiceBindingMetadata>();
- overrides.add(BA);
- ServiceBindingSet newSet = new ServiceBindingSet(C, "192.168.0.10", 30, overrides);
- updated.add(newSet);
- ServiceBindingSet replaced = new ServiceBindingSet(B, "localhost", 50);
- updated.remove(setB);
- updated.add(replaced);
- assertEquals(3, updated.size());
-
- testee.setBindingSets(updated);
-
- Set<ServiceBindingSet> result = testee.getBindingSets();
- assertNotNull(result);
- assertTrue("has setA", result.contains(setA));
- assertTrue("has setB", result.contains(replaced));
- assertTrue("has newSet", result.contains(newSet));
-
- Set<ServiceBinding> bindings = testee.getServiceBindings().get(C);
- assertNotNull(bindings);
- Map<String, ServiceBinding> byFQN = new HashMap<String, ServiceBinding>();
- for (ServiceBinding binding : bindings)
- {
- byFQN.put(binding.getFullyQualifiedName(), binding);
- }
-
- ServiceBinding aa = byFQN.get(AA.getFullyQualifiedName());
- assertNotNull(aa);
- assertEquals(AA.getServiceName(), aa.getServiceName());
- assertEquals(AA.getBindingName(), aa.getBindingName());
- assertEquals(AA.getDescription(), aa.getDescription());
- assertEquals("192.168.0.10", aa.getHostName());
- assertEquals(AA.getPort() + 30, aa.getPort());
-
- ServiceBinding ab = byFQN.get(AB.getFullyQualifiedName());
- assertNotNull(aa);
- assertEquals(AB.getServiceName(), ab.getServiceName());
- assertEquals(AB.getBindingName(), ab.getBindingName());
- assertEquals(AB.getDescription(), ab.getDescription());
- assertEquals("192.168.0.10", ab.getHostName());
- assertEquals(AB.getPort() + 30, ab.getPort());
-
- ServiceBinding anull = byFQN.get(Anull.getFullyQualifiedName());
- assertNotNull(anull);
- assertEquals(Anull.getServiceName(), anull.getServiceName());
- assertEquals(Anull.getBindingName(), anull.getBindingName());
- assertEquals(Anull.getDescription(), anull.getDescription());
- assertEquals("192.168.0.10", anull.getHostName());
- assertEquals(Anull.getPort() + 30, anull.getPort());
-
- ServiceBinding newOne = byFQN.get(BA.getFullyQualifiedName());
- assertNotNull(newOne);
- assertEquals(BA.getServiceName(), newOne.getServiceName());
- assertEquals(BA.getBindingName(), newOne.getBindingName());
- assertEquals(BA.getDescription(), newOne.getDescription());
- assertEquals("192.168.0.10", newOne.getHostName());
- assertEquals(BA.getPort() + 30, newOne.getPort());
-
- bindings = testee.getServiceBindings().get(B);
- assertNotNull(bindings);
- byFQN = new HashMap<String, ServiceBinding>();
- for (ServiceBinding binding : bindings)
- {
- byFQN.put(binding.getFullyQualifiedName(), binding);
- }
-
- aa = byFQN.get(AA.getFullyQualifiedName());
- assertNotNull(aa);
- assertEquals(AA.getServiceName(), aa.getServiceName());
- assertEquals(AA.getBindingName(), aa.getBindingName());
- assertEquals(AA.getDescription(), aa.getDescription());
- assertEquals("localhost", aa.getHostName());
- assertEquals(AA.getPort() + 50, aa.getPort());
-
- ab = byFQN.get(AB.getFullyQualifiedName());
- assertNotNull(aa);
- assertEquals(AB.getServiceName(), ab.getServiceName());
- assertEquals(AB.getBindingName(), ab.getBindingName());
- assertEquals(AB.getDescription(), ab.getDescription());
- assertEquals("localhost", ab.getHostName());
- assertEquals(AB.getPort() + 50, ab.getPort());
-
- anull = byFQN.get(Anull.getFullyQualifiedName());
- assertNotNull(anull);
- assertEquals(Anull.getServiceName(), anull.getServiceName());
- assertEquals(Anull.getBindingName(), anull.getBindingName());
- assertEquals(Anull.getDescription(), anull.getDescription());
- assertEquals("localhost", anull.getHostName());
- assertEquals(Anull.getPort() + 50, anull.getPort());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.managed.ServiceBindingManagementObject#setStandardBindings(java.util.Set)}.
- *
- * This is basically a duplicate of the same test in PojoServiceBindingStoreUnitTestCase.
- */
- public void testSetStandardBindings() throws Exception
- {
- Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
- set.addAll(Arrays.asList(AA, AB, Anull));
-
- Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
- ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 20);
- sbs.add(setB);
- ServiceBindingSet setC = new ServiceBindingSet(C, "192.168.0.10", 30);
- sbs.add(setC);
-
- ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", sbs, set);
- testee.start();
-
- Set<ServiceBindingMetadata> updatedSet =
- new HashSet<ServiceBindingMetadata>(testee.getStandardBindings());
- assertEquals(3, updatedSet.size());
- ServiceBindingMetadata updated = new ServiceBindingMetadata(AA);
- updated.setPort(9999);
- updated.setDescription("updated");
- updatedSet.remove(AA);
- updatedSet.add(updated);
- updatedSet.add(BA);
- assertEquals(4, updatedSet.size());
-
- testee.setStandardBindings(updatedSet);
-
- Set<ServiceBindingMetadata> result = testee.getStandardBindings();
- assertNotNull(result);
- assertTrue("has updated", result.contains(updated));
- assertTrue("has AB", result.contains(AB));
- assertTrue("has Anull", result.contains(Anull));
- assertTrue("has BA", result.contains(BA));
-
- for (ServiceBindingSet bindingSet : sbs)
- {
- String setName = bindingSet.getName();
- Set<ServiceBinding> bindings = testee.getServiceBindings().get(setName);
- assertNotNull(bindings);
- assertEquals(4, bindings.size());
- Map<String, ServiceBinding> byFQN = new HashMap<String, ServiceBinding>();
- for (ServiceBinding binding : bindings)
- {
- byFQN.put(binding.getFullyQualifiedName(), binding);
- }
-
- ServiceBinding aa = byFQN.get(updated.getFullyQualifiedName());
- assertNotNull(aa);
- assertEquals(setName + "/updated/serviceName", updated.getServiceName(), aa.getServiceName());
- assertEquals(setName + "/updated/bindingName", updated.getBindingName(), aa.getBindingName());
- assertEquals(setName + "/updated/description", updated.getDescription(), aa.getDescription());
- assertEquals(setName + "/updated/hostName", bindingSet.getDefaultHostName(), aa.getHostName());
- assertEquals(setName + "/updated/port", updated.getPort() + bindingSet.getPortOffset(), aa.getPort());
-
- ServiceBinding ab = byFQN.get(AB.getFullyQualifiedName());
- assertNotNull(aa);
- assertEquals(setName + "/AB/serviceName", AB.getServiceName(), ab.getServiceName());
- assertEquals(setName + "/AB/bindingName", AB.getBindingName(), ab.getBindingName());
- assertEquals(setName + "/AB/description", AB.getDescription(), ab.getDescription());
- assertEquals(setName + "/AB/hostName", bindingSet.getDefaultHostName(), ab.getHostName());
- assertEquals(setName + "/AB/port", AB.getPort() + bindingSet.getPortOffset(), ab.getPort());
-
- ServiceBinding anull = byFQN.get(Anull.getFullyQualifiedName());
- assertNotNull(anull);
- assertEquals(setName + "/Anull/serviceName", Anull.getServiceName(), anull.getServiceName());
- assertEquals(setName + "/Anull/bindingName", Anull.getBindingName(), anull.getBindingName());
- assertEquals(setName + "/Anull/description", Anull.getDescription(), anull.getDescription());
- assertEquals(setName + "/Anull/hostName", bindingSet.getDefaultHostName(), anull.getHostName());
- assertEquals(setName + "/Anull/port", Anull.getPort() + bindingSet.getPortOffset(), anull.getPort());
-
- ServiceBinding newOne = byFQN.get(BA.getFullyQualifiedName());
- assertNotNull(newOne);
- assertEquals(setName + "/BA/serviceName", BA.getServiceName(), newOne.getServiceName());
- assertEquals(setName + "/BA/bindingName", BA.getBindingName(), newOne.getBindingName());
- assertEquals(setName + "/BA/description", BA.getDescription(), newOne.getDescription());
- assertEquals(setName + "/BA/hostName", bindingSet.getDefaultHostName(), newOne.getHostName());
- assertEquals(setName + "/BA/port", BA.getPort() + bindingSet.getPortOffset(), newOne.getPort());
- }
- }
-
- /**
- * The objects returned via a management console don't include the
- * value source class or config; the ServiceBindingManagementObject is
- * responsible for preserving objects associated with the existing configs.
- * This is a test of that for the standard bindings.
- *
- * @throws Exception
- */
- public void testPreserveValueSourceStandardBinding() throws Exception
- {
-
- Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
- set.addAll(Arrays.asList(AA, AB));
- ServiceBindingMetadata value = new ServiceBindingMetadata("value-source", null, null, 25);
- // Add value-source configs we expect to retain!
- value.setServiceBindingValueSourceClassName(XSLTServiceBindingValueSourceImpl.class.getName());
- value.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
- set.add(value);
-
- Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
- ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 0);
- sbs.add(setB);
-
- ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", sbs, set);
- testee.start();
-
- set = testee.getStandardBindings();
- assertEquals(3, set.size());
- boolean found = false;
- for (ServiceBindingMetadata md : set)
- {
- if ("value-source".equals(md.getFullyQualifiedName()))
- {
- found = true;
- assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
- Object config = md.getServiceBindingValueSourceConfig();
- assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
- assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
- break;
- }
- }
- assertTrue(found);
-
- Map<String, Set<ServiceBinding>> bindingsMap = testee.getServiceBindings();
- assertNotNull(bindingsMap);
- Set<ServiceBinding> bindings = bindingsMap.get(B);
- assertNotNull(bindings);
- found = false;
- for (ServiceBinding md : bindings)
- {
- if ("value-source".equals(md.getFullyQualifiedName()))
- {
- found = true;
- assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
- Object config = md.getServiceBindingValueSourceConfig();
- assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
- assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
- break;
- }
- }
- assertTrue(found);
-
-
- set = new HashSet<ServiceBindingMetadata>();
- set.addAll(Arrays.asList(AA, AB));
- set.add(new ServiceBindingMetadata("value-source", null, null, 25));
- // KEY POINT IN THE WHOLE TEST: we don't configure the value source stuff
-
- testee.setStandardBindings(set);
-
- set = testee.getStandardBindings();
- assertEquals(3, set.size());
- found = false;
- for (ServiceBindingMetadata md : set)
- {
- if ("value-source".equals(md.getFullyQualifiedName()))
- {
- found = true;
- assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
- Object config = md.getServiceBindingValueSourceConfig();
- assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
- assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
- break;
- }
- }
- assertTrue(found);
-
- bindingsMap = testee.getServiceBindings();
- assertNotNull(bindingsMap);
- bindings = bindingsMap.get(B);
- assertNotNull(bindings);
- found = false;
- for (ServiceBinding md : bindings)
- {
- if ("value-source".equals(md.getFullyQualifiedName()))
- {
- found = true;
- assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
- Object config = md.getServiceBindingValueSourceConfig();
- assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
- assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
- break;
- }
- }
- assertTrue(found);
- }
-
- /**
- * The objects returned via a management console don't include the
- * value source class or config; the ServiceBindingManagementObject is
- * responsible for preserving objects associated with the existing configs.
- * This is a test of that for ServiceBindingMetadata in a ServiceBindingSet's
- * override set.
- *
- * @throws Exception
- */
- public void testPreserveValueSourceOverrideBinding() throws Exception
- {
-
- Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
- set.addAll(Arrays.asList(AA, AB));
-
- ServiceBindingMetadata value = new ServiceBindingMetadata("value-source", null, null, 25);
- // Add value-source configs we expect to retain!
- value.setServiceBindingValueSourceClassName(XSLTServiceBindingValueSourceImpl.class.getName());
- value.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
- Set<ServiceBindingMetadata> overrides = new HashSet<ServiceBindingMetadata>();
- overrides.add(value);
-
- Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
- ServiceBindingSet setB = new ServiceBindingSet(B, "localhost", 0, overrides);
- sbs.add(setB);
-
- ServiceBindingManagementObject testee = new ServiceBindingManagementObject("test", sbs, set);
- testee.start();
-
- sbs = testee.getBindingSets();
- assertEquals(1, sbs.size());
-
- boolean found = false;
- for (ServiceBindingSet sb : sbs)
- {
- for (ServiceBindingMetadata md : sb.getOverrideBindings())
- {
- if ("value-source".equals(md.getFullyQualifiedName()))
- {
- found = true;
- assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
- Object config = md.getServiceBindingValueSourceConfig();
- assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
- assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
- break;
- }
- }
- assertTrue(found);
- }
-
- Map<String, Set<ServiceBinding>> bindingsMap = testee.getServiceBindings();
- assertNotNull(bindingsMap);
- Set<ServiceBinding> bindings = bindingsMap.get(B);
- assertNotNull(bindings);
- found = false;
- for (ServiceBinding md : bindings)
- {
- if ("value-source".equals(md.getFullyQualifiedName()))
- {
- found = true;
- assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
- Object config = md.getServiceBindingValueSourceConfig();
- assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
- assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
- break;
- }
- }
- assertTrue(found);
-
-
- overrides = new HashSet<ServiceBindingMetadata>();
- overrides.add(new ServiceBindingMetadata("value-source", null, null, 25));
- // KEY POINT IN THE WHOLE TEST: we don't configure the value source stuff
-
- setB = new ServiceBindingSet(B, "localhost", 0, overrides);
- sbs = new HashSet<ServiceBindingSet>();
- sbs.add(setB);
- testee.setBindingSets(sbs);
-
- sbs = testee.getBindingSets();
- assertEquals(1, sbs.size());
-
- found = false;
- for (ServiceBindingSet sb : sbs)
- {
- for (ServiceBindingMetadata md : sb.getOverrideBindings())
- {
- if ("value-source".equals(md.getFullyQualifiedName()))
- {
- found = true;
- assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
- Object config = md.getServiceBindingValueSourceConfig();
- assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
- assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
- break;
- }
- }
- assertTrue(found);
- }
-
- bindingsMap = testee.getServiceBindings();
- assertNotNull(bindingsMap);
- bindings = bindingsMap.get(B);
- assertNotNull(bindings);
- found = false;
- for (ServiceBinding md : bindings)
- {
- if ("value-source".equals(md.getFullyQualifiedName()))
- {
- found = true;
- assertEquals(XSLTServiceBindingValueSourceImpl.class.getName(), md.getServiceBindingValueSourceClassName());
- Object config = md.getServiceBindingValueSourceConfig();
- assertTrue(config instanceof XSLTServiceBindingValueSourceConfig);
- assertEquals("test", ((XSLTServiceBindingValueSourceConfig) config).getXslt());
- break;
- }
- }
- assertTrue(found);
- }
-
-}
Deleted: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperTestCase.java 2009-06-03 20:24:30 UTC (rev 89766)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperTestCase.java 2009-06-03 20:26:16 UTC (rev 89767)
@@ -1,106 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.services.binding.test;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
-import org.jboss.services.binding.managed.ServiceBindingMetadataMapper;
-
-/**
- * Unit test of {@link ServiceBindingMetadataMapper}.
- *
- * @author Brian Stansberry
- *
- */
-public class ServiceBindingMetadataMapperTestCase extends TestCase
-{
-
- /**
- * Create a new ServiceBindingMetadataMapperTestCase.
- *
- * @param name
- */
- public ServiceBindingMetadataMapperTestCase(String name)
- {
- super(name);
- }
-
- public void testRoundTrip() throws Exception
- {
- Set<ServiceBindingMetadata> input = new HashSet<ServiceBindingMetadata>();
- ServiceBindingMetadata complete = new ServiceBindingMetadata("complete", "binding", "host", 10, true, true);
- complete.setDescription("desc");
- complete.setServiceBindingValueSource(new StringReplacementServiceBindingValueSourceImpl());
- complete.setServiceBindingValueSourceConfig(new StringReplacementServiceBindingValueSourceConfig());
- input.add(complete);
-
- ServiceBindingMetadata nulls = new ServiceBindingMetadata("nulls", null, null, 20);
- input.add(nulls);
-
- ServiceBindingMetadataMapper mapper = new ServiceBindingMetadataMapper();
- MetaValue wrapped = mapper.createMetaValue(null, input);
- Set<ServiceBindingMetadata> output = mapper.unwrapMetaValue(wrapped);
-
- assertEquals(input, output);
- for (ServiceBindingMetadata md : output)
- {
- if ("complete".equals(md.getServiceName()))
- {
- assertEquals(complete.getFullyQualifiedName(), md.getFullyQualifiedName());
- assertEquals(complete.getBindingName(), md.getBindingName());
- assertEquals(complete.getDescription(), md.getDescription());
- assertEquals(complete.getHostName(), md.getHostName());
- assertEquals(complete.getPort(), md.getPort());
- assertEquals(complete.isFixedHostName(), md.isFixedHostName());
- assertEquals(complete.isFixedPort(), md.isFixedPort());
- // We expect null for the following, but if the impl changes these can change
- assertNull(md.getServiceBindingValueSourceClassName());
- assertNull(md.getServiceBindingValueSourceConfig());
- }
- else if ("nulls".equals(md.getServiceName()))
- {
- assertEquals(nulls.getFullyQualifiedName(), md.getFullyQualifiedName());
- assertNull(md.getBindingName());
- assertNull(md.getDescription());
- assertNull(md.getHostName());
- assertEquals(nulls.getPort(), md.getPort());
- assertFalse(md.isFixedHostName());
- assertFalse(md.isFixedPort());
- assertNull(md.getServiceBindingValueSourceClassName());
- assertNull(md.getServiceBindingValueSourceConfig());
-
- }
- else
- {
- fail("Unexpected member " + md.getFullyQualifiedName());
- }
- }
- }
-}
Copied: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java (from rev 89766, trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperTestCase.java)
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java 2009-06-03 20:26:16 UTC (rev 89767)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.services.binding.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.services.binding.ServiceBindingMetadata;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
+import org.jboss.services.binding.managed.ServiceBindingMetadataMapper;
+
+/**
+ * Unit test of {@link ServiceBindingMetadataMapper}.
+ *
+ * @author Brian Stansberry
+ *
+ */
+public class ServiceBindingMetadataMapperTestCase extends TestCase
+{
+
+ /**
+ * Create a new ServiceBindingMetadataMapperTestCase.
+ *
+ * @param name
+ */
+ public ServiceBindingMetadataMapperTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testRoundTrip() throws Exception
+ {
+ Set<ServiceBindingMetadata> input = new HashSet<ServiceBindingMetadata>();
+ ServiceBindingMetadata complete = new ServiceBindingMetadata("complete", "binding", "host", 10, true, true);
+ complete.setDescription("desc");
+ complete.setServiceBindingValueSource(new StringReplacementServiceBindingValueSourceImpl());
+ complete.setServiceBindingValueSourceConfig(new StringReplacementServiceBindingValueSourceConfig());
+ input.add(complete);
+
+ ServiceBindingMetadata nulls = new ServiceBindingMetadata("nulls", null, null, 20);
+ input.add(nulls);
+
+ ServiceBindingMetadataMapper mapper = new ServiceBindingMetadataMapper();
+ MetaValue wrapped = mapper.createMetaValue(null, input);
+ Set<ServiceBindingMetadata> output = mapper.unwrapMetaValue(wrapped);
+
+ assertEquals(input, output);
+ for (ServiceBindingMetadata md : output)
+ {
+ if ("complete".equals(md.getServiceName()))
+ {
+ assertEquals(complete.getFullyQualifiedName(), md.getFullyQualifiedName());
+ assertEquals(complete.getBindingName(), md.getBindingName());
+ assertEquals(complete.getDescription(), md.getDescription());
+ assertEquals(complete.getHostName(), md.getHostName());
+ assertEquals(complete.getPort(), md.getPort());
+ assertEquals(complete.isFixedHostName(), md.isFixedHostName());
+ assertEquals(complete.isFixedPort(), md.isFixedPort());
+ // We expect null for the following, but if the impl changes these can change
+ assertNull(md.getServiceBindingValueSourceClassName());
+ assertNull(md.getServiceBindingValueSourceConfig());
+ }
+ else if ("nulls".equals(md.getServiceName()))
+ {
+ assertEquals(nulls.getFullyQualifiedName(), md.getFullyQualifiedName());
+ assertNull(md.getBindingName());
+ assertNull(md.getDescription());
+ assertNull(md.getHostName());
+ assertEquals(nulls.getPort(), md.getPort());
+ assertFalse(md.isFixedHostName());
+ assertFalse(md.isFixedPort());
+ assertNull(md.getServiceBindingValueSourceClassName());
+ assertNull(md.getServiceBindingValueSourceConfig());
+
+ }
+ else
+ {
+ fail("Unexpected member " + md.getFullyQualifiedName());
+ }
+ }
+ }
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+
Name: svn:mergeinfo
+
Deleted: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataTestCase.java 2009-06-03 20:24:30 UTC (rev 89766)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataTestCase.java 2009-06-03 20:26:16 UTC (rev 89767)
@@ -1,334 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.services.binding.test;
-
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.ServiceBindingMetadata;
-
-/**
- * @author Brian Stansberry
- *
- */
-public class ServiceBindingMetadataTestCase extends TestCase
-{
- private static final String S = "S";
- private static final String B = "B";
- private static final String H = "H";
- private static final String FQN = S + ":" + B;
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#ServiceBindingMetadata(java.lang.String)}.
- */
- public void testServiceBindingMetadataString()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata(S);
- assertEquals(S, md.getServiceName());
-
- assertFalse(md.isFixedHostName());
- assertFalse(md.isFixedPort());
-
- try
- {
- String svcName = null;
- md = new ServiceBindingMetadata(svcName);
- fail("null serviceName allowed");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#ServiceBindingMetadata(java.lang.String, java.lang.String)}.
- */
- public void testServiceBindingMetadataStringString()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata(S, B);
- assertEquals(S, md.getServiceName());
- assertEquals(B, md.getBindingName());
-
- assertFalse(md.isFixedHostName());
- assertFalse(md.isFixedPort());
-
- md = new ServiceBindingMetadata(S, null);
- assertEquals(S, md.getServiceName());
- assertEquals(null, md.getBindingName());
-
- assertFalse(md.isFixedHostName());
- assertFalse(md.isFixedPort());
-
- try
- {
- md = new ServiceBindingMetadata(null, B);
- fail("null serviceName allowed");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#ServiceBindingMetadata(java.lang.String, java.lang.String, java.lang.String, int)}.
- */
- public void testServiceBindingMetadataStringStringStringInt()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata(S, B, H, 1);
- assertEquals(S, md.getServiceName());
- assertEquals(B, md.getBindingName());
- assertEquals(H, md.getHostName());
- assertEquals(1, md.getPort());
- assertFalse(md.isFixedPort());
- assertTrue(md.isFixedHostName());
-
- md = new ServiceBindingMetadata(S, null, null, 1);
- assertEquals(S, md.getServiceName());
- assertEquals(null, md.getBindingName());
- assertEquals(null, md.getHostName());
- assertEquals(1, md.getPort());
- assertFalse(md.isFixedPort());
- assertFalse(md.isFixedHostName());
-
- try
- {
- md = new ServiceBindingMetadata(null, B, H, 1);
- fail("null serviceName allowed");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#ServiceBindingMetadata(java.lang.String, java.lang.String, java.lang.String, int, boolean, boolean)}.
- */
- public void testServiceBindingMetadataStringStringStringIntBooleanBoolean()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata(S, B, H, 1, true, true);
- assertEquals(S, md.getServiceName());
- assertEquals(B, md.getBindingName());
- assertEquals(H, md.getHostName());
- assertEquals(1, md.getPort());
- assertTrue(md.isFixedPort());
- assertTrue(md.isFixedHostName());
-
- md = new ServiceBindingMetadata(S, null, null, 1, true, true);
- assertEquals(S, md.getServiceName());
- assertEquals(null, md.getBindingName());
- assertEquals(null, md.getHostName());
- assertEquals(1, md.getPort());
- assertTrue(md.isFixedPort());
- assertTrue(md.isFixedHostName());
-
- try
- {
- md = new ServiceBindingMetadata(null, B, H, 1, true, true);
- fail("null serviceName allowed");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setServiceName(java.lang.String)}.
- */
- public void testSetServiceName()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- md.setServiceName(S);
- assertEquals(S, md.getServiceName());
-
- try
- {
- md.setServiceName(null);
- fail("null serviceName allowed");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setBindingName(java.lang.String)}.
- */
- public void testSetBindingName()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- md.setBindingName(B);
- assertEquals(B, md.getBindingName());
- md.setBindingName(null);
- assertEquals(null, md.getBindingName());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#getFullyQualifiedName()}.
- */
- public void testGetFullyQualifiedName()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata(S, B);
- assertEquals(FQN, md.getFullyQualifiedName());
-
- md = new ServiceBindingMetadata(S, null);
- assertEquals(S,md.getFullyQualifiedName());
-
- md = new ServiceBindingMetadata();
- try
- {
- md.getFullyQualifiedName();
- fail("getFullyQualifiedName should fail with no serviceName set");
- }
- catch (IllegalStateException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setHostName(java.lang.String)}.
- */
- public void testSetHostName()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- md.setHostName(H);
- assertEquals(H, md.getHostName());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setPort(int)}.
- */
- public void testSetPort()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- md.setPort(2);
- assertEquals(2, md.getPort());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setServiceBindingValueSource(org.jboss.services.binding.ServiceBindingValueSource)}.
- */
- public void testSetServiceBindingValueSource()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- MockServiceBindingValueSource mock = new MockServiceBindingValueSource();
- md.setServiceBindingValueSource(mock);
- assertSame(mock, md.getServiceBindingValueSource());
- assertEquals(mock.getClass().getName(), md.getServiceBindingValueSourceClassName());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setServiceBindingValueSourceClassName(java.lang.String)}.
- */
- public void testSetServiceBindingValueSourceClassName()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- md.setServiceBindingValueSourceClassName(S);
- assertEquals(S, md.getServiceBindingValueSourceClassName());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setServiceBindingValueSourceConfig(java.lang.Object)}.
- */
- public void testSetServiceBindingValueSourceConfig()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- Object config = new Object();
- md.setServiceBindingValueSourceConfig(config);
- assertSame(config, md.getServiceBindingValueSourceConfig());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setFixedPort(boolean)}.
- */
- public void testSetFixedPort()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- assertFalse(md.isFixedPort());
- md.setFixedPort(true);
- assertTrue(md.isFixedPort());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setFixedHostName(boolean)}.
- */
- public void testSetFixedHostName()
- {
- ServiceBindingMetadata md = new ServiceBindingMetadata();
- assertFalse(md.isFixedHostName());
- md.setFixedHostName(true);
- assertTrue(md.isFixedHostName());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#equals(java.lang.Object)}.
- */
- public void testEqualsObject()
- {
- ServiceBindingMetadata md1 = new ServiceBindingMetadata();
- ServiceBindingMetadata md2 = new ServiceBindingMetadata();
- try
- {
- md1.equals(md2);
- fail("equals should fail with unset serviceName");
- }
- catch (IllegalStateException good) {}
-
- md1 = new ServiceBindingMetadata(S, B);
- md2 = new ServiceBindingMetadata(S, null);
- assertFalse(md1.equals(md2));
- assertFalse(md2.equals(md1));
-
- md2 = new ServiceBindingMetadata(B, B);
- assertFalse(md1.equals(md2));
- assertFalse(md2.equals(md1));
-
- md2 = new ServiceBindingMetadata(S, B);
- md2.setHostName(H);
- md2.setPort(10);
- md2.setServiceBindingValueSource(new MockServiceBindingValueSource());
- md2.setServiceBindingValueSourceConfig(new Object());
- assertTrue(md1.equals(md2));
- assertTrue(md2.equals(md1));
- }
-
- /**
- * Test method for {@link ServiceBindingMetadata#compareTo(ServiceBindingMetadata)}
- */
- public void testCompareTo()
- {
- ServiceBindingMetadata md1 = new ServiceBindingMetadata();
- ServiceBindingMetadata md2 = new ServiceBindingMetadata();
- try
- {
- md1.compareTo(md2);
- fail("compareTo should fail with unset serviceName");
- }
- catch (IllegalStateException good) {}
-
- md1 = new ServiceBindingMetadata(S, B);
- md2 = new ServiceBindingMetadata(S, null);
- assertTrue(md1.compareTo(md2) > 0);
- assertTrue(md2.compareTo(md1) < 0);
-
- md2 = new ServiceBindingMetadata(B, B);
- assertTrue(md1.compareTo(md2) > 0);
- assertTrue(md2.compareTo(md1) < 0);
-
- md2 = new ServiceBindingMetadata(S, B);
- md2.setHostName(H);
- md2.setPort(10);
- md2.setServiceBindingValueSource(new MockServiceBindingValueSource());
- md2.setServiceBindingValueSourceConfig(new Object());
- assertEquals(0, md1.compareTo(md2));
- assertEquals(0, md2.compareTo(md1));
-
- }
-
-}
Copied: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java (from rev 89764, trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataTestCase.java)
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java 2009-06-03 20:26:16 UTC (rev 89767)
@@ -0,0 +1,334 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.services.binding.test;
+
+import junit.framework.TestCase;
+
+import org.jboss.services.binding.ServiceBindingMetadata;
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public class ServiceBindingMetadataTestCase extends TestCase
+{
+ private static final String S = "S";
+ private static final String B = "B";
+ private static final String H = "H";
+ private static final String FQN = S + ":" + B;
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#ServiceBindingMetadata(java.lang.String)}.
+ */
+ public void testServiceBindingMetadataString()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata(S);
+ assertEquals(S, md.getServiceName());
+
+ assertFalse(md.isFixedHostName());
+ assertFalse(md.isFixedPort());
+
+ try
+ {
+ String svcName = null;
+ md = new ServiceBindingMetadata(svcName);
+ fail("null serviceName allowed");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#ServiceBindingMetadata(java.lang.String, java.lang.String)}.
+ */
+ public void testServiceBindingMetadataStringString()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata(S, B);
+ assertEquals(S, md.getServiceName());
+ assertEquals(B, md.getBindingName());
+
+ assertFalse(md.isFixedHostName());
+ assertFalse(md.isFixedPort());
+
+ md = new ServiceBindingMetadata(S, null);
+ assertEquals(S, md.getServiceName());
+ assertEquals(null, md.getBindingName());
+
+ assertFalse(md.isFixedHostName());
+ assertFalse(md.isFixedPort());
+
+ try
+ {
+ md = new ServiceBindingMetadata(null, B);
+ fail("null serviceName allowed");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#ServiceBindingMetadata(java.lang.String, java.lang.String, java.lang.String, int)}.
+ */
+ public void testServiceBindingMetadataStringStringStringInt()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata(S, B, H, 1);
+ assertEquals(S, md.getServiceName());
+ assertEquals(B, md.getBindingName());
+ assertEquals(H, md.getHostName());
+ assertEquals(1, md.getPort());
+ assertFalse(md.isFixedPort());
+ assertTrue(md.isFixedHostName());
+
+ md = new ServiceBindingMetadata(S, null, null, 1);
+ assertEquals(S, md.getServiceName());
+ assertEquals(null, md.getBindingName());
+ assertEquals(null, md.getHostName());
+ assertEquals(1, md.getPort());
+ assertFalse(md.isFixedPort());
+ assertFalse(md.isFixedHostName());
+
+ try
+ {
+ md = new ServiceBindingMetadata(null, B, H, 1);
+ fail("null serviceName allowed");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#ServiceBindingMetadata(java.lang.String, java.lang.String, java.lang.String, int, boolean, boolean)}.
+ */
+ public void testServiceBindingMetadataStringStringStringIntBooleanBoolean()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata(S, B, H, 1, true, true);
+ assertEquals(S, md.getServiceName());
+ assertEquals(B, md.getBindingName());
+ assertEquals(H, md.getHostName());
+ assertEquals(1, md.getPort());
+ assertTrue(md.isFixedPort());
+ assertTrue(md.isFixedHostName());
+
+ md = new ServiceBindingMetadata(S, null, null, 1, true, true);
+ assertEquals(S, md.getServiceName());
+ assertEquals(null, md.getBindingName());
+ assertEquals(null, md.getHostName());
+ assertEquals(1, md.getPort());
+ assertTrue(md.isFixedPort());
+ assertTrue(md.isFixedHostName());
+
+ try
+ {
+ md = new ServiceBindingMetadata(null, B, H, 1, true, true);
+ fail("null serviceName allowed");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setServiceName(java.lang.String)}.
+ */
+ public void testSetServiceName()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ md.setServiceName(S);
+ assertEquals(S, md.getServiceName());
+
+ try
+ {
+ md.setServiceName(null);
+ fail("null serviceName allowed");
+ }
+ catch (IllegalArgumentException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setBindingName(java.lang.String)}.
+ */
+ public void testSetBindingName()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ md.setBindingName(B);
+ assertEquals(B, md.getBindingName());
+ md.setBindingName(null);
+ assertEquals(null, md.getBindingName());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#getFullyQualifiedName()}.
+ */
+ public void testGetFullyQualifiedName()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata(S, B);
+ assertEquals(FQN, md.getFullyQualifiedName());
+
+ md = new ServiceBindingMetadata(S, null);
+ assertEquals(S,md.getFullyQualifiedName());
+
+ md = new ServiceBindingMetadata();
+ try
+ {
+ md.getFullyQualifiedName();
+ fail("getFullyQualifiedName should fail with no serviceName set");
+ }
+ catch (IllegalStateException good) {}
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setHostName(java.lang.String)}.
+ */
+ public void testSetHostName()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ md.setHostName(H);
+ assertEquals(H, md.getHostName());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setPort(int)}.
+ */
+ public void testSetPort()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ md.setPort(2);
+ assertEquals(2, md.getPort());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setServiceBindingValueSource(org.jboss.services.binding.ServiceBindingValueSource)}.
+ */
+ public void testSetServiceBindingValueSource()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ MockServiceBindingValueSource mock = new MockServiceBindingValueSource();
+ md.setServiceBindingValueSource(mock);
+ assertSame(mock, md.getServiceBindingValueSource());
+ assertEquals(mock.getClass().getName(), md.getServiceBindingValueSourceClassName());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setServiceBindingValueSourceClassName(java.lang.String)}.
+ */
+ public void testSetServiceBindingValueSourceClassName()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ md.setServiceBindingValueSourceClassName(S);
+ assertEquals(S, md.getServiceBindingValueSourceClassName());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setServiceBindingValueSourceConfig(java.lang.Object)}.
+ */
+ public void testSetServiceBindingValueSourceConfig()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ Object config = new Object();
+ md.setServiceBindingValueSourceConfig(config);
+ assertSame(config, md.getServiceBindingValueSourceConfig());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setFixedPort(boolean)}.
+ */
+ public void testSetFixedPort()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ assertFalse(md.isFixedPort());
+ md.setFixedPort(true);
+ assertTrue(md.isFixedPort());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#setFixedHostName(boolean)}.
+ */
+ public void testSetFixedHostName()
+ {
+ ServiceBindingMetadata md = new ServiceBindingMetadata();
+ assertFalse(md.isFixedHostName());
+ md.setFixedHostName(true);
+ assertTrue(md.isFixedHostName());
+ }
+
+ /**
+ * Test method for {@link org.jboss.services.binding.ServiceBindingMetadata#equals(java.lang.Object)}.
+ */
+ public void testEqualsObject()
+ {
+ ServiceBindingMetadata md1 = new ServiceBindingMetadata();
+ ServiceBindingMetadata md2 = new ServiceBindingMetadata();
+ try
+ {
+ md1.equals(md2);
+ fail("equals should fail with unset serviceName");
+ }
+ catch (IllegalStateException good) {}
+
+ md1 = new ServiceBindingMetadata(S, B);
+ md2 = new ServiceBindingMetadata(S, null);
+ assertFalse(md1.equals(md2));
+ assertFalse(md2.equals(md1));
+
+ md2 = new ServiceBindingMetadata(B, B);
+ assertFalse(md1.equals(md2));
+ assertFalse(md2.equals(md1));
+
+ md2 = new ServiceBindingMetadata(S, B);
+ md2.setHostName(H);
+ md2.setPort(10);
+ md2.setServiceBindingValueSource(new MockServiceBindingValueSource());
+ md2.setServiceBindingValueSourceConfig(new Object());
+ assertTrue(md1.equals(md2));
+ assertTrue(md2.equals(md1));
+ }
+
+ /**
+ * Test method for {@link ServiceBindingMetadata#compareTo(ServiceBindingMetadata)}
+ */
+ public void testCompareTo()
+ {
+ ServiceBindingMetadata md1 = new ServiceBindingMetadata();
+ ServiceBindingMetadata md2 = new ServiceBindingMetadata();
+ try
+ {
+ md1.compareTo(md2);
+ fail("compareTo should fail with unset serviceName");
+ }
+ catch (IllegalStateException good) {}
+
+ md1 = new ServiceBindingMetadata(S, B);
+ md2 = new ServiceBindingMetadata(S, null);
+ assertTrue(md1.compareTo(md2) > 0);
+ assertTrue(md2.compareTo(md1) < 0);
+
+ md2 = new ServiceBindingMetadata(B, B);
+ assertTrue(md1.compareTo(md2) > 0);
+ assertTrue(md2.compareTo(md1) < 0);
+
+ md2 = new ServiceBindingMetadata(S, B);
+ md2.setHostName(H);
+ md2.setPort(10);
+ md2.setServiceBindingValueSource(new MockServiceBindingValueSource());
+ md2.setServiceBindingValueSourceConfig(new Object());
+ assertEquals(0, md1.compareTo(md2));
+ assertEquals(0, md2.compareTo(md1));
+
+ }
+
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperTestCase.java 2009-06-03 20:24:30 UTC (rev 89766)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperTestCase.java 2009-06-03 20:26:16 UTC (rev 89767)
@@ -1,136 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, 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.services.binding.test;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.jboss.metatype.api.values.MetaValue;
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.jboss.services.binding.impl.ServiceBindingSet;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
-import org.jboss.services.binding.managed.ServiceBindingMetadataMapper;
-import org.jboss.services.binding.managed.ServiceBindingSetMapper;
-
-/**
- * Unit test of {@link ServiceBindingMetadataMapper}.
- *
- * @author Brian Stansberry
- *
- */
-public class ServiceBindingSetMapperTestCase extends TestCase
-{
-
- /**
- * Create a new ServiceBindingMetadataMapperTestCase.
- *
- * @param name
- */
- public ServiceBindingSetMapperTestCase(String name)
- {
- super(name);
- }
-
- public void testRoundTrip() throws Exception
- {
- Set<ServiceBindingSet> input = new HashSet<ServiceBindingSet>();
-
- Set<ServiceBindingMetadata> overrideInput = new HashSet<ServiceBindingMetadata>();
- ServiceBindingMetadata complete = new ServiceBindingMetadata("complete", "binding", "host", 10, true, true);
- complete.setDescription("desc");
- complete.setServiceBindingValueSource(new StringReplacementServiceBindingValueSourceImpl());
- complete.setServiceBindingValueSourceConfig(new StringReplacementServiceBindingValueSourceConfig());
- overrideInput.add(complete);
-
- ServiceBindingMetadata nulls = new ServiceBindingMetadata("nulls", null, null, 20);
- overrideInput.add(nulls);
-
- ServiceBindingSet withOverride = new ServiceBindingSet("withOverride", "localhost", 1000, overrideInput);
- input.add(withOverride);
-
- ServiceBindingSet noOverride = new ServiceBindingSet("noOverride", "localhost", 900);
- input.add(noOverride);
-
- ServiceBindingSetMapper mapper = new ServiceBindingSetMapper();
- MetaValue wrapped = mapper.createMetaValue(null, input);
- Set<ServiceBindingSet> output = mapper.unwrapMetaValue(wrapped);
-
- for (ServiceBindingSet outputSet : output)
- {
- if ("withOverride".equals(outputSet.getName()))
- {
- Set<ServiceBindingMetadata> overrideOutput = outputSet.getOverrideBindings();
- assertNotNull("has overrideOutput", overrideOutput);
- assertEquals("localhost", outputSet.getDefaultHostName());
- assertEquals(1000, outputSet.getPortOffset());
-
- for (ServiceBindingMetadata md : overrideOutput)
- {
- if ("complete".equals(md.getServiceName()))
- {
- assertEquals(complete.getFullyQualifiedName(), md.getFullyQualifiedName());
- assertEquals(complete.getBindingName(), md.getBindingName());
- assertEquals(complete.getDescription(), md.getDescription());
- assertEquals(complete.getHostName(), md.getHostName());
- assertEquals(complete.getPort(), md.getPort());
- assertEquals(complete.isFixedHostName(), md.isFixedHostName());
- assertEquals(complete.isFixedPort(), md.isFixedPort());
- // We expect null for the following, but if the impl changes these can change
- assertNull(md.getServiceBindingValueSourceClassName());
- assertNull(md.getServiceBindingValueSourceConfig());
- }
- else if ("nulls".equals(md.getServiceName()))
- {
- assertEquals(nulls.getFullyQualifiedName(), md.getFullyQualifiedName());
- assertNull(md.getBindingName());
- assertNull(md.getDescription());
- assertNull(md.getHostName());
- assertEquals(nulls.getPort(), md.getPort());
- assertFalse(md.isFixedHostName());
- assertFalse(md.isFixedPort());
- assertNull(md.getServiceBindingValueSourceClassName());
- assertNull(md.getServiceBindingValueSourceConfig());
-
- }
- else
- {
- fail("Unexpected member " + md.getFullyQualifiedName());
- }
- }
- }
- else if ("noOverride".equals(outputSet.getName()))
- {
- assertEquals("localhost", outputSet.getDefaultHostName());
- assertEquals(900, outputSet.getPortOffset());
- assertNotNull("has no overrideOutput", outputSet.getOverrideBindings());
- }
- else
- {
- fail("Unexpected member " + outputSet.getName());
- }
- }
- }
-}
Copied: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java (from rev 89766, trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperTestCase.java)
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java (rev 0)
+++ trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java 2009-06-03 20:26:16 UTC (rev 89767)
@@ -0,0 +1,136 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.services.binding.test;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.services.binding.ServiceBindingMetadata;
+import org.jboss.services.binding.impl.ServiceBindingSet;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceConfig;
+import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
+import org.jboss.services.binding.managed.ServiceBindingMetadataMapper;
+import org.jboss.services.binding.managed.ServiceBindingSetMapper;
+
+/**
+ * Unit test of {@link ServiceBindingMetadataMapper}.
+ *
+ * @author Brian Stansberry
+ *
+ */
+public class ServiceBindingSetMapperTestCase extends TestCase
+{
+
+ /**
+ * Create a new ServiceBindingMetadataMapperTestCase.
+ *
+ * @param name
+ */
+ public ServiceBindingSetMapperTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testRoundTrip() throws Exception
+ {
+ Set<ServiceBindingSet> input = new HashSet<ServiceBindingSet>();
+
+ Set<ServiceBindingMetadata> overrideInput = new HashSet<ServiceBindingMetadata>();
+ ServiceBindingMetadata complete = new ServiceBindingMetadata("complete", "binding", "host", 10, true, true);
+ complete.setDescription("desc");
+ complete.setServiceBindingValueSource(new StringReplacementServiceBindingValueSourceImpl());
+ complete.setServiceBindingValueSourceConfig(new StringReplacementServiceBindingValueSourceConfig());
+ overrideInput.add(complete);
+
+ ServiceBindingMetadata nulls = new ServiceBindingMetadata("nulls", null, null, 20);
+ overrideInput.add(nulls);
+
+ ServiceBindingSet withOverride = new ServiceBindingSet("withOverride", "localhost", 1000, overrideInput);
+ input.add(withOverride);
+
+ ServiceBindingSet noOverride = new ServiceBindingSet("noOverride", "localhost", 900);
+ input.add(noOverride);
+
+ ServiceBindingSetMapper mapper = new ServiceBindingSetMapper();
+ MetaValue wrapped = mapper.createMetaValue(null, input);
+ Set<ServiceBindingSet> output = mapper.unwrapMetaValue(wrapped);
+
+ for (ServiceBindingSet outputSet : output)
+ {
+ if ("withOverride".equals(outputSet.getName()))
+ {
+ Set<ServiceBindingMetadata> overrideOutput = outputSet.getOverrideBindings();
+ assertNotNull("has overrideOutput", overrideOutput);
+ assertEquals("localhost", outputSet.getDefaultHostName());
+ assertEquals(1000, outputSet.getPortOffset());
+
+ for (ServiceBindingMetadata md : overrideOutput)
+ {
+ if ("complete".equals(md.getServiceName()))
+ {
+ assertEquals(complete.getFullyQualifiedName(), md.getFullyQualifiedName());
+ assertEquals(complete.getBindingName(), md.getBindingName());
+ assertEquals(complete.getDescription(), md.getDescription());
+ assertEquals(complete.getHostName(), md.getHostName());
+ assertEquals(complete.getPort(), md.getPort());
+ assertEquals(complete.isFixedHostName(), md.isFixedHostName());
+ assertEquals(complete.isFixedPort(), md.isFixedPort());
+ // We expect null for the following, but if the impl changes these can change
+ assertNull(md.getServiceBindingValueSourceClassName());
+ assertNull(md.getServiceBindingValueSourceConfig());
+ }
+ else if ("nulls".equals(md.getServiceName()))
+ {
+ assertEquals(nulls.getFullyQualifiedName(), md.getFullyQualifiedName());
+ assertNull(md.getBindingName());
+ assertNull(md.getDescription());
+ assertNull(md.getHostName());
+ assertEquals(nulls.getPort(), md.getPort());
+ assertFalse(md.isFixedHostName());
+ assertFalse(md.isFixedPort());
+ assertNull(md.getServiceBindingValueSourceClassName());
+ assertNull(md.getServiceBindingValueSourceConfig());
+
+ }
+ else
+ {
+ fail("Unexpected member " + md.getFullyQualifiedName());
+ }
+ }
+ }
+ else if ("noOverride".equals(outputSet.getName()))
+ {
+ assertEquals("localhost", outputSet.getDefaultHostName());
+ assertEquals(900, outputSet.getPortOffset());
+ assertNotNull("has no overrideOutput", outputSet.getOverrideBindings());
+ }
+ else
+ {
+ fail("Unexpected member " + outputSet.getName());
+ }
+ }
+ }
+}
Property changes on: trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java
___________________________________________________________________
Name: svn:keywords
+
Name: svn:mergeinfo
+
More information about the jboss-cvs-commits
mailing list