Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 131386 Details for
Bug 266812
[Tests] Add tests for creating/applying patches from UI
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch_B_v01
266812_B_v01.txt (text/plain), 20.20 KB, created by
Pawel Pogorzelski
on 2009-04-09 05:55:47 EDT
(
hide
)
Description:
Patch_B_v01
Filename:
MIME Type:
Creator:
Pawel Pogorzelski
Created:
2009-04-09 05:55:47 EDT
Size:
20.20 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.cvs.ui >Index: src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java,v >retrieving revision 1.63 >diff -u -r1.63 GenerateDiffFileWizard.java >--- src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java 26 Jan 2009 12:24:05 -0000 1.63 >+++ src/org/eclipse/team/internal/ccvs/ui/wizards/GenerateDiffFileWizard.java 9 Apr 2009 09:53:49 -0000 >@@ -129,6 +129,8 @@ > * The default values store used to initialize the selections. > */ > private final DefaultValuesStore store; >+ >+ private Job waitForChangesJob = null; > > > class LocationPageContentProvider extends BaseWorkbenchContentProvider { >@@ -974,10 +976,10 @@ > return Status.OK_STATUS; > } > } >- WaitForChangesJob job =new WaitForChangesJob(this); >+ waitForChangesJob = new WaitForChangesJob(this); > //Don't need the job in the UI, make it a system job >- job.setSystem(true); >- job.schedule(); >+ waitForChangesJob.setSystem(true); >+ waitForChangesJob.schedule(); > return fParticipant.getSyncInfoSet(); > } > >#P org.eclipse.team.tests.cvs.core >Index: src/org/eclipse/team/tests/ccvs/ui/AllUITests.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/AllUITests.java,v >retrieving revision 1.10 >diff -u -r1.10 AllUITests.java >--- src/org/eclipse/team/tests/ccvs/ui/AllUITests.java 3 Jun 2008 13:35:59 -0000 1.10 >+++ src/org/eclipse/team/tests/ccvs/ui/AllUITests.java 9 Apr 2009 09:53:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2007 IBM Corporation and others. >+ * Copyright (c) 2000, 2009 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -35,7 +35,8 @@ > suite.addTest(EditorTests.suite()); > suite.addTest(PatchWizardRadioButtonGroupTests.suite()); > suite.addTest(CVSProjectSetImportTest.suite()); >+ suite.addTest(CreatePatchTest.suite()); > return suite; > } >- >+ > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/plugin.xml,v >retrieving revision 1.33 >diff -u -r1.33 plugin.xml >--- plugin.xml 22 Sep 2008 16:05:32 -0000 1.33 >+++ plugin.xml 9 Apr 2009 09:53:51 -0000 >@@ -1,41 +1,8 @@ > <?xml version="1.0" encoding="UTF-8"?> > <?eclipse version="3.0"?> >-<plugin >- id="org.eclipse.team.tests.cvs.core" >- name="Eclipse CVS Tests Core" >- version="3.3.200" >- provider-name="Eclipse.org"> >- >- <runtime> >- <library name="cvstests.jar"> >- <export name="*"/> >- </library> >- </runtime> >- <requires> >- <import plugin="org.eclipse.ui.ide" optional="true"/> >- <import plugin="org.eclipse.ui.views" optional="true"/> >- <import plugin="org.eclipse.jface.text" optional="true"/> >- <import plugin="org.eclipse.ui.workbench.texteditor" optional="true"/> >- <import plugin="org.eclipse.ui.editors" optional="true"/> >- <import plugin="org.eclipse.core.tests.harness"/> >- <import plugin="org.eclipse.core.runtime.compatibility"/> >- <import plugin="org.eclipse.core.runtime"/> >- <import plugin="org.eclipse.core.resources"/> >- <import plugin="org.eclipse.team.core"/> >- <import plugin="org.eclipse.team.cvs.core"/> >- <import plugin="org.eclipse.team.ui"/> >- <import plugin="org.eclipse.team.cvs.ui"/> >- <import plugin="org.eclipse.compare"/> >- <import plugin="org.eclipse.ui"/> >- <import plugin="org.eclipse.update.core"/> >- <import plugin="org.junit"/> >- <import plugin="org.eclipse.team.tests.core"/> >- <import plugin="org.eclipse.test.performance"/> >- <import plugin="org.eclipse.core.tests.resources"/> >- <import plugin="org.eclipse.core.expressions"/> >- </requires> >- >+<plugin> > >+ > <!-- *************** Connection Methods **************** --> > <extension > id="pserver" >Index: build.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.tests.cvs.core/build.properties,v >retrieving revision 1.8 >diff -u -r1.8 build.properties >--- build.properties 3 Jun 2008 13:35:59 -0000 1.8 >+++ build.properties 9 Apr 2009 09:53:51 -0000 >@@ -15,5 +15,6 @@ > test.xml,\ > repository.properties,\ > resources/,\ >- icons/ >+ icons/,\ >+ META-INF/ > src.includes = resources/ >Index: src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java >diff -N src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/ui/CreatePatchTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,270 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.ui; >+ >+import java.io.BufferedReader; >+import java.io.IOException; >+import java.io.InputStream; >+import java.io.InputStreamReader; >+import java.lang.reflect.InvocationTargetException; >+import java.net.URL; >+ >+import junit.framework.Test; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.resources.IProject; >+import org.eclipse.core.resources.IResource; >+import org.eclipse.core.runtime.CoreException; >+import org.eclipse.core.runtime.IPath; >+import org.eclipse.core.runtime.Path; >+import org.eclipse.core.runtime.jobs.Job; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.widgets.Button; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Event; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Text; >+import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; >+import org.eclipse.team.internal.ccvs.ui.wizards.GenerateDiffFileWizard; >+import org.eclipse.team.tests.ccvs.core.EclipseTest; >+import org.eclipse.team.tests.ccvs.core.TeamCVSTestPlugin; >+import org.eclipse.ui.IWorkbenchPage; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PlatformUI; >+ >+public class CreatePatchTest extends EclipseTest { >+ >+ public static final String PATCHDATA = "patchdata"; >+ >+ private final static int INITIAL_WIDTH = 300; >+ private final static int INITIAL_HEIGHT = 350; >+ >+ private GenerateDiffFileWizard wizard = null; >+ private WizardDialog wizardDialog = null; >+ >+ private IProject testProject = null; >+ >+ public CreatePatchTest() { >+ super(); >+ } >+ >+ public CreatePatchTest(String name) { >+ super(name); >+ } >+ >+ public static Test suite() { >+ return suite(CreatePatchTest.class); >+ } >+ >+ protected void setUp() throws Exception { >+ super.setUp(); >+ testProject = createProject("ApplyPatchTest", new String[] {}); >+ } >+ >+ protected void tearDown() throws Exception { >+ super.tearDown(); >+ testProject.delete(true, null); >+ } >+ >+ public void testCreateWorkspacePatch() throws Exception { >+ copyIntoWorkspace("exp_addition.txt", "addition.txt"); >+ testProject.refreshLocal(IResource.DEPTH_INFINITE, null); >+ >+ openGenerateDiffFileWizard(new IResource[] { testProject }); >+ assertTrue(wizard.getPageCount() == 2); >+ >+ IWizardPage locationPage = wizard.getPages()[0]; >+ >+ getButton(locationPage, "cpRadio").setSelection(false); >+ getButton(locationPage, "fsRadio").setSelection(false); >+ getButton(locationPage, "wsRadio").setSelection(true); >+ getButton(locationPage, "wsRadio").notifyListeners(SWT.Selection, >+ createSelectionEvent()); >+ getText(locationPage, "wsPathText").setText( >+ "/" + testProject.getName() + "/patch_addition.txt"); >+ >+ processQueuedEvents(); >+ assertTrue(locationPage.canFlipToNextPage()); >+ callMethod(wizardDialog, "nextPressed", new Object[] {}); >+ >+ IWizardPage optionsPage = wizard.getPages()[1]; >+ >+ getButton(optionsPage, "unifiedDiffOption").setSelection(true); >+ getButton(optionsPage, "contextDiffOption").setSelection(false); >+ getButton(optionsPage, "regularDiffOption").setSelection(false); >+ getButton(optionsPage, "unified_workspaceRelativeOption").setSelection( >+ true); >+ getButton(optionsPage, "unified_projectRelativeOption").setSelection( >+ false); >+ getButton(optionsPage, "unified_selectionRelativeOption").setSelection( >+ false); >+ >+ processQueuedEvents(); >+ assertTrue(wizard.canFinish()); >+ wizard.performFinish(); >+ wizardDialog.close(); >+ >+ // Ignore lines prefixed with following values to avoid timestamps >+ // mismatches >+ String prefixesToIgnore[] = new String[] { "#P ApplyPatchTest-", >+ "--- /dev/null", "+++ addition.txt" }; >+ >+ InputStream expectedIS = asInputStream("patch_addition.txt"); >+ String expected = filterStream(expectedIS, prefixesToIgnore); >+ >+ testProject.refreshLocal(IResource.DEPTH_INFINITE, null); >+ IFile patchFile = testProject.getFile("patch_addition.txt"); >+ String actual = filterStream(patchFile.getContents(), prefixesToIgnore); >+ >+ assertEquals(expected, actual); >+ } >+ >+ private void openGenerateDiffFileWizard(IResource resources[]) { >+ String title = CVSUIMessages.GenerateCVSDiff_title; >+ wizard = new GenerateDiffFileWizard(getActivePart(), resources, true); >+ wizard.setWindowTitle(title); >+ wizardDialog = new WizardDialog(getShell(), wizard); >+ wizardDialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); >+ wizardDialog.setBlockOnOpen(false); >+ wizardDialog.open(); >+ >+ WizardPage locationPage = (WizardPage) getField(wizard, "locationPage"); >+ Job waitForChanges = (Job) getField(locationPage, "waitForChangesJob"); >+ waitForJobCompletion(waitForChanges); >+ } >+ >+ private void copyIntoWorkspace(String source, String target) { >+ IFile file = testProject.getFile(target); >+ InputStream is = asInputStream(source); >+ try { >+ if (file.exists()) { >+ file.setContents(is, true, true, null); >+ } else { >+ file.create(is, true, null); >+ } >+ } catch (CoreException e) { >+ fail(e.getMessage()); >+ } >+ } >+ >+ private String filterStream(InputStream stream, String prefixesToIgnore[]) { >+ BufferedReader reader = new BufferedReader( >+ new InputStreamReader(stream)); >+ String line = null; >+ StringBuffer buffer = new StringBuffer(); >+ try { >+ while ((line = reader.readLine()) != null) { >+ boolean ignore = false; >+ for (int i = 0; i < prefixesToIgnore.length && !ignore; i++) { >+ line.startsWith(prefixesToIgnore[i]); >+ ignore = true; >+ } >+ if (!ignore) { >+ buffer.append(line + "\n"); >+ } >+ } >+ } catch (IOException e) { >+ fail(e.getMessage()); >+ } >+ String ret = buffer.toString(); >+ try { >+ reader.close(); >+ } catch (IOException e) { >+ fail(e.getMessage()); >+ } >+ return ret; >+ } >+ >+ private InputStream asInputStream(String name) { >+ IPath path = new Path(PATCHDATA).append(name); >+ try { >+ URL base = TeamCVSTestPlugin.getDefault().getBundle().getEntry("/"); >+ URL url = new URL(base, path.toString()); >+ return url.openStream(); >+ } catch (IOException e) { >+ fail("Failed while reading " + name); >+ return null; >+ } >+ } >+ >+ private Text getText(Object object, String name) { >+ return (Text) getField(object, name); >+ } >+ >+ private Button getButton(Object object, String name) { >+ return (Button) getField(object, name); >+ } >+ >+ private Object getField(Object object, String name) { >+ Object ret = null; >+ try { >+ ret = ReflectionUtils.getField(object, name); >+ } catch (IllegalArgumentException e) { >+ fail(e.getMessage()); >+ } catch (SecurityException e) { >+ fail(e.getMessage()); >+ } catch (IllegalAccessException e) { >+ fail(e.getMessage()); >+ } catch (NoSuchFieldException e) { >+ fail(e.getMessage()); >+ } >+ return ret; >+ } >+ >+ private Object callMethod(Object object, String name, Object args[]) { >+ Object ret = null; >+ try { >+ ret = ReflectionUtils.callMethod(object, name, args); >+ } catch (IllegalArgumentException e) { >+ fail(e.getMessage()); >+ } catch (IllegalAccessException e) { >+ fail(e.getMessage()); >+ } catch (InvocationTargetException e) { >+ fail(e.getMessage()); >+ } catch (NoSuchMethodException e) { >+ fail(e.getMessage()); >+ } >+ return ret; >+ } >+ >+ private Shell getShell() { >+ return getActivePart().getSite().getShell(); >+ } >+ >+ private IWorkbenchPart getActivePart() { >+ IWorkbenchWindow window = PlatformUI.getWorkbench() >+ .getActiveWorkbenchWindow(); >+ if (window == null) { >+ return null; >+ } >+ IWorkbenchPage page = window.getActivePage(); >+ if (page == null) { >+ return null; >+ } >+ return page.getActivePart(); >+ } >+ >+ private void processQueuedEvents() { >+ while (Display.getCurrent().readAndDispatch()) { >+ } >+ } >+ >+ private Event createSelectionEvent() { >+ Event event = new Event(); >+ event.type = SWT.Selection; >+ return event; >+ } >+ >+} >Index: META-INF/MANIFEST.MF >=================================================================== >RCS file: META-INF/MANIFEST.MF >diff -N META-INF/MANIFEST.MF >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ META-INF/MANIFEST.MF 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,41 @@ >+Manifest-Version: 1.0 >+Bundle-ManifestVersion: 2 >+Bundle-Name: Eclipse CVS Tests Core >+Bundle-SymbolicName: org.eclipse.team.tests.cvs.core; singleton:=true >+Bundle-Version: 3.3.200 >+Bundle-ClassPath: cvstests.jar >+Bundle-Activator: org.eclipse.team.tests.ccvs.core.TeamCVSTestPlugin >+Bundle-Vendor: Eclipse.org >+Bundle-Localization: plugin >+Export-Package: org.eclipse.team.tests.ccvs.core, >+ org.eclipse.team.tests.ccvs.core.compatible, >+ org.eclipse.team.tests.ccvs.core.cvsresources, >+ org.eclipse.team.tests.ccvs.core.mappings, >+ org.eclipse.team.tests.ccvs.core.provider, >+ org.eclipse.team.tests.ccvs.core.subscriber, >+ org.eclipse.team.tests.ccvs.ui, >+ org.eclipse.team.tests.ccvs.ui.benchmark >+Require-Bundle: org.eclipse.ui.ide;resolution:=optional, >+ org.eclipse.ui.views;resolution:=optional, >+ org.eclipse.jface.text;resolution:=optional, >+ org.eclipse.ui.workbench.texteditor;resolution:=optional, >+ org.eclipse.ui.editors;resolution:=optional, >+ org.eclipse.core.tests.harness, >+ org.eclipse.core.runtime.compatibility, >+ org.eclipse.core.runtime, >+ org.eclipse.core.resources, >+ org.eclipse.team.core, >+ org.eclipse.team.cvs.core, >+ org.eclipse.team.ui, >+ org.eclipse.team.cvs.ui, >+ org.eclipse.compare, >+ org.eclipse.ui, >+ org.eclipse.update.core, >+ org.junit, >+ org.eclipse.team.tests.core, >+ org.eclipse.test.performance, >+ org.eclipse.core.tests.resources, >+ org.eclipse.core.expressions >+Bundle-ActivationPolicy: lazy >+Eclipse-AutoStart: true >+Plugin-Class: org.eclipse.team.tests.ccvs.core.TeamCVSTestPlugin >Index: src/org/eclipse/team/tests/ccvs/ui/ReflectionUtils.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/ui/ReflectionUtils.java >diff -N src/org/eclipse/team/tests/ccvs/ui/ReflectionUtils.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/ui/ReflectionUtils.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,56 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.ui; >+ >+import java.lang.reflect.Field; >+import java.lang.reflect.InvocationTargetException; >+import java.lang.reflect.Method; >+ >+public class ReflectionUtils { >+ >+ public static Object callMethod(Object object, String name, Object args[]) >+ throws IllegalArgumentException, IllegalAccessException, >+ InvocationTargetException, NoSuchMethodException { >+ Class types[] = new Class[args.length]; >+ for (int i = 0; i < args.length; i++) { >+ types[i] = args[i].getClass(); >+ } >+ Method method = null; >+ Class clazz = object.getClass(); >+ NoSuchMethodException ex = null; >+ while (method == null && clazz != null) { >+ try { >+ method = clazz.getDeclaredMethod(name, types); >+ } catch (NoSuchMethodException e) { >+ if (ex == null) { >+ ex = e; >+ } >+ clazz = clazz.getSuperclass(); >+ } >+ } >+ if (method == null) { >+ throw ex; >+ } >+ method.setAccessible(true); >+ Object ret = method.invoke(object, args); >+ return ret; >+ } >+ >+ public static Object getField(Object object, String name) >+ throws IllegalArgumentException, IllegalAccessException, >+ SecurityException, NoSuchFieldException { >+ Field field = object.getClass().getDeclaredField(name); >+ field.setAccessible(true); >+ Object ret = field.get(object); >+ return ret; >+ } >+ >+} >\ No newline at end of file >Index: patchdata/patch_addition.txt >=================================================================== >RCS file: patchdata/patch_addition.txt >diff -N patchdata/patch_addition.txt >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ patchdata/patch_addition.txt 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,18 @@ >+### Eclipse Workspace Patch 1.0 >+#P ApplyPatchTest- >+Index: addition.txt >+=================================================================== >+RCS file: addition.txt >+diff -N addition.txt >+--- /dev/null >++++ addition.txt >+@@ -0,0 +1,9 @@ >++[1] >++[2] >++[3] >++[4] >++[5] >++[6] >++[7] >++[8] >++[9] >Index: src/org/eclipse/team/tests/ccvs/core/TeamCVSTestPlugin.java >=================================================================== >RCS file: src/org/eclipse/team/tests/ccvs/core/TeamCVSTestPlugin.java >diff -N src/org/eclipse/team/tests/ccvs/core/TeamCVSTestPlugin.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/team/tests/ccvs/core/TeamCVSTestPlugin.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,27 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.team.tests.ccvs.core; >+ >+import org.eclipse.core.runtime.Plugin; >+ >+public class TeamCVSTestPlugin extends Plugin { >+ >+ private static TeamCVSTestPlugin fgPlugin; >+ >+ public TeamCVSTestPlugin() { >+ fgPlugin = this; >+ } >+ >+ public static TeamCVSTestPlugin getDefault() { >+ return fgPlugin; >+ } >+ >+} >Index: patchdata/exp_addition.txt >=================================================================== >RCS file: patchdata/exp_addition.txt >diff -N patchdata/exp_addition.txt >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ patchdata/exp_addition.txt 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,9 @@ >+[1] >+[2] >+[3] >+[4] >+[5] >+[6] >+[7] >+[8] >+[9]
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 266812
:
131127
|
131136
|
131383
|
131386
|
131388
|
131851