blob: 09ea9a8566a061336ba306926e66515ff8e12686 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*******************************************************************************
* Copyright (c) 2014, 2016 Orange.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*******************************************************************************/
package org.eclipse.om2m.ipe.sdt.testsuite;
import org.eclipse.om2m.commons.constants.Constants;
import org.eclipse.om2m.core.service.CseService;
import org.eclipse.om2m.ipe.sdt.testsuite.subscription.SubscriptionTestSuite;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceReference;
import org.osgi.util.tracker.ServiceTracker;
import org.osgi.util.tracker.ServiceTrackerCustomizer;
public class Activator implements BundleActivator {
public static final String SDT_IPE_LOCATION = "/" + Constants.CSE_ID + "/" + Constants.CSE_NAME + "/SDT_IPE";
private BundleContext bundleContext;
private CseService cseService;
private ServiceTracker cseServiceTracker;
private SubscriptionTestSuite subscriptionTestSuite;
@Override
public void start(final BundleContext context) throws Exception {
bundleContext = context;
cseServiceTracker = new ServiceTracker(context, CseService.class.getName(), new ServiceTrackerCustomizer() {
@Override
public void removedService(ServiceReference reference, Object service) {
cseService = null;
}
@Override
public void modifiedService(ServiceReference reference, Object service) {
}
@Override
public Object addingService(ServiceReference reference) {
cseService = (CseService) context.getService(reference);
startTest();
return cseService;
}
});
cseServiceTracker.open();
// start tests
}
@Override
public void stop(BundleContext context) throws Exception {
// stop tests
if (subscriptionTestSuite != null) {
subscriptionTestSuite.stopTests();
Thread.sleep(5000);
subscriptionTestSuite.printTestReports();
}
}
public void startTest() {
try {
// DeviceDiscoveryTestSuite deviceDiscoveryTestSuite = new DeviceDiscoveryTestSuite(bundleContext, cseService);
// SDTModuleTestSuite moduleTestSuite = new SDTModuleTestSuite(bundleContext, cseService);
subscriptionTestSuite = new SubscriptionTestSuite(bundleContext, cseService);
} catch (Exception e) {
e.printStackTrace();
}
}
}
|