Package org.jboss.managed.api

Examples of org.jboss.managed.api.ManagedComponent


      ComponentType compType = new ComponentType("ConnectionFactory", "NoTx");
      createComponentTest("NoTxConnectionFactoryTemplate", propValues, "testNoTxCf", compType, jndiName);

      // Validate the config-property
      ManagementView mgtView = getManagementView();
      ManagedComponent dsMC = getManagedComponent(mgtView, compType, jndiName);
      ManagedProperty configProperty = dsMC.getProperty("config-property");
      assertNotNull(configProperty);
      MetaValue value = configProperty.getValue();
      assertTrue("MapCompositeMetaType", value.getMetaType() instanceof MapCompositeMetaType);
     
      MapCompositeValueSupport cValue = (MapCompositeValueSupport) value;
      cValue.put("testKey", new SimpleValueSupport(SimpleMetaType.STRING, "testValue"));
     
      mgtView.updateComponent(dsMC);

      mgtView = getManagementView();
      dsMC = getManagedComponent(mgtView, compType, jndiName);
      configProperty = dsMC.getProperty("config-property");
      assertNotNull(configProperty);
      cValue = (MapCompositeValueSupport) configProperty.getValue();
      assertNotNull(cValue.get("testKey"));
   }
View Full Code Here


      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MCBean", "JTA");
      Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
      int count = comps.size();
      assertEquals("There is 1 MCBean:JTA ManagedComponent", 1, 1);
      ManagedComponent comp = comps.iterator().next();
      Map<String, ManagedProperty> props = comp.getProperties();
      for(ManagedProperty prop : props.values())
      {
         log.info(prop+", : "+prop.getValue());
      }
   }
View Full Code Here

      mgtView.applyTemplate(deploymentName, dsInfo);

      // reload the view
      activeView = null;
      mgtView = getManagementView();
      ManagedComponent dsMC = getManagedComponent(mgtView, componentType, componentName);
      assertNotNull(dsMC);

      Set<String> mcPropNames = new HashSet<String>(dsMC.getPropertyNames());
      for(String propName : propValues.keySet())
      {
         ManagedProperty prop = dsMC.getProperty(propName);
         log.debug("Checking: "+propName);
         assertNotNull(propName, prop);
         Object propValue = prop.getValue();
         Object expectedValue = propValues.get(propName);
         if(propValue instanceof MetaValue)
         {
            if (prop.getMetaType().isComposite())
            {
               // TODO / FIXME - compare composites
               log.warn("Not checking composite: "+propValue);
            }
            else
            {
               // Compare the MetaValues
               assertEquals(prop.getName(), expectedValue, propValue);
            }
         }
         else if(propValue != null)
         {
            fail(prop.getName()+" is not a MetaValue: "+propValue);
         }

         mcPropNames.remove(propName);
      }

      if(!mcPropNames.isEmpty())
      {
         log.warn(getName() + "> untested properties: " + mcPropNames);
         for(String propName : mcPropNames)
         {
            ManagedProperty prop = dsMC.getProperty(propName);
            log.info(prop);
         }
      }
   }
View Full Code Here

      // reload the view and new datasource component
      ComponentType componentType = new ComponentType("DataSource", "LocalTx");
      activeView = null;
      mgtView = getManagementView();
      ManagedComponent dsMC = getManagedComponent(mgtView, componentType, jndiName);
      assertNotNull(dsMC);

      // Validate that the use-java-context value is true
      useJavaCtx = dsMC.getProperty("use-java-context");
      assertNotNull(useJavaCtx);
      assertEquals(SimpleValueSupport.wrap(Boolean.TRUE), useJavaCtx.getValue());
     
      // Update the use-java-context value
      ManagedProperty minPoolSize = dsMC.getProperty("min-pool-size");
      MetaValue oldValue = minPoolSize.getValue();
      minPoolSize.setValue(SimpleValueSupport.wrap(1));
      minPoolSize.setRemoved(true);
      ManagedProperty maxPoolSize = dsMC.getProperty("max-pool-size");
      maxPoolSize.setValue(SimpleValueSupport.wrap(999));
      activeView.updateComponent(dsMC);
      dsMC = getManagedComponent(mgtView, componentType, jndiName);
      assertNotNull(dsMC);
      minPoolSize = dsMC.getProperty("min-pool-size");
      assertEquals(oldValue, minPoolSize.getValue());
      maxPoolSize = dsMC.getProperty("max-pool-size");
      assertEquals(SimpleValueSupport.wrap(999), maxPoolSize.getValue());
     
      // Remove the deployment
      removeDeployment("testRemovedProperties-ds.xml");
   }
View Full Code Here

   public void testClassLoadingMXBean()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MBean", "Platform");
      ManagedComponent clMC = mgtView.getComponent(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, type);
      assertEquals(ManagementFactory.CLASS_LOADING_MXBEAN_NAME, clMC.getName());

      Map<String, ManagedProperty> props = clMC.getProperties();
      assertNotNull(props);
      // totalLoadedClassCount
      ManagedProperty totalLoadedClassCount = props.get("totalLoadedClassCount");
      assertNotNull(totalLoadedClassCount);
      assertEquals(SimpleMetaType.LONG_PRIMITIVE, totalLoadedClassCount.getMetaType());
View Full Code Here

   public void testMemoryMXBean()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MBean", "Platform");
      ManagedComponent mo = mgtView.getComponent(ManagementFactory.MEMORY_MXBEAN_NAME, type);
      assertNotNull(mo);
      assertEquals(ManagementFactory.MEMORY_MXBEAN_NAME, mo.getName());

      Map<String, ManagedProperty> props = mo.getProperties();
      assertNotNull(props);

      // heapMemoryUsage
      ManagedProperty heapMemoryUsage = props.get("heapMemoryUsage");
      assertNotNull(heapMemoryUsage);
      assertEquals("object representing the heap memory usage.", heapMemoryUsage.getDescription());
      CompositeValue heapMemoryUsageMV = CompositeValue.class.cast(heapMemoryUsage.getValue());
      assertNotNull(heapMemoryUsageMV);
      getLog().debug("heapMemoryUsageMV; "+heapMemoryUsageMV);
      MemoryUsage heapMemoryUsageMU = ManagementFactoryUtils.unwrapMemoryUsage(heapMemoryUsageMV);
      assertTrue(heapMemoryUsageMU.getInit() >= 0);
      assertTrue(heapMemoryUsageMU.getUsed() >= 1000);
      assertTrue(heapMemoryUsageMU.getMax() >= heapMemoryUsageMU.getCommitted());
      assertTrue(heapMemoryUsageMU.getCommitted() >=  heapMemoryUsageMU.getUsed());

      // nonHeapMemoryUsage
      ManagedProperty nonHeapMemoryUsage = props.get("nonHeapMemoryUsage");
      assertNotNull(nonHeapMemoryUsage);
      assertEquals("object representing the non-heap memory usage.", nonHeapMemoryUsage.getDescription());
      CompositeValue nonHeapMemoryUsageMV = CompositeValue.class.cast(nonHeapMemoryUsage.getValue());
      assertNotNull(nonHeapMemoryUsageMV);
      getLog().debug("nonHeapMemoryUsageMV; "+nonHeapMemoryUsageMV);
      MemoryUsage nonHeapMemoryUsageMU = ManagementFactoryUtils.unwrapMemoryUsage(nonHeapMemoryUsageMV);
      assertTrue(nonHeapMemoryUsageMU.getInit() >= 0);
      assertTrue(nonHeapMemoryUsageMU.getUsed() >= 1000);
      // Ignore undefined nonHeap max memory, seen with IBM JDK 6
      if(nonHeapMemoryUsageMU.getMax() != -1)
        assertTrue(nonHeapMemoryUsageMU.getMax() >= nonHeapMemoryUsageMU.getCommitted());
      assertTrue(nonHeapMemoryUsageMU.getCommitted() >=  nonHeapMemoryUsageMU.getUsed());
      // objectPendingFinalizationCount
      ManagedProperty objectPendingFinalizationCount = props.get("objectPendingFinalizationCount");
      assertNotNull(objectPendingFinalizationCount);
      assertEquals("the approximate number objects for which finalization is pending.", objectPendingFinalizationCount.getDescription());
      MetaValue objectPendingFinalizationCountMV = objectPendingFinalizationCount.getValue();
      assertNotNull(objectPendingFinalizationCountMV);
      getLog().debug("objectPendingFinalizationCountMV; "+objectPendingFinalizationCountMV);

      // verbose
      ManagedProperty verbose = props.get("verbose");
      assertNotNull(verbose);
      assertEquals(SimpleMetaType.BOOLEAN_PRIMITIVE, verbose.getMetaType());
      assertEquals("the verbose output flag for the memory system.", verbose.getDescription());
      SimpleValue verboseSV = SimpleValue.class.cast(verbose.getValue());
      assertNotNull(verboseSV);
      getLog().debug("verboseSV; "+verboseSV);

      // The gc op
      Set<ManagedOperation> ops = mo.getOperations();
      assertNotNull(ops);
      assertEquals("There is 1 op", 1, ops.size());
      ManagedOperation gc = ops.iterator().next();
      assertEquals("gc", gc.getName());
      assertEquals("Runs the garbage collector", gc.getDescription());
View Full Code Here

   {
      ManagementView mgtView = getManagementView();
      //mgtView.reloadProfile();

      ComponentType type = new ComponentType("MBean", "Platform");
      ManagedComponent mo = mgtView.getComponent(ManagementFactory.THREAD_MXBEAN_NAME, type);
      assertNotNull(mo);
      assertEquals(ManagementFactory.THREAD_MXBEAN_NAME, mo.getName());
     
      // Test ThreadInfo MetaValue wrap/unwrap
      MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();

      // Properties
      ManagedProperty allThreadIds = mo.getProperty("allThreadIds");
      assertNotNull(allThreadIds);
      MetaValue allThreadIdsMV = allThreadIds.getValue();
      assertTrue("allThreadIds is Array", allThreadIdsMV instanceof ArrayValue);
      ArrayValue idsArray = ArrayValue.class.cast(allThreadIdsMV);
      assertTrue(idsArray.getLength() > 10);
      SimpleValue tid0SV = SimpleValue.class.cast(idsArray.getValue(0));
      ManagedProperty currentThreadCpuTime = mo.getProperty("currentThreadCpuTime");
      assertNotNull(currentThreadCpuTime);
      long x = (Long) metaValueFactory.unwrap(currentThreadCpuTime.getValue());
      assertTrue(x > 1000);
      ManagedProperty currentThreadUserTime = mo.getProperty("currentThreadUserTime");
      assertNotNull(currentThreadUserTime);
      ManagedProperty daemonThreadCount = mo.getProperty("daemonThreadCount");
      assertNotNull(daemonThreadCount);
      x = (Integer) metaValueFactory.unwrap(daemonThreadCount.getValue());
      assertTrue(x > 1);
      ManagedProperty peakThreadCount = mo.getProperty("peakThreadCount");
      assertNotNull(peakThreadCount);
      x = (Integer) metaValueFactory.unwrap(peakThreadCount.getValue());
      assertTrue(x > 10);
      ManagedProperty threadCount = mo.getProperty("threadCount");
      assertNotNull(threadCount);
      x = (Integer) metaValueFactory.unwrap(threadCount.getValue());
      assertTrue(x > 10);
      ManagedProperty totalStartedThreadCount = mo.getProperty("totalStartedThreadCount");
      assertNotNull(totalStartedThreadCount);
      x = (Long) metaValueFactory.unwrap(totalStartedThreadCount.getValue());
      assertTrue(x > 10);
      ManagedProperty currentThreadCpuTimeSupported = mo.getProperty("currentThreadCpuTimeSupported");
      assertNotNull(currentThreadCpuTimeSupported);
      Boolean flag = (Boolean) metaValueFactory.unwrap(currentThreadCpuTimeSupported.getValue());
      assertNotNull(flag);
      ManagedProperty threadContentionMonitoringEnabled = mo.getProperty("threadContentionMonitoringEnabled");
      assertNotNull(threadContentionMonitoringEnabled);
      flag = (Boolean) metaValueFactory.unwrap(threadContentionMonitoringEnabled.getValue());
      assertNotNull(flag);
      ManagedProperty threadContentionMonitoringSupported = mo.getProperty("threadContentionMonitoringSupported");
      assertNotNull(threadContentionMonitoringSupported);
      flag = (Boolean) metaValueFactory.unwrap(threadContentionMonitoringSupported.getValue());
      assertNotNull(flag);
      ManagedProperty threadCpuTimeEnabled = mo.getProperty("threadCpuTimeEnabled");
      assertNotNull(threadCpuTimeEnabled);
      flag = (Boolean) metaValueFactory.unwrap(threadCpuTimeEnabled.getValue());
      assertNotNull(flag);
      ManagedProperty threadCpuTimeSupported = mo.getProperty("threadCpuTimeSupported");
      assertNotNull(threadCpuTimeSupported);
      flag = (Boolean) metaValueFactory.unwrap(threadCpuTimeSupported.getValue());
      assertNotNull(flag);

      // Ops
      Set<ManagedOperation> ops = mo.getOperations();
      log.debug(ops);

      String javaSpecVersion = System.getProperty("java.specification.version");
      if (javaSpecVersion.equals("1.5") || javaSpecVersion.equals("5.0"))
         assertEquals(mo + " has wrong number of ManagedOperations.", 8, ops.size());
View Full Code Here

   public void testRuntimeMXBean()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MBean", "Platform");
      ManagedComponent mo = mgtView.getComponent(ManagementFactory.RUNTIME_MXBEAN_NAME, type);
      assertNotNull(mo);
      assertEquals(ManagementFactory.RUNTIME_MXBEAN_NAME, mo.getName());

      RuntimeMXBean mbean = ManagementFactory.getRuntimeMXBean();
      MetaValueFactory metaValueFactory = MetaValueFactory.getInstance();
     
      ManagedProperty bootClassPath = mo.getProperty("bootClassPath");
      String x = (String) metaValueFactory.unwrap(bootClassPath.getValue());
      assertTrue(x.length() > 0);
      ManagedProperty classPath = mo.getProperty("classPath");
      x = (String) metaValueFactory.unwrap(classPath.getValue());
      assertTrue(x.length() > 0);
      ManagedProperty libraryPath = mo.getProperty("libraryPath");
      x = (String) metaValueFactory.unwrap(libraryPath.getValue());
      assertTrue(x.length() > 0);
      ManagedProperty managementSpecVersion = mo.getProperty("managementSpecVersion");
      x = (String) metaValueFactory.unwrap(managementSpecVersion.getValue());
      assertEquals(mbean.getManagementSpecVersion(), x);     
      ManagedProperty specName = mo.getProperty("specName");
      x = (String) metaValueFactory.unwrap(specName.getValue());
      assertEquals(mbean.getSpecName(), x);     
      ManagedProperty specVendor = mo.getProperty("specVendor");
      x = (String) metaValueFactory.unwrap(specVendor.getValue());
      assertEquals(mbean.getSpecVendor(), x);     
      ManagedProperty specVersion = mo.getProperty("specVersion");
      x = (String) metaValueFactory.unwrap(specVersion.getValue());
      assertEquals(mbean.getSpecVersion(), x);     
      ManagedProperty vmName = mo.getProperty("vmName");
      x = (String) metaValueFactory.unwrap(vmName.getValue());
      assertEquals(mbean.getVmName(), x);     
      ManagedProperty vmVendor = mo.getProperty("vmVendor");
      x = (String) metaValueFactory.unwrap(vmVendor.getValue());
      assertEquals(mbean.getVmVendor(), x);     
      ManagedProperty vmVersion = mo.getProperty("vmVersion");
      x = (String) metaValueFactory.unwrap(vmVersion.getValue());
      assertEquals(mbean.getVmVersion(), x);
      ManagedProperty startTime = mo.getProperty("startTime");
      long time = (Long) metaValueFactory.unwrap(startTime.getValue());
      assertTrue(time > 10000000);
      ManagedProperty uptime = mo.getProperty("uptime");
      time = (Long) metaValueFactory.unwrap(uptime.getValue());
      ManagedProperty inputArguments = mo.getProperty("inputArguments");
      List<String> ls = (List<String>) metaValueFactory.unwrap(inputArguments.getValue());
      assertTrue(ls.size() > 0);
      ManagedProperty systemProperties = mo.getProperty("systemProperties");
      MetaValue sysPropsMV = systemProperties.getValue();
      Map<String, String> sysProps = (Map<String, String>) metaValueFactory.unwrap(sysPropsMV);
      log.debug(sysProps);
      assertNotNull(sysProps.get("jboss.home.dir"));
      assertTrue(sysProps.get("jboss.home.dir") instanceof String);
View Full Code Here

   public void testOperatingSystemMXBean()
      throws Exception
   {
      ManagementView mgtView = getManagementView();
      ComponentType type = new ComponentType("MBean", "Platform");
      ManagedComponent mo = mgtView.getComponent(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, type);
      assertNotNull(mo);
      assertEquals(ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME, mo.getName());

      ManagedProperty arch = mo.getProperty("arch");
      assertNotNull(arch);
      ManagedProperty availableProcessors = mo.getProperty("availableProcessors");
      assertNotNull(availableProcessors);
      SimpleValue procsSV = (SimpleValue) availableProcessors.getValue();
      Integer procs = (Integer) procsSV.getValue();
      assertTrue(procs.intValue() >= 1);
      ManagedProperty version = mo.getProperty("version");
      assertNotNull(version);
      log.debug(version.getValue());
   }
View Full Code Here

   private ManagedComponent getServiceBindingManagerManagedComponent() throws Exception
   {
      ManagementView managementView = getManagementView();
      ComponentType type = new ComponentType("MCBean", "ServiceBindingManager");
      ManagedComponent component = managementView.getComponent("ServiceBindingManager", type);
      assertNotNull(component);
      return component;
   }
View Full Code Here

TOP

Related Classes of org.jboss.managed.api.ManagedComponent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.