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