|
|
Re: Unit Test for DSL with dependent DSL [message #1245003 is a reply to message #1244331] |
Thu, 13 February 2014 06:36 |
Sebastian Neumann Messages: 9 Registered: December 2010 |
Junior Member |
|
|
Hi Christian,
I quickly set up the two DSLs. The MainDsl imports the SubDSL. For the ease of use both just define one element. I also added a test module using the DSLs.
Eventually the sub files will look like this:
Sub - hyperlink newPage {"//*abc" : XPATH}
Main - click newPage (where newPage is the element defined in the sub)
Now I want to write a unit test where I parse both language models, and when I assert the 'click' element, I want to have access to the hyperlink associated via the 'newPage" reference.
I hope that illustrates my problem. Pls let me know if you need further information; I appreciate your support!
Cheers,
Sebastian
[Updated on: Thu, 13 February 2014 06:37] Report message to a moderator
|
|
|
Re: Unit Test for DSL with dependent DSL [message #1245017 is a reply to message #1245003] |
Thu, 13 February 2014 07:03 |
|
Hmm this works strainght forward...
@InjectWith(typeof(ExtMainDslInjectorProvider))
@RunWith(typeof(XtextRunner))
class ClickHyperlinkTest {
@Inject extension ExtendedParseHelper<Model>
@Inject Provider <ResourceSet> rsp
/**
* Have to hack the test a bit in order to have access to both DSL (.define and .test)
*/
@Test
def void parseForms() {
val rs = rsp.get
'''
hyperlink newPage {"//*abc" : XPATH}
'''.parse(URI.createURI("test.sub"), rs)
val domainModel = '''
click newPage
'''.parse(rs)
assertEquals(ElementType.XPATH, domainModel.fields.get(0).link.findBy.type)
}
}
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Re: Unit Test for DSL with dependent DSL [message #1405461 is a reply to message #1245075] |
Thu, 07 August 2014 12:09 |
|
Hi,
Is there any way to read this content from file instead of hardcoding in code :
hyperlink newPage {"//*abc" : XPATH} This content should be read from file so that we can pass contents to parse() method.
I tried using parse(InputStream in, URI uriToUse, Map options,ResourceSet resourceSet) but not sure what to pass as options.
Please suggest.
Cheers
Kunal
|
|
|
|
Re: Unit Test for DSL with dependent DSL [message #1416000 is a reply to message #1405503] |
Thu, 04 September 2014 06:02 |
|
Hi,
For the above case of Running Junit for Dependent DSL's, If I try to run the Junit Test Case from command Line , I am getting below exception:
Guice configuration errors:
1) No implementation for javax.inject.Provider<org.eclipse.emf.ecore.resource.ResourceSet> was bound.
[java] while locating javax.inject.Provider<org.eclipse.emf.ecore.resource.ResourceSet>
[java] for field at com.mydsl.TestMyDsl.resourceSet(TestMyDsl.java:48)
[java] while locating com.mydsl.TestMyDsl
Any Clue, what would be the reason why Guice is not able to locate dependent dsl.
Cheers
Kunal
|
|
|
|
|
|
|
|
Re: Unit Test for DSL with dependent DSL [message #1419272 is a reply to message #1419126] |
Mon, 08 September 2014 11:02 |
|
Hi Christian,
Thanks for the reply, I figured out the issue in my code it was all due to below line :
@Inject
private Provider<ResourceSet> resourceSet;
It was unable to find the implementation class to inject the Provider class.
I modified the above declaration and used below code
try {
resourceSet = new Provider<ResourceSet>() {
@Override
public ResourceSet get() {
ResourceSet resourceSet = new ResourceSetImpl();
return resourceSet;
}
};
Thanks a lot for Reply.
Cheers
Kunal
|
|
|
Powered by
FUDForum. Page generated in 0.03293 seconds