tmf: add JUnits for coalescing across parent/children providers
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.core.tests / stubs / org / eclipse / tracecompass / tmf / tests / stubs / trace / TmfExperimentStub.java
1 /*******************************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.tmf.tests.stubs.trace;
14
15 import java.lang.reflect.Method;
16 import java.util.LinkedList;
17 import java.util.List;
18
19 import org.eclipse.core.resources.IResource;
20 import org.eclipse.tracecompass.internal.tmf.core.request.TmfCoalescedEventRequest;
21 import org.eclipse.tracecompass.tmf.core.component.TmfEventProvider;
22 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
23 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
24 import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment;
25 import org.eclipse.tracecompass.tmf.core.trace.indexer.ITmfTraceIndexer;
26
27 /**
28 * <b><u>TmfExperimentStub</u></b>
29 * <p>
30 * Implement me. Please.
31 * <p>
32 */
33 @SuppressWarnings("javadoc")
34 public class TmfExperimentStub extends TmfExperiment {
35
36 /**
37 * Default constructor. Should not be called directly by the code, but
38 * needed for the extension point.
39 *
40 * @deprecated Only used by the extension point.
41 */
42 @Deprecated
43 public TmfExperimentStub() {
44 super();
45 }
46
47 public TmfExperimentStub(String name, ITmfTrace[] traces, int blockSize) {
48 super(ITmfEvent.class, name, traces, blockSize, null);
49 }
50
51 @Override
52 protected ITmfTraceIndexer createIndexer(int interval) {
53 return new TmfIndexerStub(this, interval);
54 }
55
56 @Override
57 public TmfIndexerStub getIndexer() {
58 return (TmfIndexerStub) super.getIndexer();
59 }
60
61 @Override
62 public void initExperiment(final Class<? extends ITmfEvent> type, final String path, final ITmfTrace[] traces, final int indexPageSize, IResource resource) {
63 super.initExperiment(type, path, traces, indexPageSize, resource);
64 }
65
66 /**
67 * @return a copy of the pending request list
68 * @throws Exception if java reflection failed
69 */
70 public List<TmfCoalescedEventRequest> getAllPendingRequests() throws Exception {
71 Method m = TmfEventProvider.class.getDeclaredMethod("getPendingRequests");
72 m.setAccessible(true);
73 LinkedList<?> list= (LinkedList<?>) m.invoke(this);
74 LinkedList<TmfCoalescedEventRequest> retList = new LinkedList<>();
75 for (Object element : list) {
76 retList.add((TmfCoalescedEventRequest) element);
77 }
78
79 return retList;
80 }
81
82 /**
83 * Clears the pending request list
84 * @throws Exception if java reflection failed
85 */
86 public void clearAllPendingRequests() throws Exception {
87 Method m = TmfEventProvider.class.getDeclaredMethod("clearPendingRequests");
88 m.setAccessible(true);
89 m.invoke(this);
90 }
91
92 /**
93 * Sets the timer flag
94 * @param enabled
95 * flag to set
96 * @throws Exception if java reflection failed
97 */
98 public void setTimerEnabledFlag(boolean enabled) throws Exception {
99 Class<?>[] paramTypes = new Class[1];
100 paramTypes[0] = Boolean.class;
101 Method m = TmfEventProvider.class.getDeclaredMethod("setTimerEnabled", paramTypes);
102
103 Object[] params = new Object[1];
104 params[0] = Boolean.valueOf(enabled);
105 m.setAccessible(true);
106 m.invoke(this, params);
107 }
108 }
This page took 0.047371 seconds and 6 git commands to generate.