use of org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor in project mylyn.docs by eclipse.
the class TemplateProcessorTest method testBasicTemplatesNoParametersRecLoopDetection.
public void testBasicTemplatesNoParametersRecLoopDetection() {
// Bug 379783
Template template1 = new Template();
template1.setName("rec_a");
template1.setTemplateMarkup("+ rec_a {{rec_b}} rec_a +");
markupLanguage.getTemplates().add(template1);
Template template2 = new Template();
template2.setName("rec_b");
template2.setTemplateMarkup("+ rec_b {{rec_c}} rec_b +");
markupLanguage.getTemplates().add(template2);
Template template3 = new Template();
template3.setName("rec_c");
template3.setTemplateMarkup("+ rec_c {{rec_a}} rec_c +");
markupLanguage.getTemplates().add(template3);
TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
String markup = templateProcessor.processTemplates("{{rec_a}}");
assertEquals("+ rec_a + rec_b + rec_c <span class=\"error\">Template loop detected:rec_a</span> rec_c + rec_b + rec_a +", markup);
}
use of org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor in project mylyn.docs by eclipse.
the class TemplateProcessorTest method testBasicTemplatesNoParametersRec.
public void testBasicTemplatesNoParametersRec() {
// Bug 379783
Template templateFoo = new Template();
templateFoo.setName("foo");
templateFoo.setTemplateMarkup("_{{bar}}expanded_");
markupLanguage.getTemplates().add(templateFoo);
Template templateBar = new Template();
templateBar.setName("bar");
templateBar.setTemplateMarkup("+exp+");
markupLanguage.getTemplates().add(templateBar);
TemplateProcessor templateProcessor = new TemplateProcessor(markupLanguage);
String markup = templateProcessor.processTemplates("one {{foo}} two");
assertEquals("one _+exp+expanded_ two", markup);
}
use of org.eclipse.mylyn.wikitext.mediawiki.internal.TemplateProcessor in project mylyn.docs by eclipse.
the class WikiTemplateResolverTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
TestWikiTemplateResolver resolverUnderTest = new TestWikiTemplateResolver();
resolverUnderTest.setWikiBaseUrl("http://wiki.eclipse.org");
Map<String, String> serverContent = new HashMap<>();
serverContent.put("http://wiki.eclipse.org/index.php?title=Template%3Abug&action=raw", BUG_TEMPLATE_CONTENT);
serverContent.put("http://wiki.eclipse.org/index.php?title=Test&action=raw", TEST_TEMPLATE_CONTENT);
serverContent.put("http://wiki.eclipse.org/index.php?title=Other%3ATest&action=raw", OTHER_TEMPLATE_CONTENT);
resolverUnderTest.setServerContent(serverContent);
MediaWikiLanguage markupLanguage = new MediaWikiLanguage();
markupLanguage.getTemplateProviders().add(resolverUnderTest);
this.templateProcessor = new TemplateProcessor(markupLanguage);
this.resolver = resolverUnderTest;
}
Aggregations