Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaul Pazderski2019-05-17 11:10:34 +0000
committerPaul Pazderski2019-05-18 12:52:49 +0000
commit5e9e26b1abe5bd1df37faa91fde2d87fd79ed06b (patch)
tree8e5ee9064468d7d051715dcb67637b08e0c01ad0 /tests
parent47b1fa3fbb58588f218c6138e4bcd9ecbcc5d036 (diff)
downloadeclipse.platform.team-5e9e26b1abe5bd1df37faa91fde2d87fd79ed06b.tar.gz
eclipse.platform.team-5e9e26b1abe5bd1df37faa91fde2d87fd79ed06b.tar.xz
eclipse.platform.team-5e9e26b1abe5bd1df37faa91fde2d87fd79ed06b.zip
Bug 547304 - [cleanup] Fix wrong line delimiters
This updates all Java files with wrong or mixed line delimiters to use Unix style delimiters. The change includes only whitespace formatting and no code changes. Change-Id: I1f6bc53b2a6827208b42ec562a855874d9ce69ae
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java862
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java508
2 files changed, 685 insertions, 685 deletions
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
index 3e2f44306..265450dde 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
@@ -1,434 +1,434 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2013 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011, 2013 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ui;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.Test;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareViewerSwitchingPane;
-import org.eclipse.compare.ITypedElement;
-import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
-import org.eclipse.compare.internal.CompareEditor;
-import org.eclipse.compare.internal.CompareUIPlugin;
-import org.eclipse.compare.internal.MergeSourceViewer;
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.compare.structuremergeviewer.ICompareInput;
-import org.eclipse.compare.tests.ReflectionUtils;
-import org.eclipse.core.internal.runtime.RuntimeLog;
-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.ILogListener;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.internal.ui.mapping.AbstractCompareInput;
-import org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier;
-import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
-import org.eclipse.team.internal.ui.synchronize.SaveablesCompareEditorInput;
-import org.eclipse.team.tests.core.TeamTest;
-import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
-import org.eclipse.ui.PlatformUI;
-
-public class SaveableCompareEditorInputTest extends TeamTest {
-
- public static Test suite() {
- return suite(SaveableCompareEditorInputTest.class);
- }
-
- private static final String COMPARE_EDITOR = CompareUIPlugin.PLUGIN_ID
- + ".CompareEditor"; //$NON-NLS-1$
-
- private IFile file1;
- private IFile file2;
- private String appendFileContents = "_append";
- private String fileContents1 = "FileContents";
- private String fileContents2 = "FileContents2";
- private TestLogListener logListener = new TestLogListener();
- private IProject project;
-
- protected void setUp() throws Exception {
- super.setUp();
-
- project = createProject("Project_", new String[] {
- "File1.txt", "File2.txt" });
-
- file1 = project.getFile("File1.txt");
- file2 = project.getFile("File2.txt");
- file1.setContents(new ByteArrayInputStream(fileContents1.getBytes()),
- true, true, null);
- file2.setContents(new ByteArrayInputStream(fileContents2.getBytes()),
- true, true, null);
-
- RuntimeLog.addLogListener(logListener);
- }
-
- protected void tearDown() throws Exception {
- // remove log listener
- RuntimeLog.removeLogListener(logListener);
- super.tearDown();
- }
-
- private class TestFileElement implements ITypedElement {
-
- private IFile file;
-
- public IFile getFile() {
- return file;
- }
-
- public TestFileElement(IFile file) {
- super();
- this.file = file;
- }
-
- public String getName() {
- return file.getName();
- }
-
- public Image getImage() {
- return null;
- }
-
- public String getType() {
- return TEXT_TYPE;
- }
- }
-
- private class TestLogListener implements ILogListener {
- public void logging(IStatus status, String plugin) {
- if (status.getSeverity() == IStatus.ERROR)
- fail(status.toString());
- }
- }
-
- private class TestDiffNode extends AbstractCompareInput {
-
- private CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() {
-
- private IResource getResource(ITypedElement el) {
- if (el instanceof LocalResourceTypedElement) {
- return ((LocalResourceTypedElement) el).getResource();
- }
- if (el instanceof TestFileElement) {
- return ((TestFileElement) el).getFile();
- }
- return null;
- }
-
- protected IResource[] getResources(ICompareInput input) {
-
- List resources = new ArrayList();
- if (getResource(getLeft()) != null) {
- resources.add(getResource(getLeft()));
- }
- if (getResource(getRight()) != null) {
- resources.add(getResource(getRight()));
- }
- return (IResource[]) resources.toArray(new IResource[2]);
- }
- };
-
- public TestDiffNode(ITypedElement left, ITypedElement right) {
- super(Differencer.CHANGE, null, left, right);
- }
-
- public void fireChange() {
- super.fireChange();
- }
-
- protected CompareInputChangeNotifier getChangeNotifier() {
- return notifier;
- }
-
- public boolean needsUpdate() {
- // The remote never changes
- return false;
- }
-
- public void update() {
- fireChange();
- }
- }
-
- private class TestSaveableEditorInput extends SaveableCompareEditorInput {
-
- protected ITypedElement left;
- protected ITypedElement right;
- private ICompareInput input;
-
- public Object getCompareResult() {
- return input;
- }
-
- public TestSaveableEditorInput(ITypedElement left, ITypedElement right,
- CompareConfiguration conf) {
- super(conf, PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage());
- this.left = left;
- this.right = right;
- }
-
- protected ICompareInput prepareCompareInput(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- input = createCompareInput();
- getCompareConfiguration().setLeftEditable(true);
- getCompareConfiguration().setRightEditable(false);
- return null;
- }
-
- private ICompareInput createCompareInput() {
- return new TestDiffNode(left, right);
- }
-
- protected void fireInputChange() {
- ((TestDiffNode) getCompareResult()).fireChange();
- }
- }
-
- private void verifyDirtyStateChanges(
- TestSaveableEditorInput compareEditorInput)
- throws IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getShell();
-
- TextMergeViewer viewer = (TextMergeViewer) compareEditorInput
- .findContentViewer(null, compareEditorInput.input, shell);
- viewer.setInput(compareEditorInput.getCompareResult());
-
- MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField(
- viewer, "fLeft");
-
- StyledText leftText = left.getSourceViewer().getTextWidget();
-
- // modify the left side of editor
- leftText.append(appendFileContents);
-
- assertTrue(compareEditorInput.isDirty());
-
- // save editor
- viewer.flush(null);
-
- assertFalse(compareEditorInput.isDirty());
- }
-
- public void testDirtyFlagOnLocalResourceTypedElement()
- throws CoreException, InvocationTargetException,
- InterruptedException, IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException,
- NoSuchMethodException, IOException {
-
- // Create left element by SaveableCompareEditorInput to be properly
- // saved, see javadoc to SaveableCompareEditorInput
- LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
- .createFileElement(file1);
- ITypedElement el2 = new TestFileElement(file2);
-
- CompareConfiguration conf = new CompareConfiguration();
- conf.setLeftEditable(true);
- TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
- el1, el2, conf);
-
- compareEditorInput.prepareCompareInput(null);
-
- verifyDirtyStateChanges(compareEditorInput);
-
- // check whether file was saved
-
- assertTrue(compareContent(new ByteArrayInputStream(
- (fileContents1 + appendFileContents).getBytes()),
- file1.getContents()));
- }
-
- public void testDirtyFlagOnCustomTypedElement() throws CoreException,
- InvocationTargetException, InterruptedException,
- IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException,
- NoSuchMethodException, IOException {
-
- ITypedElement el1 = new TestFileElement(file1);
- ITypedElement el2 = new TestFileElement(file2);
-
- CompareConfiguration conf = new CompareConfiguration();
- conf.setLeftEditable(true);
- TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
- el1, el2, conf);
-
- compareEditorInput.prepareCompareInput(null);
-
- verifyDirtyStateChanges(compareEditorInput);
-
- /*
- * not checking if changes were saved because in this case saving is not
- * handled, see javadoc to SaveableCompareEditorInput.
- */
- }
-
- public void testDirtyFlagOnLocalResourceTypedElementAndEmptyRight()
- throws CoreException, InvocationTargetException,
- InterruptedException, IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException,
- NoSuchMethodException, IOException {
-
- // Create left element by SaveableCompareEditorInput to be properly
- // saved, see javadoc to SaveableCompareEditorInput
- LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
- .createFileElement(file1);
- ITypedElement el2 = null;
-
- CompareConfiguration conf = new CompareConfiguration();
- conf.setLeftEditable(true);
- TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
- el1, el2, conf);
-
- compareEditorInput.prepareCompareInput(null);
-
- verifyDirtyStateChanges(compareEditorInput);
-
- // check whether file was saved
-
- assertTrue(compareContent(new ByteArrayInputStream(
- (fileContents1 + appendFileContents).getBytes()),
- file1.getContents()));
- }
-
- public void testDirtyFlagOnCustomTypedElementAndEmptyRight()
- throws CoreException, InvocationTargetException,
- InterruptedException, IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException,
- NoSuchMethodException, IOException {
-
- ITypedElement el1 = new TestFileElement(file1);
- ITypedElement el2 = null;
-
- CompareConfiguration conf = new CompareConfiguration();
- conf.setLeftEditable(true);
- TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
- el1, el2, conf);
-
- compareEditorInput.prepareCompareInput(null);
-
- verifyDirtyStateChanges(compareEditorInput);
-
- /*
- * not checking if changes were saved because in this case saving is not
- * handled, see javadoc to SaveableCompareEditorInput.
- */
- }
-
- private void verifyModifyAndSaveBothSidesOfCompareEditor(String extention)
- throws InterruptedException, InvocationTargetException,
- IllegalArgumentException, SecurityException,
- IllegalAccessException, NoSuchFieldException, CoreException {
-
- // create files to compare
- IFile file1 = project.getFile("CompareFile1." + extention);
- IFile file2 = project.getFile("CompareFile2." + extention);
- file1.create(new ByteArrayInputStream(fileContents1.getBytes()), true,
- null);
- file2.create(new ByteArrayInputStream(fileContents2.getBytes()), true,
- null);
-
- // prepare comparison
- SaveablesCompareEditorInput input = new SaveablesCompareEditorInput(
- null, SaveablesCompareEditorInput.createFileElement(file1),
- SaveablesCompareEditorInput.createFileElement(file2),
- PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage());
- input.run(null);
-
- // open CompareEditor
- CompareEditor editor = (CompareEditor) PlatformUI.getWorkbench()
- .getActiveWorkbenchWindow().getActivePage()
- .openEditor(input, COMPARE_EDITOR, true);
-
- CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) ReflectionUtils
- .getField(input, "fContentInputPane", true);
-
- Viewer viewer = pane.getViewer();
-
- MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField(
- viewer, "fLeft", true);
- MergeSourceViewer right = (MergeSourceViewer) ReflectionUtils.getField(
- viewer, "fRight", true);
-
- // modify both sides of CompareEditor
- StyledText leftText = left.getSourceViewer().getTextWidget();
- StyledText rightText = right.getSourceViewer().getTextWidget();
- leftText.append(appendFileContents);
- rightText.append(appendFileContents);
-
- // save both sides
- editor.doSave(null);
-
- assertFalse(editor.isDirty());
-
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
- .closeEditor(editor, false);
-
- // validate if both sides where saved
- assertTrue(compareContent(new ByteArrayInputStream(
- (fileContents1 + appendFileContents).getBytes()),
- file1.getContents()));
- assertTrue(compareContent(new ByteArrayInputStream(
- (fileContents2 + appendFileContents).getBytes()),
- file2.getContents()));
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorHtml()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("html");
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorTxt()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("txt");
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorJava()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("java");
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorXml()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("xml");
- }
-
- public void testModifyAndSaveBothSidesOfCompareEditorProperties()
- throws IllegalArgumentException, SecurityException,
- InterruptedException, InvocationTargetException,
- IllegalAccessException, NoSuchFieldException, CoreException {
- verifyModifyAndSaveBothSidesOfCompareEditor("properties");
- }
-}
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.tests.ui;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareViewerSwitchingPane;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.internal.CompareEditor;
+import org.eclipse.compare.internal.CompareUIPlugin;
+import org.eclipse.compare.internal.MergeSourceViewer;
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.compare.tests.ReflectionUtils;
+import org.eclipse.core.internal.runtime.RuntimeLog;
+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.ILogListener;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ui.mapping.AbstractCompareInput;
+import org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier;
+import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement;
+import org.eclipse.team.internal.ui.synchronize.SaveablesCompareEditorInput;
+import org.eclipse.team.tests.core.TeamTest;
+import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput;
+import org.eclipse.ui.PlatformUI;
+
+public class SaveableCompareEditorInputTest extends TeamTest {
+
+ public static Test suite() {
+ return suite(SaveableCompareEditorInputTest.class);
+ }
+
+ private static final String COMPARE_EDITOR = CompareUIPlugin.PLUGIN_ID
+ + ".CompareEditor"; //$NON-NLS-1$
+
+ private IFile file1;
+ private IFile file2;
+ private String appendFileContents = "_append";
+ private String fileContents1 = "FileContents";
+ private String fileContents2 = "FileContents2";
+ private TestLogListener logListener = new TestLogListener();
+ private IProject project;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ project = createProject("Project_", new String[] {
+ "File1.txt", "File2.txt" });
+
+ file1 = project.getFile("File1.txt");
+ file2 = project.getFile("File2.txt");
+ file1.setContents(new ByteArrayInputStream(fileContents1.getBytes()),
+ true, true, null);
+ file2.setContents(new ByteArrayInputStream(fileContents2.getBytes()),
+ true, true, null);
+
+ RuntimeLog.addLogListener(logListener);
+ }
+
+ protected void tearDown() throws Exception {
+ // remove log listener
+ RuntimeLog.removeLogListener(logListener);
+ super.tearDown();
+ }
+
+ private class TestFileElement implements ITypedElement {
+
+ private IFile file;
+
+ public IFile getFile() {
+ return file;
+ }
+
+ public TestFileElement(IFile file) {
+ super();
+ this.file = file;
+ }
+
+ public String getName() {
+ return file.getName();
+ }
+
+ public Image getImage() {
+ return null;
+ }
+
+ public String getType() {
+ return TEXT_TYPE;
+ }
+ }
+
+ private class TestLogListener implements ILogListener {
+ public void logging(IStatus status, String plugin) {
+ if (status.getSeverity() == IStatus.ERROR)
+ fail(status.toString());
+ }
+ }
+
+ private class TestDiffNode extends AbstractCompareInput {
+
+ private CompareInputChangeNotifier notifier = new CompareInputChangeNotifier() {
+
+ private IResource getResource(ITypedElement el) {
+ if (el instanceof LocalResourceTypedElement) {
+ return ((LocalResourceTypedElement) el).getResource();
+ }
+ if (el instanceof TestFileElement) {
+ return ((TestFileElement) el).getFile();
+ }
+ return null;
+ }
+
+ protected IResource[] getResources(ICompareInput input) {
+
+ List resources = new ArrayList();
+ if (getResource(getLeft()) != null) {
+ resources.add(getResource(getLeft()));
+ }
+ if (getResource(getRight()) != null) {
+ resources.add(getResource(getRight()));
+ }
+ return (IResource[]) resources.toArray(new IResource[2]);
+ }
+ };
+
+ public TestDiffNode(ITypedElement left, ITypedElement right) {
+ super(Differencer.CHANGE, null, left, right);
+ }
+
+ public void fireChange() {
+ super.fireChange();
+ }
+
+ protected CompareInputChangeNotifier getChangeNotifier() {
+ return notifier;
+ }
+
+ public boolean needsUpdate() {
+ // The remote never changes
+ return false;
+ }
+
+ public void update() {
+ fireChange();
+ }
+ }
+
+ private class TestSaveableEditorInput extends SaveableCompareEditorInput {
+
+ protected ITypedElement left;
+ protected ITypedElement right;
+ private ICompareInput input;
+
+ public Object getCompareResult() {
+ return input;
+ }
+
+ public TestSaveableEditorInput(ITypedElement left, ITypedElement right,
+ CompareConfiguration conf) {
+ super(conf, PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage());
+ this.left = left;
+ this.right = right;
+ }
+
+ protected ICompareInput prepareCompareInput(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ input = createCompareInput();
+ getCompareConfiguration().setLeftEditable(true);
+ getCompareConfiguration().setRightEditable(false);
+ return null;
+ }
+
+ private ICompareInput createCompareInput() {
+ return new TestDiffNode(left, right);
+ }
+
+ protected void fireInputChange() {
+ ((TestDiffNode) getCompareResult()).fireChange();
+ }
+ }
+
+ private void verifyDirtyStateChanges(
+ TestSaveableEditorInput compareEditorInput)
+ throws IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException {
+ Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getShell();
+
+ TextMergeViewer viewer = (TextMergeViewer) compareEditorInput
+ .findContentViewer(null, compareEditorInput.input, shell);
+ viewer.setInput(compareEditorInput.getCompareResult());
+
+ MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField(
+ viewer, "fLeft");
+
+ StyledText leftText = left.getSourceViewer().getTextWidget();
+
+ // modify the left side of editor
+ leftText.append(appendFileContents);
+
+ assertTrue(compareEditorInput.isDirty());
+
+ // save editor
+ viewer.flush(null);
+
+ assertFalse(compareEditorInput.isDirty());
+ }
+
+ public void testDirtyFlagOnLocalResourceTypedElement()
+ throws CoreException, InvocationTargetException,
+ InterruptedException, IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ // Create left element by SaveableCompareEditorInput to be properly
+ // saved, see javadoc to SaveableCompareEditorInput
+ LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
+ .createFileElement(file1);
+ ITypedElement el2 = new TestFileElement(file2);
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ // check whether file was saved
+
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents1 + appendFileContents).getBytes()),
+ file1.getContents()));
+ }
+
+ public void testDirtyFlagOnCustomTypedElement() throws CoreException,
+ InvocationTargetException, InterruptedException,
+ IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ ITypedElement el1 = new TestFileElement(file1);
+ ITypedElement el2 = new TestFileElement(file2);
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ /*
+ * not checking if changes were saved because in this case saving is not
+ * handled, see javadoc to SaveableCompareEditorInput.
+ */
+ }
+
+ public void testDirtyFlagOnLocalResourceTypedElementAndEmptyRight()
+ throws CoreException, InvocationTargetException,
+ InterruptedException, IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ // Create left element by SaveableCompareEditorInput to be properly
+ // saved, see javadoc to SaveableCompareEditorInput
+ LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
+ .createFileElement(file1);
+ ITypedElement el2 = null;
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ // check whether file was saved
+
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents1 + appendFileContents).getBytes()),
+ file1.getContents()));
+ }
+
+ public void testDirtyFlagOnCustomTypedElementAndEmptyRight()
+ throws CoreException, InvocationTargetException,
+ InterruptedException, IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ ITypedElement el1 = new TestFileElement(file1);
+ ITypedElement el2 = null;
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ /*
+ * not checking if changes were saved because in this case saving is not
+ * handled, see javadoc to SaveableCompareEditorInput.
+ */
+ }
+
+ private void verifyModifyAndSaveBothSidesOfCompareEditor(String extention)
+ throws InterruptedException, InvocationTargetException,
+ IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+
+ // create files to compare
+ IFile file1 = project.getFile("CompareFile1." + extention);
+ IFile file2 = project.getFile("CompareFile2." + extention);
+ file1.create(new ByteArrayInputStream(fileContents1.getBytes()), true,
+ null);
+ file2.create(new ByteArrayInputStream(fileContents2.getBytes()), true,
+ null);
+
+ // prepare comparison
+ SaveablesCompareEditorInput input = new SaveablesCompareEditorInput(
+ null, SaveablesCompareEditorInput.createFileElement(file1),
+ SaveablesCompareEditorInput.createFileElement(file2),
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ .getActivePage());
+ input.run(null);
+
+ // open CompareEditor
+ CompareEditor editor = (CompareEditor) PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage()
+ .openEditor(input, COMPARE_EDITOR, true);
+
+ CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) ReflectionUtils
+ .getField(input, "fContentInputPane", true);
+
+ Viewer viewer = pane.getViewer();
+
+ MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField(
+ viewer, "fLeft", true);
+ MergeSourceViewer right = (MergeSourceViewer) ReflectionUtils.getField(
+ viewer, "fRight", true);
+
+ // modify both sides of CompareEditor
+ StyledText leftText = left.getSourceViewer().getTextWidget();
+ StyledText rightText = right.getSourceViewer().getTextWidget();
+ leftText.append(appendFileContents);
+ rightText.append(appendFileContents);
+
+ // save both sides
+ editor.doSave(null);
+
+ assertFalse(editor.isDirty());
+
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
+ .closeEditor(editor, false);
+
+ // validate if both sides where saved
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents1 + appendFileContents).getBytes()),
+ file1.getContents()));
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents2 + appendFileContents).getBytes()),
+ file2.getContents()));
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorHtml()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("html");
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorTxt()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("txt");
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorJava()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("java");
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorXml()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("xml");
+ }
+
+ public void testModifyAndSaveBothSidesOfCompareEditorProperties()
+ throws IllegalArgumentException, SecurityException,
+ InterruptedException, InvocationTargetException,
+ IllegalAccessException, NoSuchFieldException, CoreException {
+ verifyModifyAndSaveBothSidesOfCompareEditor("properties");
+ }
+}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
index 78f7d9cd6..3ebc90b65 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/ui/RepositoriesViewTests.java
@@ -1,257 +1,257 @@
-/*******************************************************************************
- * Copyright (c) 2011, 2012 IBM Corporation and others.
+/*******************************************************************************
+ * Copyright (c) 2011, 2012 IBM Corporation and others.
*
- * This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License 2.0
- * which accompanies this distribution, and is available at
+ * This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License 2.0
+ * which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.tests.ccvs.ui;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
-import org.eclipse.team.internal.ccvs.ui.model.AllRootsElement;
-import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
-import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
-import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider;
-import org.eclipse.team.internal.ccvs.ui.model.RemoteModule;
-import org.eclipse.team.internal.ccvs.ui.model.VersionCategory;
-import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
-import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
-import org.eclipse.team.tests.ccvs.core.EclipseTest;
-
-public class RepositoriesViewTests extends EclipseTest {
-
- public RepositoriesViewTests(String testName) {
- super(testName);
- }
-
- protected void setUp() throws Exception {
- super.setUp();
- // clear repository root cache
- RepositoryRoot repositoryRoot = getRepositoryRoot();
- String remotePaths[] = repositoryRoot.getKnownRemotePaths();
- for (int i = 0; i < remotePaths.length; i++) {
- repositoryRoot.removeTags(remotePaths[i],
- repositoryRoot.getAllKnownTags(remotePaths[i]));
- }
- }
-
- private RepositoryRoot getRepositoryRoot() {
- RemoteContentProvider rcp = new RemoteContentProvider();
- AllRootsElement are = new AllRootsElement();
- Object[] repositoryRoots = rcp.getElements(are);
- for (int i = 0; i < repositoryRoots.length; i++) {
- RepositoryRoot repositoryRoot = (RepositoryRoot) repositoryRoots[i];
- if (getRepository().equals(repositoryRoot.getRoot())) {
- return repositoryRoot;
- }
- }
- fail(getRepository() + " not found");
- return null;
- }
-
- public static Test suite() {
- String testName = System.getProperty("eclipse.cvs.testName");
- if (testName == null) {
- TestSuite suite = new TestSuite(RepositoriesViewTests.class);
- return new CVSTestSetup(suite);
- } else {
- return new CVSTestSetup(new RepositoriesViewTests(testName));
- }
- }
-
- public void testBranchSubmoduleChildren() throws TeamException,
- CoreException {
-
- String time = Long.toString(System.currentTimeMillis());
- String moduleName = "TestBranchSubmoduleChildrenTestModule" + time;
- String branchName = "TestBranchSubmoduleChildrenBranch" + time;
- String versionName = "Root_" + branchName;
-
- // create project
- IProject project = getUniqueTestProject("TestBranchSubmoduleChildrenProject");
- // share project under module
- shareProject(getRepository(), project,
- moduleName + "/" + project.getName(), DEFAULT_MONITOR);
- assertValidCheckout(project);
-
- // add some files
- addResources(project, new String[] { "file1.txt" }, true);
-
- // make branch
- CVSTag version = new CVSTag(versionName, CVSTag.VERSION);
- CVSTag branch = new CVSTag(branchName, CVSTag.BRANCH);
-
- makeBranch(new IResource[] { project }, version, branch, true);
-
- // check if module is the only branch child
- RemoteContentProvider rcp = new RemoteContentProvider();
- Object[] categories = rcp.getChildren(getRepositoryRoot());
- assertEquals(4, categories.length);
- assertTrue(categories[1] instanceof BranchCategory);
- Object[] branches = rcp.getChildren(categories[1]);
- assertEquals(1, branches.length);
- assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
- .getName());
- Object[] modules = rcp.getChildren(branches[0]);
- assertEquals(1, modules.length);
- assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
-
- // check if after refresh module is still the only branch child
- branches = rcp.getChildren(categories[1]);
- assertEquals(1, branches.length);
- assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
- .getName());
- modules = rcp.getChildren(branches[0]);
- assertEquals(1, modules.length);
- assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
- }
-
- public void testTagSubmoduleChildren() throws TeamException, CoreException {
-
- String time = Long.toString(System.currentTimeMillis());
- String moduleName = "TestTagSubmoduleChildrenTestModule" + time;
- String versionName = "TestTagSubmoduleChildrenBranch" + time;
-
- // create project
- IProject project = getUniqueTestProject("TestTagSubmoduleChildrenProject");
- // share project under module
- shareProject(getRepository(), project,
- moduleName + "/" + project.getName(), DEFAULT_MONITOR);
- assertValidCheckout(project);
-
- // make some changes
- addResources(project, new String[] { "file1.txt" }, true);
-
- // tag project
- CVSTag tag = new CVSTag(versionName, CVSTag.VERSION);
-
- tagProject(project, tag, true);
-
-
- RemoteContentProvider rcp = new RemoteContentProvider();
- Object[] categories = rcp.getChildren(getRepositoryRoot());
- assertEquals(4, categories.length);
-
- // check if version exists for module
- assertTrue(categories[2] instanceof VersionCategory);
- Object[] modules = rcp.getChildren(categories[2]);
- for (int i = 0; i < modules.length; i++) {
- if (modules[i] instanceof RemoteModule
- && ((RemoteModule) (modules[i])).getCVSResource().getName()
- .equals(moduleName)) {
- Object folders[] = rcp.getChildren(modules[i]);
- assertEquals(1, folders.length);
- assertEquals(versionName, ((RemoteFolder) folders[0]).getTag()
- .getName());
- return;
- }
- }
- fail(moduleName + " not found");
- }
-
- public void testTagsOnDifferentLevels() throws CoreException {
- String time = Long.toString(System.currentTimeMillis());
- String firstModule = "Module_1" + time;
- String secondModule = "Module_2" + time;
- String secondModulePath = firstModule + "/" + secondModule;
- // Create repository data
- // Module_1/Project_1
- IProject project1 = getUniqueTestProject("Project_1");
- shareProject(getRepository(), project1,
- firstModule + "/" + project1.getName(), DEFAULT_MONITOR);
- // Module_1/Module_2/Project_2
- IProject project2 = getUniqueTestProject("Project_2");
- shareProject(getRepository(), project2, secondModulePath + "/"
- + project2.getName(), DEFAULT_MONITOR);
- // Module_1/Module_2/Project_3
- IProject project3 = getUniqueTestProject("Project_3");
- shareProject(getRepository(), project3, secondModulePath + "/"
- + project3.getName(), DEFAULT_MONITOR);
- // Module_1/Project_4
- IProject project4 = getUniqueTestProject("Project_4");
- shareProject(getRepository(), project4,
- firstModule + "/" + project4.getName(), DEFAULT_MONITOR);
-
- // Create branches
- String branch1 = "Branch_1" + time;
- String version1 = "Root_" + branch1;
- String branch2 = "Branch_2" + time;
- String version2 = "Root_" + branch2;
-
- // Tag projects:
- // Module_1/Project_1 -> [Branch_1][Branch_2]
- // Module_1/Module_2/Project_2 -> [Branch_1][Branch_2]
- // Module_1/Module_2/Project_3 -> [Branch_2]
- // Module_1/Project_4 -> [Branch_4]
- makeBranch(new IResource[] { project1, project2 }, new CVSTag(version1,
- CVSTag.VERSION), new CVSTag(branch1, CVSTag.BRANCH), true);
- makeBranch(new IResource[] { project1, project2, project2, project4 },
- new CVSTag(version2, CVSTag.VERSION), new CVSTag(branch2,
- CVSTag.BRANCH), true);
-
- // verify if tree structure is built from cache
- RemoteContentProvider rcp = new RemoteContentProvider();
- Object[] categories = rcp.getChildren(getRepositoryRoot());
- assertEquals(4, categories.length);
- assertTrue(categories[1] instanceof BranchCategory);
- Object[] branches = rcp.getChildren(categories[1]);
- assertEquals(2, branches.length); // should be [Branch_1] and [Branch_2]
- CVSTagElement branch1Element;
- CVSTagElement branch2Element;
- if (((CVSTagElement) branches[0]).getTag().getName().equals(branch1)) {
- branch1Element = (CVSTagElement) branches[0];
- branch2Element = (CVSTagElement) branches[1];
- } else {
- branch1Element = (CVSTagElement) branches[1];
- branch2Element = (CVSTagElement) branches[0];
- }
- Object[] modules = rcp.getChildren(branch1Element);
- assertEquals(1, modules.length); // should be [Branch_1]/Module_1
- assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
- modules = rcp.getChildren(modules[0]);
- // should contain:
- // [Branch_1]/Module_1/Project_1
- // [Branch_1]/Module_1/Module_2
- assertEquals(2, modules.length);
- for (int i = 0; i < modules.length; i++) {
- if (((RemoteResource) (modules[i])).getName().equals(
- project1.getName())) {
- // Project_1 should have contents retrieved from CVS
- assertTrue(rcp.hasChildren(modules[i]));
- } else if (((RemoteResource) (modules[i])).getName().equals(
- secondModule)) {
- // should be only [Branch_1]/Module_1/Module_2/Project_2.
- // [Branch_1]/Module_1/Module_2/Project_3 should NOT be on the
- // list, it is not branched with Branch_1
- Object[] module2Children = rcp.getChildren(modules[i]);
- assertEquals(1, module2Children.length);
- assertEquals(project2.getName(),
- ((RemoteResource) module2Children[0]).getName());
- }
- }
- modules = rcp.getChildren(branch2Element);
- assertEquals(1, modules.length); // should be [Branch_2]/Module_1
- assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
- // should contain:
- // [Branch_2]/Module_1/Project_1
- // [Branch_2]/Module_1/Module_2
- // [Branch_2]/Module_1/Project_4
- modules = rcp.getChildren(modules[0]);
- assertEquals(3, modules.length);
- }
-}
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.tests.ccvs.ui;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
+import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
+import org.eclipse.team.internal.ccvs.ui.model.AllRootsElement;
+import org.eclipse.team.internal.ccvs.ui.model.BranchCategory;
+import org.eclipse.team.internal.ccvs.ui.model.CVSTagElement;
+import org.eclipse.team.internal.ccvs.ui.model.RemoteContentProvider;
+import org.eclipse.team.internal.ccvs.ui.model.RemoteModule;
+import org.eclipse.team.internal.ccvs.ui.model.VersionCategory;
+import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
+import org.eclipse.team.tests.ccvs.core.CVSTestSetup;
+import org.eclipse.team.tests.ccvs.core.EclipseTest;
+
+public class RepositoriesViewTests extends EclipseTest {
+
+ public RepositoriesViewTests(String testName) {
+ super(testName);
+ }
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ // clear repository root cache
+ RepositoryRoot repositoryRoot = getRepositoryRoot();
+ String remotePaths[] = repositoryRoot.getKnownRemotePaths();
+ for (int i = 0; i < remotePaths.length; i++) {
+ repositoryRoot.removeTags(remotePaths[i],
+ repositoryRoot.getAllKnownTags(remotePaths[i]));
+ }
+ }
+
+ private RepositoryRoot getRepositoryRoot() {
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ AllRootsElement are = new AllRootsElement();
+ Object[] repositoryRoots = rcp.getElements(are);
+ for (int i = 0; i < repositoryRoots.length; i++) {
+ RepositoryRoot repositoryRoot = (RepositoryRoot) repositoryRoots[i];
+ if (getRepository().equals(repositoryRoot.getRoot())) {
+ return repositoryRoot;
+ }
+ }
+ fail(getRepository() + " not found");
+ return null;
+ }
+
+ public static Test suite() {
+ String testName = System.getProperty("eclipse.cvs.testName");
+ if (testName == null) {
+ TestSuite suite = new TestSuite(RepositoriesViewTests.class);
+ return new CVSTestSetup(suite);
+ } else {
+ return new CVSTestSetup(new RepositoriesViewTests(testName));
+ }
+ }
+
+ public void testBranchSubmoduleChildren() throws TeamException,
+ CoreException {
+
+ String time = Long.toString(System.currentTimeMillis());
+ String moduleName = "TestBranchSubmoduleChildrenTestModule" + time;
+ String branchName = "TestBranchSubmoduleChildrenBranch" + time;
+ String versionName = "Root_" + branchName;
+
+ // create project
+ IProject project = getUniqueTestProject("TestBranchSubmoduleChildrenProject");
+ // share project under module
+ shareProject(getRepository(), project,
+ moduleName + "/" + project.getName(), DEFAULT_MONITOR);
+ assertValidCheckout(project);
+
+ // add some files
+ addResources(project, new String[] { "file1.txt" }, true);
+
+ // make branch
+ CVSTag version = new CVSTag(versionName, CVSTag.VERSION);
+ CVSTag branch = new CVSTag(branchName, CVSTag.BRANCH);
+
+ makeBranch(new IResource[] { project }, version, branch, true);
+
+ // check if module is the only branch child
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ Object[] categories = rcp.getChildren(getRepositoryRoot());
+ assertEquals(4, categories.length);
+ assertTrue(categories[1] instanceof BranchCategory);
+ Object[] branches = rcp.getChildren(categories[1]);
+ assertEquals(1, branches.length);
+ assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
+ .getName());
+ Object[] modules = rcp.getChildren(branches[0]);
+ assertEquals(1, modules.length);
+ assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
+
+ // check if after refresh module is still the only branch child
+ branches = rcp.getChildren(categories[1]);
+ assertEquals(1, branches.length);
+ assertEquals(branchName, ((CVSTagElement) (branches[0])).getTag()
+ .getName());
+ modules = rcp.getChildren(branches[0]);
+ assertEquals(1, modules.length);
+ assertEquals(moduleName, ((RemoteResource) modules[0]).getName());
+ }
+
+ public void testTagSubmoduleChildren() throws TeamException, CoreException {
+
+ String time = Long.toString(System.currentTimeMillis());
+ String moduleName = "TestTagSubmoduleChildrenTestModule" + time;
+ String versionName = "TestTagSubmoduleChildrenBranch" + time;
+
+ // create project
+ IProject project = getUniqueTestProject("TestTagSubmoduleChildrenProject");
+ // share project under module
+ shareProject(getRepository(), project,
+ moduleName + "/" + project.getName(), DEFAULT_MONITOR);
+ assertValidCheckout(project);
+
+ // make some changes
+ addResources(project, new String[] { "file1.txt" }, true);
+
+ // tag project
+ CVSTag tag = new CVSTag(versionName, CVSTag.VERSION);
+
+ tagProject(project, tag, true);
+
+
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ Object[] categories = rcp.getChildren(getRepositoryRoot());
+ assertEquals(4, categories.length);
+
+ // check if version exists for module
+ assertTrue(categories[2] instanceof VersionCategory);
+ Object[] modules = rcp.getChildren(categories[2]);
+ for (int i = 0; i < modules.length; i++) {
+ if (modules[i] instanceof RemoteModule
+ && ((RemoteModule) (modules[i])).getCVSResource().getName()
+ .equals(moduleName)) {
+ Object folders[] = rcp.getChildren(modules[i]);
+ assertEquals(1, folders.length);
+ assertEquals(versionName, ((RemoteFolder) folders[0]).getTag()
+ .getName());
+ return;
+ }
+ }
+ fail(moduleName + " not found");
+ }
+
+ public void testTagsOnDifferentLevels() throws CoreException {
+ String time = Long.toString(System.currentTimeMillis());
+ String firstModule = "Module_1" + time;
+ String secondModule = "Module_2" + time;
+ String secondModulePath = firstModule + "/" + secondModule;
+ // Create repository data
+ // Module_1/Project_1
+ IProject project1 = getUniqueTestProject("Project_1");
+ shareProject(getRepository(), project1,
+ firstModule + "/" + project1.getName(), DEFAULT_MONITOR);
+ // Module_1/Module_2/Project_2
+ IProject project2 = getUniqueTestProject("Project_2");
+ shareProject(getRepository(), project2, secondModulePath + "/"
+ + project2.getName(), DEFAULT_MONITOR);
+ // Module_1/Module_2/Project_3
+ IProject project3 = getUniqueTestProject("Project_3");
+ shareProject(getRepository(), project3, secondModulePath + "/"
+ + project3.getName(), DEFAULT_MONITOR);
+ // Module_1/Project_4
+ IProject project4 = getUniqueTestProject("Project_4");
+ shareProject(getRepository(), project4,
+ firstModule + "/" + project4.getName(), DEFAULT_MONITOR);
+
+ // Create branches
+ String branch1 = "Branch_1" + time;
+ String version1 = "Root_" + branch1;
+ String branch2 = "Branch_2" + time;
+ String version2 = "Root_" + branch2;
+
+ // Tag projects:
+ // Module_1/Project_1 -> [Branch_1][Branch_2]
+ // Module_1/Module_2/Project_2 -> [Branch_1][Branch_2]
+ // Module_1/Module_2/Project_3 -> [Branch_2]
+ // Module_1/Project_4 -> [Branch_4]
+ makeBranch(new IResource[] { project1, project2 }, new CVSTag(version1,
+ CVSTag.VERSION), new CVSTag(branch1, CVSTag.BRANCH), true);
+ makeBranch(new IResource[] { project1, project2, project2, project4 },
+ new CVSTag(version2, CVSTag.VERSION), new CVSTag(branch2,
+ CVSTag.BRANCH), true);
+
+ // verify if tree structure is built from cache
+ RemoteContentProvider rcp = new RemoteContentProvider();
+ Object[] categories = rcp.getChildren(getRepositoryRoot());
+ assertEquals(4, categories.length);
+ assertTrue(categories[1] instanceof BranchCategory);
+ Object[] branches = rcp.getChildren(categories[1]);
+ assertEquals(2, branches.length); // should be [Branch_1] and [Branch_2]
+ CVSTagElement branch1Element;
+ CVSTagElement branch2Element;
+ if (((CVSTagElement) branches[0]).getTag().getName().equals(branch1)) {
+ branch1Element = (CVSTagElement) branches[0];
+ branch2Element = (CVSTagElement) branches[1];
+ } else {
+ branch1Element = (CVSTagElement) branches[1];
+ branch2Element = (CVSTagElement) branches[0];
+ }
+ Object[] modules = rcp.getChildren(branch1Element);
+ assertEquals(1, modules.length); // should be [Branch_1]/Module_1
+ assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
+ modules = rcp.getChildren(modules[0]);
+ // should contain:
+ // [Branch_1]/Module_1/Project_1
+ // [Branch_1]/Module_1/Module_2
+ assertEquals(2, modules.length);
+ for (int i = 0; i < modules.length; i++) {
+ if (((RemoteResource) (modules[i])).getName().equals(
+ project1.getName())) {
+ // Project_1 should have contents retrieved from CVS
+ assertTrue(rcp.hasChildren(modules[i]));
+ } else if (((RemoteResource) (modules[i])).getName().equals(
+ secondModule)) {
+ // should be only [Branch_1]/Module_1/Module_2/Project_2.
+ // [Branch_1]/Module_1/Module_2/Project_3 should NOT be on the
+ // list, it is not branched with Branch_1
+ Object[] module2Children = rcp.getChildren(modules[i]);
+ assertEquals(1, module2Children.length);
+ assertEquals(project2.getName(),
+ ((RemoteResource) module2Children[0]).getName());
+ }
+ }
+ modules = rcp.getChildren(branch2Element);
+ assertEquals(1, modules.length); // should be [Branch_2]/Module_1
+ assertEquals(firstModule, ((RemoteResource) modules[0]).getName());
+ // should contain:
+ // [Branch_2]/Module_1/Project_1
+ // [Branch_2]/Module_1/Module_2
+ // [Branch_2]/Module_1/Project_4
+ modules = rcp.getChildren(modules[0]);
+ assertEquals(3, modules.length);
+ }
+}

Back to the top