|
Lines 1-5
Link Here
|
| 1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
| 2 |
* Copyright (c) 2005, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2005, 2011 IBM Corporation and others. |
| 3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
| 4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
|
Lines 36-41
Link Here
|
| 36 |
import org.eclipse.ui.dialogs.IOverwriteQuery; |
36 |
import org.eclipse.ui.dialogs.IOverwriteQuery; |
| 37 |
import org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation; |
37 |
import org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation; |
| 38 |
import org.eclipse.ui.internal.wizards.datatransfer.TarEntry; |
38 |
import org.eclipse.ui.internal.wizards.datatransfer.TarEntry; |
|
|
39 |
import org.eclipse.ui.internal.wizards.datatransfer.TarException; |
| 39 |
import org.eclipse.ui.internal.wizards.datatransfer.TarFile; |
40 |
import org.eclipse.ui.internal.wizards.datatransfer.TarFile; |
| 40 |
import org.eclipse.ui.tests.harness.util.FileUtil; |
41 |
import org.eclipse.ui.tests.harness.util.FileUtil; |
| 41 |
import org.eclipse.ui.tests.harness.util.UITestCase; |
42 |
import org.eclipse.ui.tests.harness.util.UITestCase; |
|
Lines 47-52
Link Here
|
| 47 |
private static final String ZIP_FILE_EXT = "zip"; |
48 |
private static final String ZIP_FILE_EXT = "zip"; |
| 48 |
private static final String TAR_FILE_EXT = "tar"; |
49 |
private static final String TAR_FILE_EXT = "tar"; |
| 49 |
private static final String[] directoryNames = { "dir1", "dir2" }; |
50 |
private static final String[] directoryNames = { "dir1", "dir2" }; |
|
|
51 |
private static final String[] emptyDirectoryNames = { "dir3" }; |
| 50 |
private static final String[] fileNames = { "file1.txt", "file2.txt" }; |
52 |
private static final String[] fileNames = { "file1.txt", "file2.txt" }; |
| 51 |
|
53 |
|
| 52 |
private String localDirectory; |
54 |
private String localDirectory; |
|
Lines 84-92
Link Here
|
| 84 |
|
86 |
|
| 85 |
operation.setUseCompression(false); |
87 |
operation.setUseCompression(false); |
| 86 |
operation.setUseTarFormat(false); |
88 |
operation.setUseTarFormat(false); |
| 87 |
openTestWindow().run(true, true, operation); |
89 |
operation.run(new NullProgressMonitor()); |
| 88 |
|
90 |
|
| 89 |
verifyFolders(directoryNames.length, ZIP_FILE_EXT); |
91 |
verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); |
| 90 |
|
92 |
|
| 91 |
} |
93 |
} |
| 92 |
|
94 |
|
|
Lines 99-105
Link Here
|
| 99 |
|
101 |
|
| 100 |
operation.setUseCompression(true); |
102 |
operation.setUseCompression(true); |
| 101 |
operation.setUseTarFormat(false); |
103 |
operation.setUseTarFormat(false); |
| 102 |
openTestWindow().run(true, true, operation); |
104 |
operation.run(new NullProgressMonitor()); |
| 103 |
verifyCompressed(ZIP_FILE_EXT); |
105 |
verifyCompressed(ZIP_FILE_EXT); |
| 104 |
} |
106 |
} |
| 105 |
|
107 |
|
|
Lines 123-131
Link Here
|
| 123 |
operation.setCreateLeadupStructure(false); |
125 |
operation.setCreateLeadupStructure(false); |
| 124 |
operation.setUseCompression(false); |
126 |
operation.setUseCompression(false); |
| 125 |
operation.setUseTarFormat(false); |
127 |
operation.setUseTarFormat(false); |
| 126 |
openTestWindow().run(true, true, operation); |
128 |
operation.run(new NullProgressMonitor()); |
| 127 |
flattenPaths = true; |
129 |
flattenPaths = true; |
| 128 |
verifyFolders(directoryNames.length, ZIP_FILE_EXT); |
130 |
verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); |
| 129 |
} |
131 |
} |
| 130 |
|
132 |
|
| 131 |
public void testExportZipCreateSelectedDirectoriesWithFolders() throws Exception { |
133 |
public void testExportZipCreateSelectedDirectoriesWithFolders() throws Exception { |
|
Lines 142-150
Link Here
|
| 142 |
operation.setCreateLeadupStructure(false); |
144 |
operation.setCreateLeadupStructure(false); |
| 143 |
operation.setUseCompression(false); |
145 |
operation.setUseCompression(false); |
| 144 |
operation.setUseTarFormat(false); |
146 |
operation.setUseTarFormat(false); |
| 145 |
openTestWindow().run(true, true, operation); |
147 |
operation.run(new NullProgressMonitor()); |
| 146 |
excludeProjectPath = true; |
148 |
excludeProjectPath = true; |
| 147 |
verifyFolders(directoryNames.length, ZIP_FILE_EXT); |
149 |
verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); |
| 148 |
} |
150 |
} |
| 149 |
|
151 |
|
| 150 |
public void testExportZipCreateSelectedDirectoriesCompressed() throws Exception { |
152 |
public void testExportZipCreateSelectedDirectoriesCompressed() throws Exception { |
|
Lines 167-176
Link Here
|
| 167 |
operation.setCreateLeadupStructure(false); |
169 |
operation.setCreateLeadupStructure(false); |
| 168 |
operation.setUseCompression(true); |
170 |
operation.setUseCompression(true); |
| 169 |
operation.setUseTarFormat(false); |
171 |
operation.setUseTarFormat(false); |
| 170 |
openTestWindow().run(true, true, operation); |
172 |
operation.run(new NullProgressMonitor()); |
| 171 |
flattenPaths = true; |
173 |
flattenPaths = true; |
| 172 |
verifyCompressed(ZIP_FILE_EXT); |
174 |
verifyCompressed(ZIP_FILE_EXT); |
| 173 |
verifyFolders(directoryNames.length, ZIP_FILE_EXT); |
175 |
verifyFolders(directoryNames.length + emptyDirectoryNames.length, ZIP_FILE_EXT); |
| 174 |
} |
176 |
} |
| 175 |
|
177 |
|
| 176 |
public void testExportTar() throws Exception { |
178 |
public void testExportTar() throws Exception { |
|
Lines 182-190
Link Here
|
| 182 |
operation.setUseTarFormat(true); |
184 |
operation.setUseTarFormat(true); |
| 183 |
operation.setUseCompression(false); |
185 |
operation.setUseCompression(false); |
| 184 |
|
186 |
|
| 185 |
openTestWindow().run(true, true, operation); |
187 |
operation.run(new NullProgressMonitor()); |
| 186 |
|
188 |
|
| 187 |
verifyFolders(directoryNames.length, TAR_FILE_EXT); |
189 |
verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); |
| 188 |
} |
190 |
} |
| 189 |
|
191 |
|
| 190 |
public void testExportTarCompressed() throws Exception { |
192 |
public void testExportTarCompressed() throws Exception { |
|
Lines 196-202
Link Here
|
| 196 |
|
198 |
|
| 197 |
operation.setUseTarFormat(true); |
199 |
operation.setUseTarFormat(true); |
| 198 |
operation.setUseCompression(true); |
200 |
operation.setUseCompression(true); |
| 199 |
openTestWindow().run(true, true, operation); |
201 |
operation.run(new NullProgressMonitor()); |
| 200 |
verifyCompressed(TAR_FILE_EXT); |
202 |
verifyCompressed(TAR_FILE_EXT); |
| 201 |
} |
203 |
} |
| 202 |
|
204 |
|
|
Lines 220-228
Link Here
|
| 220 |
operation.setCreateLeadupStructure(false); |
222 |
operation.setCreateLeadupStructure(false); |
| 221 |
operation.setUseCompression(false); |
223 |
operation.setUseCompression(false); |
| 222 |
operation.setUseTarFormat(true); |
224 |
operation.setUseTarFormat(true); |
| 223 |
openTestWindow().run(true, true, operation); |
225 |
operation.run(new NullProgressMonitor()); |
| 224 |
flattenPaths = true; |
226 |
flattenPaths = true; |
| 225 |
verifyFolders(directoryNames.length, TAR_FILE_EXT); |
227 |
verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); |
| 226 |
} |
228 |
} |
| 227 |
|
229 |
|
| 228 |
public void testExportTarCreateSelectedDirectoriesWithFolders() throws Exception { |
230 |
public void testExportTarCreateSelectedDirectoriesWithFolders() throws Exception { |
|
Lines 239-247
Link Here
|
| 239 |
operation.setCreateLeadupStructure(false); |
241 |
operation.setCreateLeadupStructure(false); |
| 240 |
operation.setUseCompression(false); |
242 |
operation.setUseCompression(false); |
| 241 |
operation.setUseTarFormat(true); |
243 |
operation.setUseTarFormat(true); |
| 242 |
openTestWindow().run(true, true, operation); |
244 |
operation.run(new NullProgressMonitor()); |
| 243 |
excludeProjectPath = true; |
245 |
excludeProjectPath = true; |
| 244 |
verifyFolders(directoryNames.length, TAR_FILE_EXT); |
246 |
verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); |
| 245 |
|
247 |
|
| 246 |
} |
248 |
} |
| 247 |
|
249 |
|
|
Lines 265-274
Link Here
|
| 265 |
operation.setCreateLeadupStructure(false); |
267 |
operation.setCreateLeadupStructure(false); |
| 266 |
operation.setUseCompression(true); |
268 |
operation.setUseCompression(true); |
| 267 |
operation.setUseTarFormat(true); |
269 |
operation.setUseTarFormat(true); |
| 268 |
openTestWindow().run(true, true, operation); |
270 |
operation.run(new NullProgressMonitor()); |
| 269 |
flattenPaths = true; |
271 |
flattenPaths = true; |
| 270 |
verifyCompressed(TAR_FILE_EXT); |
272 |
verifyCompressed(TAR_FILE_EXT); |
| 271 |
verifyFolders(directoryNames.length, TAR_FILE_EXT); |
273 |
verifyFolders(directoryNames.length + emptyDirectoryNames.length, TAR_FILE_EXT); |
| 272 |
|
274 |
|
| 273 |
} |
275 |
} |
| 274 |
|
276 |
|
|
Lines 324-329
Link Here
|
| 324 |
true, new NullProgressMonitor()); |
326 |
true, new NullProgressMonitor()); |
| 325 |
} |
327 |
} |
| 326 |
} |
328 |
} |
|
|
329 |
|
| 330 |
// create empty folders to test bug 278402 |
| 331 |
for(int i = 0; i < emptyDirectoryNames.length; i++){ |
| 332 |
IFolder folder = project.getFolder(emptyDirectoryNames[i]); |
| 333 |
folder.create(false, true, new NullProgressMonitor()); |
| 334 |
} |
| 327 |
} |
335 |
} |
| 328 |
catch(Exception e){ |
336 |
catch(Exception e){ |
| 329 |
fail(e.toString()); |
337 |
fail(e.toString()); |
|
Lines 358-364
Link Here
|
| 358 |
in.close(); |
366 |
in.close(); |
| 359 |
} |
367 |
} |
| 360 |
} |
368 |
} |
| 361 |
catch (Exception e){ |
369 |
catch (IOException e){ |
| 362 |
fail(e.getMessage()); |
370 |
fail(e.getMessage()); |
| 363 |
} |
371 |
} |
| 364 |
assertTrue(fileName + " does not appear to be compressed.", compressed); |
372 |
assertTrue(fileName + " does not appear to be compressed.", compressed); |
|
Lines 390-396
Link Here
|
| 390 |
else |
398 |
else |
| 391 |
verifyArchive(folderCount, allEntries); |
399 |
verifyArchive(folderCount, allEntries); |
| 392 |
} |
400 |
} |
| 393 |
catch (Exception e){ |
401 |
catch (IOException e){ |
|
|
402 |
fail(e.getMessage()); |
| 403 |
} |
| 404 |
catch (TarException e){ |
| 394 |
fail(e.getMessage()); |
405 |
fail(e.getMessage()); |
| 395 |
} |
406 |
} |
| 396 |
} |
407 |
} |
|
Lines 405-411
Link Here
|
| 405 |
int idx = entryName.lastIndexOf("/"); |
416 |
int idx = entryName.lastIndexOf("/"); |
| 406 |
String folderPath = entryName.substring(0, idx); |
417 |
String folderPath = entryName.substring(0, idx); |
| 407 |
String fileName = entryName.substring(idx+1, entryName.length()); |
418 |
String fileName = entryName.substring(idx+1, entryName.length()); |
| 408 |
files.add(fileName); |
419 |
// we get empty strings for folder entries, don't add them as a file name |
|
|
420 |
if (fileName.length() != 0) { |
| 421 |
files.add(fileName); |
| 422 |
} |
| 409 |
int idx2 = folderPath.lastIndexOf("/"); |
423 |
int idx2 = folderPath.lastIndexOf("/"); |
| 410 |
if (idx2 != -1){ |
424 |
if (idx2 != -1){ |
| 411 |
String folderName = folderPath.substring(idx2 + 1, folderPath.length()); |
425 |
String folderName = folderPath.substring(idx2 + 1, folderPath.length()); |
|
Lines 461-475
Link Here
|
| 461 |
if (directoryNames[i].equals(name)) |
475 |
if (directoryNames[i].equals(name)) |
| 462 |
return true; |
476 |
return true; |
| 463 |
} |
477 |
} |
|
|
478 |
for (int i = 0; i < emptyDirectoryNames.length; i++){ |
| 479 |
if (emptyDirectoryNames[i].equals(name)) |
| 480 |
return true; |
| 481 |
} |
| 464 |
return false; |
482 |
return false; |
| 465 |
} |
483 |
} |
| 466 |
|
484 |
|
| 467 |
private boolean isDirectory(IResource resource){ |
485 |
private boolean isDirectory(IResource resource){ |
| 468 |
for (int i = 0; i < directoryNames.length; i++){ |
486 |
return isDirectory(resource.getName()); |
| 469 |
if (directoryNames[i].equals(resource.getName())) |
|
|
| 470 |
return true; |
| 471 |
} |
| 472 |
return false; |
| 473 |
} |
487 |
} |
| 474 |
|
488 |
|
| 475 |
private boolean isFile(IResource resource){ |
489 |
private boolean isFile(IResource resource){ |