1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.tests
.request
;
16 import junit
.framework
.TestCase
;
18 import org
.eclipse
.linuxtools
.tmf
.event
.TmfEvent
;
19 import org
.eclipse
.linuxtools
.tmf
.request
.TmfCoalescedDataRequest
;
20 import org
.eclipse
.linuxtools
.tmf
.request
.TmfDataRequest
;
21 import org
.eclipse
.linuxtools
.tmf
.request
.TmfDataRequestStub
;
24 * <b><u>TmfCoalescedDataRequestTest</u></b>
26 * TODO: Implement me. Please.
28 public class TmfCoalescedDataRequestTest
extends TestCase
{
30 // ------------------------------------------------------------------------
32 // ------------------------------------------------------------------------
34 public TmfCoalescedDataRequestTest(String name
) {
39 public void setUp() throws Exception
{
43 public void tearDown() throws Exception
{
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
50 public void testTmfCoalescedDataRequest() {
51 TmfCoalescedDataRequest
<TmfEvent
> request
= new TmfCoalescedDataRequest
<TmfEvent
>(TmfEvent
.class);
53 assertEquals("getIndex", 0, request
.getIndex());
54 assertEquals("getNbRequestedEvents", TmfDataRequest
.ALL_DATA
, request
.getNbRequested());
55 assertEquals("getBlockize", TmfDataRequest
.DEFAULT_BLOCK_SIZE
, request
.getBlockize());
58 public void testTmfCoalescedDataRequestIndex() {
59 TmfCoalescedDataRequest
<TmfEvent
> request
= new TmfCoalescedDataRequest
<TmfEvent
>(TmfEvent
.class, 10);
61 assertEquals("getIndex", 10, request
.getIndex());
62 assertEquals("getNbRequestedEvents", TmfDataRequest
.ALL_DATA
, request
.getNbRequested());
63 assertEquals("getBlockize", TmfDataRequest
.DEFAULT_BLOCK_SIZE
, request
.getBlockize());
66 public void testTmfCoalescedDataRequestIndexNbRequested() {
67 TmfCoalescedDataRequest
<TmfEvent
> request
= new TmfCoalescedDataRequest
<TmfEvent
>(TmfEvent
.class, 10, 100);
69 assertEquals("getIndex", 10, request
.getIndex());
70 assertEquals("getNbRequestedEvents", 100, request
.getNbRequested());
71 assertEquals("getBlockize", TmfDataRequest
.DEFAULT_BLOCK_SIZE
, request
.getBlockize());
74 public void testTmfCoalescedDataRequestIndexNbEventsBlocksize() {
75 TmfCoalescedDataRequest
<TmfEvent
> request
= new TmfCoalescedDataRequest
<TmfEvent
>(TmfEvent
.class, 10, 100, 200);
77 assertEquals("getIndex", 10, request
.getIndex());
78 assertEquals("getNbRequestedEvents", 100, request
.getNbRequested());
79 assertEquals("getBlockize", 200, request
.getBlockize());
82 // ------------------------------------------------------------------------
84 // ------------------------------------------------------------------------
86 public void testIsCompatible() {
87 TmfCoalescedDataRequest
<TmfEvent
> coalescedRequest
= new TmfCoalescedDataRequest
<TmfEvent
>(TmfEvent
.class, 10, 100, 200);
88 TmfDataRequest
<TmfEvent
> request1
= new TmfDataRequestStub
<TmfEvent
>(TmfEvent
.class, 10, 100, 200);
89 TmfDataRequest
<TmfEvent
> request2
= new TmfDataRequestStub
<TmfEvent
>(TmfEvent
.class, 11, 100, 200);
90 TmfDataRequest
<TmfEvent
> request3
= new TmfDataRequestStub
<TmfEvent
>(TmfEvent
.class, 10, 101, 200);
91 TmfDataRequest
<TmfEvent
> request4
= new TmfDataRequestStub
<TmfEvent
>(TmfEvent
.class, 10, 100, 201);
93 assertTrue ("isCompatible", coalescedRequest
.isCompatible(request1
));
94 assertFalse("isCompatible", coalescedRequest
.isCompatible(request2
));
95 assertFalse("isCompatible", coalescedRequest
.isCompatible(request3
));
96 assertFalse("isCompatible", coalescedRequest
.isCompatible(request4
));