[jboss-cvs] JBossAS SVN: r89886 - in projects/service-binding/trunk: build and 19 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Jun 5 13:34:46 EDT 2009
Author: bstansberry at jboss.com
Date: 2009-06-05 13:34:45 -0400 (Fri, 05 Jun 2009)
New Revision: 89886
Added:
projects/service-binding/trunk/core/src/main/java/org/
projects/service-binding/trunk/core/src/main/java/org/jboss/
projects/service-binding/trunk/core/src/main/java/org/jboss/services/
projects/service-binding/trunk/core/src/main/java/org/jboss/services/binding/
projects/service-binding/trunk/core/src/test/java/org/
projects/service-binding/trunk/core/src/test/resources/
projects/service-binding/trunk/core/src/test/resources/org/
projects/service-binding/trunk/management/src/main/java/org/
projects/service-binding/trunk/management/src/main/java/org/jboss/
projects/service-binding/trunk/management/src/main/java/org/jboss/services/
projects/service-binding/trunk/management/src/main/java/org/jboss/services/binding/
projects/service-binding/trunk/management/src/main/java/org/jboss/services/binding/managed/
projects/service-binding/trunk/management/src/test/java/org/
Removed:
projects/service-binding/trunk/core/src/main/java/org/jboss/services/binding/managed/
projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java
projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java
projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/MockServiceBindingStore.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingTestBase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java
Modified:
projects/service-binding/trunk/build/pom.xml
projects/service-binding/trunk/core/pom.xml
projects/service-binding/trunk/core/src/main/java/org/jboss/services/binding/impl/Util.java
projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java
projects/service-binding/trunk/management/pom.xml
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java
projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java
projects/service-binding/trunk/pom.xml
Log:
[JBAS-6802] Port code from JBAS trunk
Modified: projects/service-binding/trunk/build/pom.xml
===================================================================
--- projects/service-binding/trunk/build/pom.xml 2009-06-05 17:25:15 UTC (rev 89885)
+++ projects/service-binding/trunk/build/pom.xml 2009-06-05 17:34:45 UTC (rev 89886)
@@ -17,7 +17,7 @@
<!-- Artifact Configuration -->
<groupId>org.jboss.service-binding</groupId>
<artifactId>jboss-service-binding-build</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<name>JBoss Service Binding Build</name>
<description>JBoss Service Binding Build</description>
<packaging>pom</packaging>
@@ -26,10 +26,8 @@
<properties>
<!-- Versioning -->
- <version.org.jboss.logging_jboss.logging.log4j>2.0.6.GA</version.org.jboss.logging_jboss.logging.log4j>
- <version.org.jboss.logging_jboss.logging.spi>2.0.5.GA</version.org.jboss.logging_jboss.logging.spi>
- <version.org.jboss.microcontainer_jboss.kernel>2.0.4.GA</version.org.jboss.microcontainer_jboss.kernel>
- <version.org.jboss_jbossxb>2.0.0.GA</version.org.jboss_jbossxb>
+ <version.org.jboss.logging_jboss.logging.spi>2.1.0.GA</version.org.jboss.logging_jboss.logging.spi>
+ <version.org.jboss_jboss.common.core>2.2.14.GA</version.org.jboss_jboss.common.core>
<version.junit_junit>4.5</version.junit_junit>
</properties>
@@ -120,9 +118,9 @@
</dependency>
<dependency>
- <groupId>org.jboss.logging</groupId>
- <artifactId>jboss-logging-log4j</artifactId>
- <version>${version.org.jboss.logging_jboss.logging.log4j}</version>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ <version>${version.org.jboss_jboss.common.core}</version>
</dependency>
<dependency>
Modified: projects/service-binding/trunk/core/pom.xml
===================================================================
--- projects/service-binding/trunk/core/pom.xml 2009-06-05 17:25:15 UTC (rev 89885)
+++ projects/service-binding/trunk/core/pom.xml 2009-06-05 17:34:45 UTC (rev 89886)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.jboss.service-binding</groupId>
<artifactId>jboss-service-binding-build</artifactId>
- <version>0.1.0</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
@@ -19,7 +19,7 @@
<!-- Artifact Configuration -->
<artifactId>jboss-service-binding-core</artifactId>
<name>JBoss Service Binding Manager Core</name>
- <version>0.1.2-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<description>JBoss Service Binding Manager Service</description>
@@ -31,5 +31,20 @@
<!-- Dependencies -->
<dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.logging</groupId>
+ <artifactId>jboss-logging-spi</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-common-core</artifactId>
+ </dependency>
+
</dependencies>
</project>
Copied: projects/service-binding/trunk/core/src/main/java/org/jboss/services/binding (from rev 89882, trunk/varia/src/main/org/jboss/services/binding)
Modified: projects/service-binding/trunk/core/src/main/java/org/jboss/services/binding/impl/Util.java
===================================================================
--- trunk/varia/src/main/org/jboss/services/binding/impl/Util.java 2009-06-05 15:02:05 UTC (rev 89882)
+++ projects/service-binding/trunk/core/src/main/java/org/jboss/services/binding/impl/Util.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -33,7 +33,6 @@
import java.net.URL;
import java.net.URLConnection;
-import org.jboss.bootstrap.spi.ServerConfig;
import org.jboss.services.binding.ServiceBinding;
import org.jboss.services.binding.ServiceBindingValueSource;
@@ -45,6 +44,8 @@
*/
public class Util
{
+ /** Name of system property indicating server temp dir */
+ public static final String SERVER_TEMP_DIR_PROPERTY = "jboss.server.temp.dir";
public static InputStream getInputStream(URL url) throws IOException
{
@@ -140,7 +141,11 @@
public static File createTempFile() throws IOException
{
- String tmpName = SecurityActions.getSystemProperty(ServerConfig.SERVER_TEMP_DIR, "");
+ String tmpName = SecurityActions.getSystemProperty(SERVER_TEMP_DIR_PROPERTY, null);
+ if (tmpName == null)
+ {
+ tmpName = SecurityActions.getSystemProperty("java.io.tmpdir", "");
+ }
File tempDirectory = new File(tmpName);
File targetFile = File.createTempFile("service-binding", ".tmp", tempDirectory);
targetFile.deleteOnExit();
Copied: projects/service-binding/trunk/core/src/test/java/org (from rev 89883, trunk/varia/src/tests/org)
Deleted: projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -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: projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -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());
- }
- }
- }
-}
Modified: projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -30,7 +30,7 @@
* @author Brian Stansberry
*
*/
-public class ServiceBindingMetadataTestCase extends TestCase
+public class ServiceBindingMetadataUnitTestCase extends TestCase
{
private static final String S = "S";
private static final String B = "B";
@@ -273,12 +273,7 @@
{
ServiceBindingMetadata md1 = new ServiceBindingMetadata();
ServiceBindingMetadata md2 = new ServiceBindingMetadata();
- try
- {
- md1.equals(md2);
- fail("equals should fail with unset serviceName");
- }
- catch (IllegalStateException good) {}
+ assertFalse(md1.equals(md2));
md1 = new ServiceBindingMetadata(S, B);
md2 = new ServiceBindingMetadata(S, null);
Deleted: projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/core/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -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: projects/service-binding/trunk/core/src/test/resources/org (from rev 89884, trunk/varia/src/resources/tests/org)
Modified: projects/service-binding/trunk/management/pom.xml
===================================================================
--- projects/service-binding/trunk/management/pom.xml 2009-06-05 17:25:15 UTC (rev 89885)
+++ projects/service-binding/trunk/management/pom.xml 2009-06-05 17:34:45 UTC (rev 89886)
@@ -9,7 +9,7 @@
<parent>
<groupId>org.jboss.service-binding</groupId>
<artifactId>jboss-service-binding-build</artifactId>
- <version>0.1.0</version>
+ <version>1.0.0-SNAPSHOT</version>
<relativePath>../build/pom.xml</relativePath>
</parent>
@@ -19,10 +19,21 @@
<!-- Artifact Configuration -->
<artifactId>jboss-service-binding-mgmt</artifactId>
<name>JBoss Service Binding Manager Management Interface</name>
- <version>0.1.2-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<description>Management Interface for JBoss Service Binding Manager Service</description>
+ <!-- Properties -->
+ <properties>
+
+ <!-- Versioning -->
+ <version.org.jboss.service-binding_jboss.service-binding.core>0.1.0-SNAPSHOT</version.org.jboss.service-binding_jboss.service-binding.core>
+ <version.org.jboss.man_jboss.managed>2.1.0.SP1</version.org.jboss.man_jboss.managed>
+ <version.org.jboss.man_jboss.metatype>2.1.0.SP1</version.org.jboss.man_jboss.metatype>
+
+ </properties>
+
+
<!-- Build -->
<build>
@@ -31,5 +42,28 @@
<!-- Dependencies -->
<dependencies>
+ <dependency>
+ <groupId>org.jboss.service-binding</groupId>
+ <artifactId>jboss-service-binding-core</artifactId>
+ <version>${version.org.jboss.service-binding_jboss.service-binding.core}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-managed</artifactId>
+ <version>${version.org.jboss.man_jboss.managed}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.jboss.man</groupId>
+ <artifactId>jboss-metatype</artifactId>
+ <version>${version.org.jboss.man_jboss.metatype}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+
</dependencies>
</project>
Copied: projects/service-binding/trunk/management/src/main/java/org/jboss/services/binding/managed (from rev 89883, trunk/varia/src/main/org/jboss/services/binding/managed)
Copied: projects/service-binding/trunk/management/src/test/java/org (from rev 89883, trunk/varia/src/tests/org)
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/DefaultServiceBindingValueSourceUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,127 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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 org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingManager;
-import org.jboss.services.binding.ServiceBindingManager.BindingType;
-import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
-
-/**
- * Tests of {@link ServiceBindingManager#getServiceBindingValueSource(org.jboss.bindings.ServiceBinding, BindingType)}
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class DefaultServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
-{
- /**
- * Create a new DefaultServiceBindingValueSourceUnitTestCase.
- *
- * @param arg0
- */
- public DefaultServiceBindingValueSourceUnitTestCase(String arg0)
- {
- super(arg0);
- }
-
- public void testInjectedSource() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource("test");
- bindingMetadata.setServiceBindingValueSource(source);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertEquals(source, ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC));
- }
-
- public void testInjectedSourceClassName() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceClassName(MockServiceBindingValueSource.class.getName());
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC) instanceof MockServiceBindingValueSource);
- }
-
- public void testInt() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.INT) instanceof SimpleServiceBindingValueSourceImpl);
- }
-
- public void testInetAddress() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.INETADDRESS) instanceof SimpleServiceBindingValueSourceImpl);
- }
-
- public void testString() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.STRING) instanceof StringReplacementServiceBindingValueSourceImpl);
- }
-
- public void testElement() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.ELEMENT) instanceof StringReplacementServiceBindingValueSourceImpl);
- }
-
- public void testResource() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.RESOURCE) instanceof StringReplacementServiceBindingValueSourceImpl);
- }
-
- public void testURL() throws Exception
- {
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.URL) instanceof StringReplacementServiceBindingValueSourceImpl);
- }
-
- public void testElementXSLT() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.ELEMENT) instanceof XSLTServiceBindingValueSourceImpl);
- }
-
- public void testResourceXSLT() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.RESOURCE) instanceof XSLTServiceBindingValueSourceImpl);
- }
-
- public void testURLXSLT() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(new XSLTServiceBindingValueSourceConfig("test"));
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertTrue(ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.URL) instanceof XSLTServiceBindingValueSourceImpl);
- }
-
- public void testGeneric() throws Exception
- {
- try
- {
- ServiceBindingManager.getServiceBindingValueSource(binding, BindingType.GENERIC);
- fail("unknown generic should fail");
- }
- catch(IllegalStateException good) {}
- }
-
-}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/MockServiceBindingStore.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingStore.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/MockServiceBindingStore.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,116 +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.net.UnknownHostException;
-import java.util.Collections;
-import java.util.Set;
-
-import org.jboss.services.binding.DuplicateServiceException;
-import org.jboss.services.binding.NoSuchBindingException;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.jboss.services.binding.ServiceBindingStore;
-
-/**
- * Mock implementation of ServiceBindingStore. Stores a single ServiceBinding.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class MockServiceBindingStore implements ServiceBindingStore
-{
- public static final String HOSTNAME = "192.168.1.10";
-
- private final String serverName;
- private ServiceBinding binding;
-
- public MockServiceBindingStore(ServiceBinding binding, String serverName)
- {
- this.binding = binding;
- this.serverName = serverName;
- }
-
- public ServiceBinding getServiceBinding(String serverName, String serviceName, String bindingName)
- throws NoSuchBindingException
- {
- if (this.binding == null
- || this.serverName.equals(serverName) == false
- || this.binding.getServiceName().equals(serviceName) == false
- || safeEquals(this.binding.getBindingName(), bindingName) == false)
- {
- throw new NoSuchBindingException(serverName, serviceName, bindingName);
- }
-
- return binding;
- }
-
- public Set<ServiceBinding> getServiceBindings(String serverName)
- {
- if (this.serverName.equals(serverName) == false)
- throw new IllegalArgumentException("Invalid serverName " + serverName);
- return Collections.singleton(binding);
- }
-
- public void removeServiceBinding(String serverName, ServiceBindingMetadata binding)
- {
- throw new UnsupportedOperationException("unimplemented");
- }
-
- public void addServiceBinding(String serverName, ServiceBindingMetadata binding)
- throws DuplicateServiceException, UnknownHostException
- {
- if (this.binding != null)
- throw new IllegalStateException("MockServiceBindingStore already has a binding");
- if (this.serverName.equals(serverName) == false)
- throw new IllegalArgumentException("Invalid serverName " + serverName);
-
- this.binding = new ServiceBinding(binding, getDefaultHostName(serverName), getDefaultPortOffset(serverName));
- }
-
- public String getDefaultHostName(String serverName)
- {
- return HOSTNAME;
- }
-
- public int getDefaultPortOffset(String serverName)
- {
- return 1000;
- }
-
- /**
- * Set the binding.
- *
- * @param binding The binding to set.
- */
- public void setBinding(ServiceBinding binding)
- {
- this.binding = binding;
- }
-
- private boolean safeEquals(Object a, Object b)
- {
- return (a == b || (a != null && a.equals(b)));
- }
-
-}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/MockServiceBindingValueSource.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,61 +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 org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingValueSource;
-
-/**
- * Mock implementation of ServiceBindingValueSource. Returms an injected return
- * value; keeps a reference to passed in params so the test driver can analyze them.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class MockServiceBindingValueSource implements ServiceBindingValueSource
-{
- private final Object returnValue;
- private Object[] params;
-
- public MockServiceBindingValueSource()
- {
- this.returnValue = null;
- }
-
- public MockServiceBindingValueSource(Object returnValue)
- {
- this.returnValue = returnValue;
- }
-
- public Object getServiceBindingValue(ServiceBinding binding, Object... params)
- {
- this.params = params;
- return returnValue;
- }
-
- public Object[] getParams()
- {
- return params;
- }
-
-}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/PojoServiceBindingStoreUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,422 +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.net.InetAddress;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.DuplicateServiceException;
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.jboss.services.binding.NoSuchBindingException;
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.impl.PojoServiceBindingStore;
-import org.jboss.services.binding.impl.ServiceBindingSet;
-
-/**
- * Tests of PojoServiceBindingStore.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class PojoServiceBindingStoreUnitTestCase extends TestCase
-{
- private static final String A = "A";
- private static final String B = "B";
- private static final String C = "C";
- private static final String D = "D";
-
- 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 PojoServiceBindingStoreUnitTestCase.
- *
- * @param name
- */
- public PojoServiceBindingStoreUnitTestCase(String name)
- {
- super(name);
- }
-
- @Override
- 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);
- }
-
- private static ServiceBinding getServiceBinding(ServiceBindingMetadata md, ServiceBindingSet set) throws UnknownHostException
- {
- return new ServiceBinding(md, set.getDefaultHostName(), set.getPortOffset());
- }
-
-
- public void testGetServiceBinding() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore();
- store.setServiceBindingSets(bindingSets);
- store.setStandardBindings(bindings);
- store.start();
-
- assertEquals(getServiceBinding(AA, SET_A), store.getServiceBinding(A, A, A));
- assertEquals(getServiceBinding(AA, SET_B), store.getServiceBinding(B, A, A));
- assertEquals(getServiceBinding(AA, SET_C), store.getServiceBinding(C, A, A));
-
- assertEquals(getServiceBinding(AB, SET_A), store.getServiceBinding(A, A, B));
- assertEquals(getServiceBinding(AB, SET_B), store.getServiceBinding(B, A, B));
- assertEquals(getServiceBinding(AB, SET_C), store.getServiceBinding(C, A, B));
-
- assertEquals(getServiceBinding(Anull, SET_A), store.getServiceBinding(A, A, null));
- assertEquals(getServiceBinding(Anull, SET_B), store.getServiceBinding(B, A, null));
- assertEquals(getServiceBinding(Anull, SET_C), store.getServiceBinding(C, A, null));
-
- try
- {
- store.getServiceBinding(D, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(A, B, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(A, B, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
- }
-
- public void testAddServiceBinding() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore();
- store.setServiceBindingSets(bindingSets);
- store.setStandardBindings(bindings);
- store.start();
-
- ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "localhost", 1, false, false);
- store.addServiceBinding(A, new1);
- store.addServiceBinding(B, new1);
- store.addServiceBinding(C, new1);
-
- assertEquals(getServiceBinding(new1, SET_A), store.getServiceBinding(A, B, A));
- assertEquals(getServiceBinding(new1, SET_B), store.getServiceBinding(B, B, A));
- assertEquals(getServiceBinding(new1, SET_C), store.getServiceBinding(C, B, A));
-
- ServiceBindingMetadata new2 = new ServiceBindingMetadata(B, A, "localhost", 2, false, false);
- try
- {
- store.addServiceBinding(D, new2);
- fail("add for unknown binding set succeeded");
- }
- catch (IllegalArgumentException good) {}
-
- try
- {
- store.addServiceBinding(A, new2);
- fail("duplicate add succeeded");
- }
- catch (DuplicateServiceException good) {}
- }
-
- public void testRemoveServiceBinding() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore();
- store.setServiceBindingSets(bindingSets);
- store.setStandardBindings(bindings);
- store.start();
-
- store.removeServiceBinding(A, AA);
-
- try
- {
- store.getServiceBinding(A, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- store.removeServiceBinding(B, AA);
-
- try
- {
- store.getServiceBinding(B, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- store.removeServiceBinding(A, Anull);
-
- try
- {
- store.getServiceBinding(A, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- store.removeServiceBinding(B, Anull);
-
- try
- {
- store.getServiceBinding(B, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "localhost", 1, false, false);
- store.removeServiceBinding(A, new1);
- store.removeServiceBinding(A, BA);
- }
-
-
- public void testAddServiceBindingToAll() throws Exception
- {
- Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
- set.addAll(Arrays.asList(AA, AB, Anull));
-
- Set<ServiceBindingSet> ourSets = new HashSet<ServiceBindingSet>();
- ServiceBindingSet newSetA = new ServiceBindingSet(A, null, 10, set);
- ourSets.add(newSetA);
- ServiceBindingSet newSetB = new ServiceBindingSet(B, "localhost", 20, set);
- ourSets.add(newSetB);
- ServiceBindingSet newSetC = new ServiceBindingSet(C, "192.168.0.10", 30, set);
- ourSets.add(newSetC);
-
- PojoServiceBindingStore store = new PojoServiceBindingStore();
- store.setServiceBindingSets(ourSets);
- store.start();
-
- ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "192.168.0.22", 1, false, true);
- store.addServiceBinding(new1);
-
- InetAddress address = InetAddress.getByName("192.168.0.22");
-
- ServiceBinding got = store.getServiceBinding(A, B, A);
- assertEquals(getServiceBinding(new1, newSetA), got);
- assertEquals(11, got.getPort());
- assertEquals("192.168.0.22", got.getHostName());
- assertEquals(address, got.getBindAddress());
-
- got = store.getServiceBinding(B, B, A);
- assertEquals(getServiceBinding(new1, newSetB), got);
- assertEquals(21, got.getPort());
- assertEquals("192.168.0.22", got.getHostName());
- assertEquals(address, got.getBindAddress());
-
- got = store.getServiceBinding(C, B, A);
- assertEquals(getServiceBinding(new1, newSetC), got);
- assertEquals(31, got.getPort());
- assertEquals("192.168.0.22", got.getHostName());
- assertEquals(address, got.getBindAddress());
-
- ServiceBindingMetadata new2 = new ServiceBindingMetadata(B, A, "localhost", 2, false, false);
- try
- {
- store.addServiceBinding(new2);
- fail("duplicate add succeeded");
- }
- catch (DuplicateServiceException good) {}
-
- ServiceBindingMetadata new3 = new ServiceBindingMetadata(C, C, null, 3, false, false);
- store.addServiceBinding(new3);
-
- got = store.getServiceBinding(A, C, C);
- assertEquals(getServiceBinding(new3, newSetA), got);
- assertEquals(13, got.getPort());
- assertNull(got.getHostName());
- assertEquals(InetAddress.getByName(null), got.getBindAddress());
-
- got = store.getServiceBinding(B, C, C);
- assertEquals(getServiceBinding(new3, newSetB), got);
- assertEquals(23, got.getPort());
- assertEquals("localhost", got.getHostName());
- assertEquals(InetAddress.getByName("localhost"), got.getBindAddress());
-
- got = store.getServiceBinding(C, C, C);
- assertEquals(getServiceBinding(new3, newSetC), got);
- assertEquals(33, got.getPort());
- assertEquals("192.168.0.10", got.getHostName());
- assertEquals(InetAddress.getByName("192.168.0.10"), got.getBindAddress());
-
- }
-
- public void testRemoveServiceBindingFromAll() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore();
- store.setServiceBindingSets(bindingSets);
- store.setStandardBindings(bindings);
- store.start();
-
- store.removeServiceBinding(AA);
-
- try
- {
- store.getServiceBinding(A, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- store.removeServiceBinding(B, AA);
-
- try
- {
- store.getServiceBinding(B, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(C, A, A);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- String nullA = null;
- store.removeServiceBinding(A, nullA);
-
- try
- {
- store.getServiceBinding(A, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(B, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- try
- {
- store.getServiceBinding(C, A, null);
- fail("invalid");
- }
- catch (NoSuchBindingException e) {}
-
- ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "localhost", 1, false, false);
- store.removeServiceBinding(new1);
- store.removeServiceBinding(B, A);
- }
-
- public void testDefaultDefaults() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore();
- store.setServiceBindingSets(bindingSets);
- store.setStandardBindings(bindings);
- store.start();
-
- String[] names = {A, B, C};
-
- for (String name :names)
- {
- assertEquals("localhost", store.getDefaultHostName(name));
- assertEquals(0, store.getDefaultPortOffset(name));
- }
- }
-
- public void testDefaults() throws Exception
- {
- Set<ServiceBindingMetadata> set = new HashSet<ServiceBindingMetadata>();
- set.addAll(Arrays.asList(AA, AB, Anull));
-
- Set<ServiceBindingSet> sbs = new HashSet<ServiceBindingSet>();
- sbs.add(new ServiceBindingSet(A, null, 10, set));
- sbs.add(new ServiceBindingSet(B, "localhost", 20, set));
- sbs.add(new ServiceBindingSet(C, "192.168.0.10", 30, set));
-
- PojoServiceBindingStore store = new PojoServiceBindingStore();
- store.setServiceBindingSets(sbs);
- store.start();
-
- assertNull(store.getDefaultHostName(A));
- assertEquals(10, store.getDefaultPortOffset(A));
-
- assertEquals("localhost", store.getDefaultHostName(B));
- assertEquals(20, store.getDefaultPortOffset(B));
-
- assertEquals("192.168.0.10", store.getDefaultHostName(C));
- assertEquals(30, store.getDefaultPortOffset(C));
- }
-
- public void testGetServiceBindings() throws Exception
- {
- PojoServiceBindingStore store = new PojoServiceBindingStore();
- store.setServiceBindingSets(bindingSets);
- store.setStandardBindings(bindings);
- store.start();
-
- String[] servers = {A, B, C};
- for (String server : servers)
- {
- Set<ServiceBinding> set = store.getServiceBindings(server);
- assertEquals(bindings.size(), set.size());
- for (ServiceBinding binding : set)
- {
- ServiceBindingMetadata metadata = new ServiceBindingMetadata(binding);
- assertTrue(server + " includes " + metadata, bindings.contains(metadata));
- }
- }
- }
-
-
-}
Modified: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagementObjectUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -44,7 +44,7 @@
*
* @version $Revision: $
*/
-public class ServiceBindingManagmentObjectUnitTestCase extends TestCase
+public class ServiceBindingManagementObjectUnitTestCase extends TestCase
{
private static final String A = "A";
private static final String B = "B";
@@ -67,7 +67,7 @@
*
* @param name
*/
- public ServiceBindingManagmentObjectUnitTestCase(String name)
+ public ServiceBindingManagementObjectUnitTestCase(String name)
{
super(name);
}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingManagerUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,475 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.io.File;
-import java.net.InetAddress;
-import java.net.URL;
-import java.util.Collections;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingManager;
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.w3c.dom.Element;
-
-/**
- * Tests of ServiceBindingManager.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class ServiceBindingManagerUnitTestCase extends ServiceBindingTestBase
-{
- private static final String SERVER = "server";
- private static final String INPUT = "${host}";
-
- private ServiceBindingManager testee;
- private ServiceBindingMetadata noNameMetadata;
- private ServiceBinding noNameBinding;
- private MockServiceBindingStore mockStore;
- private InetAddress address;
-
- /**
- * Create a new ServiceBindingManagerUnitTestCase.
- *
- * @param arg0
- */
- public ServiceBindingManagerUnitTestCase(String arg0)
- {
- super(arg0);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- mockStore = new MockServiceBindingStore(binding, SERVER);
- testee = new ServiceBindingManager(SERVER, mockStore);
- noNameMetadata = new ServiceBindingMetadata(SVC_NAME, null, null, PORT);
- noNameBinding = new ServiceBinding(noNameMetadata, HOST, 0);
- address = InetAddress.getByName(HOST);
- }
-
- public void testGetServerName()
- {
- assertEquals(SERVER, testee.getServerName());
- }
-
- public void testGetServiceBindings()
- {
- assertEquals(Collections.singleton(binding), testee.getServiceBindings());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getIntBinding(java.lang.String)}.
- * @throws Exception
- */
- public void testGetIntBindingString() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- assertEquals(PORT, testee.getIntBinding(SVC_NAME));
- }
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getIntBinding(java.lang.String, java.lang.String)}.
- */
- public void testGetIntBindingStringString() throws Exception
- {
- assertEquals(PORT, testee.getIntBinding(SVC_NAME, BINDING_NAME));
- }
-
- public void testGetIntBindingViaGeneric() throws Exception
- {
- Integer result = new Integer(5);
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
- bindingMetadata.setServiceBindingValueSource(source);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
- assertEquals(5, testee.getIntBinding(SVC_NAME, BINDING_NAME));
- Object[] params = source.getParams();
- assertNull(params);
- }
-
- public void testGetIntBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- assertEquals(binding.getPort() + mockStore.getDefaultPortOffset(SERVER), testee.getIntBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(binding.getPort() + mockStore.getDefaultPortOffset(SERVER), testee.getIntBinding(SVC_NAME, BINDING_NAME, null, binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(binding.getPort(), testee.getIntBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort(), true, true));
-
- }
-
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getInetAddressBinding(java.lang.String)}.
- */
- public void testGetInetAddressBindingString() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- assertEquals(address, testee.getInetAddressBinding(SVC_NAME));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getInetAddressBinding(java.lang.String, java.lang.String)}.
- */
- public void testGetInetAddressBindingStringString() throws Exception
- {
- assertEquals(address, testee.getInetAddressBinding(SVC_NAME, BINDING_NAME));
- }
-
- public void testGetInetAddressBindingViaGeneric() throws Exception
- {
- InetAddress result = InetAddress.getByName("localhost");
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
- bindingMetadata.setServiceBindingValueSource(source);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
- assertEquals(result, testee.getInetAddressBinding(SVC_NAME, BINDING_NAME));
- Object[] params = source.getParams();
- assertNull(params);
- }
-
- public void testGetInetAddressBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- assertEquals(binding.getBindAddress(), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(InetAddress.getByName(mockStore.getDefaultHostName(SERVER)), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, null, binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(InetAddress.getByName(mockStore.getDefaultHostName(SERVER)), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, binding.getHostName(), binding.getPort(), false, false));
- mockStore.setBinding(null);
- assertEquals(InetAddress.getByName(null), testee.getInetAddressBinding(SVC_NAME, BINDING_NAME, null, binding.getPort(), true, true));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getStringBinding(java.lang.String, java.lang.String)}.
- */
- public void testGetStringBindingStringString() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- assertEquals(HOST, testee.getStringBinding(SVC_NAME, INPUT));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getStringBinding(java.lang.String, java.lang.String, java.lang.String)}.
- */
- public void testGetStringBindingStringStringString() throws Exception
- {
- assertEquals(HOST, testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT));
- }
-
- public void testGetStringBindingViaGeneric() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
- bindingMetadata.setServiceBindingValueSource(source);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
- assertEquals(SVC_NAME, testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(INPUT, params[0]);
- }
-
- public void testGetStringBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- assertEquals(binding.getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, binding.getHostName(), binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(InetAddress.getByName(mockStore.getDefaultHostName(SERVER)).getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, null, binding.getPort()));
- mockStore.setBinding(null);
- assertEquals(InetAddress.getByName(mockStore.getDefaultHostName(SERVER)).getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, binding.getHostName(), binding.getPort(), false, false));
- mockStore.setBinding(null);
- assertEquals(InetAddress.getByName(null).getHostName(), testee.getStringBinding(SVC_NAME, BINDING_NAME, INPUT, null, binding.getPort(), true, true));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getElementBinding(java.lang.String, org.w3c.dom.Element)}.
- */
- public void testGetElementBindingStringElement() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element input = (Element) editor.getValue();
- Element output = testee.getElementBinding(SVC_NAME, input);
- validateOutputElement(output, false, false);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getElementBinding(java.lang.String, java.lang.String, org.w3c.dom.Element)}.
- */
- public void testGetElementBindingStringStringElement() throws Exception
- {
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element input = (Element) editor.getValue();
- Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input);
- validateOutputElement(output);
- }
-
- public void testGetElementBindingViaGeneric() throws Exception
- {
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element result = (Element) editor.getValue();
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
- bindingMetadata.setServiceBindingValueSource(source);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
- assertEquals(result, testee.getElementBinding(SVC_NAME, BINDING_NAME, result));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(result, params[0]);
- }
-
- public void testGetElementBindingViaXSLT() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(getXSLTConfig());
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
-
- Element input = getDocumentElementFromClasspath(XSL_INPUT);
- Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input);
- validateXSLTOutputElement(output);
- }
-
- public void testGetElementBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element input = (Element) editor.getValue();
- Element output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
- validateOutputElement(output, false, true);
-
- mockStore.setBinding(null);
- output = testee.getElementBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
- validateOutputElement(output, true, true);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getURLBinding(java.lang.String, java.net.URL)}.
- */
- public void testGetURLBindingStringURL() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- String resource = getFullyQualifiedResourceName("input.xml");
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = testee.getURLBinding(SVC_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getURLBinding(java.lang.String, java.lang.String, java.net.URL)}.
- */
- public void testGetURLBindingStringStringURL() throws Exception
- {
- String resource = getFullyQualifiedResourceName("input.xml");
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- public void testGetURLBindingViaGeneric() throws Exception
- {
- URL result = new File(getFullyQualifiedResourceName("input.xml")).toURL();
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(result);
- bindingMetadata.setServiceBindingValueSource(source);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
- assertEquals(result, testee.getURLBinding(SVC_NAME, BINDING_NAME, result));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(result, params[0]);
- }
-
- public void testGetURLBindingViaXSLT() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(getXSLTConfig());
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
-
- URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
- URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetURLBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- String resource = getFullyQualifiedResourceName("input.xml");
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element, false, true);
-
- mockStore.setBinding(null);
- output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
- assertNotNull(output);
- element = getDocumentElement(output);
- validateOutputElement(element, true, true);
-
- mockStore.setBinding(null);
- output = testee.getURLBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort(), false, false);
- assertNotNull(output);
- element = getDocumentElement(output);
- validateOutputElement(element, true, true);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getResourceBinding(java.lang.String, java.lang.String)}.
- */
- public void testGetResourceBindingStringString() throws Exception
- {
- String input = getFullyQualifiedResourceName("input.xml");
- String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getResourceBinding(java.lang.String, java.lang.String, java.lang.String)}.
- */
- public void testGetResourceBindingStringStringString() throws Exception
- {
- mockStore.setBinding(noNameBinding);
- String input = getFullyQualifiedResourceName("input.xml");
- String output = testee.getResourceBinding(SVC_NAME, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- public void testGetResourceBindingViaGeneric() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
- bindingMetadata.setServiceBindingValueSource(source);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
- assertEquals(SVC_NAME, testee.getResourceBinding(SVC_NAME, BINDING_NAME, INPUT));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(INPUT, params[0]);
- }
-
- public void testGetResourceBindingViaXSLT() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(getXSLTConfig());
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
-
- String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, XSL_INPUT);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetResourceBindingNoBinding() throws Exception
- {
- mockStore.setBinding(null);
- String input = getFullyQualifiedResourceName("input.xml");
- String output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort());
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element, false, true);
-
- mockStore.setBinding(null);
- output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, null, binding.getPort());
- assertNotNull(output);
- element = getDocumentElement(output);
- validateOutputElement(element, true, true);
-
- mockStore.setBinding(null);
- output = testee.getResourceBinding(SVC_NAME, BINDING_NAME, input, binding.getHostName(), binding.getPort(), false, false);
- assertNotNull(output);
- element = getDocumentElement(output);
- validateOutputElement(element, true, true);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getGenericBinding(java.lang.String, java.lang.Object[])}.
- */
- public void testGetGenericBindingStringObjectArray() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
- noNameMetadata.setServiceBindingValueSource(source);
- noNameBinding = new ServiceBinding(noNameMetadata, HOST, 0);
- mockStore.setBinding(noNameBinding);
- assertEquals(SVC_NAME, testee.getGenericBinding(SVC_NAME, null, INPUT));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(INPUT, params[0]);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBindingManager#getGenericBinding(java.lang.String, java.lang.String, java.lang.Object[])}.
- */
- public void testGetGenericBindingStringStringObjectArray() throws Exception
- {
- MockServiceBindingValueSource source = new MockServiceBindingValueSource(SVC_NAME);
- bindingMetadata.setServiceBindingValueSource(source);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- mockStore.setBinding(binding);
- assertEquals(SVC_NAME, testee.getGenericBinding(SVC_NAME, BINDING_NAME, INPUT));
- Object[] params = source.getParams();
- assertNotNull(params);
- assertEquals(1, params.length);
- assertEquals(INPUT, params[0]);
- }
-
- public void testGetGenericBindingNoValueSource() throws Exception
- {
- try
- {
- Object[] params = null;
- testee.getGenericBinding(SVC_NAME, BINDING_NAME, params);
- fail("should not succeed without value source");
- }
- catch (IllegalStateException good) {}
- }
-
- protected void validateOutputElement(Element output, boolean expectDefaultHost, boolean expectOffset)
- {
- assertNotNull(output);
- assertEquals(expectDefaultHost ? mockStore.getDefaultHostName(SERVER) : HOST, output.getAttribute("host"));
- int expectedPort = PORT + (expectOffset ? mockStore.getDefaultPortOffset(SERVER) : 0);
- assertEquals(String.valueOf(expectedPort), output.getFirstChild().getNodeValue());
- }
-
-}
Modified: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataMapperUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -39,7 +39,7 @@
* @author Brian Stansberry
*
*/
-public class ServiceBindingMetadataMapperTestCase extends TestCase
+public class ServiceBindingMetadataMapperUnitTestCase extends TestCase
{
/**
@@ -47,7 +47,7 @@
*
* @param name
*/
- public ServiceBindingMetadataMapperTestCase(String name)
+ public ServiceBindingMetadataMapperUnitTestCase(String name)
{
super(name);
}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingMetadataUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -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));
-
- }
-
-}
Modified: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetMapperUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -41,7 +41,7 @@
* @author Brian Stansberry
*
*/
-public class ServiceBindingSetMapperTestCase extends TestCase
+public class ServiceBindingSetMapperUnitTestCase extends TestCase
{
/**
@@ -49,7 +49,7 @@
*
* @param name
*/
- public ServiceBindingSetMapperTestCase(String name)
+ public ServiceBindingSetMapperUnitTestCase(String name)
{
super(name);
}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingSetUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,144 +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.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.jboss.services.binding.impl.ServiceBindingSet;
-
-/**
- * A ServiceBindingSetUnitTestCase.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class ServiceBindingSetUnitTestCase extends TestCase
-{
- private static final String A = "A";
- private static final String B = "B";
-
- private static ServiceBindingMetadata AA;
- private static ServiceBindingMetadata AB;
- private static ServiceBindingMetadata Anull;
-
- private Set<ServiceBindingMetadata> bindings = new HashSet<ServiceBindingMetadata>();
-
- /**
- * Create a new ServiceBindingSetUnitTestCase.
- *
- * @param name
- */
- public ServiceBindingSetUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- AA = new ServiceBindingMetadata(A, A, "localhost", 1, false, false);
- AB = new ServiceBindingMetadata(A, B, "localhost", 1, false, false);
- Anull = new ServiceBindingMetadata(A, null, "localhost", 1, false, false);
-
- bindings.addAll(Arrays.asList(AA, AB, Anull));
- }
-
- public void testBasicConstructor() throws UnknownHostException
- {
- ServiceBindingSet set = new ServiceBindingSet(A, new HashSet<ServiceBindingMetadata>(bindings));
-
- assertEquals(A, set.getName());
-
- for (ServiceBindingMetadata binding : set.getOverrideBindings())
- {
- assertEquals(1, binding.getPort());
- assertTrue(bindings.remove(binding));
- }
-
- assertEquals(0, bindings.size());
-
- assertNull(set.getDefaultHostName());
- assertEquals(0, set.getPortOffset());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.ServiceBindingSet#PortOffsetServiceBindingSet(java.util.Set, int)}.
- * @throws UnknownHostException
- */
- public void testOffsetConstructor() throws UnknownHostException
- {
- ServiceBindingSet set = new ServiceBindingSet(A, 5);
-
- assertEquals(A, set.getName());
-
- assertEquals(0, set.getOverrideBindings().size());
-
- assertNull(set.getDefaultHostName());
- assertEquals(5, set.getPortOffset());
- }
-
- public void testOffsetConstructorWithDefaultHost() throws UnknownHostException
- {
- ServiceBindingSet set = new ServiceBindingSet(A, "192.168.0.10", 5, new HashSet<ServiceBindingMetadata>(bindings));
-
- assertEquals(A, set.getName());
-
- for (ServiceBindingMetadata binding : set.getOverrideBindings())
- {
- assertEquals(1, binding.getPort());
- assertTrue(bindings.remove(binding));
- }
-
- assertEquals(0, bindings.size());
-
- assertEquals("192.168.0.10", set.getDefaultHostName());
- assertEquals(5, set.getPortOffset());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.ServiceBindingSet#PortOffsetServiceBindingSet(java.util.Set, int, java.util.Set)}.
- * @throws UnknownHostException
- */
- public void testOverrideConstructor() throws UnknownHostException
- {
- ServiceBindingSet set = new ServiceBindingSet(A, new HashSet<ServiceBindingMetadata>(bindings));
- for (ServiceBindingMetadata binding : set.getOverrideBindings())
- {
- assertTrue(bindings.remove(binding));
-
- }
-
- assertEquals(0, bindings.size());
-
- assertEquals(null, set.getDefaultHostName());
- assertEquals(0, set.getPortOffset());
- }
-
-}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingTestBase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingTestBase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingTestBase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,209 +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.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-import org.jboss.util.propertyeditor.ElementEditor;
-import org.jboss.util.xml.JBossEntityResolver;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-/**
- * Base class for service binding manager related test classes.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public abstract class ServiceBindingTestBase extends TestCase
-{
- protected static final String SVC_NAME = "SVC";
- protected static final String BINDING_NAME = "BIND";
- protected static final String HOST = "192.168.0.10";
- protected static final int PORT = 999;
- protected static final String HOST_MARKER = "${host}";
- protected static final String PORT_MARKER = "${port}";
- protected static final String ELEMENT_INPUT = "<element host=\"" + HOST_MARKER + "\">" + PORT_MARKER + "</element>";
-
- protected static final String OTHER_PARAM = "other";
- protected static final String OTHER_VALUE = "ABC";
- protected static final String XSL_INPUT = getFullyQualifiedResourceName("xslt_input.xml");
-
- private static final String SERVER_TEMP_DIR_PROPERTY = "jboss.server.temp.dir";
-
- protected ServiceBindingMetadata bindingMetadata;
- protected ServiceBinding binding;
-
- private PropertyEditor existingElementEditor;
- private String serverTempDir;
-
- public ServiceBindingTestBase()
- {
- super();
- }
-
- public ServiceBindingTestBase(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- existingElementEditor = PropertyEditorManager.findEditor(Element.class);
- if (existingElementEditor == null)
- PropertyEditorManager.registerEditor(Element.class, ElementEditor.class);
-
- serverTempDir = System.getProperty(SERVER_TEMP_DIR_PROPERTY);
- if (serverTempDir == null)
- System.setProperty(SERVER_TEMP_DIR_PROPERTY, System.getProperty("java.io.tmpdir"));
-
- bindingMetadata = new ServiceBindingMetadata(SVC_NAME, BINDING_NAME, HOST, PORT, false, false);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- }
-
- @Override
- protected void tearDown() throws Exception
- {
- if (existingElementEditor == null)
- PropertyEditorManager.registerEditor(Element.class, null);
- if (serverTempDir == null)
- System.clearProperty(SERVER_TEMP_DIR_PROPERTY);
-
- super.tearDown();
- }
-
- public static String getFullyQualifiedResourceName(String unqualified)
- {
- String base = ServiceBindingTestBase.class.getPackage().getName();
- base = base.replace('.', '/');
- return base + "/" + unqualified;
- }
-
- protected void validateOutputElement(Element output)
- {
- assertNotNull(output);
- assertEquals(HOST, output.getAttribute("host"));
- assertEquals(String.valueOf(PORT), output.getFirstChild().getNodeValue());
- }
-
- protected void validateXSLTOutputElement(Element output)
- {
- assertNotNull(output);
- NodeList children = output.getElementsByTagName("attribute");
- assertEquals(3, children.getLength());
- for (int i = 0; i < children.getLength(); i++)
- {
- Element e = (Element) children.item(i);
- String name = e.getAttribute("name");
- if ("host".equals(name))
- assertEquals(HOST, e.getFirstChild().getNodeValue());
- else if ("port".equals(name))
- assertEquals(String.valueOf(PORT), e.getFirstChild().getNodeValue());
- else if ("other".equals(name))
- assertEquals(OTHER_VALUE, e.getFirstChild().getNodeValue());
- else
- fail("Unknown attribute name " + name);
- }
- }
-
- public static Element getDocumentElement(String filename) throws Exception
- {
- File f = new File(filename);
- Assert.assertTrue(f.exists());
- Assert.assertFalse(f.isDirectory());
- InputStreamReader reader = new InputStreamReader(new FileInputStream(f));
- return getDocumentElement(reader);
- }
-
- public static Element getDocumentElementFromClasspath(String resourcename) throws Exception
- {
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStreamReader reader = new InputStreamReader(cl.getResourceAsStream(resourcename));
- return getDocumentElement(reader);
- }
-
- public static Element getDocumentElement(URL url) throws Exception
- {
- URLConnection conn = url.openConnection();
- conn.connect();
- InputStreamReader reader = new InputStreamReader(url.openStream());
- return getDocumentElement(reader);
- }
-
- public static Element getDocumentElement(Reader reader) throws Exception
- {
- DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
- DocumentBuilder parser = factory.newDocumentBuilder();
- try
- {
-
- InputSource is = new InputSource(reader);
-// is.setSystemId(url.toString());
- parser.setEntityResolver(new JBossEntityResolver());
-
- Document document = parser.parse(is);
- return document.getDocumentElement();
- }
- finally
- {
- reader.close();
- }
-
- }
-
- public static XSLTServiceBindingValueSourceConfig getXSLTConfig() throws Exception
- {
- Element element = getDocumentElementFromClasspath(getFullyQualifiedResourceName("xslt.xml"));
- String xslt = element.getFirstChild().getNodeValue();
-
- Map<String, String> addlParams = new HashMap<String, String>();
- addlParams.put(OTHER_PARAM, OTHER_VALUE);
-
- return new XSLTServiceBindingValueSourceConfig(xslt, addlParams);
- }
-
-
-
-}
\ No newline at end of file
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/ServiceBindingUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,196 +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.net.InetAddress;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.ServiceBindingMetadata;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
-
-import junit.framework.TestCase;
-
-/**
- * Tests of ServiceBinding.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class ServiceBindingUnitTestCase extends TestCase
-{
-
- /**
- * Create a new ServiceBindingUnitTestCase.
- *
- * @param name
- */
- public ServiceBindingUnitTestCase(String name)
- {
- super(name);
- }
-
- public void testNullMetadata() throws Exception
- {
- try
- {
- new ServiceBinding(null, "host", 0);
- fail("null metadata should fail");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testNullServiceName() throws Exception
- {
- try
- {
- new ServiceBinding(new ServiceBindingMetadata(), "host", 0);
- fail("null serviceName should fail");
- }
- catch (IllegalStateException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#getServiceBindingValueSource()}.
- */
- public void testServiceBindingValueSource() throws Exception
- {
- ServiceBindingMetadata metadata = new ServiceBindingMetadata("svc");
- String className = XSLTServiceBindingValueSourceImpl.class.getName();
- metadata.setServiceBindingValueSourceClassName(className);
- ServiceBinding binding = new ServiceBinding(metadata, "localhost", 1);
- assertEquals(className, binding.getServiceBindingValueSourceClassName());
- assertTrue(binding.getServiceBindingValueSource() instanceof XSLTServiceBindingValueSourceImpl);
-
- MockServiceBindingValueSource mock = new MockServiceBindingValueSource();
- metadata.setServiceBindingValueSource(mock);
- Object config = new Object();
- metadata.setServiceBindingValueSourceConfig(config);
- binding = new ServiceBinding(metadata, "localhost", 1);
- assertSame(mock, binding.getServiceBindingValueSource());
- assertEquals(mock.getClass().getName(), binding.getServiceBindingValueSourceClassName());
- assertSame(config, binding.getServiceBindingValueSourceConfig());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#getOffsetBinding(int)}.
- */
- public void testGetOffsetBinding() throws Exception
- {
- ServiceBindingMetadata metadata = new ServiceBindingMetadata("svc", "binding", "192.168.0.2", 1, false, true);
- String className = XSLTServiceBindingValueSourceImpl.class.getName();
- metadata.setServiceBindingValueSourceClassName(className);
-
- ServiceBinding binding = new ServiceBinding(metadata, "192.168.0.2", 10);
- assertEquals(metadata.getServiceName(), binding.getServiceName());
- assertEquals(metadata.getBindingName(), binding.getBindingName());
- assertEquals(metadata.getHostName(), binding.getHostName());
- assertEquals(InetAddress.getByName(metadata.getHostName()), binding.getBindAddress());
-
- assertEquals(1, metadata.getPort());
- assertEquals(11, binding.getPort());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#getOffsetBinding(int, String)}.
- */
- public void testGetOffsetBindingWithHost() throws Exception
- {
- ServiceBindingMetadata metadata = new ServiceBindingMetadata("svc", "binding", "192.168.0.2", 1, false, true);
- ServiceBinding binding = new ServiceBinding(metadata, "192.168.0.3", 10);
- assertEquals(metadata.getServiceName(), binding.getServiceName());
- assertEquals(metadata.getBindingName(), binding.getBindingName());
- assertEquals(metadata.getHostName(), binding.getHostName());
- assertEquals(InetAddress.getByName(metadata.getHostName()), binding.getBindAddress());
-
- assertEquals(1, metadata.getPort());
- assertEquals(11, binding.getPort());
-
- metadata = new ServiceBindingMetadata("svc", "binding", "192.168.0.2", 1, false, false);
- binding = new ServiceBinding(metadata, "192.168.0.3", 10);
- assertEquals(metadata.getServiceName(), binding.getServiceName());
- assertEquals(metadata.getBindingName(), binding.getBindingName());
- assertEquals("192.168.0.3", binding.getHostName());
- assertEquals(InetAddress.getByName("192.168.0.3"), binding.getBindAddress());
-
- assertEquals(1, metadata.getPort());
- assertEquals(11, binding.getPort());
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#equals(java.lang.Object)}.
- */
- public void testEquals() throws Exception
- {
- ServiceBinding bindingAA0 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.2", 1);
- ServiceBinding bindingAA1 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.2", 2);
- ServiceBinding bindingAA2 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.1", 1);
- ServiceBinding bindingAB = new ServiceBinding(new ServiceBindingMetadata("A", "B"), "192.168.0.2", 1);
- ServiceBinding bindingBA = new ServiceBinding(new ServiceBindingMetadata("B", "A"), "192.168.0.2", 1);
- ServiceBinding bindingAnull = new ServiceBinding(new ServiceBindingMetadata("A", null), "192.168.0.2", 1);
- ServiceBinding bindingBnull = new ServiceBinding(new ServiceBindingMetadata("B", null), "192.168.0.2", 1);
- ServiceBinding bindingBnull1 = new ServiceBinding(new ServiceBindingMetadata("B", null), "192.168.0.2", 2);
-
- assertEquals(bindingAA0, bindingAA1);
- assertEquals(bindingAA0, bindingAA2);
- assertFalse(bindingAA0.equals(bindingAB));
- assertFalse(bindingAA0.equals(bindingBA));
- assertFalse(bindingAB.equals(bindingBA));
- assertFalse(bindingAA0.equals(bindingAnull));
- assertFalse(bindingBA.equals(bindingBnull));
- assertFalse(bindingAnull.equals(bindingBnull));
- assertEquals(bindingBnull, bindingBnull1);
-
- assertFalse(bindingAA0.equals(new Object()));
-
- assertFalse(bindingAA0.equals(null));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.ServiceBinding#hashCode()}.
- */
- public void testHashCode() throws Exception
- {
- ServiceBinding bindingAA0 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.2", 1);
- ServiceBinding bindingAA1 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.2", 2);
- ServiceBinding bindingAA2 = new ServiceBinding(new ServiceBindingMetadata("A", "A"), "192.168.0.1", 1);
- ServiceBinding bindingAB = new ServiceBinding(new ServiceBindingMetadata("A", "B"), "192.168.0.2", 1);
- ServiceBinding bindingBA = new ServiceBinding(new ServiceBindingMetadata("B", "A"), "192.168.0.2", 1);
- ServiceBinding bindingAnull = new ServiceBinding(new ServiceBindingMetadata("A", null), "192.168.0.2", 1);
- ServiceBinding bindingBnull = new ServiceBinding(new ServiceBindingMetadata("B", null), "192.168.0.2", 1);
- ServiceBinding bindingBnull1 = new ServiceBinding(new ServiceBindingMetadata("B", null), "192.168.0.2", 2);
-
- assertEquals(bindingAA0.hashCode(), bindingAA1.hashCode());
- assertEquals(bindingAA0.hashCode(), bindingAA2.hashCode());
- assertFalse(bindingAA0.hashCode() == bindingAB.hashCode());
- assertFalse(bindingAA0.hashCode() == bindingBA.hashCode());
-
- // A quirk of the values means these have same hashcode
- assertEquals(bindingAB.hashCode(), bindingBA.hashCode());
-
- assertFalse(bindingAA0.hashCode() == bindingAnull.hashCode());
- assertFalse(bindingBA.hashCode() == bindingBnull.hashCode());
- assertFalse(bindingAnull.hashCode() == bindingBnull.hashCode());
- assertEquals(bindingBnull.hashCode(), bindingBnull1.hashCode());
- }
-
-}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/SimpleServiceBindingValueSourceUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,101 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.net.InetAddress;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl;
-
-/**
- * Unit tests of {@link SimpleServiceBindingValueSourceImpl}.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class SimpleServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
-{
- private SimpleServiceBindingValueSourceImpl testee;
- private InetAddress address;
-
- /**
- * Create a new SimpleServiceBindingValueSourceUnitTestCase.
- *
- * @param name name of the test
- */
- public SimpleServiceBindingValueSourceUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
- testee = new SimpleServiceBindingValueSourceImpl();
- address = InetAddress.getByName(HOST);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getIntServiceBindingValue(org.jboss.bindings.ServiceBinding)}.
- */
- public void testGetIntServiceBindingValue()
- {
- assertEquals(PORT, testee.getIntServiceBindingValue(binding));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getInetAddressServiceBindingValue(org.jboss.bindings.ServiceBinding)}.
- */
- public void testGetInetAddressServiceBindingValue()
- {
- assertEquals(address, testee.getInetAddressServiceBindingValue(binding));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.SimpleServiceBindingValueSourceImpl#getServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.Object[])}.
- * @throws Exception
- */
- public void testGetServiceBindingValue() throws Exception
- {
- Object[] params = null;
- assertEquals("Correct generic value", new Integer(PORT), testee.getServiceBindingValue(binding, params));
- }
-
- public void testGetServiceBindingValueBadParam() throws Exception
- {
- try
- {
- testee.getServiceBindingValue(binding, new Object());
- fail("Should fail passing a param");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testUnknownConfigObject() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(new Object());
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertEquals(PORT, testee.getIntServiceBindingValue(binding));
- }
-
-}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/StringReplacementServiceBindingValueSourceUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,248 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.beans.PropertyEditor;
-import java.beans.PropertyEditorManager;
-import java.net.URL;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl;
-import org.w3c.dom.Element;
-
-/**
- * Tests of {@link StringReplacementServiceBindingValueSourceImpl}.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class StringReplacementServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
-{
- private static final String INPUT = HOST_MARKER + ":" + PORT_MARKER;
- private static final String ALT_HOST_MARKER = "${alt.host}";
- private static final String ALT_PORT_MARKER = "${alt.port}";
- private static final String ALT_INPUT = ALT_HOST_MARKER + ":" + ALT_PORT_MARKER;
- private static final String OUTPUT = HOST + ":" + PORT;
- private static final String ALT_ELEMENT_INPUT = "<element host=\"" + ALT_HOST_MARKER + "\">" + ALT_PORT_MARKER + "</element>";
-
- private StringReplacementServiceBindingValueSourceImpl testee;
- private StringReplacementServiceBindingValueSourceConfig config;
-
- public StringReplacementServiceBindingValueSourceUnitTestCase(String name)
- {
- super(name);
- }
-
- protected void setUp() throws Exception
- {
- super.setUp();
-
- testee = new StringReplacementServiceBindingValueSourceImpl();
- config = new StringReplacementServiceBindingValueSourceConfig(ALT_HOST_MARKER, ALT_PORT_MARKER);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetStringServiceBindingValue() throws Exception
- {
- assertEquals(OUTPUT, testee.getStringServiceBindingValue(binding, INPUT));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetStringServiceBindingValueNullInput() throws Exception
- {
- assertEquals(HOST, testee.getStringServiceBindingValue(binding, null));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getStringServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetStringServiceBindingValueOverrideMarkers() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(config);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertEquals(OUTPUT, testee.getStringServiceBindingValue(binding, ALT_INPUT));
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getElementServiceBindingValue(org.jboss.bindings.ServiceBinding, org.w3c.dom.Element)}.
- */
- public void testGetElementServiceBindingValue() throws Exception
- {
- elementBindingTest(ELEMENT_INPUT);
- }
-
- public void testGetElementServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getResourceServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetElementServiceBindingValueOverrideMarkers() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(config);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- elementBindingTest(ALT_ELEMENT_INPUT);
- }
-
- private void elementBindingTest(String inputText) throws Exception
- {
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(inputText);
- Element input = (Element) editor.getValue();
- Element output = testee.getElementServiceBindingValue(binding, input);
- validateOutputElement(output);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getResourceServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetResourceServiceBindingValue() throws Exception
- {
- resourceBindingTest("input.xml");
- }
-
- public void testGetResourceServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getResourceServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetResourceServiceBindingValueOverrideMarkers() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(config);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- resourceBindingTest("alt_input.xml");
- }
-
- private void resourceBindingTest(String inputText) throws Exception
- {
- String input = getFullyQualifiedResourceName(inputText);
- String output = testee.getResourceServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getURLServiceBindingValue(org.jboss.bindings.ServiceBinding, java.net.URL)}.
- */
- public void testGetURLServiceBindingValue() throws Exception
- {
- urlBindingTest("input.xml");
- }
-
- public void testGetURLServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getURLServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetURLServiceBindingValueOverrideMarkers() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(config);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- urlBindingTest("alt_input.xml");
- }
-
- private void urlBindingTest(String inputText) throws Exception
- {
- String resource = getFullyQualifiedResourceName(inputText);
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = testee.getURLServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- public void testGetServiceBindingValueNullInput() throws Exception
- {
- Object[] params = null;
- assertEquals(HOST, testee.getServiceBindingValue(binding, params));
- }
-
- public void testGetServiceBindingValueBadInput() throws Exception
- {
- try
- {
- testee.getServiceBindingValue(binding, new Object());
- fail("Should fail passing an unknown input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetServiceBindingValueStringInput() throws Exception
- {
- assertEquals(OUTPUT, testee.getServiceBindingValue(binding, INPUT));
- }
-
- public void testGetServiceBindingValueElementInput() throws Exception
- {
- PropertyEditor editor = PropertyEditorManager.findEditor(Element.class);
- editor.setAsText(ELEMENT_INPUT);
- Element input = (Element) editor.getValue();
- Element output = (Element) testee.getServiceBindingValue(binding, input);
- validateOutputElement(output);
- }
-
- public void testGetServiceBindingValueURLInput() throws Exception
- {
- String resource = getFullyQualifiedResourceName("input.xml");
- URL input = Thread.currentThread().getContextClassLoader().getResource(resource);
- URL output = (URL) testee.getServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateOutputElement(element);
- }
-
- public void testGetServiceBindingValueOverrideMarkers() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(config);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertEquals(OUTPUT, testee.getServiceBindingValue(binding, ALT_INPUT));
- }
-
- public void testUnknownConfigObject() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(new Object());
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- assertEquals(HOST, testee.getStringServiceBindingValue(binding, null));
- }
-
-}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceConfigUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2006, 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.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-
-/**
- * Tests of {@link XSLTServiceBindingValueSourceConfig}.
- *
- * @author <a href="brian.stansberry at jboss.com">Brian Stansberry</a>
- * @version $Revision$
- */
-public class XSLTServiceBindingValueSourceConfigUnitTestCase extends TestCase
-{
-
- /**
- * Create a new XSLTServiceBindingValueSourceConfigUnitTestCase.
- *
- * @param arg0
- */
- public XSLTServiceBindingValueSourceConfigUnitTestCase(String arg0)
- {
- super(arg0);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig#getAdditionalAttributes()}.
- */
- public void testGetAdditionalAttributes()
- {
- XSLTServiceBindingValueSourceConfig config = new XSLTServiceBindingValueSourceConfig("test");
- Map<String, String> addl = config.getAdditionalAttributes();
- assertNotNull(addl);
- assertEquals(0, addl.size());
-
- addl = new HashMap<String, String>();
- addl.put("a", "a");
-
- config = new XSLTServiceBindingValueSourceConfig("test", addl);
- Map<String, String> addl1 = config.getAdditionalAttributes();
- assertEquals(addl, addl1);
-
- }
-
-}
Deleted: projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java
===================================================================
--- trunk/varia/src/tests/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java 2009-06-05 15:13:02 UTC (rev 89883)
+++ projects/service-binding/trunk/management/src/test/java/org/jboss/test/services/binding/test/XSLTServiceBindingValueSourceUnitTestCase.java 2009-06-05 17:34:45 UTC (rev 89886)
@@ -1,198 +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.net.URL;
-
-import org.jboss.services.binding.ServiceBinding;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceConfig;
-import org.jboss.services.binding.impl.XSLTServiceBindingValueSourceImpl;
-import org.w3c.dom.Element;
-
-/**
- * Tests of {@link XSLTServiceBindingValueSourceImpl}.
- *
- * @author Brian Stansberry
- * @version $Revision$
- */
-public class XSLTServiceBindingValueSourceUnitTestCase extends ServiceBindingTestBase
-{
- private XSLTServiceBindingValueSourceImpl testee;
- private XSLTServiceBindingValueSourceConfig xsltConfig;
-
- /**
- * Create a new XSLTServiceBindingValueSourceUnitTestCase.
- *
- * @param name
- */
- public XSLTServiceBindingValueSourceUnitTestCase(String name)
- {
- super(name);
- }
-
- @Override
- protected void setUp() throws Exception
- {
- super.setUp();
-
- testee = new XSLTServiceBindingValueSourceImpl();
- xsltConfig = getXSLTConfig();
- bindingMetadata.setServiceBindingValueSourceConfig(xsltConfig);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getElementServiceBindingValue(org.jboss.bindings.ServiceBinding, org.w3c.dom.Element)}.
- */
- public void testGetElementServiceBindingValue() throws Exception
- {
- Element input = getDocumentElementFromClasspath(XSL_INPUT);
- Element output = testee.getElementServiceBindingValue(binding, input);
- validateXSLTOutputElement(output);
- }
-
- public void testGetElementServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getResourceServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getResourceServiceBindingValue(org.jboss.bindings.ServiceBinding, java.lang.String)}.
- */
- public void testGetResourceServiceBindingValue() throws Exception
- {
- String output = testee.getResourceServiceBindingValue(binding, XSL_INPUT);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetResourceServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getResourceServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- /**
- * Test method for {@link org.jboss.services.binding.impl.StringReplacementServiceBindingValueSourceImpl#getURLServiceBindingValue(org.jboss.bindings.ServiceBinding, java.net.URL)}.
- */
- public void testGetURLServiceBindingValue() throws Exception
- {
- URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
- URL output = testee.getURLServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetURLServiceBindingValueNullInput() throws Exception
- {
- try
- {
- testee.getURLServiceBindingValue(binding, null);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetServiceBindingValueNullInput() throws Exception
- {
- Object[] params = null;
- try
- {
- testee.getServiceBindingValue(binding, params);
- fail("Should fail passing a null input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetServiceBindingValueBadInput() throws Exception
- {
- try
- {
- testee.getServiceBindingValue(binding, new Object());
- fail("Should fail passing an unknown input");
- }
- catch (IllegalArgumentException good) {}
- }
-
- public void testGetServiceBindingValueStringInput() throws Exception
- {
- String output = (String) testee.getServiceBindingValue(binding, XSL_INPUT);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testGetServiceBindingValueElementInput() throws Exception
- {
- Element input = getDocumentElementFromClasspath(XSL_INPUT);
- Element output = (Element) testee.getServiceBindingValue(binding, input);
- validateXSLTOutputElement(output);
- }
-
- public void testGetServiceBindingValueURLInput() throws Exception
- {
- URL input = Thread.currentThread().getContextClassLoader().getResource(XSL_INPUT);
- URL output = (URL) testee.getServiceBindingValue(binding, input);
- assertNotNull(output);
- Element element = getDocumentElement(output);
- validateXSLTOutputElement(element);
- }
-
- public void testNullConfigObject() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(null);
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- String input = getFullyQualifiedResourceName("xlst_input.xml");
- try
- {
- testee.getResourceServiceBindingValue(binding, input);
- fail("Should fail using an unknown xsltConfig");
- }
- catch (IllegalStateException good) {}
- }
-
- public void testUnknownConfigObject() throws Exception
- {
- bindingMetadata.setServiceBindingValueSourceConfig(new Object());
- binding = new ServiceBinding(bindingMetadata, HOST, 0);
- String input = getFullyQualifiedResourceName("xlst_input.xml");
- try
- {
- testee.getResourceServiceBindingValue(binding, input);
- fail("Should fail using an unknown xsltConfig");
- }
- catch (IllegalStateException good) {}
- }
-
-}
Modified: projects/service-binding/trunk/pom.xml
===================================================================
--- projects/service-binding/trunk/pom.xml 2009-06-05 17:25:15 UTC (rev 89885)
+++ projects/service-binding/trunk/pom.xml 2009-06-05 17:34:45 UTC (rev 89886)
@@ -23,7 +23,7 @@
<!-- Artifact Information -->
<groupId>org.jboss.service-binding</groupId>
<artifactId>jboss-service-binding-parent</artifactId>
- <version>0.1.0-SNAPSHOT</version>
+ <version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>JBoss Service Binding Aggregator</name>
<url>http://www.jboss.org</url>
More information about the jboss-cvs-commits
mailing list