Skip to content

Package: EcoreHelperDefaultPackageRegistryContents_PTest

EcoreHelperDefaultPackageRegistryContents_PTest

nameinstructionbranchcomplexitylinemethod
EcoreHelperDefaultPackageRegistryContents_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%
installResourcesProject()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
setUpBeforeClass()
M: 2 C: 14
88%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 1 C: 6
86%
M: 0 C: 1
100%
tearDown()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
testGetDefaultPackageRegistryContentsWithIDEEcore()
M: 0 C: 31
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 9
100%
M: 0 C: 1
100%
testGetDefaultPackageRegistryContentsWithRegisteredIDEEcore()
M: 0 C: 33
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 10
100%
M: 0 C: 1
100%
testGetDefaultPackageRegistryContentsWithRegisteredWorkspaceEcore()
M: 3 C: 30
91%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 2 C: 7
78%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Johannes Faltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ide.util.test;
15:
16: import static org.junit.Assert.assertFalse;
17: import static org.junit.Assert.assertTrue;
18:
19: import java.io.IOException;
20:
21: import org.eclipse.core.resources.IProject;
22: import org.eclipse.core.resources.IWorkspaceRoot;
23: import org.eclipse.core.resources.ResourcesPlugin;
24: import org.eclipse.core.runtime.NullProgressMonitor;
25: import org.eclipse.emf.ecp.ide.spi.util.EcoreHelper;
26: import org.eclipse.jface.resource.JFaceResources;
27: import org.junit.After;
28: import org.junit.BeforeClass;
29: import org.junit.Test;
30:
31: public class EcoreHelperDefaultPackageRegistryContents_PTest {
32:
33:         private static final String A_ECORE_PATH = "/TestEcoreHelperProjectResources/A.ecore";
34:         private static final String A_NS_URI = "a.nsuri";
35:         private static final String VIEW_NS_URI = "http://org/eclipse/emf/ecp/view/model/1180";
36:         private static final String VIEW_ECORE_PATH = "/TestEcoreHelperProjectResources/view.ecore";
37:
38:         // BEGIN SUPRESS CATCH EXCEPTION
39:         @BeforeClass
40:         public static void setUpBeforeClass() throws Exception {
41:                 try {
42:                         JFaceResources.getImageRegistry();
43:                 } catch (final RuntimeException e) {
44:                         // expected fail, some strange initialization error is happing
45:                 }
46:                 final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
47:                 final IProject project = root.getProject("TestEcoreHelperProjectResources");
48:                 // create resources to register and unregister
49:•                if (!project.exists()) {
50:                         installResourcesProject();
51:                 }
52:         }
53:
54:         @After
55:         public void tearDown() throws Exception {
56:                 EcoreHelper.unregisterEcore(A_ECORE_PATH);
57:                 EcoreHelper.unregisterEcore(VIEW_ECORE_PATH);
58:         }
59:
60:         private static void installResourcesProject() throws Exception {
61:                 final ProjectInstallerWizard wiz = new ProjectInstallerWizard();
62:                 wiz.installExample(new NullProgressMonitor());
63:         }
64:         // END SUPRESS CATCH EXCEPTION
65:
66:         @Test
67:         public void testGetDefaultPackageRegistryContentsWithIDEEcore() {
68:                 final Object[] defaultPackageRegistryContents = EcoreHelper.getDefaultPackageRegistryContents();
69:                 boolean found = false;
70:•                for (final Object nsURI : defaultPackageRegistryContents) {
71:•                        if (VIEW_NS_URI.equals(nsURI)) {
72:                                 found = true;
73:                                 break;
74:                         }
75:                 }
76:                 assertTrue("The view model package was not returned.",
77:                         found);
78:         }
79:
80:         @Test
81:         public void testGetDefaultPackageRegistryContentsWithRegisteredIDEEcore() throws IOException {
82:                 EcoreHelper.registerEcore(VIEW_ECORE_PATH);
83:                 final Object[] defaultPackageRegistryContents = EcoreHelper.getDefaultPackageRegistryContents();
84:                 boolean found = false;
85:•                for (final Object nsURI : defaultPackageRegistryContents) {
86:•                        if (VIEW_NS_URI.equals(nsURI)) {
87:                                 found = true;
88:                                 break;
89:                         }
90:                 }
91:                 assertTrue("The view model package was not returned.",
92:                         found);
93:         }
94:
95:         @Test
96:         public void testGetDefaultPackageRegistryContentsWithRegisteredWorkspaceEcore() throws IOException {
97:                 EcoreHelper.registerEcore(A_ECORE_PATH);
98:                 final Object[] defaultPackageRegistryContents = EcoreHelper.getDefaultPackageRegistryContents();
99:                 boolean found = false;
100:•                for (final Object nsURI : defaultPackageRegistryContents) {
101:•                        if (A_NS_URI.equals(nsURI)) {
102:                                 found = true;
103:                                 break;
104:                         }
105:                 }
106:                 assertFalse("Workspace only Ecore was returned.", found);
107:         }
108: }