Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2009, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2009, 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 11-19
Link Here
|
11 |
package org.eclipse.team.tests.ccvs.ui; |
11 |
package org.eclipse.team.tests.ccvs.ui; |
12 |
|
12 |
|
13 |
import java.io.BufferedReader; |
13 |
import java.io.BufferedReader; |
|
|
14 |
import java.io.FileNotFoundException; |
15 |
import java.io.FileOutputStream; |
14 |
import java.io.IOException; |
16 |
import java.io.IOException; |
15 |
import java.io.InputStream; |
17 |
import java.io.InputStream; |
16 |
import java.io.InputStreamReader; |
18 |
import java.io.InputStreamReader; |
|
|
19 |
import java.io.PrintStream; |
17 |
import java.net.URL; |
20 |
import java.net.URL; |
18 |
|
21 |
|
19 |
import junit.framework.Test; |
22 |
import junit.framework.Test; |
Lines 26-32
Link Here
|
26 |
import org.eclipse.core.runtime.CoreException; |
29 |
import org.eclipse.core.runtime.CoreException; |
27 |
import org.eclipse.core.runtime.IPath; |
30 |
import org.eclipse.core.runtime.IPath; |
28 |
import org.eclipse.core.runtime.IProgressMonitor; |
31 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
|
32 |
import org.eclipse.core.runtime.IStatus; |
29 |
import org.eclipse.core.runtime.Path; |
33 |
import org.eclipse.core.runtime.Path; |
|
|
34 |
import org.eclipse.core.runtime.Status; |
30 |
import org.eclipse.jface.wizard.IWizardPage; |
35 |
import org.eclipse.jface.wizard.IWizardPage; |
31 |
import org.eclipse.jface.wizard.WizardDialog; |
36 |
import org.eclipse.jface.wizard.WizardDialog; |
32 |
import org.eclipse.swt.SWT; |
37 |
import org.eclipse.swt.SWT; |
Lines 35-40
Link Here
|
35 |
import org.eclipse.swt.widgets.Event; |
40 |
import org.eclipse.swt.widgets.Event; |
36 |
import org.eclipse.swt.widgets.Shell; |
41 |
import org.eclipse.swt.widgets.Shell; |
37 |
import org.eclipse.swt.widgets.Text; |
42 |
import org.eclipse.swt.widgets.Text; |
|
|
43 |
import org.eclipse.team.internal.ccvs.core.CVSException; |
44 |
import org.eclipse.team.internal.ccvs.core.CVSStatus; |
45 |
import org.eclipse.team.internal.ccvs.core.ICVSFolder; |
46 |
import org.eclipse.team.internal.ccvs.core.client.Command; |
47 |
import org.eclipse.team.internal.ccvs.core.client.Session; |
48 |
import org.eclipse.team.internal.ccvs.core.client.listeners.DiffListener; |
38 |
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; |
49 |
import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; |
39 |
import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard; |
50 |
import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard; |
40 |
import org.eclipse.team.tests.ccvs.core.EclipseTest; |
51 |
import org.eclipse.team.tests.ccvs.core.EclipseTest; |
Lines 279-282
Link Here
|
279 |
return event; |
290 |
return event; |
280 |
} |
291 |
} |
281 |
|
292 |
|
|
|
293 |
public void testBug319661() throws FileNotFoundException, CoreException { |
294 |
|
295 |
Session session = new Session(getRepository(), |
296 |
(ICVSFolder) getCVSResource(testProject)) { |
297 |
// Override the session so it always returns response with an error. |
298 |
private BufferedReader serverResp = new BufferedReader( |
299 |
new InputStreamReader( |
300 |
asInputStream("server_response_with_error.txt"))); |
301 |
|
302 |
|
303 |
public String readLine() throws CVSException { |
304 |
try { |
305 |
return serverResp.readLine(); |
306 |
} catch (IOException e) { |
307 |
throw new CVSException(new Status(IStatus.ERROR, null, |
308 |
null, e)); |
309 |
} |
310 |
} |
311 |
|
312 |
public void close() { |
313 |
try { |
314 |
super.close(); |
315 |
serverResp.close(); |
316 |
} catch (IOException e) { |
317 |
fail(e.getMessage()); |
318 |
} |
319 |
} |
320 |
}; |
321 |
|
322 |
PrintStream stream = new PrintStream(new FileOutputStream(testProject |
323 |
.getFile("/patch_with_error.txt").getLocation().toFile())); |
324 |
|
325 |
try { |
326 |
session.open(getMonitor()); |
327 |
|
328 |
DiffListener diffListener = new DiffListener(stream); |
329 |
|
330 |
IStatus status = Command.DIFF.execute(session, |
331 |
Command.NO_GLOBAL_OPTIONS, new Command.LocalOption[0], |
332 |
new String[0], diffListener, getMonitor()); |
333 |
|
334 |
assertNotNull( |
335 |
"Diff command did not report error when some changes were excluded", |
336 |
status); |
337 |
assertEquals("Diff command did not report server error", |
338 |
CVSStatus.SERVER_ERROR, status.getCode()); |
339 |
|
340 |
IStatus children[] = status.getChildren(); |
341 |
assertTrue("Diff command did not report any server errors", |
342 |
children.length > 0); |
343 |
|
344 |
boolean errorLineOccurred = false; |
345 |
for (int i = 0; i < children.length; i++) { |
346 |
if (children[i].getCode() == CVSStatus.ERROR_LINE) { |
347 |
errorLineOccurred = true; |
348 |
break; |
349 |
} |
350 |
} |
351 |
|
352 |
assertTrue("Diff command did not report error line", |
353 |
errorLineOccurred); |
354 |
|
355 |
} finally { |
356 |
session.close(); |
357 |
stream.close(); |
358 |
} |
359 |
} |
360 |
|
282 |
} |
361 |
} |