Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-05-14 21:01:03 +0000
committerJean Michel-Lemieux2002-05-14 21:01:03 +0000
commitee4478b5079d58df818eafa1f40c3eefb02e0b3c (patch)
tree11bb31adb4654bb3b4069e99bbcab3447dc721e3 /tests/org.eclipse.team.tests.core
parentdcc249b8827c12e2d1ceeee13aec3f92d851a22e (diff)
downloadeclipse.platform.team-ee4478b5079d58df818eafa1f40c3eefb02e0b3c.tar.gz
eclipse.platform.team-ee4478b5079d58df818eafa1f40c3eefb02e0b3c.tar.xz
eclipse.platform.team-ee4478b5079d58df818eafa1f40c3eefb02e0b3c.zip
*** empty log message ***
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java112
1 files changed, 105 insertions, 7 deletions
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
index e10557324..9726604d2 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
@@ -1,10 +1,19 @@
package org.eclipse.team.tests.core;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
import java.util.Properties;
import junit.extensions.TestSetup;
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -17,8 +26,8 @@ import org.eclipse.team.core.target.TargetProvider;
public class TargetProviderTests extends TeamTest {
- private final String test_url = "http://paris.ott.oti.com/dav/";
-
+ final String test_url = "http://paris.ott.oti.com/dav/";
+
public TargetProviderTests() {
super();
}
@@ -34,9 +43,64 @@ public class TargetProviderTests extends TeamTest {
}
Site getDavSite() {
- return TargetManager.getSite("org.eclipse.team.webdav", test_url);
+ try {
+ URL url = new URL(test_url);
+ return TargetManager.getSite("org.eclipse.team.webdav", url);
+ } catch (MalformedURLException e) {
+ return null;
+ }
}
+ public IResource[] buildResources(IContainer container, String[] hierarchy, boolean includeContainer) throws CoreException {
+ List resources = new ArrayList(hierarchy.length + 1);
+ resources.addAll(Arrays.asList(buildResources(container, hierarchy)));
+ if (includeContainer)
+ resources.add(container);
+ IResource[] result = (IResource[]) resources.toArray(new IResource[resources.size()]);
+ ensureExistsInWorkspace(result, true);
+ for (int i = 0; i < result.length; i++) {
+ if (result[i].getType() == IResource.FILE)
+ // 3786 bytes is the average size of Eclipse Java files!
+ ((IFile) result[i]).setContents(getRandomContents(100), true, false, null);
+ }
+ return result;
+ }
+
+ protected static InputStream getRandomContents(int sizeAtLeast) {
+ StringBuffer randomStuff = new StringBuffer(sizeAtLeast + 100);
+ while (randomStuff.length() < sizeAtLeast) {
+ randomStuff.append(getRandomSnippet());
+ }
+ return new ByteArrayInputStream(randomStuff.toString().getBytes());
+ }
+
+ public static String getRandomSnippet() {
+ switch ((int) Math.round(Math.random() * 10)) {
+ case 0 :
+ return "este e' o meu conteudo (portuguese)";
+ case 1 :
+ return "Dann brauchen wir aber auch einen deutschen Satz!";
+ case 2 :
+ return "I'll be back";
+ case 3 :
+ return "don't worry, be happy";
+ case 4 :
+ return "there is no imagination for more sentences";
+ case 5 :
+ return "customize yours";
+ case 6 :
+ return "foo";
+ case 7 :
+ return "bar";
+ case 8 :
+ return "foobar";
+ case 9 :
+ return "case 9";
+ default :
+ return "these are my contents";
+ }
+ }
+
public void testWebDavProjectMapping() throws CoreException, TeamException {
IProject project = getUniqueTestProject("webdav-projectmapping");
TargetManager.map(project, getDavSite(), Path.EMPTY);
@@ -49,15 +113,49 @@ public class TargetProviderTests extends TeamTest {
public void testWebDavPut() throws CoreException, TeamException {
IProject project = getUniqueTestProject("webdav-put");
- IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt"});
- ensureExistsInWorkspace(resources, true);
- TargetManager.map(project, getDavSite(), new Path("noauth"));
+ IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt"}, false);
+
+ TargetManager.map(project, getDavSite(), new Path("noauth").append(project.getName()));
TargetProvider target = TargetManager.getProvider(project);
- assertTrue(getDavSite().equals(target.getSite()));
target.put(resources, null);
TargetManager.unmap(project);
+ }
+
+ public void testWebDavGet() throws CoreException, TeamException {
+ IProject project = getUniqueTestProject("webdav-get");
+ IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt"}, false);
+
+ TargetManager.map(project, getDavSite(), new Path("noauth").append(project.getName()));
+ TargetProvider target = TargetManager.getProvider(project);
+
+ target.put(resources, null);
+
+ for (int i = 0; i < resources.length; i++) {
+ resources[i].delete(true, null);
+ }
+
+ for (int i = 0; i < resources.length; i++) {
+ if(resources[i].getType() == IResource.FILE) {
+ assertTrue(!project.getFile(resources[i].getName()).exists());
+ } else {
+ assertTrue(!project.getFolder(resources[i].getName()).exists());
+ }
+ }
+
+ target.get(new IResource[] {project}, null);
+ project.refreshLocal(IResource.DEPTH_INFINITE, null);
+ IResource[] members = project.members();
+ for (int i = 0; i < resources.length; i++) {
+ if(resources[i].getType() == IResource.FILE) {
+ assertTrue(project.getFile(resources[i].getProjectRelativePath()).exists());
+ } else {
+ assertTrue(project.getFolder(resources[i].getProjectRelativePath()).exists());
+ }
+ }
+
+ TargetManager.unmap(project);
assertNull(TargetManager.getProvider(project));
}

Back to the top