[jboss-cvs] JBossAS SVN: r81880 - trunk/testsuite/src/main/org/jboss/test/profileservice/test.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Sun Nov 30 23:44:30 EST 2008
Author: bstansberry at jboss.com
Date: 2008-11-30 23:44:30 -0500 (Sun, 30 Nov 2008)
New Revision: 81880
Added:
trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServiceBindingManagedObjectsTestCase.java
Log:
[JBAS-6259] Basic test of SBM managed objects
Added: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServiceBindingManagedObjectsTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServiceBindingManagedObjectsTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ServiceBindingManagedObjectsTestCase.java 2008-12-01 04:44:30 UTC (rev 81880)
@@ -0,0 +1,273 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt 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.profileservice.test;
+
+import java.net.InetAddress;
+import java.util.Map;
+import java.util.Set;
+
+import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.managed.api.ComponentType;
+import org.jboss.managed.api.ManagedComponent;
+import org.jboss.managed.api.ManagedProperty;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+
+/**
+ * <p>
+ * Profile service ServiceBindingManager tests.
+ * </p>
+ *
+ * @author Brian Stansberry
+ * @version $Revision:$
+ */
+public class ServiceBindingManagedObjectsTestCase extends AbstractProfileServiceTest
+{
+ /**
+ * <p>
+ * Creates an instance of {@code SecurityManagedObjectsTestCase} with the specified name.
+ * </p>
+ *
+ * @param name a {@code String} representing the name of this {@code TestCase}.
+ */
+ public ServiceBindingManagedObjectsTestCase(String name)
+ {
+ super(name);
+ }
+
+ /**
+ * <p>
+ * Validates at the {@code ServiceBindingManager} managed component.
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the test.
+ */
+ public void testServiceBindingManager() throws Exception
+ {
+ ManagementView managementView = getManagementView();
+ ComponentType type = new ComponentType("MCBean", "ServiceBindingManager");
+ ManagedComponent component = managementView.getComponent("ports-default", type);
+ assertNotNull(component);
+
+ // verify that the component has the expected properties.
+ Map<String, ManagedProperty> properties = component.getProperties();
+ assertNotNull(properties);
+
+ ManagedProperty prop = properties.get("serverName");
+ assertNotNull("Missing property serverName", prop);
+ MetaValue val = prop.getValue();
+ assertNotNull("property serverName has no value", val);
+ assertTrue("property serverName value is SimpleValue", val instanceof SimpleValue);
+ assertEquals("incorrect serverName value", "ports-default", ((SimpleValue) val).getValue());
+
+ prop = properties.get("serviceBindings");
+ assertNotNull("Missing property serviceBindings", prop);
+ val = prop.getValue();
+ // FIXME not sure why this doesn't work
+// assertNotNull("property serviceBindings has no value", val);
+// assertTrue("property serviceBindings value is CollectionValue", val instanceof CollectionValue);
+// getLog().info(((CollectionValue) val).getElements());
+
+ assertEquals("Unexpected number of properties", 2, properties.size());
+ }
+
+ /**
+ * <p>
+ * Validates the {@code ServiceBindingStore} managed component.
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the test.
+ */
+ public void testServiceBindingStore() throws Exception
+ {
+ ManagementView managementView = super.getManagementView();
+ ComponentType type = new ComponentType("MCBean", "ServiceBindingStore");
+ // FIXME following should work but doesn't
+ //ManagedComponent component = managementView.getComponent("PojoServiceBindingStore", type);
+ ManagedComponent component = managementView.getComponent("ServiceBindingStore", type);
+ assertNotNull(component);
+
+ // verify that the component has the expected properties.
+ Map<String, ManagedProperty> properties = component.getProperties();
+ assertNotNull(properties);
+
+ ManagedProperty prop = properties.get("standardBindings");
+ assertNotNull("Missing property standardBindings", prop);
+ // FIXME not sure why this doesn't work
+// MetaValue val = prop.getValue();
+// assertNotNull("property standardBindings has no value", val);
+// assertTrue("property standardBindings value is CollectionValue", val instanceof CollectionValue);
+// getLog().info(((CollectionValue) val).getElements());
+
+ prop = properties.get("bindingSets");
+ assertNotNull("Missing property bindingSets", prop);
+ // FIXME not sure why this doesn't work
+// val = prop.getValue();
+// assertNotNull("property bindingSets has no value", val);
+// assertTrue("property bindingSets value is CollectionValue", val instanceof CollectionValue);
+// getLog().info(((CollectionValue) val).getElements());
+ }
+
+ public void testPortsDefault() throws Exception
+ {
+ serviceBindingSetTest("ports-default", 0);
+ }
+
+ public void testPorts01() throws Exception
+ {
+ serviceBindingSetTest("ports-01", 100);
+ }
+
+ public void testPorts02() throws Exception
+ {
+ serviceBindingSetTest("ports-02", 200);
+ }
+
+ public void testPorts03() throws Exception
+ {
+ serviceBindingSetTest("ports-03", 300);
+ }
+
+ private void serviceBindingSetTest(String name, int offset) throws Exception
+ {
+ ManagementView managementView = super.getManagementView();
+ ComponentType type = new ComponentType("MCBean", "ServiceBindingSet");
+ ManagedComponent component = managementView.getComponent(name, type);
+ assertNotNull(component);
+
+ // verify that the component has the expected properties.
+ Map<String, ManagedProperty> properties = component.getProperties();
+ assertNotNull(properties);
+
+ ManagedProperty prop = properties.get("name");
+ assertNotNull("Missing property name", prop);
+ MetaValue val = prop.getValue();
+ assertNotNull("property name has no value", val);
+ assertTrue("property name value is SimpleValue", val instanceof SimpleValue);
+ assertEquals(name, ((SimpleValue) val).getValue());
+
+ prop = properties.get("defaultHostName");
+ assertNotNull("Missing property defaultHostName", prop);
+ val = prop.getValue();
+ assertNotNull("property defaultHostName has no value", val);
+ assertEquals("type of defaultHostName value isn't String", String.class.getName(), val.getMetaType().getClassName());
+ assertTrue("property defaultHostName value is SimpleValue", val instanceof SimpleValue);
+ assertEquals(InetAddress.getByName(getServerHost()), InetAddress.getByName((String) ((SimpleValue) val).getValue()));
+
+ prop = properties.get("portOffset");
+ assertNotNull("Missing property portOffset", prop);
+ val = prop.getValue();
+ assertNotNull("property portOffset has no value", val);
+ assertTrue("property portOffset value is SimpleValue", val instanceof SimpleValue);
+ assertEquals(Integer.valueOf(offset), ((SimpleValue) val).getValue());
+
+ prop = properties.get("overrideBindings");
+ assertNotNull("Missing property overrideBindings", prop);
+ // FIXME not sure why this doesn't work
+// val = prop.getValue();
+// assertNotNull("property overrideBindings has no value", val);
+// assertTrue("property overrideBindings value is CollectionValue", val instanceof CollectionValue);
+// getLog().info(((CollectionValue) val).getElements());
+
+ }
+
+ public void testServiceBindingMetadata() throws Exception
+ {
+ ManagementView managementView = getManagementView();
+ ComponentType type = new ComponentType("MCBean", "ServiceBindingMetadata");
+ Set<ManagedComponent> mcs = managementView.getComponentsForType(type);
+ assertTrue("There are MCBean,Security components", mcs.size() > 0);
+ super.getLog().debug("MCBeans: " + mcs);
+
+ // Not all bindings have a val for bindingName or hostName,
+ // so check until we find one that does
+ boolean checkedBindingName = false;
+ boolean checkedHostName = false;
+ for (ManagedComponent component : mcs)
+ {
+ if (checkedBindingName && checkedHostName)
+ break;
+
+ // verify that the component has the expected properties.
+ Map<String, ManagedProperty> properties = component.getProperties();
+ assertNotNull(properties);
+
+ ManagedProperty prop = properties.get("fullyQualifiedName");
+ assertNotNull("Missing property fullyQualifiedName", prop);
+ MetaValue val = prop.getValue();
+ assertNotNull("property fullyQualifiedName has no value", val);
+ assertTrue("property fullyQualifiedName value is SimpleValue", val instanceof SimpleValue);
+ assertNotNull("property fullyQualifiedName value is not null", ((SimpleValue) val).getValue());
+
+ prop = properties.get("serviceName");
+ assertNotNull("Missing property serviceName", prop);
+ val = prop.getValue();
+ assertNotNull("property serviceName has no value", val);
+ assertTrue("property serviceName value is SimpleValue", val instanceof SimpleValue);
+ assertNotNull("property serviceName value is not null", ((SimpleValue) val).getValue());
+
+ prop = properties.get("bindingName");
+ assertNotNull("Missing property bindingName", prop);
+ val = prop.getValue();
+ if (val != null)
+ {
+ checkedBindingName = true;
+ assertNotNull("property bindingName has no value", val);
+ assertTrue("property bindingName value is SimpleValue", val instanceof SimpleValue);
+ assertEquals("type of bindingName value isn't String", String.class.getName(), val.getMetaType().getClassName());
+ }
+
+ prop = properties.get("hostName");
+ assertNotNull("Missing property hostName", prop);
+ val = prop.getValue();
+ if (val != null)
+ {
+ checkedHostName = true;
+ assertNotNull("property hostName has no value", val);
+ assertTrue("property hostName value is SimpleValue", val instanceof SimpleValue);
+ assertNotNull("property hostName value is not null", ((SimpleValue) val).getValue());
+ assertEquals("type of hostName value isn't String", String.class.getName(), val.getMetaType().getClassName());
+ }
+
+ prop = properties.get("port");
+ assertNotNull("Missing property port", prop);
+ val = prop.getValue();
+ assertNotNull("property port has no value", val);
+ assertTrue("property port value is SimpleValue", val instanceof SimpleValue);
+ assertNotNull("property port value is not null", ((SimpleValue) val).getValue());
+ assertEquals("type of port value isn't Integer", Integer.class.getName(), val.getMetaType().getClassName());
+ assertNotNull("property port value is not null", ((SimpleValue) val).getValue());
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.test.profileservice.test.AbstractProfileServiceTest#getProfileName()
+ */
+ @Override
+ protected String getProfileName()
+ {
+ return "profileservice";
+ }
+}
More information about the jboss-cvs-commits
mailing list