You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by ev...@apache.org on 2003/12/13 21:20:31 UTC
cvs commit: maven-scm/generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/command/changelog StarteamChangeLogCommandTest.java StarteamChangeLogConsumerTest.java
evenisse 2003/12/13 12:20:31
Modified: generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/changelog
StarteamChangeLogCommand.java
StarteamChangeLogConsumer.java
generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/command/checkout
StarteamCheckOutCommandTest.java
Added: generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/command/changelog
StarteamChangeLogCommandTest.java
StarteamChangeLogConsumerTest.java
Log:
Add some tests. Starteam provider is at 91.5%
Revision Changes Path
1.6 +6 -14 maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/changelog/StarteamChangeLogCommand.java
Index: StarteamChangeLogCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/changelog/StarteamChangeLogCommand.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StarteamChangeLogCommand.java 6 Dec 2003 17:09:29 -0000 1.5
+++ StarteamChangeLogCommand.java 13 Dec 2003 20:20:31 -0000 1.6
@@ -87,7 +87,7 @@
*/
public void setStartDate(Date startDate)
{
- if (consumer != null && consumer instanceof StarteamChangeLogConsumer)
+ if (consumer instanceof StarteamChangeLogConsumer)
{
((StarteamChangeLogConsumer)consumer).setStartDate(startDate);
}
@@ -98,7 +98,7 @@
*/
public Date getStartDate()
{
- if (consumer != null && consumer instanceof StarteamChangeLogConsumer)
+ if (consumer instanceof StarteamChangeLogConsumer)
{
return ((StarteamChangeLogConsumer)consumer).getStartDate();
}
@@ -113,7 +113,7 @@
*/
public void setEndDate(Date endDate)
{
- if (consumer != null && consumer instanceof StarteamChangeLogConsumer)
+ if (consumer instanceof StarteamChangeLogConsumer)
{
((StarteamChangeLogConsumer)consumer).setEndDate(endDate);
}
@@ -124,7 +124,7 @@
*/
public Date getEndDate()
{
- if (consumer != null && consumer instanceof StarteamChangeLogConsumer)
+ if (consumer instanceof StarteamChangeLogConsumer)
{
return ((StarteamChangeLogConsumer)consumer).getEndDate();
}
@@ -139,18 +139,10 @@
*/
public void setRange(int numDays)
{
- if (consumer != null && consumer instanceof StarteamChangeLogConsumer)
+ if (consumer instanceof StarteamChangeLogConsumer)
{
((StarteamChangeLogConsumer)consumer).setDateRange(numDays);
}
-
- setStartDate(
- new Date(
- System.currentTimeMillis()
- - (long)numDays * 24 * 60 * 60 * 1000));
- setEndDate(
- new Date(
- System.currentTimeMillis() + (long)1 * 24 * 60 * 60 * 1000));
}
/* (non-Javadoc)
1.4 +3 -3 maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/changelog/StarteamChangeLogConsumer.java
Index: StarteamChangeLogConsumer.java
===================================================================
RCS file: /home/cvs/maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/changelog/StarteamChangeLogConsumer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StarteamChangeLogConsumer.java 6 Dec 2003 17:09:29 -0000 1.3
+++ StarteamChangeLogConsumer.java 13 Dec 2003 20:20:31 -0000 1.4
@@ -288,8 +288,8 @@
else
{
// keep gathering comments
- //getCurrentLogEntry().setComment(
- // getCurrentLogEntry().getComment() + line + "\n");
+ getCurrentLogEntry().setComment(
+ getCurrentLogEntry().getComment() + line + "\n");
}
}
1.2 +2 -1 maven-scm/generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/command/checkout/StarteamCheckOutCommandTest.java
Index: StarteamCheckOutCommandTest.java
===================================================================
RCS file: /home/cvs/maven-scm/generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/command/checkout/StarteamCheckOutCommandTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StarteamCheckOutCommandTest.java 9 Dec 2003 21:30:31 -0000 1.1
+++ StarteamCheckOutCommandTest.java 13 Dec 2003 20:20:31 -0000 1.2
@@ -60,6 +60,7 @@
import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.provider.starteam.repository.StarteamRepository;
+import org.apache.maven.genericscm.provider.starteam.command.changelog.StarteamChangeLogConsumer;
import org.apache.maven.genericscm.util.Commandline;
/**
1.1 maven-scm/generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/command/changelog/StarteamChangeLogCommandTest.java
Index: StarteamChangeLogCommandTest.java
===================================================================
package org.apache.maven.genericscm.provider.starteam.command.changelog;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-userName documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import java.util.Calendar;
import java.util.Date;
import junit.framework.TestCase;
import org.apache.maven.genericscm.ScmException;
import org.apache.maven.genericscm.provider.starteam.repository.StarteamRepository;
import org.apache.maven.genericscm.util.Commandline;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: StarteamChangeLogCommandTest.java,v 1.1 2003/12/13 20:20:31 evenisse Exp $
*/
public class StarteamChangeLogCommandTest extends TestCase
{
private StarteamChangeLogCommand instance;
private StarteamRepository repo;
private String baseDir;
public StarteamChangeLogCommandTest(String testName)
{
super(testName);
}
/**
* Initialize per test data
* @throws Exception when there is an unexpected problem
*/
public void setUp() throws Exception
{
baseDir = System.getProperty("basedir");
assertNotNull("The system property basedir was not defined.", baseDir);
repo = new StarteamRepository();
repo.setDelimiter(":");
repo.setConnection("myusername:mypassword@myhost:1234/projecturl");
instance = new StarteamChangeLogCommand();
instance.setRepository(repo);
}
public void testGetCommandLine()
{
try
{
instance.setWorkingDirectory(baseDir);
Commandline cl = instance.getCommandLine();
System.out.println(cl.toString());
assertEquals(
"stcmd hist -x -nologo -is -p myusername:mypassword@myhost:1234/projecturl",
cl.toString());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testGetCommandLineWithTag()
{
try
{
instance.setTag("myTag");
Commandline cl = instance.getCommandLine();
System.out.println(cl.toString());
assertEquals(
"stcmd hist -x -nologo -is -p myusername:mypassword@myhost:1234/projecturl -vl myTag",
cl.toString());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testSetDateRange()
{
instance.setRange(30);
assertNotNull(instance.getStartDate());
assertNotNull(instance.getEndDate());
}
public void testSetStartDate()
{
Calendar cal = Calendar.getInstance();
cal.set(2003, 12, 13);
Date startDate = cal.getTime();
instance.setStartDate(startDate);
assertEquals(startDate, instance.getStartDate());
}
public void testSetEndDate()
{
Calendar cal = Calendar.getInstance();
cal.set(2003, 12, 13);
Date endDate = cal.getTime();
instance.setEndDate(endDate);
assertEquals(endDate, instance.getEndDate());
}
public void testGetName()
{
assertEquals("changelog", instance.getName());
}
public void testGetDisplayName()
{
try
{
assertEquals("ChangeLog", instance.getDisplayName());
}
catch(Exception e)
{
fail(e.getMessage());
}
}
public void testSetValidConsumer()
{
try
{
StarteamChangeLogConsumer cons = new StarteamChangeLogConsumer();
instance.setConsumer(cons);
assertEquals(cons, instance.getConsumer());
}
catch(ScmException e)
{
fail(e.getMessage());
}
}
public void testSetInvalidConsumer()
{
try
{
instance.setConsumer(null);
fail();
}
catch(ScmException e)
{
}
}
}
1.1 maven-scm/generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/command/changelog/StarteamChangeLogConsumerTest.java
Index: StarteamChangeLogConsumerTest.java
===================================================================
package org.apache.maven.genericscm.provider.starteam.command.changelog;
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-userName documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Maven" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Maven", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.Iterator;
import junit.framework.TestCase;
import org.apache.maven.genericscm.command.changelog.ChangeLogEntry;
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @version $Id: StarteamChangeLogConsumerTest.java,v 1.1 2003/12/13 20:20:31 evenisse Exp $
*/
public class StarteamChangeLogConsumerTest extends TestCase
{
/** the {@link StarteamChangeLogConsumer} used for testing */
private StarteamChangeLogConsumer instance;
/** file with test results to check against */
private String testFile;
/**
* Create a test with the given name
* @param testName the name of the test
*/
public StarteamChangeLogConsumerTest(String testName)
{
super(testName);
}
/**
* Initialize per test data
* @throws Exception when there is an unexpected problem
*/
public void setUp() throws Exception
{
String baseDir = System.getProperty("basedir");
assertNotNull("The system property basedir was not defined.", baseDir);
testFile = baseDir + "/src/test-resources/starteam/changelog/starteamlog.txt";
instance = new StarteamChangeLogConsumer();
}
/**
* Test of parse method
* @throws Exception when there is an unexpected problem
*/
public void testParse() throws Exception
{
FileInputStream fis = new FileInputStream(testFile);
BufferedReader in = new BufferedReader(new InputStreamReader(fis));
String s = in.readLine();
while ( s != null )
{
instance.consumeLine( s );
s = in.readLine();
}
Collection entries = instance.getModifications();
assertEquals("Wrong number of entries returned", 3, entries.size());
ChangeLogEntry entry = null;
for (Iterator i = entries.iterator(); i.hasNext(); )
{
entry = (ChangeLogEntry) i.next();
assertTrue("ChangeLogEntry erroneously picked up",
entry.toString().indexOf("ChangeLogEntry.java") == -1);
}
}
}