-
Notifications
You must be signed in to change notification settings - Fork 0
/
EmfParsleyDslPluginXmlGeneratorTests.xtend
169 lines (157 loc) · 5.16 KB
/
EmfParsleyDslPluginXmlGeneratorTests.xtend
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*******************************************************************************
* Copyright (c) 2013 RCP Vision (http://www.rcp-vision.com) and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Lorenzo Bettini - initial API and implementation
*******************************************************************************/
package org.eclipse.emf.parsley.dsl.tests
import com.google.inject.Inject
import org.eclipse.emf.parsley.dsl.EmfParsleyDslInjectorProvider
import org.eclipse.emf.parsley.dsl.generator.EmfParsleyDslOutputConfigurationProvider
import org.eclipse.emf.parsley.dsl.generator.EmfParsleyDslPluginXmlGenerator
import org.eclipse.emf.parsley.dsl.model.Module
import org.eclipse.xtext.generator.InMemoryFileSystemAccess
import org.eclipse.xtext.junit4.InjectWith
import org.eclipse.xtext.junit4.XtextRunner
import org.junit.Test
import org.junit.runner.RunWith
import org.eclipse.xtext.generator.IFileSystemAccess
@RunWith(typeof(XtextRunner))
@InjectWith(typeof(EmfParsleyDslInjectorProvider))
class EmfParsleyDslPluginXmlGeneratorTests extends EmfParsleyDslAbstractTests {
@Inject EmfParsleyDslPluginXmlGenerator pluginXmlGenerator
@Test
def void testEmptyContents() {
"".assertPluginXmlContents(
'''
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
</plugin>
'''
)
}
@Test
def void testViewExtensionPoint() {
'''
<view
category="org.eclipse.emf.parsley"
class="my.test.TestExecutableExtensionFactory:org.eclipse.emf.parsley.views.AbstractSaveableTreeView"
id="my.view.part"
name="My View"
restorable="true">
</view>
'''.assertEqualsStrings(
pluginXmlGenerator.generateExtensionPoint(
inputs.nonEmptyViewsSpecifications.partSpecification
)
)
}
@Test
def void testNoViewSpecification() {
inputs.emptyModule.module.assertPluginXmlContents("")
}
@Test
def void testSingleViewSpecification() {
inputs.nonEmptyViewsSpecifications.module.assertPluginXmlContents(
'''
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.views">
<view
category="org.eclipse.emf.parsley"
class="my.test.TestExecutableExtensionFactory:org.eclipse.emf.parsley.views.AbstractSaveableTreeView"
id="my.view.part"
name="My View"
restorable="true">
</view>
</extension>
</plugin>
'''
)
}
@Test
def void testMultipleViewSpecification() {
inputs.multipleViewsSpecifications.module.assertPluginXmlContents(
'''
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.views">
<view
category="org.eclipse.emf.parsley"
class="my.test.TestExecutableExtensionFactory:org.eclipse.emf.parsley.views.AbstractSaveableTreeView"
id="my.view.tree.part"
name="My Tree View"
restorable="true">
</view>
<view
category="my.view.category"
class="my.test.TestExecutableExtensionFactory:org.eclipse.emf.parsley.views.AbstractSaveableTreeFormView"
id="my.view.form.part"
name="My Tree Form View"
restorable="true">
</view>
</extension>
</plugin>
'''
)
}
@Test
def void testPluginXmlGen() {
inputs.multipleViewsSpecifications.
assertPluginXmlGeneration(
'''
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.views">
<view
category="org.eclipse.emf.parsley"
class="my.test.TestExecutableExtensionFactory:org.eclipse.emf.parsley.views.AbstractSaveableTreeView"
id="my.view.tree.part"
name="My Tree View"
restorable="true">
</view>
<view
category="my.view.category"
class="my.test.TestExecutableExtensionFactory:org.eclipse.emf.parsley.views.AbstractSaveableTreeFormView"
id="my.view.form.part"
name="My Tree Form View"
restorable="true">
</view>
</extension>
</plugin>
'''
)
}
def private void assertPluginXmlGeneration(CharSequence input, CharSequence expected) {
val access = new InMemoryFileSystemAccess();
val parsed = input.parseAndAssertNoError
pluginXmlGenerator.doGenerate(parsed.eResource(), access);
val textFiles = access.getTextFiles()
val entrySet = textFiles.entrySet()
// both the plugin.xml_emfparsley_gen and the plugin.xml
assertEqualsStrings(1, entrySet.size)
assertEqualsStrings(expected,
textFiles.get(
IFileSystemAccess.DEFAULT_OUTPUT +
"my/test/" + EmfParsleyDslOutputConfigurationProvider.PLUGIN_XML_GEN_FILE
)
)
}
def private void assertPluginXmlContents(Module module, CharSequence expected) {
assertEqualsStrings(expected, pluginXmlGenerator.generatePluginXml(module))
}
def private void assertPluginXmlContents(CharSequence contents, CharSequence expected) {
assertEqualsStrings(expected, pluginXmlGenerator.generatePluginXml(contents))
}
}