KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > dozer > util > mapping > jmx > DozerStatisticsControllerTest


1 /*
2  * Copyright 2005-2007 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package net.sf.dozer.util.mapping.jmx;
17
18 import java.util.Set JavaDoc;
19
20 import net.sf.dozer.util.mapping.DozerTestBase;
21 import net.sf.dozer.util.mapping.stats.StatisticTypeConstants;
22
23
24 /**
25  * @author tierney.matt
26  */

27 public class DozerStatisticsControllerTest extends DozerTestBase {
28   
29   private DozerStatisticsController controller;
30   
31   protected void setUp() throws Exception JavaDoc {
32     super.setUp();
33     controller = new DozerStatisticsController();
34   }
35
36   public void testIsStatisticsEnabled() throws Exception JavaDoc {
37       boolean isStatisticsEnabled = controller.isStatisticsEnabled();
38       controller.setStatisticsEnabled(!isStatisticsEnabled);
39       assertEquals("statistics enabled value was not updated", !isStatisticsEnabled, controller.isStatisticsEnabled());
40   }
41   
42   public void testGetStatisticValues() throws Exception JavaDoc {
43     //just verify these values are zero
44
controller.clearAll();
45     assertEquals(0,controller.getMappingSuccessCount());
46     assertEquals(0,controller.getMappingFailureCount());
47     assertEquals(0,controller.getMapperInstancesCount());
48     assertEquals(0,controller.getMappingOverallTime());
49     assertEquals(0,controller.getFieldMappingSuccessCount());
50     assertEquals(0,controller.getFieldMappingFailureCount());
51     assertEquals(0,controller.getFieldMappingFailureIgnoredCount());
52   }
53   
54   public void testGetStatisticEntries() throws Exception JavaDoc {
55     controller.clearAll();
56     Set JavaDoc entries = controller.getStatisticEntries(StatisticTypeConstants.CACHE_HIT_COUNT);
57     assertEquals("incorrect entries size", 0, entries.size());
58   }
59   
60   public void testGetStatisticEntries_UnknownType() throws Exception JavaDoc {
61     controller.clearAll();
62     Set JavaDoc entries = controller.getStatisticEntries(String.valueOf(System.currentTimeMillis()));
63     assertEquals("incorrect entries size", 0, entries.size());
64   }
65   
66   public void testGetStatisticValue_UnknownType() throws Exception JavaDoc {
67     controller.clearAll();
68     long value = controller.getStatisticValue(String.valueOf(System.currentTimeMillis()));
69     assertEquals("incorrect value", 0, value);
70   }
71   
72   
73   
74   
75 }
76
Popular Tags