You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by bo...@apache.org on 2005/02/15 15:46:47 UTC

cvs commit: ant/proposal/sandbox/svn/src/testcases/org/apache/tools/ant/taskdefs/svn SvnChangeLogTaskTest.java SvnRevisionDiffTest.java

bodewig     2005/02/15 06:46:46

  Modified:    proposal/sandbox/svn/src/etc/testcases changelog.xml
                        revisiondiff.xml
  Added:       proposal/sandbox/svn/src/testcases/org/apache/tools/ant/taskdefs/svn
                        SvnChangeLogTaskTest.java SvnRevisionDiffTest.java
  Log:
  Silly me forgot to commit the tests
  
  Revision  Changes    Path
  1.3       +0 -1      ant/proposal/sandbox/svn/src/etc/testcases/changelog.xml
  
  Index: changelog.xml
  ===================================================================
  RCS file: /home/cvs/ant/proposal/sandbox/svn/src/etc/testcases/changelog.xml,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- changelog.xml	15 Feb 2005 11:12:56 -0000	1.2
  +++ changelog.xml	15 Feb 2005 14:46:45 -0000	1.3
  @@ -21,7 +21,6 @@
   
     <property name="tmpdir" value="tmpdir"/>
     <property name="trunkdir" value="${tmpdir}/trunk"/>
  -  <property name="file" value="ebcdic.h"/>
   
     <target name="setup">
       <mkdir dir="${tmpdir}"/>
  
  
  
  1.2       +1 -3      ant/proposal/sandbox/svn/src/etc/testcases/revisiondiff.xml
  
  Index: revisiondiff.xml
  ===================================================================
  RCS file: /home/cvs/ant/proposal/sandbox/svn/src/etc/testcases/revisiondiff.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- revisiondiff.xml	15 Feb 2005 13:30:49 -0000	1.1
  +++ revisiondiff.xml	15 Feb 2005 14:46:46 -0000	1.2
  @@ -21,7 +21,6 @@
   
     <property name="tmpdir" value="tmpdir"/>
     <property name="trunkdir" value="${tmpdir}/trunk"/>
  -  <property name="file" value="ebcdic.h"/>
   
     <target name="dir-prep">
       <mkdir dir="${tmpdir}"/>
  @@ -44,8 +43,7 @@
         destfile="${tmpdir}/diff.xml" start="152904" end="153682"/>
     </target>
   
  -  <target name="report">
  -  <!--target name="report" depends="diff-using-url"-->
  +  <target name="report" depends="diff-using-url">
       <style in="${tmpdir}/diff.xml" 
         out="${tmpdir}/diff.html" 
         style="src/etc/revisiondiff.xsl">
  
  
  
  1.1                  ant/proposal/sandbox/svn/src/testcases/org/apache/tools/ant/taskdefs/svn/SvnChangeLogTaskTest.java
  
  Index: SvnChangeLogTaskTest.java
  ===================================================================
  /*
   * Copyright  2005 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  package org.apache.tools.ant.taskdefs.svn;
  
  import java.io.IOException;
  import java.io.FileReader;
  
  import org.apache.tools.ant.BuildFileTest;
  import org.apache.tools.ant.util.FileUtils;
  
  import junit.framework.Assert;
  
  /**
   */
  public class SvnChangeLogTaskTest extends BuildFileTest {
  
      public SvnChangeLogTaskTest(String name) {
          super(name);
      }
  
      public void setUp() {
          configureProject("src/etc/testcases/changelog.xml");
      }
  
      public void tearDown() {
          executeTarget("cleanup");
      }
  
      public void testLog() throws IOException {
          String log = executeTargetAndReadLogFully("log");
          assertRev153687(log);
          assertRev152685(log);
      }
  
      public void testStart() throws IOException {
          String log = executeTargetAndReadLogFully("start");
          assertRev153687(log);
          assertNoRev152685(log);
      }
  
      public void testStartDate() throws IOException {
          String log = executeTargetAndReadLogFully("startDate");
          assertRev153687(log);
          assertNoRev152685(log);
      }
  
      public void testEnd() throws IOException {
          String log = executeTargetAndReadLogFully("end");
          assertNoRev153687(log);
          assertRev152685(log);
      }
  
      public void testEndDate() throws IOException {
          String log = executeTargetAndReadLogFully("endDate");
          assertNoRev153687(log);
          assertRev152685(log);
      }
  
      private String executeTargetAndReadLogFully(String target) 
          throws IOException {
          executeTarget(target);
          FileReader r = new FileReader(getProject()
                                        .resolveFile("tmpdir/log.xml"));
          try {
              return FileUtils.readFully(r);
          } finally {
              r.close();
          }
      }
  
      private static final void assertRev153687(String log) {
          int rev = log.indexOf("<revision>153687</revision>");
          Assert.assertTrue(rev > -1);
          int entryBeforeRev = log.lastIndexOf("<entry>", rev);
          int entryAfterRev = log.indexOf("</entry>", rev);
  
          Assert.assertTrue(entryBeforeRev > -1);
          Assert.assertTrue(entryAfterRev > -1);
  
          Assert
              .assertTrue(log.lastIndexOf("<author><![CDATA[dbrosius]]></author>",
                                          rev) > entryBeforeRev);
          Assert
              .assertTrue(log.indexOf("<name><![CDATA[/jakarta/bcel/trunk/src"
                                      + "/java/org/apache/bcel/util/BCELifier."
                                      + "java]]></name>", rev) < entryAfterRev);
          Assert
              .assertTrue(log.indexOf("<action>modified</action>", rev) 
                          < entryAfterRev);
          Assert
              .assertTrue(log.indexOf("<message><![CDATA[Update BCELifier to "
                                      + "handle the new method access flags "
                                      + "(ACC_BRIDGE, ACC_VARARGS)]]></message>",
                                      rev)
                          < entryAfterRev);
      }
  
      private static final void assertRev152685(String log) {
          int rev = log.indexOf("<revision>152685</revision>");
          Assert.assertTrue(rev > -1);
          int entryBeforeRev = log.lastIndexOf("<entry>", rev);
          int entryAfterRev = log.indexOf("</entry>", rev);
  
          Assert.assertTrue(entryBeforeRev > -1);
          Assert.assertTrue(entryAfterRev > -1);
  
          Assert
              .assertTrue(log.lastIndexOf("<![CDATA[(no author)]]>", rev) 
                          > entryBeforeRev);
          Assert
              .assertTrue(log.indexOf("<name><![CDATA[/jakarta/bcel/branches]]>"
                                      + "</name>", rev) < entryAfterRev);
          Assert
              .assertTrue(log.indexOf("<action>added</action>", rev) 
                          < entryAfterRev);
          Assert
              .assertTrue(log.indexOf("<message><![CDATA[New repository "
                                      + "initialized by cvs2svn.]]></message>",
                                      rev)
                          < entryAfterRev);
      }
  
      private static final void assertNoRev153687(String log) {
          int rev = log.indexOf("<revision>153687</revision>");
          Assert.assertEquals(-1, rev);
      }
  
      private static final void assertNoRev152685(String log) {
          int rev = log.indexOf("<revision>152685</revision>");
          Assert.assertEquals(-1, rev);
      }
  }
  
  
  
  1.1                  ant/proposal/sandbox/svn/src/testcases/org/apache/tools/ant/taskdefs/svn/SvnRevisionDiffTest.java
  
  Index: SvnRevisionDiffTest.java
  ===================================================================
  /*
   * Copyright  2005 The Apache Software Foundation
   *
   *  Licensed under the Apache License, Version 2.0 (the "License");
   *  you may not use this file except in compliance with the License.
   *  You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   *  Unless required by applicable law or agreed to in writing, software
   *  distributed under the License is distributed on an "AS IS" BASIS,
   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *  See the License for the specific language governing permissions and
   *  limitations under the License.
   *
   */
  package org.apache.tools.ant.taskdefs.svn;
  
  import java.io.IOException;
  import java.io.FileReader;
  
  import org.apache.tools.ant.BuildFileTest;
  import org.apache.tools.ant.util.FileUtils;
  
  import junit.framework.Assert;
  
  /**
   */
  public class SvnRevisionDiffTest extends BuildFileTest {
  
      public SvnRevisionDiffTest(String name) {
          super(name);
      }
  
      public void setUp() {
          configureProject("src/etc/testcases/revisiondiff.xml");
      }
  
      public void tearDown() {
          executeTarget("cleanup");
      }
  
      public void testDiff() throws IOException {
          String log = executeTargetAndReadLogFully("diff");
          assertAttributesNoURL(log);
          assertAdded(log);
          assertModified(log);
          assertDeleted(log);
      }
  
      public void testDiffUrl() throws IOException {
          String log = executeTargetAndReadLogFully("diff-using-url");
          assertAttributesWithURL(log);
          assertAdded(log);
          assertModified(log);
          assertDeleted(log);
      }
  
      private String executeTargetAndReadLogFully(String target) 
          throws IOException {
          executeTarget(target);
          FileReader r = new FileReader(getProject()
                                        .resolveFile("tmpdir/diff.xml"));
          try {
              return FileUtils.readFully(r);
          } finally {
              r.close();
          }
      }
  
      private static final void assertAttributes(String log) {
          int start = log.indexOf("<revisiondiff");
          Assert.assertTrue(start > -1);
          int end = log.indexOf(">", start);
          Assert.assertTrue(end > -1);
          Assert.assertTrue(log.indexOf("start=\"152904\"", start) > -1);
          Assert.assertTrue(log.indexOf("start=\"152904\"") < end);
          Assert.assertTrue(log.indexOf("end=\"153682\"", start) > -1);
          Assert.assertTrue(log.indexOf("end=\"153682\"") < end);
      }
  
      private static final void assertAttributesNoURL(String log) {
          assertAttributes(log);
          Assert.assertEquals(-1, log.indexOf("svnurl="));
      }
  
      private static final void assertAttributesWithURL(String log) {
          assertAttributes(log);
          int start = log.indexOf("<revisiondiff");
          int end = log.indexOf(">", start);
          Assert.assertTrue(log.indexOf("svnurl=\"http://svn.apache.org/repos/"
                                        + "asf/jakarta/bcel/trunk\"", start)
                            > -1);
          Assert.assertTrue(log.indexOf("svnurl=\"http://svn.apache.org/repos/"
                                        + "asf/jakarta/bcel/trunk\"", start)
                            < end);
      }
  
      private static final void assertAdded(String log) {
          int name = log.indexOf("<![CDATA[src/java/org/apache/bcel/classfile/"
                                 + "ElementValuePair.java]]>");
          Assert.assertTrue(name > -1);
  
          int pathAfterName = log.indexOf("</path>", name);
          Assert.assertTrue(pathAfterName > -1);
  
          Assert.assertTrue(log.indexOf("<action>added</action>", name) > -1);
          Assert.assertTrue(log.indexOf("<action>added</action>", name) 
                            < pathAfterName);
      }
  
      private static final void assertModified(String log) {
          int name = log.indexOf("<name><![CDATA[xdocs/stylesheets/project."
                                 + "xml]]></name>");
          Assert.assertTrue(name > -1);
  
          int pathAfterName = log.indexOf("</path>", name);
          Assert.assertTrue(pathAfterName > -1);
  
          Assert.assertTrue(log.indexOf("<action>modified</action>", name) > -1);
          Assert.assertTrue(log.indexOf("<action>modified</action>", name) 
                            < pathAfterName);
      }
  
      private static final void assertDeleted(String log) {
          int name = log.indexOf("<name><![CDATA[lib/CCK.jar]]></name>");
          Assert.assertTrue(name > -1);
  
          int pathAfterName = log.indexOf("</path>", name);
          Assert.assertTrue(pathAfterName > -1);
  
          Assert.assertTrue(log.indexOf("<action>deleted</action>", name) > -1);
          Assert.assertTrue(log.indexOf("<action>deleted</action>", name) 
                            < pathAfterName);
      }
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org