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: * @(#)TestProxyBindingStatistics.java
025: * Copyright 2004-2007 Sun Microsystems, Inc. All Rights Reserved.
026: *
027: * END_HEADER - DO NOT EDIT
028: */
029: package com.sun.jbi.binding.proxy;
030:
031: import java.util.Date;
032:
033: public class TestProxyBindingStatistics extends
034: junit.framework.TestCase {
035:
036: /**
037: * Instance of ProxyBindingStatistics
038: */
039: private ProxyBindingStatistics mPBStats;
040:
041: /**
042: * The constructor for this testcase, forwards the test name to
043: * the jUnit TestCase base class.
044: * @param aTestName String with the name of this test.
045: */
046: public TestProxyBindingStatistics(String aTestName) {
047: super (aTestName);
048: }
049:
050: /**
051: * Setup for the test. This creates the ComponentStatistics instance
052: * and other objects needed for the tests.
053: * @throws Exception when set up fails for any reason.
054: */
055: public void setUp() throws Exception {
056: super .setUp();
057: mPBStats = new ProxyBindingStatistics();
058: }
059:
060: /**
061: * Cleanup for the test.
062: * @throws Exception when tearDown fails for any reason.
063: */
064: public void tearDown() throws Exception {
065: super .tearDown();
066: }
067:
068: /**
069: * Tests get/incrementSentExchanges()
070: * @throws Exception if unexpected error occurs.
071: */
072: public void testIncrementSentExchanges() {
073: int init = 0;
074: assertEquals("Failure on getIncrementSentExchanges:", new Long(
075: init), new Long(mPBStats.getSentExchanges()));
076: mPBStats.incrementSentExchanges();
077: init++;
078:
079: assertEquals("Failure on incrementSentExchanges:", new Long(
080: init), new Long(mPBStats.getSentExchanges()));
081: }
082:
083: /**
084: * Tests get/incrementReceivedExchanges()
085: * @throws Exception if unexpected error occurs.
086: */
087: public void testIncrementReceivedExchanges() {
088: int init = 0;
089: assertEquals("Failure on getIncrementReceivedExchanges:",
090: new Long(init), new Long(mPBStats
091: .getReceivedExchanges()));
092: mPBStats.incrementReceivedExchanges();
093: init++;
094:
095: assertEquals("Failure on incrementReceivedExchanges:",
096: new Long(init), new Long(mPBStats
097: .getReceivedExchanges()));
098: }
099:
100: /**
101: * Tests get/incrementSentBytes()
102: * @throws Exception if unexpected error occurs.
103: */
104: public void testIncrementSentBytes() {
105: int init = 0;
106: assertEquals("Failure on getIncrementSentBytes:",
107: new Long(init), new Long(mPBStats.getSentBytes()));
108: init++;
109: mPBStats.incrementSentBytes(init);
110:
111: assertEquals("Failure on incrementSentBytes:", new Long(init),
112: new Long(mPBStats.getSentBytes()));
113: }
114:
115: /**
116: * Tests get/incrementReceivedBytes()
117: * @throws Exception if unexpected error occurs.
118: */
119: public void testIncrementReceivedBytes() {
120: int init = 0;
121: assertEquals("Failure on getIncrementReceivedBytes:", new Long(
122: init), new Long(mPBStats.getReceivedBytes()));
123: init++;
124: mPBStats.incrementReceivedBytes(init);
125:
126: assertEquals("Failure on incrementReceivedBytes:", new Long(
127: init), new Long(mPBStats.getReceivedBytes()));
128: }
129:
130: /**
131: * Tests get/incrementSentMessages()
132: * @throws Exception if unexpected error occurs.
133: */
134: public void testIncrementSentMessages() {
135: int init = 0;
136: assertEquals("Failure on getIncrementSentMessages:", new Long(
137: init), new Long(mPBStats.getSentMessages()));
138: init++;
139: mPBStats.incrementSentMessages(init);
140:
141: assertEquals("Failure on incrementSentMessages:",
142: new Long(init), new Long(mPBStats.getSentMessages()));
143: }
144:
145: /**
146: * Tests get/incrementReceivedMessages()
147: * @throws Exception if unexpected error occurs.
148: */
149: public void testIncrementReceivedMessages() {
150: int init = 0;
151: assertEquals("Failure on getIncrementReceivedMessages:",
152: new Long(init),
153: new Long(mPBStats.getReceivedMessages()));
154: init++;
155: mPBStats.incrementReceivedMessages(init);
156:
157: assertEquals("Failure on incrementReceivedMessages:", new Long(
158: init), new Long(mPBStats.getReceivedMessages()));
159: }
160:
161: /**
162: * Tests get/incrementSentEvents()
163: * @throws Exception if unexpected error occurs.
164: */
165: public void testIncrementSentEvents() {
166: int init = 0;
167: assertEquals("Failure on getIncrementSentEvents:", new Long(
168: init), new Long(mPBStats.getSentEvents()));
169: init++;
170: mPBStats.incrementSentEvents();
171:
172: assertEquals("Failure on incrementSentEvents:", new Long(init),
173: new Long(mPBStats.getSentEvents()));
174: }
175:
176: /**
177: * Tests get/incrementReceivedEvents()
178: * @throws Exception if unexpected error occurs.
179: */
180: public void testIncrementReceivedEvents() {
181: int init = 0;
182: assertEquals("Failure on getIncrementReceivedEvents:",
183: new Long(init), new Long(mPBStats.getReceivedEvents()));
184: init++;
185: mPBStats.incrementReceivedEvents();
186:
187: assertEquals("Failure on incrementReceivedEvents:", new Long(
188: init), new Long(mPBStats.getReceivedEvents()));
189: }
190:
191: /**
192: * Tests get/incrementMessageFaults()
193: * @throws Exception if unexpected error occurs.
194: */
195: public void testIncrementMessageFaults() {
196: int init = 0;
197: assertEquals("Failure on getIncrementMessageFaults:", new Long(
198: init), new Long(mPBStats.getMessageFaults()));
199: init++;
200: mPBStats.incrementMessageFaults();
201:
202: assertEquals("Failure on incrementMessageFaults:", new Long(
203: init), new Long(mPBStats.getMessageFaults()));
204: }
205:
206: /**
207: * Tests get/incrementMessageErrors()
208: * @throws Exception if unexpected error occurs.
209: */
210: public void testIncrementMessageErrors() {
211: int init = 0;
212: assertEquals("Failure on getIncrementMessageErrors:", new Long(
213: init), new Long(mPBStats.getMessageErrors()));
214: init++;
215: mPBStats.incrementMessageErrors();
216:
217: assertEquals("Failure on incrementMessageErrors:", new Long(
218: init), new Long(mPBStats.getMessageErrors()));
219: }
220:
221: /**
222: * Tests get/incrementCompletedExchanges()
223: * @throws Exception if unexpected error occurs.
224: */
225: public void testIncrementCompletedExchanges() {
226: int init = 0;
227: assertEquals("Failure on getIncrementCompletedExchanges:",
228: new Long(init), new Long(mPBStats
229: .getCompletedExchanges()));
230: init++;
231: mPBStats.incrementCompletedExchanges();
232:
233: assertEquals("Failure on incrementMessageErrors:", new Long(
234: init), new Long(mPBStats.getCompletedExchanges()));
235: }
236:
237: /**
238: * Tests get/setNodeRestartTime()
239: * @throws Exception if unexpected error occurs.
240: */
241: public void testsetNodeRestartTime() {
242: Date now = new Date();
243: mPBStats.setNodeRestartTime(now);
244: assertEquals("Failure on getNodeLastRestartTime:", now,
245: mPBStats.getLastNodeRestartTime());
246: now = new Date();
247: mPBStats.setNodeRestartTime(now);
248:
249: assertEquals("Failure on setNodeRestartTime:", now, mPBStats
250: .getLastNodeRestartTime());
251: }
252: }
|