Skip to content

Package: StartUp_PTest

StartUp_PTest

nameinstructionbranchcomplexitylinemethod
StartUp_PTest()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getBundleStateText(int)
M: 16 C: 0
0%
M: 7 C: 0
0%
M: 7 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
test()
M: 33 C: 66
67%
M: 1 C: 7
88%
M: 1 C: 4
80%
M: 6 C: 16
73%
M: 0 C: 1
100%

Coverage

1: package org.eclipse.emf.ecp.integrationtest;
2:
3: import static org.junit.Assert.assertEquals;
4:
5: import java.util.ArrayList;
6: import java.util.LinkedHashSet;
7: import java.util.List;
8: import java.util.Set;
9:
10: import org.junit.Test;
11: import org.osgi.framework.Bundle;
12: import org.osgi.framework.BundleContext;
13:
14: public class StartUp_PTest {
15:
16:         @Test
17:         public void test() {
18:                 // get bundle instance via the OSGi Framework Util class
19:                 final BundleContext ctx = Activator.getContext();
20:                 try {
21:                         Thread.sleep(1000);
22:                 } catch (final InterruptedException e) {
23:                         // TODO Auto-generated catch block
24:                         e.printStackTrace();
25:                 }
26:
27:                 final Set<String> bundlesToIgnore = new LinkedHashSet<String>();
28:                 bundlesToIgnore.add("org.eclipse.emf.ecp.integrationtest");
29:                 bundlesToIgnore.add("org.eclipse.emf.ecp.makeithappen.wizards");
30:
31:                 final Bundle[] bundles = ctx.getBundles();
32:                 final List<String> list = new ArrayList<String>();
33:                 String result = "";
34:
35:•                for (final Bundle bundle : bundles) {
36:•                        if (bundle.getSymbolicName().contains("ecp")
37:•                                && !bundlesToIgnore.contains(bundle.getSymbolicName())) {
38:                                 final int state = bundle.getState();
39:
40:•                                if ((state & (Bundle.RESOLVED | Bundle.STARTING)) == 0) {
41:                                         final String string = "Plug is not resolved: "
42:                                                 + bundle.getSymbolicName() + " state: "
43:                                                 + getBundleStateText(state);
44:                                         list.add(string);
45:                                         result += string + "\n";
46:                                 }
47:
48:                         }
49:                 }
50:
51:                 assertEquals(result, 0, list.size());
52:         }
53:
54:         private String getBundleStateText(int state) {
55:•                switch (state) {
56:                 case Bundle.RESOLVED:
57:                         return "RESOLVED";
58:                 case Bundle.INSTALLED:
59:                         return "INSTALLED";
60:                 case Bundle.STARTING:
61:                         return "STARTING";
62:                 case Bundle.ACTIVE:
63:                         return "ACTIVE";
64:                 case Bundle.START_TRANSIENT:
65:                         return "START_TRANSIENT";
66:                 case Bundle.STOPPING:
67:                         return "STOPPING";
68:
69:                 default:
70:                         return "No State";
71:                 }
72:
73:         }
74: }