[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[Java][PATCH] Build system changes and test seed code for SWIG/Java

From: Daniel L. Rall <dlr_at_finemaltcoding.com>
Date: 2004-03-15 20:26:39 CET

Any comments?

                               ------------

Integrated more of the SWIG/Java build into the gen_make.py system,
and added test code. Added automation to the gen_make.py system to
JAR up .class files.

* Makefile.in
   (SWIG_EXTRA_JAVA_DIR, SWIG_EXTRA_SWIG_DIR, SWIG_JAVA_SOURCES):
     Removed, obviated by configuration in build.conf.

   (swig-java-setup): New target derived from code from the
     INSTALL_EXTRA_SWIG_JAVA macro.

   (INSTALL_EXTRA_SWIG_JAVA): Reduced to only true installation
     operations. Compilation and JAR'ing are now handled by the
     gen_make.py system.

   (check-swig-java): New target for running the SWIG/Java regression
     tests.

* build.conf
   (swig-java-api): New target for building the implementation-agnostic
     SVN Java API. Currently coupled to the SWIG/Java implementation
     targets, this will either be decoupled or merged in the future.

   (swig-java-java): New target for building the SWIG-dependent Java
     code.

   (swig-java-tests): New target for building the SWIG-dependent Java
     testing code.

   (javahl-java, javahl-tests): Added "package-roots" config parameter
     for correct dependency list generation and JAR'ing of .class
     files.

* build/generator/gen_base.py
   (TargetJava.__init__): Added new "packages" and "jar" instance
     members, respectively set by the "package-roots" and "jar" config
     params.

   (TargetJava.add_dependencies): As .class files are likely not
     generated into the same directory as the source files, the object
     path may need adjustment. To this effect, take "target_ob.classes"
     into account. This fixes a problem with the generation of the
     path to the .class files, used in places like "javahl_java_DEPS"
     in build-outputs.mk. The algorithm I used could misinterpret the
     path information, but is "good enough" for the code we have to
     date.

   (TargetJavaClasses.add_dependencies): Use os.sep. Latent bug?

* build/generator/gen_make.py
   (Generator.write): Use the "classes" rather than "path" field for
     TargetJava generation (I'm worried this could break something),
     working around an assertion failure triggered by
     TargetJava.add_dependencies()'s adjustment of the path to .class
     files.

     Added a TODO for passing -g to javac when --enable-maintainer-mode
     is in effect.

     Broke long line.

     When a TargetJava instance has its "jar" member set, automate
     JAR'ing of .class files (only lightly tested). I didn't turn this
     on for javahl.

* subversion/bindings/swig/java/org/tigris/subversion/test/SVNTests.java
* subversion/bindings/swig/java/org/tigris/subversion/test/BasicTests.java
   Used modified copies of JavaHL's test cases as starting points for
   SWIG/Java testing.

Index: Makefile.in
===================================================================
--- Makefile.in (revision 9068)
+++ Makefile.in (working copy)
@@ -200,29 +200,19 @@
        $(top_srcdir)/build/copy-swig-py.sh "$(PYTHON)" "$(INSTALL_DATA)" "${SWIG_BUILD_DIR}/python" "$(DESTDIR)$(swig_pydir)" ; \
    fi
 
-# These are for the SWIG generated bindings
+# The path to generated and complementary source files for the SWIG
+# generated bindings.
 SWIG_JAVA_DIR = $(abs_builddir)/subversion/bindings/swig/java
-# These are the 'extra' classes which complement SWIG's generated bindings
-SWIG_EXTRA_JAVA_DIR = $(abs_srcdir)/subversion/bindings/java
-SWIG_EXTRA_SWIG_DIR = $(abs_srcdir)/subversion/bindings/swig/java
-SWIG_JAVA_SOURCES = $(SWIG_EXTRA_JAVA_DIR)/org/tigris/subversion/*.java \
- $(SWIG_EXTRA_JAVA_DIR)/org/tigris/subversion/auth/*.java \
- $(SWIG_EXTRA_JAVA_DIR)/org/tigris/subversion/client/*.java \
- $(SWIG_EXTRA_JAVA_DIR)/org/tigris/subversion/opt/*.java \
- $(SWIG_EXTRA_JAVA_DIR)/org/tigris/subversion/wc/*.java \
- $(SWIG_EXTRA_SWIG_DIR)/org/tigris/subversion/util/*.java \
- $(SWIG_EXTRA_SWIG_DIR)/org/tigris/subversion/client/*.java \
- $(SWIG_JAVA_DIR)/org/tigris/subversion/swig/*.java
 
-# Have to work around different versions of SWIG that output the java files
-# in different directories.
-INSTALL_EXTRA_SWIG_JAVA=\
+# Different versions of SWIG generate the Java source files in
+# different directories.
+swig-java-setup:
         if [ ! -d $(SWIG_JAVA_DIR)/build ]; then mkdir $(SWIG_JAVA_DIR)/build; fi; \
- if [ ! -f $(SWIG_JAVA_DIR)/org/tigris/subversion/swig/clientJNI.java ]; then mv $(SWIG_JAVA_DIR)/*.java $(SWIG_JAVA_DIR)/org/tigris/subversion/swig; fi; \
- $(JAVAC) -g -d $(SWIG_JAVA_DIR)/build $(SWIG_JAVA_SOURCES); \
- $(JAR) cf $(SWIG_JAVA_DIR)/build/svn-api.jar -C $(SWIG_JAVA_DIR)/build org; \
- $(INSTALL_DATA) $(SWIG_JAVA_DIR)/build/svn-api.jar $(DESTDIR)$(swig_javadir);
+ if [ ! -f $(SWIG_JAVA_DIR)/org/tigris/subversion/swig/clientJNI.java ]; then mv $(SWIG_JAVA_DIR)/*.java $(SWIG_JAVA_DIR)/org/tigris/subversion/swig; fi
 
+INSTALL_EXTRA_SWIG_JAVA=\
+ $(INSTALL_DATA) $(SWIG_JAVA_DIR)/build/svn-api.jar $(DESTDIR)$(swig_javadir)
+
 INSTALL_EXTRA_JAVAHL_JAVA=\
         $(JAR) cf subversion/bindings/java/javahl/svn-javahl.jar -C subversion/bindings/java/javahl/classes org; \
         $(INSTALL_DATA) subversion/bindings/java/javahl/svn-javahl.jar $(DESTDIR)$(javahl_javadir);
@@ -299,6 +289,10 @@
 check-javahl:
         $(JAVA) -Djava.library.path=$(libdir) -classpath subversion/bindings/java/javahl/classes:$(javahl_tests_CLASSPATH) org.tigris.subversion.javahl.tests.BasicTests
 
+# SWIG/Java testing
+check-swig-java: swig-java-tests
+ $(JAVA) -Djava.library.path=$(libdir):$(SVN_APR_PREFIX)/lib -classpath $(SWIG_JAVA_DIR)/build/svn-api.jar:$(JAVA_CLASSPATH) org.tigris.subversion.test.BasicTests
+
 # "make check CLEANUP=true" will clean up directories for successful tests.
 # "make check TESTS=subversion/tests/clients/cmdline/basic_tests.py"
 # will perform only basic tests (likewise for other tests).
Index: build.conf
===================================================================
--- build.conf (revision 9068)
+++ build.conf (working copy)
@@ -332,6 +332,41 @@
 compile-cmd = $(COMPILE_SWIG_JAVA)
 msvc-static = yes
 
+[swig-java-api]
+type = java
+path = subversion/bindings/java/org/tigris/subversion
+sources = *.java opt/*.java auth/*.java client/*.java wc/*.java
+#install = For now, API code is installed by swig-java-java.
+link-cmd = $(JAVAC)
+### Decouple API targets from SWIG-specific targets
+#classes = subversion/bindings/java/build
+classes = subversion/bindings/swig/java/build
+#add-deps = swig-java-api-setup
+add-deps = swig-java-setup
+package-roots = org
+
+[swig-java-java]
+type = java
+path = subversion/bindings/swig/java/org/tigris/subversion
+sources = swig/*.java util/*.java client/*.java
+install = swig-java-java
+link-cmd = $(JAVAC)
+classes = subversion/bindings/swig/java/build
+### A JAR containing SWIG-specific classes shouldn't be named -api.
+jar = svn-api.jar
+package-roots = org
+add-deps = swig-java-api swig-java-setup
+
+[swig-java-tests]
+type = java
+path = subversion/bindings/swig/java/org/tigris/subversion
+sources = test/*.java
+#install = test code isn't installed
+link-cmd = $(JAVAC)
+classes = subversion/bindings/swig/java/build
+package-roots = org
+add-deps = swig-java-java
+
 # SWIG utility library for Perl modules
 [libsvn_swig_perl]
 type = swig_lib
@@ -355,6 +390,7 @@
 install = javahl-java
 link-cmd = $(COMPILE_JAVAHL_JAVAC)
 classes = subversion/bindings/java/javahl/classes
+package-roots = org
 
 [javahl-tests]
 type = java
@@ -363,6 +399,7 @@
 install = javahl-java
 link-cmd = $(COMPILE_JAVAHL_JAVAC)
 classes = subversion/bindings/java/javahl/classes
+package-roots = org
 
 [javahl-javah]
 type = javah
Index: build/generator/gen_base.py
===================================================================
--- build/generator/gen_base.py (revision 9068)
+++ build/generator/gen_base.py (working copy)
@@ -606,6 +606,8 @@
   def __init__(self, name, options, cfg, extmap):
     TargetLib.__init__(self, name, options, cfg, extmap)
     self.link_cmd = options.get('link-cmd')
+ self.packages = string.split(options.get('package-roots', ''))
+ self.jar = options.get('jar')
     self.deps = [ ]
     self.filename = ''
 
@@ -685,6 +687,22 @@
     for src, reldir in sources:
       if src[-5:] == '.java':
         objname = src[:-5] + self.objext
+
+ # As .class files are likely not generated into the same
+ # directory as the source files, the object path may need
+ # adjustment. To this effect, take "target_ob.classes" into
+ # account.
+ dirs = string.split(objname, os.sep)
+ i = len(dirs) - 2 # Last element is the .class file name.
+ while i >= 0:
+ if dirs[i] in self.packages:
+ # Java package root found.
+ objname = os.path.join(self.classes, string.join(dirs[i:], os.sep))
+ print "%s -> %s" % (src, objname)
+ break
+ i = i - 1
+ if i < 0:
+ raise GenError('Unable to find Java package root in path')
       else:
         raise GenError('ERROR: unknown file extension on ' + src)
 
@@ -704,7 +722,7 @@
     graph.add(DT_LIST, LT_TARGET_DIRS, self.path)
     graph.add(DT_LIST, LT_TARGET_DIRS, self.classes)
     for pattern in string.split(self.sources):
- idx = string.rfind(pattern, '/')
+ idx = string.rfind(pattern, os.sep)
       if idx != -1:
         ### hmm. probably shouldn't be os.path.join() right here
         ### (at this point in the control flow; defer to output)
Index: build/generator/gen_make.py
===================================================================
--- build/generator/gen_make.py (revision 9068)
+++ build/generator/gen_make.py (working copy)
@@ -38,7 +38,10 @@
       sources = self.graph.get_sources(gen_base.DT_LINK, target_ob.name)
 
       target = target_ob.name
- path = target_ob.path
+ if isinstance(target_ob, gen_base.TargetJava):
+ path = target_ob.classes
+ else:
+ path = target_ob.path
 
       retreat = gen_base._retreat_dots(path)
 
@@ -71,6 +74,8 @@
       objnames = string.join(gen_base._strip_path(path, objects))
 
       if isinstance(target_ob, gen_base.TargetJava):
+ ### TODO: --enable-maintainer-mode should add the -g argument
+ ### to include all debugging info in compiled bytecodes.
         self.ofile.write(
           '%s_DEPS = %s %s\n'
           '%s: $(%s_DEPS)\n'
@@ -82,12 +87,22 @@
              targ_varname))
         for dep in target_ob.deps:
           if isinstance(dep, gen_base.SourceFile):
- self.ofile.write('%s ' % os.path.join('$(abs_srcdir)', dep.filename))
+ self.ofile.write('%s ' % os.path.join('$(abs_srcdir)',
+ dep.filename))
           elif isinstance(dep, gen_base.HeaderFile):
             self.ofile.write('%s ' % dep.classname)
           else:
             print type(dep)
             raise UnknownDependency
+
+ # Once the bytecodes have been compiled up, we produce the
+ # JAR.
+ if target_ob.jar:
+ self.ofile.write('\n\t$(JAR) cf %s -C %s %s' %
+ (os.path.join(target_ob.classes, target_ob.jar),
+ target_ob.classes,
+ string.join(target_ob.packages, ' ')))
+
         self.ofile.write('\n\n')
       else:
         self.ofile.write(
Index: subversion/bindings/swig/java/org/tigris/subversion/test/BasicTests.java
===================================================================
--- subversion/bindings/swig/java/org/tigris/subversion/test/BasicTests.java (revision 0)
+++ subversion/bindings/swig/java/org/tigris/subversion/test/BasicTests.java (working copy)
@@ -1,805 +1,868 @@
-package org.tigris.subversion.javahl.tests;
-
-/**
- * @copyright
- * ====================================================================
- * Copyright (c) 2003-2004 CollabNet. All rights reserved.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at http://subversion.tigris.org/license-1.html.
- * If newer versions of this license are posted there, you may use a
- * newer version instead, at your option.
- *
- * This software consists of voluntary contributions made by many
- * individuals. For exact contribution history, see the revision
- * history and logs, available at http://subversion.tigris.org/.
- * ====================================================================
- * @endcopyright
- */
-
-import org.tigris.subversion.javahl.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.PrintWriter;
-import java.util.Arrays;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class BasicTests extends SVNTests
-{
- static
- {
- testCounter = 0;
- }
-
- public BasicTests()
- {
- testBaseName = "basic_test";
- }
-
- public static Test suite() {
- return new TestSuite(BasicTests.class);
- }
-
- public static void main(String[] args) {
- junit.textui.TestRunner.run(suite());
- }
-
- public void testBasicCheckout() throws Throwable
- {
- OneTest thisTest = new OneTest();
- try
- {
- client.checkout(thisTest.getUrl() + "/A", thisTest.getWorkingCopy().getAbsolutePath(), null, true);
- fail("missing exception");
- }
- catch (ClientException e)
- {
- }
- File mu = new File(thisTest.getWorkingCopy(), "A/mu");
- PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
- muPW.print("appended mu text");
- muPW.close();
- thisTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
- File lambda = new File(thisTest.getWorkingCopy(), "A/B/lambda");
- lambda.delete();
- thisTest.getWc().setItemTextStatus("A/B/lambda", Status.Kind.missing);
- client.remove(new String[]{thisTest.getWorkingCopy().getAbsolutePath() + "/A/D/G"}, null, false);
- thisTest.getWc().setItemTextStatus("A/D/G", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G/pi", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G/tau", Status.Kind.deleted);
- thisTest.checkStatus();
- client.checkout(thisTest.getUrl(), thisTest.getWorkingCopy().getAbsolutePath(), null, true);
- thisTest.getWc().setItemTextStatus("A/B/lambda", Status.Kind.normal);
- thisTest.checkStatus();
- }
-
- public void testBasicStatus() throws Throwable
- {
- OneTest thisTest = new OneTest();
- thisTest.checkStatus();
- }
-
- public void testBasicCommit() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File mu = new File(thisTest.getWorkingCopy(), "A/mu");
- PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
- muPW.print("appended mu text");
- muPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
- thisTest.getWc().setItemContent("A/mu", thisTest.getWc().getItemContent("A/mu") + "appended mu text");
- File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
- PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
- rhoPW.print("new appended text for rho");
- rhoPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
- thisTest.getWc().setItemContent("A/D/G/rho", thisTest.getWc().getItemContent("A/D/G/rho") + "new appended text for rho");
- assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log msg", true), 2);
- thisTest.checkStatus();
- }
-
- public void testBasicUpdate() throws Throwable
- {
- OneTest thisTest = new OneTest();
- OneTest backupTest = thisTest.copy(".backup");
- File mu = new File(thisTest.getWorkingCopy(), "A/mu");
- PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
- muPW.print("appended mu text");
- muPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
- thisTest.getWc().setItemContent("A/mu", thisTest.getWc().getItemContent("A/mu") + "appended mu text");
- File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
- PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
- rhoPW.print("new appended text for rho");
- rhoPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
- thisTest.getWc().setItemContent("A/D/G/rho", thisTest.getWc().getItemContent("A/D/G/rho") + "new appended text for rho");
- assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log msg", true), 2);
- thisTest.checkStatus();
- assertEquals("wrong revision number from update", client.update(backupTest.getWorkingCopy().getAbsolutePath(), null, true), 2);
- backupTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
- backupTest.getWc().setItemContent("A/mu", backupTest.getWc().getItemContent("A/mu") + "appended mu text");
- backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
- backupTest.getWc().setItemContent("A/D/G/rho", backupTest.getWc().getItemContent("A/D/G/rho") + "new appended text for rho");
- backupTest.checkStatus();
- }
-
- public void testBasicMkdirUrl() throws Throwable
- {
- OneTest thisTest = new OneTest();
- client.mkdir(new String[]{thisTest.getUrl() + "/Y", thisTest.getUrl() + "/Y/Z"}, "log_msg");
- thisTest.getWc().addItem("Y", null);
- thisTest.getWc().setItemWorkingCopyRevision("Y", 2);
- thisTest.getWc().addItem("Y/Z", null);
- thisTest.getWc().setItemWorkingCopyRevision("Y/Z", 2);
- assertEquals("wrong revision from update", client.update(thisTest.getWorkingCopy().getAbsolutePath(), null, true), 2);
- thisTest.checkStatus();
- }
-
- public void testBasicMergingUpdate() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File mu = new File(thisTest.getWorkingCopy(), "A/mu");
- PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
- String muContent = thisTest.getWc().getItemContent("A/mu");
- File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
- PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
- String rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
- for (int i = 2; i < 11; i++)
- {
- muPW.print("\nThis is line " + i + " in mu");
- muContent = muContent + "\nThis is line " + i + " in mu";
- rhoPW.print("\nThis is line " + i + " in rho");
- rhoContent = rhoContent + "\nThis is line " + i + " in rho";
- }
- muPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
- thisTest.getWc().setItemContent("A/mu", muContent);
- rhoPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
- thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
- assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log msg", true), 2);
- thisTest.checkStatus();
- OneTest backupTest = thisTest.copy(".backup");
- muPW = new PrintWriter(new FileOutputStream(mu, true));
- muContent = thisTest.getWc().getItemContent("A/mu");
- rhoPW = new PrintWriter(new FileOutputStream(rho, true));
- rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
- muPW.print(" Appended to line 10 of mu");
- muContent = muContent + " Appended to line 10 of mu";
- rhoPW.print(" Appended to line 10 of rho");
- rhoContent = rhoContent + " Appended to line 10 of rho";
- muPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/mu", 3);
- thisTest.getWc().setItemContent("A/mu", muContent);
- rhoPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 3);
- thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
- assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log msg", true), 3);
- thisTest.checkStatus();
- mu = new File(backupTest.getWorkingCopy(), "A/mu");
- muPW = new PrintWriter(new FileOutputStream(mu));
- muPW.print("This is the new line 1 in the backup copy of mu");
- muContent = "This is the new line 1 in the backup copy of mu";
- rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho");
- rhoPW = new PrintWriter(new FileOutputStream(rho));
- rhoPW.print("This is the new line 1 in the backup copy of rho");
- rhoContent = "This is the new line 1 in the backup copy of rho";
- for (int i = 2; i < 11; i++)
- {
- muPW.print("\nThis is line " + i + " in mu");
- muContent = muContent + "\nThis is line " + i + " in mu";
- rhoPW.print("\nThis is line " + i + " in rho");
- rhoContent = rhoContent + "\nThis is line " + i + " in rho";
- }
- muPW.close();
- backupTest.getWc().setItemWorkingCopyRevision("A/mu", 3);
- muContent = muContent + " Appended to line 10 of mu";
- backupTest.getWc().setItemContent("A/mu", muContent);
- backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
- rhoPW.close();
- backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 3);
- rhoContent = rhoContent + " Appended to line 10 of rho";
- backupTest.getWc().setItemContent("A/D/G/rho", rhoContent);
- backupTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
- assertEquals("wrong revision number from update", client.update(backupTest.getWorkingCopy().getAbsolutePath(), null, true), 3);
- backupTest.checkStatus();
- }
-
- public void testBasicConflict() throws Throwable
- {
- OneTest thisTest = new OneTest();
- OneTest backupTest = thisTest.copy(".backup");
- File mu = new File(thisTest.getWorkingCopy(), "A/mu");
- PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
- String muContent = thisTest.getWc().getItemContent("A/mu");
- File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
- PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
- String rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
- muPW.print("\nOriginal appended text for mu");
- muContent = muContent + "\nOriginal appended text for mu";
- rhoPW.print("\nOriginal appended text for rho");
- rhoContent = rhoContent + "\nOriginal appended text for rho";
- muPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
- thisTest.getWc().setItemContent("A/mu", muContent);
- rhoPW.close();
- thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
- thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
- assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log msg", true), 2);
- thisTest.checkStatus();
- mu = new File(backupTest.getWorkingCopy(), "A/mu");
- muPW = new PrintWriter(new FileOutputStream(mu, true));
- rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho");
- rhoPW = new PrintWriter(new FileOutputStream(rho, true));
- muPW.print("\nConflicting appended text for mu");
- muContent = "<<<<<<< .mine\nThis is the file 'mu'.\nConflicting appended text for mu=======\nThis is the file 'mu'.\nOriginal appended text for mu>>>>>>> .r2";
- rhoPW.print("\nConflicting appended text for rho");
- rhoContent = "<<<<<<< .mine\nThis is the file 'rho'.\nConflicting appended text for rho=======\nhis is the file 'rho'.\nOriginal appended text for rho>>>>>>> .r2";
- muPW.close();
- backupTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
- backupTest.getWc().setItemContent("A/mu", muContent);
- backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.conflicted);
- rhoPW.close();
- backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
- backupTest.getWc().setItemContent("A/D/G/rho", rhoContent);
- backupTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.conflicted);
- backupTest.getWc().addItem("A/mu.r1", "");
- backupTest.getWc().setItemNodeKind("A/mu.r1", NodeKind.unknown);
- backupTest.getWc().setItemTextStatus("A/mu.r1", Status.Kind.unversioned);
- backupTest.getWc().addItem("A/mu.r2", "");
- backupTest.getWc().setItemNodeKind("A/mu.r2", NodeKind.unknown);
- backupTest.getWc().setItemTextStatus("A/mu.r2", Status.Kind.unversioned);
- backupTest.getWc().addItem("A/mu.mine", "");
- backupTest.getWc().setItemNodeKind("A/mu.mine", NodeKind.unknown);
- backupTest.getWc().setItemTextStatus("A/mu.mine", Status.Kind.unversioned);
- backupTest.getWc().addItem("A/D/G/rho.r1", "");
- backupTest.getWc().setItemNodeKind("A/D/G/rho.r1", NodeKind.unknown);
- backupTest.getWc().setItemTextStatus("A/D/G/rho.r1", Status.Kind.unversioned);
- backupTest.getWc().addItem("A/D/G/rho.r2", "");
- backupTest.getWc().setItemNodeKind("A/D/G/rho.r2", NodeKind.unknown);
- backupTest.getWc().setItemTextStatus("A/D/G/rho.r2", Status.Kind.unversioned);
- backupTest.getWc().addItem("A/D/G/rho.mine", "");
- backupTest.getWc().setItemNodeKind("A/D/G/rho.mine", NodeKind.unknown);
- backupTest.getWc().setItemTextStatus("A/D/G/rho.mine", Status.Kind.unversioned);
- assertEquals("wrong revision number from update", client.update(backupTest.getWorkingCopy().getAbsolutePath(), null, true), 2);
- backupTest.checkStatus();
- client.resolved(backupTest.getWorkingCopy().getAbsolutePath()+"/A/mu",false);
- client.resolved(backupTest.getWorkingCopy().getAbsolutePath()+"/A/D/G/rho",false);
- backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
- backupTest.getWc().removeItem("A/mu.r1");
- backupTest.getWc().removeItem("A/mu.r2");
- backupTest.getWc().removeItem("A/mu.mine");
- backupTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
- backupTest.getWc().removeItem("A/D/G/rho.r1");
- backupTest.getWc().removeItem("A/D/G/rho.r2");
- backupTest.getWc().removeItem("A/D/G/rho.mine");
- backupTest.checkStatus();
- }
-
- public void testBasicCleanup() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File adminLock = new File(thisTest.getWorkingCopy(),"A/B/.svn/lock");
- PrintWriter pw = new PrintWriter(new FileOutputStream(adminLock));
- pw.print("stop looking!");
- pw.close();
- thisTest.getWc().setItemIsLocked("A/B", true);
- adminLock = new File(thisTest.getWorkingCopy(),"A/D/G/.svn/lock");
- pw = new PrintWriter(new FileOutputStream(adminLock));
- pw.print("stop looking!");
- pw.close();
- thisTest.getWc().setItemIsLocked("A/D/G", true);
- adminLock = new File(thisTest.getWorkingCopy(),"A/C/.svn/lock");
- pw = new PrintWriter(new FileOutputStream(adminLock));
- pw.print("stop looking!");
- pw.close();
- thisTest.getWc().setItemIsLocked("A/C", true);
- thisTest.checkStatus();
- client.cleanup(thisTest.getWorkingCopy().getAbsolutePath());
- thisTest.getWc().setItemIsLocked("A/B", false);
- thisTest.getWc().setItemIsLocked("A/D/G", false);
- thisTest.getWc().setItemIsLocked("A/C", false);
- thisTest.checkStatus();
- }
-
- public void testBasicRevert() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File file = new File(thisTest.getWorkingCopy(), "A/B/E/beta");
- PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
- pw.print("Added some text to 'beta'.");
- pw.close();
- thisTest.getWc().setItemTextStatus("A/B/E/beta", Status.Kind.modified);
- file = new File(thisTest.getWorkingCopy(), "iota");
- pw = new PrintWriter(new FileOutputStream(file, true));
- pw.print("Added some text to 'iota'.");
- pw.close();
- thisTest.getWc().setItemTextStatus("iota", Status.Kind.modified);
- file = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
- pw = new PrintWriter(new FileOutputStream(file, true));
- pw.print("Added some text to 'rho'.");
- pw.close();
- thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
- file = new File(thisTest.getWorkingCopy(), "A/D/H/zeta");
- pw = new PrintWriter(new FileOutputStream(file, true));
- pw.print("Added some text to 'zeta'.");
- pw.close();
- thisTest.getWc().addItem("A/D/H/zeta", "Added some text to 'zeta'.");
- thisTest.getWc().setItemTextStatus("A/D/H/zeta", Status.Kind.added);
- client.add(file.getAbsolutePath(), false);
- thisTest.checkStatus();
- client.revert(thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/E/beta", false);
- client.revert(thisTest.getWorkingCopy().getAbsolutePath()+"/iota", false);
- client.revert(thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G/rho", false);
- client.revert(thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/H/zeta", false);
- thisTest.getWc().setItemTextStatus("A/B/E/beta", Status.Kind.normal);
- thisTest.getWc().setItemTextStatus("iota", Status.Kind.normal);
- thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.normal);
- thisTest.getWc().setItemTextStatus("A/D/H/zeta", Status.Kind.unversioned);
- thisTest.getWc().setItemNodeKind("A/D/H/zeta", NodeKind.unknown);
- thisTest.checkStatus();
-
- file = new File(thisTest.getWorkingCopy(), "A/B/E/beta");
- file.delete();
- client.revert(file.getAbsolutePath(), false);
- assertTrue("reverted file is not readonly", file.canWrite()&& file.canRead());
- thisTest.checkStatus();
-
- client.mkdir(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/X"}, null);
- thisTest.getWc().addItem("X", null);
- thisTest.getWc().setItemTextStatus("X", Status.Kind.added);
- thisTest.checkStatus();
-
- removeDirectoryWithContent(new File(thisTest.getWorkingCopy(), "X"));
- client.revert(thisTest.getWorkingCopy().getAbsolutePath()+"/X", false);
- thisTest.getWc().removeItem("X");
- thisTest.checkStatus();
-
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/E"}, null, true);
- removeDirectoryWithContent(new File(thisTest.getWorkingCopy(), "A/B/E"));
- thisTest.getWc().setItemTextStatus("A/B/E", Status.Kind.deleted);
- thisTest.getWc().removeItem("A/B/E/alpha");
- thisTest.getWc().removeItem("A/B/E/beta");
- thisTest.checkStatus();
- client.revert(thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/E", true);
- thisTest.checkStatus();
- }
-
- public void testBasicSwitch() throws Throwable
- {
- OneTest thisTest = new OneTest();
- String iotaPath = thisTest.getWorkingCopy().getAbsolutePath() + "\\iota";
- String gammaUrl = thisTest.getUrl() + "/A/D/gamma";
- thisTest.getWc().setItemContent("iota", greekWC.getItemContent("A/D/gamma"));
- thisTest.getWc().setItemIsSwitched("iota", true);
- client.doSwitch(iotaPath, gammaUrl, null, true);
- thisTest.checkStatus();
-
- String adhPath = thisTest.getWorkingCopy().getAbsolutePath() + "/A/D/H";
- String adgURL = thisTest.getUrl() + "/A/D/G";
- thisTest.getWc().setItemIsSwitched("A/D/H",true);
- thisTest.getWc().removeItem("A/D/H/chi");
- thisTest.getWc().removeItem("A/D/H/omega");
- thisTest.getWc().removeItem("A/D/H/psi");
- thisTest.getWc().addItem("A/D/H/pi", thisTest.getWc().getItemContent("A/D/G/pi"));
- thisTest.getWc().addItem("A/D/H/rho", thisTest.getWc().getItemContent("A/D/G/rho"));
- thisTest.getWc().addItem("A/D/H/tau", thisTest.getWc().getItemContent("A/D/G/tau"));
- client.doSwitch(adhPath, adgURL, null, true);
- thisTest.checkStatus();
- }
-
- public void testBasicDelete() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File file = new File(thisTest.getWorkingCopy(), "A/D/H/chi");
- PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
- pw.print("added to chi");
- pw.close();
- thisTest.getWc().setItemTextStatus("A/D/H/chi", Status.Kind.modified);
- client.propertySet(thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G/rho", "abc", "def", true);
- thisTest.getWc().setItemPropStatus("A/D/G/rho", Status.Kind.modified);
- client.propertySet(thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/F", "abc", "def", false);
- thisTest.getWc().setItemPropStatus("A/B/F", Status.Kind.modified);
- file = new File(thisTest.getWorkingCopy().getAbsolutePath(),"A/C/sigma");
- pw = new PrintWriter(new FileOutputStream(file));
- pw.print("unversioned sigma");
- pw.close();
- thisTest.getWc().addItem("A/C/sigma", "unversioned sigma");
- thisTest.getWc().setItemTextStatus("A/C/sigma", Status.Kind.unversioned);
- thisTest.getWc().setItemNodeKind("A/C/sigma", NodeKind.unknown);
- file = new File(thisTest.getWorkingCopy().getAbsolutePath(), "A/C/Q");
- file.mkdir();
- thisTest.getWc().addItem("A/C/Q", null);
- thisTest.getWc().setItemNodeKind("A/C/Q", NodeKind.unknown);
- thisTest.getWc().setItemTextStatus("A/C/Q", Status.Kind.unversioned);
- file = new File(thisTest.getWorkingCopy().getAbsolutePath(), "A/B/X");
- client.mkdir(new String[] {file.getAbsolutePath()}, null);
- thisTest.getWc().addItem("A/B/X", null);
- thisTest.getWc().setItemTextStatus("A/B/X", Status.Kind.added);
- file = new File(file, "xi");
- pw = new PrintWriter(new FileOutputStream(file));
- pw.print("added xi");
- pw.close();
- client.add(file.getAbsolutePath(),false);
- thisTest.getWc().addItem("A/B/X/xi", "added xi");
- thisTest.getWc().setItemTextStatus("A/B/X/xi", Status.Kind.added);
- file = new File(thisTest.getWorkingCopy().getAbsolutePath(), "A/B/Y");
- client.mkdir(new String[] {file.getAbsolutePath()}, null);
- thisTest.getWc().addItem("A/B/Y", null);
- thisTest.getWc().setItemTextStatus("A/B/Y", Status.Kind.added);
- thisTest.checkStatus();
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/H/chi"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/H"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G/rho"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/F"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/C/sigma"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/C"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- try
- {
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/X"}, null, false);
- fail("missing exception");
- }
- catch(ClientException e)
- {
- }
-
- thisTest.checkStatus();
-
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/E"}, null, false);
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/H"}, null, true);
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G"}, null, true);
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/F"}, null, true);
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/C"}, null, true);
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/X"}, null, true);
- file = new File(thisTest.getWorkingCopy(), "iota");
- file.delete();
- client.remove(new String[] {file.getAbsolutePath()}, null, true);
- file = new File(thisTest.getWorkingCopy(), "A/D/gamma");
- file.delete();
- client.remove(new String[] {file.getAbsolutePath()}, null, false);
- client.remove(new String[] {file.getAbsolutePath()}, null, true);
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/E"}, null, false);
- thisTest.getWc().setItemTextStatus("A/D/H",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/H/chi",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/H/omega",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/H/psi",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G/rho",Status.Kind.deleted);
- thisTest.getWc().setItemPropStatus("A/D/G/rho", Status.Kind.none);
- thisTest.getWc().setItemTextStatus("A/D/G/pi",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G/tau",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/B/E",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/B/E/alpha",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/B/E/beta",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/B/F",Status.Kind.deleted);
- thisTest.getWc().setItemPropStatus("A/B/F", Status.Kind.none);
- thisTest.getWc().setItemTextStatus("A/C",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("iota",Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/gamma",Status.Kind.deleted);
- thisTest.getWc().removeItem("A/B/X");
- thisTest.getWc().removeItem("A/B/X/xi");
- thisTest.getWc().removeItem("A/C/sigma");
- thisTest.getWc().removeItem("A/C/Q");
- thisTest.checkStatus();
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D"},null, true);
- thisTest.getWc().setItemTextStatus("A/D", Status.Kind.deleted);
- thisTest.getWc().removeItem("A/D/Y");
- thisTest.checkStatus();
-
- assertFalse("failed to remove text modified file", new File(thisTest.getWorkingCopy(), "A/D/G/rho").exists());
- assertFalse("failed to remove prop modified file", new File(thisTest.getWorkingCopy(), "A/D/H/chi").exists());
- assertFalse("failed to remove unversioned file", new File(thisTest.getWorkingCopy(), "A/C/sigma").exists());
- assertFalse("failed to remove unmodified file", new File(thisTest.getWorkingCopy(), "A/B/E/alpha").exists());
- file = new File(thisTest.getWorkingCopy(),"A/B/F");
- assertTrue("removed versioned dir", file.exists() && file.isDirectory());
- assertFalse("failed to remove unversioned dir", new File(thisTest.getWorkingCopy(), "A/C/Q").exists());
- assertFalse("failed to remove added dir", new File(thisTest.getWorkingCopy(), "A/B/X").exists());
-
- file = new File(thisTest.getWorkingCopy().getAbsolutePath(),"foo");
- pw = new PrintWriter(new FileOutputStream(file));
- pw.print("unversioned foo");
- pw.close();
- client.remove(new String[] {file.getAbsolutePath()}, null, true);
- assertFalse("failed to remove unversioned file foo", file.exists());
- client.remove(new String[] {file.getAbsolutePath()}, null, true);
- client.remove(new String[] {thisTest.getUrl()+"/iota"}, "delete iota URL", false);
- }
-
- public void testBasicCheckoutDeleted() throws Throwable
- {
- OneTest thisTest = new OneTest();
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D"}, null, true);
- thisTest.getWc().setItemTextStatus("A/D", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G/pi", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/G/tau", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/H", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/H/chi", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/H/psi", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/H/omega", Status.Kind.deleted);
- thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.deleted);
- thisTest.checkStatus();
- assertEquals("wrong revision from commit",client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log message", true),2);
- thisTest.getWc().removeItem("A/D");
- thisTest.getWc().removeItem("A/D/G");
- thisTest.getWc().removeItem("A/D/G/rho");
- thisTest.getWc().removeItem("A/D/G/pi");
- thisTest.getWc().removeItem("A/D/G/tau");
- thisTest.getWc().removeItem("A/D/H");
- thisTest.getWc().removeItem("A/D/H/chi");
- thisTest.getWc().removeItem("A/D/H/psi");
- thisTest.getWc().removeItem("A/D/H/omega");
- thisTest.getWc().removeItem("A/D/gamma");
- thisTest.checkStatus();
- client.checkout(thisTest.getUrl()+"/A/D", thisTest.getWorkingCopy().getAbsolutePath()+"/new_D", new Revision.Number(1), true);
- }
-
- public void testBasicNodeKindChange() throws Throwable
- {
- OneTest thisTest = new OneTest();
- client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/gamma"}, null, false);
- thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.deleted);
- thisTest.checkStatus();
- try
- {
- client.mkdir(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/gamma"}, null);
- fail("can change node kind");
- }
- catch(ClientException e)
- {
-
- }
- thisTest.checkStatus();
- assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()},"log message", true), 2);
- thisTest.getWc().removeItem("A/D/gamma");
- thisTest.checkStatus();
-
- try
- {
- client.mkdir(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/gamma"}, null);
- fail("can change node kind");
- }
- catch(ClientException e)
- {
-
- }
- thisTest.checkStatus();
- client.update(thisTest.getWorkingCopy().getAbsolutePath(), null, true);
- thisTest.checkStatus();
- client.mkdir(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/gamma"}, null);
- thisTest.getWc().addItem("A/D/gamma", null);
- thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.added);
- thisTest.checkStatus();
- }
-
- public void testBasicImport() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File file = new File(thisTest.getWorkingCopy().getAbsolutePath(),"new_file");
- PrintWriter pw = new PrintWriter(new FileOutputStream(file));
- pw.print("some text");
- pw.close();
- client.doImport(file.getAbsolutePath(), thisTest.getUrl()+"/dirA/dirB/new_file","log message for new import", true);
- file.delete();
- assertEquals("wrong revision from commit",client.update(thisTest.getWorkingCopy().getAbsolutePath(), null, true),2);
- thisTest.getWc().addItem("dirA", null);
- thisTest.getWc().setItemWorkingCopyRevision("dirA",2);
- thisTest.getWc().addItem("dirA/dirB", null);
- thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB",2);
- thisTest.getWc().addItem("dirA/dirB/new_file", "some text");
- thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB/new_file",2);
- thisTest.checkStatus();
- }
-
- public void testBasicCat() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File mu = new File(thisTest.getWorkingCopy(), "A/mu");
- PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true));
- pw.print("some text");
- pw.close();
- byte[] content = client.fileContent(thisTest.getWorkingCopy().getAbsolutePath()+"/A/mu", null);
- byte[] testContent = thisTest.getWc().getItemContent("A/mu").getBytes();
- assertTrue("content changed", Arrays.equals(content, testContent));
- }
-
- public void testBasicLs() throws Throwable
- {
- OneTest thisTest = new OneTest();
-
- DirEntry[] entries = client.list(thisTest.getWorkingCopy().getAbsolutePath(), null, false);
- thisTest.getWc().check(entries,"", false);
- entries = client.list(thisTest.getWorkingCopy().getAbsolutePath()+"/A", null, false);
- thisTest.getWc().check(entries,"A", false);
- entries = client.list(thisTest.getWorkingCopy().getAbsolutePath()+"/A", Revision.BASE, false);
- thisTest.getWc().check(entries,"A", false);
- entries = client.list(thisTest.getWorkingCopy().getAbsolutePath()+"/A/mu", null, false);
- thisTest.getWc().check(entries,"A/mu");
- }
-
- public void testBasicAddIgnores() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File dir = new File(thisTest.getWorkingCopy(), "dir");
- dir.mkdir();
- File fileC = new File(dir, "foo.c");
- new FileOutputStream(fileC).close();
- File fileO = new File(dir, "foo.o");
- new FileOutputStream(fileO).close();
- client.add(dir.getAbsolutePath(), true);
- thisTest.getWc().addItem("dir", null);
- thisTest.getWc().setItemTextStatus("dir",Status.Kind.added);
- thisTest.getWc().addItem("dir/foo.c", "");
- thisTest.getWc().setItemTextStatus("dir/foo.c",Status.Kind.added);
- thisTest.getWc().addItem("dir/foo.o", "");
- thisTest.getWc().setItemTextStatus("dir/foo.o",Status.Kind.ignored);
- thisTest.getWc().setItemNodeKind("dir/foo.o", NodeKind.unknown);
- thisTest.checkStatus();
- }
-
- public void testBasicImportIgnores() throws Throwable
- {
- OneTest thisTest = new OneTest();
- File dir = new File(thisTest.getWorkingCopy(), "dir");
- dir.mkdir();
- File fileC = new File(dir, "foo.c");
- new FileOutputStream(fileC).close();
- File fileO = new File(dir, "foo.o");
- new FileOutputStream(fileO).close();
- client.doImport(dir.getAbsolutePath(), thisTest.getUrl()+"/dir","log message for import", true);
- removeDirectoryWithContent(dir);
- assertEquals("wrong revision from update", 2, client.update(thisTest.getWorkingCopy().getAbsolutePath(), null, true));
- thisTest.getWc().addItem("dir", null);
- thisTest.getWc().addItem("dir/foo.c", "");
- thisTest.checkStatus();
-/*
- 'do not import ignored files in imported dirs'
-
- # The bug was that
- #
- # $ svn import dir
- #
- # where dir contains some items that match the ignore list and some
- # do not would add all items, ignored or not.
- #
- # This has been fixed by testing each item with the new
- # svn_wc_is_ignored function.
-
- sbox.build()
- wc_dir = sbox.wc_dir
-
- dir_path = os.path.join(wc_dir, 'dir')
- foo_c_path = os.path.join(dir_path, 'foo.c')
- foo_o_path = os.path.join(dir_path, 'foo.o')
-
- os.mkdir(dir_path, 0755)
- open(foo_c_path, 'w')
- open(foo_o_path, 'w')
-
- # import new dir into repository
- url = svntest.main.current_repo_url + '/dir'
-
- output, errput = svntest.actions.run_and_verify_svn(
- None, None, [], 'import',
- '--username', svntest.main.wc_author,
- '--password', svntest.main.wc_passwd,
- '-m', 'Log message for new import',
- dir_path, url)
-
- lastline = string.strip(output.pop())
- cm = re.compile ("(Committed|Imported) revision [0-9]+.")
- match = cm.search (lastline)
- if not match:
- ### we should raise a less generic error here. which?
- raise svntest.actions.SVNUnexpectedOutput
-
- # remove (uncontrolled) local dir
- svntest.main.safe_rmtree(dir_path)
-
- # Create expected disk tree for the update (disregarding props)
- expected_disk = svntest.main.greek_state.copy()
- expected_disk.add({
- 'dir/foo.c' : Item(''),
- })
-
- # Create expected status tree for the update (disregarding props).
- # Newly imported file should be at revision 2.
- expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
- expected_status.add({
- 'dir' : Item(status=' ', wc_rev=2, repos_rev=2),
- 'dir/foo.c' : Item(status=' ', wc_rev=2, repos_rev=2),
- })
-
- # Create expected output tree for the update.
- expected_output = svntest.wc.State(wc_dir, {
- 'dir' : Item(status='A '),
- 'dir/foo.c' : Item(status='A '),
- })
-
- # do update and check three ways
- svntest.actions.run_and_verify_update(wc_dir,
- expected_output,
- expected_disk,
- expected_status,
- None, None, None,
- None, None, 1)
-
-*/
- }
-
-
-}
+package org.tigris.subversion.test;
+
+/**
+ * @copyright
+ * ====================================================================
+ * Copyright (c) 2003-2004 CollabNet. All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals. For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ * @endcopyright
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.util.Arrays;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.tigris.subversion.util.NativeResources;
+
+public class BasicTests extends SVNTests
+{
+ static
+ {
+ testCounter = 0;
+ }
+
+ /**
+ * @param name Method name to invoke.
+ */
+ public BasicTests(String name)
+ {
+ super(name);
+ }
+
+ public static Test suite()
+ {
+ return new TestSuite(BasicTests.class);
+ }
+
+ public static void main(String[] args)
+ {
+ junit.textui.TestRunner.run(suite());
+ }
+
+ public void testInitialization()
+ {
+ System.out.println("Initializing SVN native resources...");
+ NativeResources.getInstance().initialize();
+ System.out.println("Success!");
+ }
+
+ /*
+ public void testBasicCheckout() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ try
+ {
+ client.checkout(thisTest.getURL() + "/A",
+ thisTest.getWorkingCopy().getAbsolutePath(),
+ null, true);
+ fail("missing exception");
+ }
+ catch (ClientException e)
+ {
+ }
+ File mu = new File(thisTest.getWorkingCopy(), "A/mu");
+ PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
+ muPW.print("appended mu text");
+ muPW.close();
+ thisTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
+ File lambda = new File(thisTest.getWorkingCopy(), "A/B/lambda");
+ lambda.delete();
+ thisTest.getWc().setItemTextStatus("A/B/lambda", Status.Kind.missing);
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()
+ + "/A/D/G"}, null, false);
+ thisTest.getWc().setItemTextStatus("A/D/G", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G/pi", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G/tau", Status.Kind.deleted);
+ thisTest.checkStatus();
+ client.checkout(thisTest.getURL(),
+ thisTest.getWorkingCopy().getAbsolutePath(),
+ null, true);
+ thisTest.getWc().setItemTextStatus("A/B/lambda", Status.Kind.normal);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicStatus() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ thisTest.checkStatus();
+ }
+
+ public void testBasicCommit() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File mu = new File(thisTest.getWorkingCopy(), "A/mu");
+ PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
+ muPW.print("appended mu text");
+ muPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
+ thisTest.getWc().setItemContent("A/mu",
+ thisTest.getWc().getItemContent("A/mu")
+ + "appended mu text");
+ File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
+ PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
+ rhoPW.print("new appended text for rho");
+ rhoPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
+ thisTest.getWc().setItemContent("A/D/G/rho", thisTest.getWc().getItemContent("A/D/G/rho") + "new appended text for rho");
+ assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log msg", true), 2);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicUpdate() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ OneTest backupTest = thisTest.copy(".backup");
+ File mu = new File(thisTest.getWorkingCopy(), "A/mu");
+ PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
+ muPW.print("appended mu text");
+ muPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
+ thisTest.getWc().setItemContent("A/mu",
+ thisTest.getWc().getItemContent("A/mu")
+ + "appended mu text");
+ File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
+ PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
+ rhoPW.print("new appended text for rho");
+ rhoPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
+ thisTest.getWc().setItemContent("A/D/G/rho", thisTest.getWc().getItemContent("A/D/G/rho") + "new appended text for rho");
+ assertEquals("wrong revision number from commit",
+ client.commit(new String[] {thisTest.getWorkingCopy().getAbsolutePath()},
+ "log msg", true), 2);
+ thisTest.checkStatus();
+ assertEquals("wrong revision number from update",
+ client.update(backupTest.getWorkingCopy().getAbsolutePath(),
+ null, true), 2);
+ backupTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
+ backupTest.getWc().setItemContent("A/mu",
+ backupTest.getWc().getItemContent("A/mu") + "appended mu text");
+ backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
+ backupTest.getWc().setItemContent("A/D/G/rho",
+ backupTest.getWc().getItemContent("A/D/G/rho") + "new appended text for rho");
+ backupTest.checkStatus();
+ }
+
+ public void testBasicMkdirUrl() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ String url = thisTest.getURL();
+ client.mkdir(new String[] { url + "/Y", url + "/Y/Z" }, "log_msg");
+ thisTest.getWc().addItem("Y", null);
+ thisTest.getWc().setItemWorkingCopyRevision("Y", 2);
+ thisTest.getWc().addItem("Y/Z", null);
+ thisTest.getWc().setItemWorkingCopyRevision("Y/Z", 2);
+ assertEquals("wrong revision from update",
+ client.update(thisTest.getWorkingCopy().getAbsolutePath(),
+ null, true), 2);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicMergingUpdate() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File mu = new File(thisTest.getWorkingCopy(), "A/mu");
+ PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
+ String muContent = thisTest.getWc().getItemContent("A/mu");
+ File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
+ PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
+ String rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
+ for (int i = 2; i < 11; i++)
+ {
+ muPW.print("\nThis is line " + i + " in mu");
+ muContent = muContent + "\nThis is line " + i + " in mu";
+ rhoPW.print("\nThis is line " + i + " in rho");
+ rhoContent = rhoContent + "\nThis is line " + i + " in rho";
+ }
+ muPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
+ thisTest.getWc().setItemContent("A/mu", muContent);
+ rhoPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
+ thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
+ assertEquals("wrong revision number from commit",
+ client.commit(new String[] { thisTest.getWorkingCopy().getAbsolutePath() },
+ "log msg", true), 2);
+ thisTest.checkStatus();
+ OneTest backupTest = thisTest.copy(".backup");
+ muPW = new PrintWriter(new FileOutputStream(mu, true));
+ muContent = thisTest.getWc().getItemContent("A/mu");
+ rhoPW = new PrintWriter(new FileOutputStream(rho, true));
+ rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
+ muPW.print(" Appended to line 10 of mu");
+ muContent = muContent + " Appended to line 10 of mu";
+ rhoPW.print(" Appended to line 10 of rho");
+ rhoContent = rhoContent + " Appended to line 10 of rho";
+ muPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/mu", 3);
+ thisTest.getWc().setItemContent("A/mu", muContent);
+ rhoPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 3);
+ thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
+ assertEquals("wrong revision number from commit",
+ client.commit(new String[] { thisTest.getWorkingCopy().getAbsolutePath() },
+ "log msg", true), 3);
+ thisTest.checkStatus();
+ mu = new File(backupTest.getWorkingCopy(), "A/mu");
+ muPW = new PrintWriter(new FileOutputStream(mu));
+ muPW.print("This is the new line 1 in the backup copy of mu");
+ muContent = "This is the new line 1 in the backup copy of mu";
+ rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho");
+ rhoPW = new PrintWriter(new FileOutputStream(rho));
+ rhoPW.print("This is the new line 1 in the backup copy of rho");
+ rhoContent = "This is the new line 1 in the backup copy of rho";
+ for (int i = 2; i < 11; i++)
+ {
+ muPW.print("\nThis is line " + i + " in mu");
+ muContent = muContent + "\nThis is line " + i + " in mu";
+ rhoPW.print("\nThis is line " + i + " in rho");
+ rhoContent = rhoContent + "\nThis is line " + i + " in rho";
+ }
+ muPW.close();
+ backupTest.getWc().setItemWorkingCopyRevision("A/mu", 3);
+ muContent = muContent + " Appended to line 10 of mu";
+ backupTest.getWc().setItemContent("A/mu", muContent);
+ backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
+ rhoPW.close();
+ backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 3);
+ rhoContent = rhoContent + " Appended to line 10 of rho";
+ backupTest.getWc().setItemContent("A/D/G/rho", rhoContent);
+ backupTest.getWc().setItemTextStatus("A/D/G/rho",
+ Status.Kind.modified);
+ assertEquals("wrong revision number from update",
+ client.update(backupTest.getWorkingCopy().getAbsolutePath(),
+ null, true), 3);
+ backupTest.checkStatus();
+ }
+
+ public void testBasicConflict() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ OneTest backupTest = thisTest.copy(".backup");
+ File mu = new File(thisTest.getWorkingCopy(), "A/mu");
+ PrintWriter muPW = new PrintWriter(new FileOutputStream(mu, true));
+ String muContent = thisTest.getWc().getItemContent("A/mu");
+ File rho = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
+ PrintWriter rhoPW = new PrintWriter(new FileOutputStream(rho, true));
+ String rhoContent = thisTest.getWc().getItemContent("A/D/G/rho");
+ muPW.print("\nOriginal appended text for mu");
+ muContent = muContent + "\nOriginal appended text for mu";
+ rhoPW.print("\nOriginal appended text for rho");
+ rhoContent = rhoContent + "\nOriginal appended text for rho";
+ muPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
+ thisTest.getWc().setItemContent("A/mu", muContent);
+ rhoPW.close();
+ thisTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
+ thisTest.getWc().setItemContent("A/D/G/rho", rhoContent);
+ assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log msg", true), 2);
+ thisTest.checkStatus();
+ mu = new File(backupTest.getWorkingCopy(), "A/mu");
+ muPW = new PrintWriter(new FileOutputStream(mu, true));
+ rho = new File(backupTest.getWorkingCopy(), "A/D/G/rho");
+ rhoPW = new PrintWriter(new FileOutputStream(rho, true));
+ muPW.print("\nConflicting appended text for mu");
+ muContent = "<<<<<<< .mine\nThis is the file 'mu'.\nConflicting appended text for mu=======\nThis is the file 'mu'.\nOriginal appended text for mu>>>>>>> .r2";
+ rhoPW.print("\nConflicting appended text for rho");
+ rhoContent = "<<<<<<< .mine\nThis is the file 'rho'.\nConflicting appended text for rho=======\nhis is the file 'rho'.\nOriginal appended text for rho>>>>>>> .r2";
+ muPW.close();
+ backupTest.getWc().setItemWorkingCopyRevision("A/mu", 2);
+ backupTest.getWc().setItemContent("A/mu", muContent);
+ backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.conflicted);
+ rhoPW.close();
+ backupTest.getWc().setItemWorkingCopyRevision("A/D/G/rho", 2);
+ backupTest.getWc().setItemContent("A/D/G/rho", rhoContent);
+ backupTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.conflicted);
+ backupTest.getWc().addItem("A/mu.r1", "");
+ backupTest.getWc().setItemNodeKind("A/mu.r1", NodeKind.unknown);
+ backupTest.getWc().setItemTextStatus("A/mu.r1",
+ Status.Kind.unversioned);
+ backupTest.getWc().addItem("A/mu.r2", "");
+ backupTest.getWc().setItemNodeKind("A/mu.r2", NodeKind.unknown);
+ backupTest.getWc().setItemTextStatus("A/mu.r2",
+ Status.Kind.unversioned);
+ backupTest.getWc().addItem("A/mu.mine", "");
+ backupTest.getWc().setItemNodeKind("A/mu.mine", NodeKind.unknown);
+ backupTest.getWc().setItemTextStatus("A/mu.mine",
+ Status.Kind.unversioned);
+ backupTest.getWc().addItem("A/D/G/rho.r1", "");
+ backupTest.getWc().setItemNodeKind("A/D/G/rho.r1", NodeKind.unknown);
+ backupTest.getWc().setItemTextStatus("A/D/G/rho.r1",
+ Status.Kind.unversioned);
+ backupTest.getWc().addItem("A/D/G/rho.r2", "");
+ backupTest.getWc().setItemNodeKind("A/D/G/rho.r2", NodeKind.unknown);
+ backupTest.getWc().setItemTextStatus("A/D/G/rho.r2",
+ Status.Kind.unversioned);
+ backupTest.getWc().addItem("A/D/G/rho.mine", "");
+ backupTest.getWc().setItemNodeKind("A/D/G/rho.mine", NodeKind.unknown);
+ backupTest.getWc().setItemTextStatus("A/D/G/rho.mine",
+ Status.Kind.unversioned);
+ assertEquals("wrong revision number from update",
+ client.update(backupTest.getWorkingCopy().getAbsolutePath(),
+ null, true), 2);
+ backupTest.checkStatus();
+ client.resolved(backupTest.getWorkingCopy().getAbsolutePath() +
+ "/A/mu", false);
+ client.resolved(backupTest.getWorkingCopy().getAbsolutePath() +
+ "/A/D/G/rho", false);
+ backupTest.getWc().setItemTextStatus("A/mu", Status.Kind.modified);
+ backupTest.getWc().removeItem("A/mu.r1");
+ backupTest.getWc().removeItem("A/mu.r2");
+ backupTest.getWc().removeItem("A/mu.mine");
+ backupTest.getWc().setItemTextStatus("A/D/G/rho",
+ Status.Kind.modified);
+ backupTest.getWc().removeItem("A/D/G/rho.r1");
+ backupTest.getWc().removeItem("A/D/G/rho.r2");
+ backupTest.getWc().removeItem("A/D/G/rho.mine");
+ backupTest.checkStatus();
+ }
+
+ public void testBasicCleanup() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File adminLock = new File(thisTest.getWorkingCopy(),"A/B/.svn/lock");
+ PrintWriter pw = new PrintWriter(new FileOutputStream(adminLock));
+ pw.print("stop looking!");
+ pw.close();
+ thisTest.getWc().setItemIsLocked("A/B", true);
+ adminLock = new File(thisTest.getWorkingCopy(),"A/D/G/.svn/lock");
+ pw = new PrintWriter(new FileOutputStream(adminLock));
+ pw.print("stop looking!");
+ pw.close();
+ thisTest.getWc().setItemIsLocked("A/D/G", true);
+ adminLock = new File(thisTest.getWorkingCopy(),"A/C/.svn/lock");
+ pw = new PrintWriter(new FileOutputStream(adminLock));
+ pw.print("stop looking!");
+ pw.close();
+ thisTest.getWc().setItemIsLocked("A/C", true);
+ thisTest.checkStatus();
+ client.cleanup(thisTest.getWorkingCopy().getAbsolutePath());
+ thisTest.getWc().setItemIsLocked("A/B", false);
+ thisTest.getWc().setItemIsLocked("A/D/G", false);
+ thisTest.getWc().setItemIsLocked("A/C", false);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicRevert() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File file = new File(thisTest.getWorkingCopy(), "A/B/E/beta");
+ PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
+ pw.print("Added some text to 'beta'.");
+ pw.close();
+ thisTest.getWc().setItemTextStatus("A/B/E/beta", Status.Kind.modified);
+ file = new File(thisTest.getWorkingCopy(), "iota");
+ pw = new PrintWriter(new FileOutputStream(file, true));
+ pw.print("Added some text to 'iota'.");
+ pw.close();
+ thisTest.getWc().setItemTextStatus("iota", Status.Kind.modified);
+ file = new File(thisTest.getWorkingCopy(), "A/D/G/rho");
+ pw = new PrintWriter(new FileOutputStream(file, true));
+ pw.print("Added some text to 'rho'.");
+ pw.close();
+ thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.modified);
+ file = new File(thisTest.getWorkingCopy(), "A/D/H/zeta");
+ pw = new PrintWriter(new FileOutputStream(file, true));
+ pw.print("Added some text to 'zeta'.");
+ pw.close();
+ thisTest.getWc().addItem("A/D/H/zeta", "Added some text to 'zeta'.");
+ thisTest.getWc().setItemTextStatus("A/D/H/zeta", Status.Kind.added);
+ client.add(file.getAbsolutePath(), false);
+ thisTest.checkStatus();
+ client.revert(thisTest.getWorkingCopy().getAbsolutePath() +
+ "/A/B/E/beta", false);
+ client.revert(thisTest.getWorkingCopy().getAbsolutePath() + "/iota",
+ false);
+ client.revert(thisTest.getWorkingCopy().getAbsolutePath() +
+ "/A/D/G/rho", false);
+ client.revert(thisTest.getWorkingCopy().getAbsolutePath() +
+ "/A/D/H/zeta", false);
+ thisTest.getWc().setItemTextStatus("A/B/E/beta", Status.Kind.normal);
+ thisTest.getWc().setItemTextStatus("iota", Status.Kind.normal);
+ thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.normal);
+ thisTest.getWc().setItemTextStatus("A/D/H/zeta",
+ Status.Kind.unversioned);
+ thisTest.getWc().setItemNodeKind("A/D/H/zeta", NodeKind.unknown);
+ thisTest.checkStatus();
+
+ file = new File(thisTest.getWorkingCopy(), "A/B/E/beta");
+ file.delete();
+ client.revert(file.getAbsolutePath(), false);
+ assertTrue("reverted file is not readonly",
+ file.canWrite() && file.canRead());
+ thisTest.checkStatus();
+
+ client.mkdir(new String[] {thisTest.getWorkingCopy().getAbsolutePath()
+ + "/X"}, null);
+ thisTest.getWc().addItem("X", null);
+ thisTest.getWc().setItemTextStatus("X", Status.Kind.added);
+ thisTest.checkStatus();
+
+ removeDirectoryWithContent(new File(thisTest.getWorkingCopy(), "X"));
+ client.revert(thisTest.getWorkingCopy().getAbsolutePath()+"/X", false);
+ thisTest.getWc().removeItem("X");
+ thisTest.checkStatus();
+
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()
+ + "/A/B/E"}, null, true);
+ removeDirectoryWithContent(new File(thisTest.getWorkingCopy(),
+ "A/B/E"));
+ thisTest.getWc().setItemTextStatus("A/B/E", Status.Kind.deleted);
+ thisTest.getWc().removeItem("A/B/E/alpha");
+ thisTest.getWc().removeItem("A/B/E/beta");
+ thisTest.checkStatus();
+ client.revert(thisTest.getWorkingCopy().getAbsolutePath() + "/A/B/E",
+ true);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicSwitch() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ String iotaPath = thisTest.getWorkingCopy().getAbsolutePath() +
+ "\\iota";
+ String gammaUrl = thisTest.getURL() + "/A/D/gamma";
+ thisTest.getWc().setItemContent("iota",
+ greekWC.getItemContent("A/D/gamma"));
+ thisTest.getWc().setItemIsSwitched("iota", true);
+ client.doSwitch(iotaPath, gammaUrl, null, true);
+ thisTest.checkStatus();
+
+ String adhPath = thisTest.getWorkingCopy().getAbsolutePath() +
+ "/A/D/H";
+ String adgURL = thisTest.getURL() + "/A/D/G";
+ thisTest.getWc().setItemIsSwitched("A/D/H",true);
+ thisTest.getWc().removeItem("A/D/H/chi");
+ thisTest.getWc().removeItem("A/D/H/omega");
+ thisTest.getWc().removeItem("A/D/H/psi");
+ thisTest.getWc().addItem("A/D/H/pi",
+ thisTest.getWc().getItemContent("A/D/G/pi"));
+ thisTest.getWc().addItem("A/D/H/rho", thisTest.getWc().getItemContent("A/D/G/rho"));
+ thisTest.getWc().addItem("A/D/H/tau", thisTest.getWc().getItemContent("A/D/G/tau"));
+ client.doSwitch(adhPath, adgURL, null, true);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicDelete() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File file = new File(thisTest.getWorkingCopy(), "A/D/H/chi");
+ PrintWriter pw = new PrintWriter(new FileOutputStream(file, true));
+ pw.print("added to chi");
+ pw.close();
+ thisTest.getWc().setItemTextStatus("A/D/H/chi", Status.Kind.modified);
+ client.propertySet(thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G/rho", "abc", "def", true);
+ thisTest.getWc().setItemPropStatus("A/D/G/rho", Status.Kind.modified);
+ client.propertySet(thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/F", "abc", "def", false);
+ thisTest.getWc().setItemPropStatus("A/B/F", Status.Kind.modified);
+ file = new File(thisTest.getWorkingCopy().getAbsolutePath(),"A/C/sigma");
+ pw = new PrintWriter(new FileOutputStream(file));
+ pw.print("unversioned sigma");
+ pw.close();
+ thisTest.getWc().addItem("A/C/sigma", "unversioned sigma");
+ thisTest.getWc().setItemTextStatus("A/C/sigma", Status.Kind.unversioned);
+ thisTest.getWc().setItemNodeKind("A/C/sigma", NodeKind.unknown);
+ file = new File(thisTest.getWorkingCopy().getAbsolutePath(), "A/C/Q");
+ file.mkdir();
+ thisTest.getWc().addItem("A/C/Q", null);
+ thisTest.getWc().setItemNodeKind("A/C/Q", NodeKind.unknown);
+ thisTest.getWc().setItemTextStatus("A/C/Q", Status.Kind.unversioned);
+ file = new File(thisTest.getWorkingCopy().getAbsolutePath(), "A/B/X");
+ client.mkdir(new String[] {file.getAbsolutePath()}, null);
+ thisTest.getWc().addItem("A/B/X", null);
+ thisTest.getWc().setItemTextStatus("A/B/X", Status.Kind.added);
+ file = new File(file, "xi");
+ pw = new PrintWriter(new FileOutputStream(file));
+ pw.print("added xi");
+ pw.close();
+ client.add(file.getAbsolutePath(),false);
+ thisTest.getWc().addItem("A/B/X/xi", "added xi");
+ thisTest.getWc().setItemTextStatus("A/B/X/xi", Status.Kind.added);
+ file = new File(thisTest.getWorkingCopy().getAbsolutePath(), "A/B/Y");
+ client.mkdir(new String[] {file.getAbsolutePath()}, null);
+ thisTest.getWc().addItem("A/B/Y", null);
+ thisTest.getWc().setItemTextStatus("A/B/Y", Status.Kind.added);
+ thisTest.checkStatus();
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/H/chi"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/H"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G/rho"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/F"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/C/sigma"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/C"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ try
+ {
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/X"}, null, false);
+ fail("missing exception");
+ }
+ catch(ClientException e)
+ {
+ }
+
+ thisTest.checkStatus();
+
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/E"}, null, false);
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/H"}, null, true);
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/G"}, null, true);
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/F"}, null, true);
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/C"}, null, true);
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/X"}, null, true);
+ file = new File(thisTest.getWorkingCopy(), "iota");
+ file.delete();
+ client.remove(new String[] {file.getAbsolutePath()}, null, true);
+ file = new File(thisTest.getWorkingCopy(), "A/D/gamma");
+ file.delete();
+ client.remove(new String[] {file.getAbsolutePath()}, null, false);
+ client.remove(new String[] {file.getAbsolutePath()}, null, true);
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/B/E"}, null, false);
+ thisTest.getWc().setItemTextStatus("A/D/H",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/H/chi",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/H/omega",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/H/psi",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G/rho",Status.Kind.deleted);
+ thisTest.getWc().setItemPropStatus("A/D/G/rho", Status.Kind.none);
+ thisTest.getWc().setItemTextStatus("A/D/G/pi",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G/tau",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/B/E",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/B/E/alpha",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/B/E/beta",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/B/F",Status.Kind.deleted);
+ thisTest.getWc().setItemPropStatus("A/B/F", Status.Kind.none);
+ thisTest.getWc().setItemTextStatus("A/C",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("iota",Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/gamma",Status.Kind.deleted);
+ thisTest.getWc().removeItem("A/B/X");
+ thisTest.getWc().removeItem("A/B/X/xi");
+ thisTest.getWc().removeItem("A/C/sigma");
+ thisTest.getWc().removeItem("A/C/Q");
+ thisTest.checkStatus();
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D"},null, true);
+ thisTest.getWc().setItemTextStatus("A/D", Status.Kind.deleted);
+ thisTest.getWc().removeItem("A/D/Y");
+ thisTest.checkStatus();
+
+ assertFalse("failed to remove text modified file", new File(thisTest.getWorkingCopy(), "A/D/G/rho").exists());
+ assertFalse("failed to remove prop modified file", new File(thisTest.getWorkingCopy(), "A/D/H/chi").exists());
+ assertFalse("failed to remove unversioned file", new File(thisTest.getWorkingCopy(), "A/C/sigma").exists());
+ assertFalse("failed to remove unmodified file", new File(thisTest.getWorkingCopy(), "A/B/E/alpha").exists());
+ file = new File(thisTest.getWorkingCopy(),"A/B/F");
+ assertTrue("removed versioned dir", file.exists() && file.isDirectory());
+ assertFalse("failed to remove unversioned dir", new File(thisTest.getWorkingCopy(), "A/C/Q").exists());
+ assertFalse("failed to remove added dir", new File(thisTest.getWorkingCopy(), "A/B/X").exists());
+
+ file = new File(thisTest.getWorkingCopy().getAbsolutePath(),"foo");
+ pw = new PrintWriter(new FileOutputStream(file));
+ pw.print("unversioned foo");
+ pw.close();
+ client.remove(new String[] {file.getAbsolutePath()}, null, true);
+ assertFalse("failed to remove unversioned file foo", file.exists());
+ client.remove(new String[] {file.getAbsolutePath()}, null, true);
+ client.remove(new String[] {thisTest.getURL()+"/iota"}, "delete iota URL", false);
+ }
+
+ public void testBasicCheckoutDeleted() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D"}, null, true);
+ thisTest.getWc().setItemTextStatus("A/D", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G/rho", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G/pi", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/G/tau", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/H", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/H/chi", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/H/psi", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/H/omega", Status.Kind.deleted);
+ thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.deleted);
+ thisTest.checkStatus();
+ assertEquals("wrong revision from commit",client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()}, "log message", true),2);
+ thisTest.getWc().removeItem("A/D");
+ thisTest.getWc().removeItem("A/D/G");
+ thisTest.getWc().removeItem("A/D/G/rho");
+ thisTest.getWc().removeItem("A/D/G/pi");
+ thisTest.getWc().removeItem("A/D/G/tau");
+ thisTest.getWc().removeItem("A/D/H");
+ thisTest.getWc().removeItem("A/D/H/chi");
+ thisTest.getWc().removeItem("A/D/H/psi");
+ thisTest.getWc().removeItem("A/D/H/omega");
+ thisTest.getWc().removeItem("A/D/gamma");
+ thisTest.checkStatus();
+ client.checkout(thisTest.getURL()+"/A/D", thisTest.getWorkingCopy().getAbsolutePath()+"/new_D", new Revision.Number(1), true);
+ }
+
+ public void testBasicNodeKindChange() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ client.remove(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/gamma"}, null, false);
+ thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.deleted);
+ thisTest.checkStatus();
+ try
+ {
+ client.mkdir(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/gamma"}, null);
+ fail("can change node kind");
+ }
+ catch(ClientException e)
+ {
+
+ }
+ thisTest.checkStatus();
+ assertEquals("wrong revision number from commit", client.commit(new String[]{thisTest.getWorkingCopy().getAbsolutePath()},"log message", true), 2);
+ thisTest.getWc().removeItem("A/D/gamma");
+ thisTest.checkStatus();
+
+ try
+ {
+ client.mkdir(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/gamma"}, null);
+ fail("can change node kind");
+ }
+ catch(ClientException e)
+ {
+
+ }
+ thisTest.checkStatus();
+ client.update(thisTest.getWorkingCopy().getAbsolutePath(), null, true);
+ thisTest.checkStatus();
+ client.mkdir(new String[] {thisTest.getWorkingCopy().getAbsolutePath()+"/A/D/gamma"}, null);
+ thisTest.getWc().addItem("A/D/gamma", null);
+ thisTest.getWc().setItemTextStatus("A/D/gamma", Status.Kind.added);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicImport() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File file = new File(thisTest.getWorkingCopy().getAbsolutePath(),"new_file");
+ PrintWriter pw = new PrintWriter(new FileOutputStream(file));
+ pw.print("some text");
+ pw.close();
+ client.doImport(file.getAbsolutePath(), thisTest.getURL()+"/dirA/dirB/new_file","log message for new import", true);
+ file.delete();
+ assertEquals("wrong revision from commit",client.update(thisTest.getWorkingCopy().getAbsolutePath(), null, true),2);
+ thisTest.getWc().addItem("dirA", null);
+ thisTest.getWc().setItemWorkingCopyRevision("dirA",2);
+ thisTest.getWc().addItem("dirA/dirB", null);
+ thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB",2);
+ thisTest.getWc().addItem("dirA/dirB/new_file", "some text");
+ thisTest.getWc().setItemWorkingCopyRevision("dirA/dirB/new_file",2);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicCat() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File mu = new File(thisTest.getWorkingCopy(), "A/mu");
+ PrintWriter pw = new PrintWriter(new FileOutputStream(mu, true));
+ pw.print("some text");
+ pw.close();
+ byte[] content = client.fileContent(thisTest.getWorkingCopy().getAbsolutePath()+"/A/mu", null);
+ byte[] testContent = thisTest.getWc().getItemContent("A/mu").getBytes();
+ assertTrue("content changed", Arrays.equals(content, testContent));
+ }
+
+ public void testBasicLs() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+
+ DirEntry[] entries = client.list(thisTest.getWorkingCopy().getAbsolutePath(), null, false);
+ thisTest.getWc().check(entries,"", false);
+ entries = client.list(thisTest.getWorkingCopy().getAbsolutePath()+"/A", null, false);
+ thisTest.getWc().check(entries,"A", false);
+ entries = client.list(thisTest.getWorkingCopy().getAbsolutePath()+"/A", Revision.BASE, false);
+ thisTest.getWc().check(entries,"A", false);
+ entries = client.list(thisTest.getWorkingCopy().getAbsolutePath()+"/A/mu", null, false);
+ thisTest.getWc().check(entries,"A/mu");
+ }
+
+ public void testBasicAddIgnores() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File dir = new File(thisTest.getWorkingCopy(), "dir");
+ dir.mkdir();
+ File fileC = new File(dir, "foo.c");
+ new FileOutputStream(fileC).close();
+ File fileO = new File(dir, "foo.o");
+ new FileOutputStream(fileO).close();
+ client.add(dir.getAbsolutePath(), true);
+ thisTest.getWc().addItem("dir", null);
+ thisTest.getWc().setItemTextStatus("dir",Status.Kind.added);
+ thisTest.getWc().addItem("dir/foo.c", "");
+ thisTest.getWc().setItemTextStatus("dir/foo.c",Status.Kind.added);
+ thisTest.getWc().addItem("dir/foo.o", "");
+ thisTest.getWc().setItemTextStatus("dir/foo.o",Status.Kind.ignored);
+ thisTest.getWc().setItemNodeKind("dir/foo.o", NodeKind.unknown);
+ thisTest.checkStatus();
+ }
+
+ public void testBasicImportIgnores() throws Throwable
+ {
+ OneTest thisTest = new OneTest();
+ File dir = new File(thisTest.getWorkingCopy(), "dir");
+ dir.mkdir();
+ File fileC = new File(dir, "foo.c");
+ new FileOutputStream(fileC).close();
+ File fileO = new File(dir, "foo.o");
+ new FileOutputStream(fileO).close();
+ client.doImport(dir.getAbsolutePath(), thisTest.getURL()+"/dir","log message for import", true);
+ removeDirectoryWithContent(dir);
+ assertEquals("wrong revision from update", 2, client.update(thisTest.getWorkingCopy().getAbsolutePath(), null, true));
+ thisTest.getWc().addItem("dir", null);
+ thisTest.getWc().addItem("dir/foo.c", "");
+ thisTest.checkStatus();
+ */
+
+/*
+ 'do not import ignored files in imported dirs'
+
+ # The bug was that
+ #
+ # $ svn import dir
+ #
+ # where dir contains some items that match the ignore list and some
+ # do not would add all items, ignored or not.
+ #
+ # This has been fixed by testing each item with the new
+ # svn_wc_is_ignored function.
+
+ sbox.build()
+ wc_dir = sbox.wc_dir
+
+ dir_path = os.path.join(wc_dir, 'dir')
+ foo_c_path = os.path.join(dir_path, 'foo.c')
+ foo_o_path = os.path.join(dir_path, 'foo.o')
+
+ os.mkdir(dir_path, 0755)
+ open(foo_c_path, 'w')
+ open(foo_o_path, 'w')
+
+ # import new dir into repository
+ url = svntest.main.current_repo_url + '/dir'
+
+ output, errput = svntest.actions.run_and_verify_svn(
+ None, None, [], 'import',
+ '--username', svntest.main.wc_author,
+ '--password', svntest.main.wc_passwd,
+ '-m', 'Log message for new import',
+ dir_path, url)
+
+ lastline = string.strip(output.pop())
+ cm = re.compile ("(Committed|Imported) revision [0-9]+.")
+ match = cm.search (lastline)
+ if not match:
+ ### we should raise a less generic error here. which?
+ raise svntest.actions.SVNUnexpectedOutput
+
+ # remove (uncontrolled) local dir
+ svntest.main.safe_rmtree(dir_path)
+
+ # Create expected disk tree for the update (disregarding props)
+ expected_disk = svntest.main.greek_state.copy()
+ expected_disk.add({
+ 'dir/foo.c' : Item(''),
+ })
+
+ # Create expected status tree for the update (disregarding props).
+ # Newly imported file should be at revision 2.
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 2)
+ expected_status.add({
+ 'dir' : Item(status=' ', wc_rev=2, repos_rev=2),
+ 'dir/foo.c' : Item(status=' ', wc_rev=2, repos_rev=2),
+ })
+
+ # Create expected output tree for the update.
+ expected_output = svntest.wc.State(wc_dir, {
+ 'dir' : Item(status='A '),
+ 'dir/foo.c' : Item(status='A '),
+ })
+
+ # do update and check three ways
+ svntest.actions.run_and_verify_update(wc_dir,
+ expected_output,
+ expected_disk,
+ expected_status,
+ None, None, None,
+ None, None, 1)
+
+*/
+ //}
+}
Index: subversion/bindings/swig/java/org/tigris/subversion/test/SVNTests.java
===================================================================
--- subversion/bindings/swig/java/org/tigris/subversion/test/SVNTests.java (revision 0)
+++ subversion/bindings/swig/java/org/tigris/subversion/test/SVNTests.java (working copy)
@@ -1,296 +1,343 @@
-package org.tigris.subversion.javahl.tests;
-
-/**
- * @copyright
- * ====================================================================
- * Copyright (c) 2003-2004 CollabNet. All rights reserved.
- *
- * This software is licensed as described in the file COPYING, which
- * you should have received as part of this distribution. The terms
- * are also available at http://subversion.tigris.org/license-1.html.
- * If newer versions of this license are posted there, you may use a
- * newer version instead, at your option.
- *
- * This software consists of voluntary contributions made by many
- * individuals. For exact contribution history, see the revision
- * history and logs, available at http://subversion.tigris.org/.
- * ====================================================================
- * @endcopyright
- */
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-import org.tigris.subversion.javahl.*;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.FileInputStream;
-
-public class SVNTests extends TestCase
-{
- protected SVNAdmin admin;
- protected SVNClient client;
- protected String urlSchema = "file:///";
- protected File rootDir = new File(System.getProperty("user.dir"));
- protected String testBaseName;
- protected static int testCounter;
- protected File greekDump;
- protected File greekRepos;
- protected WC greekWC;
- protected File localTmp;
- protected File repositories;
- protected File workingCopies;
- protected File conf;
-
- protected void setUp() throws Exception
- {
- super.setUp();
- admin = new SVNAdmin();
- client = new SVNClient();
-// client.notification(new Notify() {
-// /**
-// * Handler for Subversion notifications.
-// *
-// * Override this function to allow Subversion to
-// * send notifications
-// * @param path on which action happen
-// * @param action subversion action, see svn_wc_notify_action_t
-// * @param kind node kind of path after action occurred
-// * @param mimeType mime type of path after action occurred
-// * @param contentState state of content after action occurred
-// * @param propState state of properties after action occurred
-// * @param revision revision number after action occurred
-// */
-// public void onNotify(String path, int action, int kind, String mimeType, int contentState, int propState, long revision)
-// {
-// System.out.println(path+" "+action+" "+kind+" "+mimeType+" "+contentState+" "+propState+" "+revision);
-// }
-// });
- localTmp = new File(rootDir, "local_tmp");
- if(localTmp.exists())
- removeDirectoryWithContent(localTmp);
- localTmp.mkdir();
- conf = new File(localTmp, "config");
- conf.mkdir();
- File greekFiles = buildGreekFiles();
- greekRepos = new File(localTmp, "repos");
- greekDump = new File(localTmp, "greek_dump");
- repositories = new File(rootDir, "repositories");
- repositories.mkdirs();
- workingCopies = new File(rootDir, "working_copies");
- workingCopies.mkdirs();
- admin.create(greekRepos.getAbsolutePath(), true,false, null);
- client.username("jrandom");
- client.password("rayjandom");
- client.setConfigDirectory(conf.getAbsolutePath());
- client.doImport(greekFiles.getAbsolutePath(), makeReposUrl(greekRepos),"Log message for revision 1.", true );
- admin.dump(greekRepos.getAbsolutePath(), new FileOutputer(greekDump), new IgnoreOutputer(), null, null, false);
- }
-
- private File buildGreekFiles() throws IOException
- {
- File greekFiles = new File(localTmp, "greek_files");
- greekFiles.mkdir();
- greekWC = new WC();
- greekWC.addItem("",null);
- greekWC.addItem("iota", "This is the file 'iota'.");
- greekWC.addItem("A", null);
- greekWC.addItem("A/mu", "This is the file 'mu'.");
- greekWC.addItem("A/B", null);
- greekWC.addItem("A/B/lambda", "This is the file 'lambda'.");
- greekWC.addItem("A/B/E", null);
- greekWC.addItem("A/B/E/alpha", "This is the file 'alpha'.");
- greekWC.addItem("A/B/E/beta", "This is the file 'beta'.");
- greekWC.addItem("A/B/F", null);
- greekWC.addItem("A/C", null);
- greekWC.addItem("A/D", null);
- greekWC.addItem("A/D/gamma", "This is the file 'gamma'.");
- greekWC.addItem("A/D/H", null);
- greekWC.addItem("A/D/H/chi", "This is the file 'chi'.");
- greekWC.addItem("A/D/H/psi", "This is the file 'psi'.");
- greekWC.addItem("A/D/H/omega", "This is the file 'omega'.");
- greekWC.addItem("A/D/G", null);
- greekWC.addItem("A/D/G/pi", "This is the file 'pi'.");
- greekWC.addItem("A/D/G/rho", "This is the file 'rho'.");
- greekWC.addItem("A/D/G/tau", "This is the file 'tau'.");
- greekWC.materialize(greekFiles);
- return greekFiles;
- }
-
- protected void removeDirectoryWithContent(File localTmp)
- {
- if(localTmp.isDirectory())
- {
- File[] content = localTmp.listFiles();
- for(int i = 0; i < content.length; i++)
- removeDirectoryWithContent(content[i]);
- }
- localTmp.delete();
- }
-
- protected void tearDown() throws Exception
- {
- admin.dispose();
-// client.notification(null);
- client.dispose();
- removeDirectoryWithContent(localTmp);
- super.tearDown();
- }
-
- protected String makeReposUrl(File file)
- {
- return urlSchema + file.getAbsolutePath().replace(File.separatorChar, '/');
- }
-
- public class FileOutputer implements OutputInterface
- {
- FileOutputStream myStream;
- public FileOutputer(File outputName) throws IOException
- {
- myStream = new FileOutputStream(outputName);
- }
-
- /**
- * write the bytes in data to java
- * @param data the data to be writtem
- * @throws IOException throw in case of problems.
- */
- public int write(byte[] data) throws IOException
- {
- myStream.write(data);
- return data.length;
- }
-
- /**
- * close the output
- * @throws IOException throw in case of problems.
- */
- public void close() throws IOException
- {
- myStream.close();
- }
- }
-
- public class IgnoreOutputer implements OutputInterface
- {
- /**
- * write the bytes in data to java
- * @param data the data to be writtem
- * @throws IOException throw in case of problems.
- */
- public int write(byte[] data) throws IOException
- {
- return data.length;
- }
-
- /**
- * close the output
- * @throws IOException throw in case of problems.
- */
- public void close() throws IOException
- {
- }
- }
-
- public class FileInputer implements InputInterface
- {
- FileInputStream myStream;
- public FileInputer(File inputName) throws IOException
- {
- myStream = new FileInputStream(inputName);
- }
-
- /**
- * read the number of data.length bytes from input.
- * @param data array to store the read bytes.
- * @throws IOException throw in case of problems.
- */
- public int read(byte[] data) throws IOException
- {
- return myStream.read(data);
- }
-
- /**
- * close the input
- * @throws IOException throw in case of problems.
- */
- public void close() throws IOException
- {
- myStream.close();
- }
- }
-
- public class OneTest
- {
- public File getRepository()
- {
- return repository;
- }
-
- public File getWorkingCopy()
- {
- return workingCopy;
- }
-
- public String getUrl()
- {
- return url;
- }
-
- protected File repository;
- protected File workingCopy;
- protected String url;
- protected WC wc;
-
- public WC getWc()
- {
- return wc;
- }
-
- public OneTest copy(String append) throws Exception
- {
- return new OneTest(this, append);
- }
- OneTest(OneTest orig, String append) throws Exception
- {
- String testName = testBaseName + testCounter +append;
- wc = orig.wc.copy();
- repository = orig.getRepository();
- url = orig.getUrl();
- workingCopy = createStartWorkingCopy(repository, testName);
- }
- public OneTest() throws Exception
- {
- String testName = testBaseName + ++testCounter;
- wc = greekWC.copy();
- repository = createStartRepository(testName);
- url = makeReposUrl(repository);
- workingCopy = createStartWorkingCopy(repository, testName);
- }
- protected File createStartRepository(String testName) throws Exception
- {
- File repos = new File(repositories, testName);
- removeDirectoryWithContent(repos);
- admin.create(repos.getAbsolutePath(), true, false, conf.getAbsolutePath());
- admin.load(repos.getAbsolutePath(), new FileInputer(greekDump), new IgnoreOutputer(), false, false, null);
- return repos;
- }
-
- protected File createStartWorkingCopy(File repos, String testName) throws Exception
- {
- String url = makeReposUrl(repos);
- File workingCopy = new File(workingCopies, testName);
- removeDirectoryWithContent(workingCopy);
- client.checkout(url, workingCopy.getAbsolutePath(), null, true);
- Status[] states = client.status(workingCopy.getAbsolutePath(), true, false, true, true);
- wc.check(states, workingCopy.getAbsolutePath());
- return workingCopy;
- }
-
- public void checkStatus() throws Exception
- {
- Status[] states = client.status(workingCopy.getAbsolutePath(), true, false, true, true);
- wc.check(states, workingCopy.getAbsolutePath());
- }
- }
-}
+package org.tigris.subversion.test;
+
+/**
+ * @copyright
+ * ====================================================================
+ * Copyright (c) 2003-2004 CollabNet. All rights reserved.
+ *
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at http://subversion.tigris.org/license-1.html.
+ * If newer versions of this license are posted there, you may use a
+ * newer version instead, at your option.
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals. For exact contribution history, see the revision
+ * history and logs, available at http://subversion.tigris.org/.
+ * ====================================================================
+ * @endcopyright
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.FileInputStream;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+//import org.tigris.subversion...;
+
+public class SVNTests extends TestCase
+{
+ /*
+ protected SVNAdmin admin;
+ protected SVNClient client;
+ */
+ protected String urlSchema = "file:///";
+ protected File rootDir = new File(System.getProperty("user.dir"));
+ protected String testBaseName;
+ protected static int testCounter;
+ protected File greekDump;
+ protected File greekRepos;
+ //protected WC greekWC;
+ protected File localTmp;
+ protected File repositories;
+ protected File workingCopies;
+ protected File conf;
+
+ public SVNTests(String name)
+ {
+ super(name);
+ testBaseName = name;
+ }
+
+ protected void setUp() throws Exception
+ {
+ super.setUp();
+// admin = new SVNAdmin();
+// client = new SVNClient();
+// client.notification(new Notify() {
+// /**
+// * Handler for Subversion notifications.
+// *
+// * Override this function to allow Subversion to
+// * send notifications
+// * @param path on which action happen
+// * @param action subversion action, see svn_wc_notify_action_t
+// * @param kind node kind of path after action occurred
+// * @param mimeType mime type of path after action occurred
+// * @param contentState state of content after action occurred
+// * @param propState state of properties after action occurred
+// * @param revision revision number after action occurred
+// */
+// public void onNotify(String path, int action, int kind,
+// String mimeType, int contentState,
+// int propState, long revision)
+// {
+// System.out.println(path + ' ' + action + ' ' + kind + ' ' +
+// mimeType + ' ' + contentState + ' ' +
+// propState + ' ' + revision);
+// }
+// });
+ localTmp = new File(rootDir, "local_tmp");
+ if (localTmp.exists())
+ {
+ removeDirectoryWithContent(localTmp);
+ }
+ localTmp.mkdir();
+ conf = new File(localTmp, "config");
+ conf.mkdir();
+ File greekFiles = buildGreekFiles();
+ greekRepos = new File(localTmp, "repos");
+ greekDump = new File(localTmp, "greek_dump");
+ repositories = new File(rootDir, "repositories");
+ repositories.mkdirs();
+ workingCopies = new File(rootDir, "working_copies");
+ workingCopies.mkdirs();
+ /*
+ admin.create(greekRepos.getAbsolutePath(), true, false, null);
+ client.username("jrandom");
+ client.password("rayjandom");
+ client.setConfigDirectory(conf.getAbsolutePath());
+ client.doImport(greekFiles.getAbsolutePath(), makeReposUrl(greekRepos),
+ "Log message for revision 1.", true);
+ admin.dump(greekRepos.getAbsolutePath(), new FileOutputer(greekDump),
+ new IgnoreOutputer(), null, null, false);
+ */
+ }
+
+ private File buildGreekFiles() throws IOException
+ {
+ File greekFiles = new File(localTmp, "greek_files");
+ greekFiles.mkdir();
+ /*
+ greekWC = new WC();
+ greekWC.addItem("",null);
+ greekWC.addItem("iota", "This is the file 'iota'.");
+ greekWC.addItem("A", null);
+ greekWC.addItem("A/mu", "This is the file 'mu'.");
+ greekWC.addItem("A/B", null);
+ greekWC.addItem("A/B/lambda", "This is the file 'lambda'.");
+ greekWC.addItem("A/B/E", null);
+ greekWC.addItem("A/B/E/alpha", "This is the file 'alpha'.");
+ greekWC.addItem("A/B/E/beta", "This is the file 'beta'.");
+ greekWC.addItem("A/B/F", null);
+ greekWC.addItem("A/C", null);
+ greekWC.addItem("A/D", null);
+ greekWC.addItem("A/D/gamma", "This is the file 'gamma'.");
+ greekWC.addItem("A/D/H", null);
+ greekWC.addItem("A/D/H/chi", "This is the file 'chi'.");
+ greekWC.addItem("A/D/H/psi", "This is the file 'psi'.");
+ greekWC.addItem("A/D/H/omega", "This is the file 'omega'.");
+ greekWC.addItem("A/D/G", null);
+ greekWC.addItem("A/D/G/pi", "This is the file 'pi'.");
+ greekWC.addItem("A/D/G/rho", "This is the file 'rho'.");
+ greekWC.addItem("A/D/G/tau", "This is the file 'tau'.");
+ greekWC.materialize(greekFiles);
+ */
+ return greekFiles;
+ }
+
+ protected void removeDirectoryWithContent(File localTmp)
+ {
+ if (localTmp.isDirectory())
+ {
+ File[] content = localTmp.listFiles();
+ for (int i = 0; i < content.length; i++)
+ {
+ removeDirectoryWithContent(content[i]);
+ }
+ }
+ localTmp.delete();
+ }
+
+ protected void tearDown() throws Exception
+ {
+ /*
+ admin.dispose();
+ //client.notification(null);
+ client.dispose();
+ */
+ removeDirectoryWithContent(localTmp);
+ super.tearDown();
+ }
+
+ protected String makeReposURL(File file)
+ {
+ return urlSchema + file.getAbsolutePath().replace(File.separatorChar,
+ '/');
+ }
+
+// public class FileOutputer implements OutputInterface
+// {
+// FileOutputStream myStream;
+// public FileOutputer(File outputName) throws IOException
+// {
+// myStream = new FileOutputStream(outputName);
+// }
+
+// /**
+// * write the bytes in data to java
+// * @param data the data to be writtem
+// * @throws IOException throw in case of problems.
+// */
+// public int write(byte[] data) throws IOException
+// {
+// myStream.write(data);
+// return data.length;
+// }
+
+// /**
+// * close the output
+// * @throws IOException throw in case of problems.
+// */
+// public void close() throws IOException
+// {
+// myStream.close();
+// }
+// }
+
+// public class IgnoreOutputer implements OutputInterface
+// {
+// /**
+// * write the bytes in data to java
+// * @param data the data to be writtem
+// * @throws IOException throw in case of problems.
+// */
+// public int write(byte[] data) throws IOException
+// {
+// return data.length;
+// }
+
+// /**
+// * close the output
+// * @throws IOException throw in case of problems.
+// */
+// public void close() throws IOException
+// {
+// }
+// }
+
+// public class FileInputer implements InputInterface
+// {
+// FileInputStream myStream;
+// public FileInputer(File inputName) throws IOException
+// {
+// myStream = new FileInputStream(inputName);
+// }
+
+// /**
+// * read the number of data.length bytes from input.
+// * @param data array to store the read bytes.
+// * @throws IOException throw in case of problems.
+// */
+// public int read(byte[] data) throws IOException
+// {
+// return myStream.read(data);
+// }
+
+// /**
+// * close the input
+// * @throws IOException throw in case of problems.
+// */
+// public void close() throws IOException
+// {
+// myStream.close();
+// }
+// }
+
+ public class OneTest
+ {
+ public File getRepository()
+ {
+ return repository;
+ }
+
+ public File getWorkingCopy()
+ {
+ return workingCopy;
+ }
+
+ public String getURL()
+ {
+ return url;
+ }
+
+ protected File repository;
+ protected File workingCopy;
+ protected String url;
+ //protected WC wc;
+
+ /*
+ public WC getWc()
+ {
+ return wc;
+ }
+ */
+
+ public OneTest copy(String append)
+ throws Exception
+ {
+ return new OneTest(this, append);
+ }
+
+ OneTest(OneTest orig, String append)
+ throws Exception
+ {
+ String testName = testBaseName + testCounter +append;
+ //wc = orig.wc.copy();
+ repository = orig.getRepository();
+ url = orig.getURL();
+ workingCopy = createStartWorkingCopy(repository, testName);
+ }
+
+ public OneTest()
+ throws Exception
+ {
+ String testName = testBaseName + ++testCounter;
+ //wc = greekWC.copy();
+ repository = createStartRepository(testName);
+ url = makeReposURL(repository);
+ workingCopy = createStartWorkingCopy(repository, testName);
+ }
+
+ protected File createStartRepository(String testName)
+ throws Exception
+ {
+ File repos = new File(repositories, testName);
+ removeDirectoryWithContent(repos);
+ /*
+ admin.create(repos.getAbsolutePath(), true, false,
+ conf.getAbsolutePath());
+ admin.load(repos.getAbsolutePath(), new FileInputer(greekDump),
+ new IgnoreOutputer(), false, false, null);
+ */
+ return repos;
+ }
+
+ protected File createStartWorkingCopy(File repos, String testName)
+ throws Exception
+ {
+ String url = makeReposURL(repos);
+ File workingCopy = new File(workingCopies, testName);
+ removeDirectoryWithContent(workingCopy);
+ /*
+ client.checkout(url, workingCopy.getAbsolutePath(), null, true);
+ Status[] states = client.status(workingCopy.getAbsolutePath(),
+ true, false, true, true);
+ wc.check(states, workingCopy.getAbsolutePath());
+ */
+ return workingCopy;
+ }
+
+ public void checkStatus() throws Exception
+ {
+ /*
+ Status[] states = client.status(workingCopy.getAbsolutePath(),
+ true, false, true, true);
+ wc.check(states, workingCopy.getAbsolutePath());
+ */
+ }
+ }
+}

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Mon Mar 15 20:27:10 2004

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.