Examples of IProducerRegistryAPI


Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

    for (int i=0; i<10; i++){
      service.doSomethingMethod();
    }

    //in this case we don't have anything in the Registry.
    IProducerRegistryAPI registry = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    try{
      registry.getProducer("SimpleService");
      registry.getProducer("SimpleService-1");
      fail("There should be no producer in the factory");
    }catch(NoSuchProducerException e){}

  }
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

    for (int i=0; i<10; i++){
      service.doSomethingMethod();
    }

    //in this case we don't have anything in the Registry.
    IProducerRegistryAPI registry = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)registry.getProducer("SimpleService-1");
    assertNotNull(producer);
    ServiceStats methodStats = producer.getStats("doSomethingMethod");
    assertEquals(10, methodStats.getTotalRequests());

  }
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

    for (int i=0; i<10; i++){
      monitoredInstance.doSomethingMethod();
    }

    //in this case we don't have anything in the Registry.
    IProducerRegistryAPI registry = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)registry.getProducer("SimpleService");
    assertNotNull(producer);
    ServiceStats methodStats = producer.getStats("doSomethingMethod");
    assertEquals(10, methodStats.getTotalRequests());

  }
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

        new String[] {"services-aop.xml"});
    AService service = (AService)context.getBean("AService");
    assertEquals(2*100, service.echoMethodA(100));

    //check that the call is traced
    IProducerRegistryAPI registryAPI = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    IStatsProducer<ServiceStats> producerB = registryAPI.getProducer("BServiceImpl");
    assertEquals(1, producerB.getStats().get(0).getTotalRequests());

    IStatsProducer<ServiceStats> producerC = registryAPI.getProducer("CServiceImpl");
    assertEquals(1, producerC.getStats().get(0).getTotalRequests());

    try{
      IStatsProducer<ServiceStats> producerD = registryAPI.getProducer("DServiceImpl");
      fail("Exception expected");
    }catch(NoSuchProducerException expectedException){}
  }
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

        /* waiting some time for next stats update */
        Thread.sleep(5500);

        /* if there is no MoSKito WebUI embedded in your application, stats can be accessed in a way like this */
        IProducerRegistryAPI registryAPI = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
        OnDemandStatsProducer<EhcacheStats> producer = (OnDemandStatsProducer<EhcacheStats>) registryAPI.getProducer("browser-cache");
        EhcacheStats stats =  producer.getStats("cumulated");
        System.out.println(stats.toStatsString(null, TimeUnit.MILLISECONDS));

        /* first 100 accesses will not result in hits because we don't have this pages in cache yet */
        assertEquals(9900, stats.getHits().getValueAsLong());
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

      testObject.doNotMonitorMe();
    }

    //test is finished, now to ensure that the class is really monitored...
    //you don't have to do this, as your data will probably show up in webui or logs or whatever configured.
    IProducerRegistryAPI registryAPI = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)registryAPI.getProducer("MonitoredClass");
    assertNotNull(producer);

    ServiceStats firstMethodStats = producer.getStats("firstMethod");
    assertNotNull(firstMethodStats);
    assertEquals(100, firstMethodStats.getTotalRequests());
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

      testObject.secondMethod();
    }

    //test is finished, now to ensure that the class is really monitored...
    //you don't have to do this, as your data will probably show up in webui or logs or whatever configured.
    IProducerRegistryAPI registryAPI = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    OnDemandStatsProducer<ServiceStats> producer = (OnDemandStatsProducer<ServiceStats>)registryAPI.getProducer("ClassWithMonitoredMethod");
    assertNotNull(producer);

    //the firstMethod is monitored and should therefor produce stats.
    ServiceStats firstMethodStats = producer.getStats("firstMethod");
    assertNotNull(firstMethodStats);
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

    counter.cc();
    counter.paypal();

    //As you see we had a total of 4 payments, one credit card payment, 2 ec payments and one paypal. Let's test it:
    //this code is just to test the results, you don't need to repeat it in your code, the counters will show up in the webui.
    IProducerRegistryAPI registry = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    IStatsProducer<CounterStats> producer = (IStatsProducer<CounterStats>)registry.getProducer("PaymentCounter");
    assertNotNull(producer);
    //total stats is always at first place in producer which is an instance of an on-demand-producer.
    assertEquals(4, producer.getStats().get(0).get());
    //other stats follow in order they are first called.
    assertEquals(2, producer.getStats().get(1).get());
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

    //and this payment failed
    counter.pay("cc", false);

    //As you see we had a total of 4 payments, one credit card payment, 2 ec payments and one paypal. Let's test it:
    //this code is just to test the results, you don't need to repeat it in your code, the counters will show up in the webui.
    IProducerRegistryAPI registry = new ProducerRegistryAPIFactory().createProducerRegistryAPI();

    //check successes
    OnDemandStatsProducer<CounterStats> successProducer = (OnDemandStatsProducer<CounterStats>)registry.getProducer("PaymentCounterByParameter.success");
    assertNotNull(successProducer);
    assertEquals(4, successProducer.getDefaultStats().get());
    assertEquals(2, successProducer.getStats("ec").get());
    assertEquals(1, successProducer.getStats("cc").get());
    assertEquals(1, successProducer.getStats("paypal").get());

    //check failures
    OnDemandStatsProducer<CounterStats> failureProducer = (OnDemandStatsProducer<CounterStats>)registry.getProducer("PaymentCounterByParameter.failure");
    assertNotNull(failureProducer);
    assertEquals(1, failureProducer.getDefaultStats().get());
    assertEquals(0, failureProducer.getStats("ec").get());
    assertEquals(1, failureProducer.getStats("cc").get());
    assertEquals(0, failureProducer.getStats("paypal").get());
View Full Code Here

Examples of net.anotheria.moskito.core.registry.IProducerRegistryAPI

    counter.pay("cc");
    counter.pay("paypal");

    //As you see we had a total of 4 payments, one credit card payment, 2 ec payments and one paypal. Let's test it:
    //this code is just to test the results, you don't need to repeat it in your code, the counters will show up in the webui.
    IProducerRegistryAPI registry = new ProducerRegistryAPIFactory().createProducerRegistryAPI();
    IStatsProducer<CounterStats> producer = registry.getProducer("PaymentCounterMethodBased");
    assertNotNull(producer);
    //total stats is always at first place in producer which is an instance of an on-demand-producer.
    assertEquals(4, producer.getStats().get(0).get());
    //other stats follow in order they are first called.
    assertEquals(2, producer.getStats().get(1).get());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.