Lines 34-39
Link Here
|
34 |
|
34 |
|
35 |
package org.netbeans.freemarker.templates; |
35 |
package org.netbeans.freemarker.templates; |
36 |
|
36 |
|
|
|
37 |
import java.io.File; |
37 |
import java.io.IOException; |
38 |
import java.io.IOException; |
38 |
import java.io.OutputStream; |
39 |
import java.io.OutputStream; |
39 |
import java.nio.charset.Charset; |
40 |
import java.nio.charset.Charset; |
Lines 42-47
Link Here
|
42 |
import java.util.Map; |
43 |
import java.util.Map; |
43 |
import javax.swing.text.DefaultEditorKit; |
44 |
import javax.swing.text.DefaultEditorKit; |
44 |
import javax.swing.text.Document; |
45 |
import javax.swing.text.Document; |
|
|
46 |
import static junit.framework.Assert.assertEquals; |
45 |
import org.netbeans.api.editor.mimelookup.MimePath; |
47 |
import org.netbeans.api.editor.mimelookup.MimePath; |
46 |
import org.netbeans.api.queries.FileEncodingQuery; |
48 |
import org.netbeans.api.queries.FileEncodingQuery; |
47 |
import org.netbeans.junit.MockServices; |
49 |
import org.netbeans.junit.MockServices; |
Lines 57-62
Link Here
|
57 |
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup; |
59 |
import org.netbeans.api.editor.mimelookup.test.MockMimeLookup; |
58 |
import org.openide.loaders.CreateFromTemplateHandler; |
60 |
import org.openide.loaders.CreateFromTemplateHandler; |
59 |
import org.openide.util.SharedClassObject; |
61 |
import org.openide.util.SharedClassObject; |
|
|
62 |
import org.openide.util.Utilities; |
60 |
import org.openide.util.test.MockLookup; |
63 |
import org.openide.util.test.MockLookup; |
61 |
|
64 |
|
62 |
/** |
65 |
/** |
Lines 141-146
Link Here
|
141 |
*/ |
144 |
*/ |
142 |
} |
145 |
} |
143 |
|
146 |
|
|
|
147 |
public void testExternalLicenseFile() throws Exception { |
148 |
File license = new File(getDataDir(), "licenseheader.txt"); |
149 |
assertTrue(license.exists()); |
150 |
FileObject root = FileUtil.createMemoryFileSystem().getRoot(); |
151 |
FileObject template = FileUtil.createData(root, "simple.pl"); |
152 |
OutputStream os = template.getOutputStream(); |
153 |
os.write("#!/usr/bin/perl\n<#include \"${licensePath}\">".getBytes()); |
154 |
os.close(); |
155 |
System.out.println(template.asText()); |
156 |
template.setAttribute("template", true); |
157 |
template.setAttribute("javax.script.ScriptEngine", "freemarker"); |
158 |
Map<String,Object> parameters = new HashMap<String,Object>(); |
159 |
parameters.put("licensePath", Utilities.toURI(license).toString()); |
160 |
FileObject inst = DataObject.find(template).createFromTemplate(DataFolder.findFolder(root), "pl", parameters).getPrimaryFile(); |
161 |
System.out.println(inst.asText()); |
162 |
assertTrue(inst.asText().contains("TEST LICENSE")); |
163 |
} |
164 |
|
144 |
//fix for this test was rolled back because of issue #120865 |
165 |
//fix for this test was rolled back because of issue #120865 |
145 |
public void XtestCreateFromTemplateDocumentCreated() throws Exception { |
166 |
public void XtestCreateFromTemplateDocumentCreated() throws Exception { |
146 |
FileObject root = FileUtil.createMemoryFileSystem().getRoot(); |
167 |
FileObject root = FileUtil.createMemoryFileSystem().getRoot(); |