Exemplo n.º 1
0
        public virtual void TestPutMetrics3()
        {
            // setup GraphiteSink
            GraphiteSink sink = new GraphiteSink();

            GraphiteSink.Graphite mockGraphite = MakeGraphite();
            Whitebox.SetInternalState(sink, "graphite", mockGraphite);
            // given two metrics records with timestamps 1000 milliseconds apart.
            IList <MetricsTag>           tags    = Collections.EmptyList();
            ICollection <AbstractMetric> metrics = new HashSet <AbstractMetric>();

            metrics.AddItem(MakeMetric("foo1", 1));
            MetricsRecord record1 = new MetricsRecordImpl(MsInfo.Context, 1000000000000L, tags
                                                          , metrics);
            MetricsRecord record2 = new MetricsRecordImpl(MsInfo.Context, 1000000001000L, tags
                                                          , metrics);

            sink.PutMetrics(record1);
            sink.PutMetrics(record2);
            sink.Flush();
            try
            {
                sink.Close();
            }
            catch (IOException e)
            {
                Runtime.PrintStackTrace(e);
            }
            // then the timestamps in the graphite stream should differ by one second.
            try
            {
                Org.Mockito.Mockito.Verify(mockGraphite).Write(Matchers.Eq("null.default.Context.foo1 1 1000000000\n"
                                                                           ));
                Org.Mockito.Mockito.Verify(mockGraphite).Write(Matchers.Eq("null.default.Context.foo1 1 1000000001\n"
                                                                           ));
            }
            catch (IOException e)
            {
                Runtime.PrintStackTrace(e);
            }
        }
Exemplo n.º 2
0
        public virtual void TestClose()
        {
            GraphiteSink sink = new GraphiteSink();

            GraphiteSink.Graphite mockGraphite = MakeGraphite();
            Whitebox.SetInternalState(sink, "graphite", mockGraphite);
            try
            {
                sink.Close();
            }
            catch (IOException ioe)
            {
                Runtime.PrintStackTrace(ioe);
            }
            try
            {
                Org.Mockito.Mockito.Verify(mockGraphite).Close();
            }
            catch (IOException ioe)
            {
                Runtime.PrintStackTrace(ioe);
            }
        }