001: /*
002: * BEGIN_HEADER - DO NOT EDIT
003: *
004: * The contents of this file are subject to the terms
005: * of the Common Development and Distribution License
006: * (the "License"). You may not use this file except
007: * in compliance with the License.
008: *
009: * You can obtain a copy of the license at
010: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
011: * See the License for the specific language governing
012: * permissions and limitations under the License.
013: *
014: * When distributing Covered Code, include this CDDL
015: * HEADER in each file and include the License file at
016: * https://open-esb.dev.java.net/public/CDDLv1.0.html.
017: * If applicable add the following below this CDDL HEADER,
018: * with the fields enclosed by brackets "[]" replaced with
019: * your own identifying information: Portions Copyright
020: * [year] [name of copyright owner]
021: */
022:
023: /*
024: * @(#)TestFrameworkStatistics.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.framework;
030:
031: /**
032: * Tests for FrameworkStatistics.
033: *
034: * @author Sun Microsystems, Inc.
035: */
036: public class TestFrameworkStatistics extends junit.framework.TestCase {
037: /**
038: * Instance of FrameworkStatistics.
039: */
040: private FrameworkStatistics mFrameworkStatistics;
041:
042: /**
043: * The constructor for this testcase, forwards the test name to
044: * the jUnit TestCase base class.
045: * @param aTestName String with the name of this test.
046: */
047: public TestFrameworkStatistics(String aTestName) {
048: super (aTestName);
049: }
050:
051: /**
052: * Setup for the test. This creates the FrameworkStatistics instance
053: * and other objects needed for the tests.
054: * @throws Exception when set up fails for any reason.
055: */
056: public void setUp() throws Exception {
057: super .setUp();
058:
059: mFrameworkStatistics = new FrameworkStatistics();
060: }
061:
062: /**
063: * Cleanup for the test.
064: * @throws Exception when tearDown fails for any reason.
065: */
066: public void tearDown() throws Exception {
067: super .tearDown();
068: }
069:
070: // ============================= test methods ================================
071:
072: /**
073: * Tests get/setLastRestartTime.
074: * @throws Exception if an unexpected error occurs.
075: */
076: public void testLastRestartTime() {
077: java.util.Date d = new java.util.Date();
078: mFrameworkStatistics.setLastRestartTime(d);
079: assertEquals("Failure on set/getLastRestartTime: ", d,
080: mFrameworkStatistics.getLastRestartTime());
081: }
082:
083: /**
084: * Tests get/setStartupTime.
085: * @throws Exception if an unexpected error occurs.
086: */
087: public void testStartupTime() {
088: long t = Long.MAX_VALUE - 1;
089: mFrameworkStatistics.setStartupTime(t);
090: assertEquals("Failure on set/getStartupTime: ", t,
091: mFrameworkStatistics.getStartupTime());
092: }
093:
094: /**
095: * Tests get/incrementRegistryAdds.
096: * @throws Exception if an unexpected error occurs.
097: */
098: public void testRegistryAdds() throws Exception {
099: long n = 0;
100: assertEquals("Failure on getRegistryAdds: ", new Long(n),
101: new Long(mFrameworkStatistics.getRegistryAdds()));
102: mFrameworkStatistics.incrementRegistryAdds();
103: ++n;
104: assertEquals("Failure on incrementRegistryAdds: ", new Long(n),
105: new Long(mFrameworkStatistics.getRegistryAdds()));
106: }
107:
108: /**
109: * Tests get/incrementRegistryDeletes.
110: * @throws Exception if an unexpected error occurs.
111: */
112: public void testRegistryDeletes() throws Exception {
113: long n = 0;
114: assertEquals("Failure on getRegistryDeletes: ", new Long(n),
115: new Long(mFrameworkStatistics.getRegistryDeletes()));
116: mFrameworkStatistics.incrementRegistryDeletes();
117: ++n;
118: assertEquals("Failure on incrementRegistryDeletes: ", new Long(
119: n), new Long(mFrameworkStatistics.getRegistryDeletes()));
120: }
121:
122: /**
123: * Test resetRegistryStatistics.
124: * @throws Exception if an unexpected error occurs.
125: */
126: public void testResetRegistryStatistics() {
127: mFrameworkStatistics.incrementRegistryAdds();
128: mFrameworkStatistics.incrementRegistryDeletes();
129: mFrameworkStatistics.resetRegistryStatistics();
130: long n = 0;
131: assertEquals("Failure on resetRegistryStatistics: ",
132: new Long(n), new Long(mFrameworkStatistics
133: .getRegistryAdds()));
134: assertEquals("Failure on resetRegistryStatistics: ",
135: new Long(n), new Long(mFrameworkStatistics
136: .getRegistryDeletes()));
137: }
138: }
|