|
64 | 64 | import org.eclipse.core.runtime.jobs.JobChangeAdapter; |
65 | 65 | import org.eclipse.core.runtime.preferences.IEclipsePreferences; |
66 | 66 | import org.eclipse.core.runtime.preferences.InstanceScope; |
| 67 | +import org.junit.Ignore; |
| 68 | +import org.junit.Test; |
67 | 69 | import org.osgi.service.prefs.BackingStoreException; |
68 | 70 |
|
69 | 71 | public class CharsetTest extends ResourceTest { |
@@ -193,6 +195,45 @@ public void _testBug67606() throws CoreException { |
193 | 195 | } |
194 | 196 | } |
195 | 197 |
|
| 198 | + @Test |
| 199 | + public void testCharsetMoveOnFileMove() throws CoreException { |
| 200 | + IWorkspace workspace = getWorkspace(); |
| 201 | + final IProject project = workspace.getRoot().getProject("MyProject"); |
| 202 | + try { |
| 203 | + final IFile file = project.getFile("file.txt"); |
| 204 | + ensureExistsInWorkspace(file, true); |
| 205 | + project.setDefaultCharset("FOO", getMonitor()); |
| 206 | + assertEquals("Setting up Projects default charset was successful", "FOO", file.getCharset()); |
| 207 | + file.setCharset("BAR", getMonitor()); |
| 208 | + assertEquals("Setting up file's explicit charset was successful", "BAR", file.getCharset()); |
| 209 | + file.move(project.getFullPath().append("file2.txt"), IResource.NONE, getMonitor()); |
| 210 | + IFile file2 = project.getFile("file2.txt"); |
| 211 | + assertExistsInWorkspace(file2, false); |
| 212 | + assertEquals("The file's charset was correctly copied while coying the file", "BAR", file2.getCharset()); |
| 213 | + } finally { |
| 214 | + ensureDoesNotExistInWorkspace(project); |
| 215 | + } |
| 216 | + } |
| 217 | + |
| 218 | + @Test |
| 219 | + @Ignore("https://github.com/eclipse-platform/eclipse.platform/issues/634") |
| 220 | + public void _testCopyFileCopiesCharset() throws CoreException { |
| 221 | + IWorkspace workspace = getWorkspace(); |
| 222 | + final IProject project = workspace.getRoot().getProject("MyProject"); |
| 223 | + try { |
| 224 | + ensureExistsInWorkspace(project, false); |
| 225 | + final IFile file = project.getFile("file.txt"); |
| 226 | + ensureExistsInWorkspace(file, true); |
| 227 | + file.setCharset("FOO", getMonitor()); |
| 228 | + assertEquals("File charset correctly set", file.getCharset(true), "FOO"); |
| 229 | + file.copy(project.getFullPath().append("file2.txt"), IResource.NONE, getMonitor()); |
| 230 | + final IFile copiedFile = project.getFile("file2.txt"); |
| 231 | + assertEquals("File with explicitly set charset keeps charset", copiedFile.getCharset(true), "FOO"); |
| 232 | + } finally { |
| 233 | + ensureDoesNotExistInWorkspace(project); |
| 234 | + } |
| 235 | + } |
| 236 | + |
196 | 237 | /** |
197 | 238 | * Asserts that the given resources have the given [default] charset. |
198 | 239 | */ |
|
0 commit comments