001/*
002 * Licensed to DuraSpace under one or more contributor license agreements.
003 * See the NOTICE file distributed with this work for additional information
004 * regarding copyright ownership.
005 *
006 * DuraSpace licenses this file to you under the Apache License,
007 * Version 2.0 (the "License"); you may not use this file except in
008 * compliance with the License.  You may obtain a copy of the License at
009 *
010 *     http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package org.fcrepo.services;
019
020import static org.junit.Assert.assertNotNull;
021import static org.mockito.MockitoAnnotations.initMocks;
022
023
024import javax.management.MBeanServer;
025
026import org.fcrepo.metrics.ReporterFactory;
027import org.junit.Before;
028import org.junit.Test;
029import org.mockito.Mock;
030
031import com.codahale.metrics.JmxReporter;
032import com.codahale.metrics.graphite.Graphite;
033import com.codahale.metrics.graphite.GraphiteReporter;
034
035/**
036 * ReporterFactoryTest class.
037 *
038 * @author ghill
039 */
040public class ReporterFactoryTest {
041
042    private ReporterFactory factory;
043
044    @Mock
045    private MBeanServer mockMBeanServer;
046
047    @Mock
048    private Graphite mockGraphite;
049
050    @Before
051    public void setUp() {
052        initMocks(this);
053        factory = new ReporterFactory();
054    }
055
056    @Test
057    public void testGetJmxReporter() {
058        try (final JmxReporter reporter = factory.getJmxReporter("not-used")) {
059            assertNotNull(reporter);
060        }
061    }
062
063    @Test
064    public void testGetGraphiteReporter() {
065        try (final GraphiteReporter reporter = factory.getGraphiteReporter("some-prefix", mockGraphite)) {
066            assertNotNull(reporter);
067        }
068    }
069
070}