Return-Path: Mailing-List: contact scm-cvs-help@maven.apache.org; run by ezmlm Delivered-To: mailing list scm-cvs@maven.apache.org Received: (qmail 91765 invoked from network); 15 Dec 2003 05:44:01 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 15 Dec 2003 05:44:01 -0000 Received: (qmail 31746 invoked by uid 1238); 15 Dec 2003 05:44:21 -0000 Date: 15 Dec 2003 05:44:21 -0000 Message-ID: <20031215054421.31745.qmail@minotaur.apache.org> From: evenisse@apache.org To: maven-scm-cvs@apache.org Subject: cvs commit: maven-scm/generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/repository PerforceRepositoryTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N evenisse 2003/12/14 21:44:21 Modified: generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/command/changelog PerforceChangeLogCommand.java generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/repository PerforceRepository.java Added: generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/command AbstractPerforceCommandTest.java PerforceCommandWrapperTest.java TestAbstractPerforceCommand.java generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/command/changelog PerforceChangeLogCommandTest.java PerforceChangeLogConsumerTest.java generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/repository PerforceRepositoryTest.java Log: Add some Perforce test. Perforce provider is at 94%. Revision Changes Path 1.3 +19 -14 maven-scm/generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/command/changelog/PerforceChangeLogCommand.java Index: PerforceChangeLogCommand.java =================================================================== RCS file: /home/cvs/maven-scm/generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/command/changelog/PerforceChangeLogCommand.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- PerforceChangeLogCommand.java 6 Dec 2003 17:09:29 -0000 1.2 +++ PerforceChangeLogCommand.java 15 Dec 2003 05:44:21 -0000 1.3 @@ -87,7 +87,7 @@ */ public void setStartDate(Date startDate) { - if (consumer != null && consumer instanceof PerforceChangeLogConsumer) + if (consumer instanceof PerforceChangeLogConsumer) { ((PerforceChangeLogConsumer)consumer).setStartDate(startDate); } @@ -98,7 +98,7 @@ */ public Date getStartDate() { - if (consumer != null && consumer instanceof PerforceChangeLogConsumer) + if (consumer instanceof PerforceChangeLogConsumer) { return ((PerforceChangeLogConsumer)consumer).getStartDate(); } @@ -113,7 +113,7 @@ */ public void setEndDate(Date endDate) { - if (consumer != null && consumer instanceof PerforceChangeLogConsumer) + if (consumer instanceof PerforceChangeLogConsumer) { ((PerforceChangeLogConsumer)consumer).setEndDate(endDate); } @@ -124,7 +124,7 @@ */ public Date getEndDate() { - if (consumer != null && consumer instanceof PerforceChangeLogConsumer) + if (consumer instanceof PerforceChangeLogConsumer) { return ((PerforceChangeLogConsumer)consumer).getEndDate(); } @@ -139,18 +139,10 @@ */ public void setRange(int numDays) { - if (consumer != null && consumer instanceof PerforceChangeLogConsumer) + if (consumer instanceof PerforceChangeLogConsumer) { ((PerforceChangeLogConsumer)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) @@ -186,6 +178,19 @@ command.createArgument().setValue("-p"); command.createArgument().setValue(p4port); } + + if (repo.getUser() != null) + { + command.createArgument().setValue("-u"); + command.createArgument().setValue(repo.getUser()); + } + + if (repo.getPassword() != null) + { + command.createArgument().setValue("-P"); + command.createArgument().setValue(repo.getPassword()); + } + command.createArgument().setValue("filelog"); command.createArgument().setValue("-tl"); command.createArgument().setValue(repo.getPath()); 1.2 +17 -3 maven-scm/generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/repository/PerforceRepository.java Index: PerforceRepository.java =================================================================== RCS file: /home/cvs/maven-scm/generic-scm-providers/perforce/src/java/org/apache/maven/genericscm/provider/perforce/repository/PerforceRepository.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- PerforceRepository.java 6 Dec 2003 14:25:58 -0000 1.1 +++ PerforceRepository.java 15 Dec 2003 05:44:21 -0000 1.2 @@ -140,11 +140,25 @@ public String getHost() { - return p4port.substring(0, p4port.indexOf(getDelimiter())); + if (p4port != null) + { + return p4port.substring(0, p4port.indexOf(getDelimiter())); + } + else + { + return null; + } } public String getPort() { - return p4port.substring(p4port.indexOf(getDelimiter()) + 1); + if (p4port != null) + { + return p4port.substring(p4port.indexOf(getDelimiter()) + 1); + } + else + { + return null; + } } } 1.1 maven-scm/generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/command/AbstractPerforceCommandTest.java Index: AbstractPerforceCommandTest.java =================================================================== package org.apache.maven.genericscm.provider.perforce.command; /* ==================================================================== * 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 * . * * ==================================================================== */ import junit.framework.TestCase; import org.apache.maven.genericscm.ScmException; import org.apache.maven.genericscm.provider.perforce.repository.PerforceRepository; /** * @author Emmanuel Venisse * @version $Id: AbstractPerforceCommandTest.java,v 1.1 2003/12/15 05:44:21 evenisse Exp $ */ public class AbstractPerforceCommandTest extends TestCase { private TestAbstractPerforceCommand cmd; public AbstractPerforceCommandTest(String name) { super(name); } public void setUp() throws Exception { cmd = new TestAbstractPerforceCommand(); } public void testSetValidRepository() { try { PerforceRepository repo = new PerforceRepository(); repo.setDelimiter(":"); repo.setConnection("//depot/projects/pathname"); cmd.setRepository(repo); assertEquals(repo, cmd.getRepository()); } catch(ScmException e) { fail(); } } public void testSetInvalidRepository() { try { cmd.setRepository(null); fail(); } catch(ScmException e) { } } public void testSetBranch() { cmd.setBranch("aBranch"); assertEquals("aBranch", cmd.getBranch()); } public void testSetTag() { cmd.setTag("aTag"); assertEquals("aTag", cmd.getTag()); } } 1.1 maven-scm/generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/command/PerforceCommandWrapperTest.java Index: PerforceCommandWrapperTest.java =================================================================== package org.apache.maven.genericscm.provider.perforce.command; /* ==================================================================== * 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 * . * * ==================================================================== */ import junit.framework.TestCase; import org.apache.maven.genericscm.ScmException; import org.apache.maven.genericscm.provider.perforce.repository.PerforceRepository; /** * @author Emmanuel Venisse * @version $Id: PerforceCommandWrapperTest.java,v 1.1 2003/12/15 05:44:21 evenisse Exp $ */ public class PerforceCommandWrapperTest extends TestCase { private PerforceCommandWrapper wrapper; public PerforceCommandWrapperTest(String testName) { super(testName); } public void setUp() throws Exception { wrapper = new PerforceCommandWrapper(); } public void testSetValidRepository() { try { PerforceRepository repo = new PerforceRepository(); repo.setDelimiter(":"); repo.setConnection("pserver:anonymous@Perforce.apache.org:/scm:maven"); wrapper.setRepository(repo); assertEquals(repo, wrapper.getRepository()); } catch(ScmException e) { fail(e.getMessage()); } } public void testSetInvalidRepository() { try { wrapper.setRepository(null); fail(); } catch(ScmException e) { } } } 1.1 maven-scm/generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/command/TestAbstractPerforceCommand.java Index: TestAbstractPerforceCommand.java =================================================================== package org.apache.maven.genericscm.provider.perforce.command; /* ==================================================================== * 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 * . * * ==================================================================== */ import junit.framework.TestCase; import org.apache.maven.genericscm.ScmException; import org.apache.maven.genericscm.util.Commandline; /** * @author Emmanuel Venisse * @version $Id: TestAbstractPerforceCommand.java,v 1.1 2003/12/15 05:44:21 evenisse Exp $ */ public class TestAbstractPerforceCommand extends AbstractPerforceCommand { public Commandline getCommandLine() throws ScmException { return null; } public String getName() throws Exception { return null; } public String getDisplayName() { return null; } } 1.1 maven-scm/generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/command/changelog/PerforceChangeLogCommandTest.java Index: PerforceChangeLogCommandTest.java =================================================================== package org.apache.maven.genericscm.provider.perforce.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 * . * * ==================================================================== */ import java.util.Calendar; import java.util.Date; import junit.framework.TestCase; import org.apache.maven.genericscm.ScmException; import org.apache.maven.genericscm.provider.perforce.repository.PerforceRepository; import org.apache.maven.genericscm.util.Commandline; /** * @author Emmanuel Venisse * @version $Id: PerforceChangeLogCommandTest.java,v 1.1 2003/12/15 05:44:21 evenisse Exp $ */ public class PerforceChangeLogCommandTest extends TestCase { private PerforceChangeLogCommand instance; private PerforceRepository repo; private String baseDir; public PerforceChangeLogCommandTest(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 PerforceRepository(); repo.setDelimiter(":"); instance = new PerforceChangeLogCommand(); } public void testGetCommandLine() { try { repo.setConnection("//depot/projects/pathname"); instance.setRepository(repo); instance.setWorkingDirectory(baseDir); Commandline cl = instance.getCommandLine(); System.out.println(cl.toString()); assertEquals( "p4 filelog -tl //depot/projects/pathname", cl.toString()); } catch(Exception e) { fail(e.getMessage()); } } public void testGetCommandLineWithTag() { try { repo.setPassword("myPassword"); repo.setConnection("myhost:1234:username@//depot/projects/pathname"); instance.setRepository(repo); instance.setTag("myTag"); Commandline cl = instance.getCommandLine(); System.out.println(cl.toString()); assertEquals( "p4 -p myhost:1234 -u username -P myPassword filelog -tl //depot/projects/pathname", 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 { PerforceChangeLogConsumer cons = new PerforceChangeLogConsumer(); 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/perforce/src/test/org/apache/maven/genericscm/provider/perforce/command/changelog/PerforceChangeLogConsumerTest.java Index: PerforceChangeLogConsumerTest.java =================================================================== package org.apache.maven.genericscm.provider.perforce.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 * . * * ==================================================================== */ import java.io.BufferedReader; import java.io.FileInputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Iterator; import junit.framework.TestCase; import org.apache.maven.genericscm.command.changelog.ChangeLogEntry; /** * @author Emmanuel Venisse * @version $Id: PerforceChangeLogConsumerTest.java,v 1.1 2003/12/15 05:44:21 evenisse Exp $ */ public class PerforceChangeLogConsumerTest extends TestCase { /** the {@link PerforceChangeLogConsumer} used for testing */ private PerforceChangeLogConsumer 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 PerforceChangeLogConsumerTest(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/perforce/perforcelog.txt"; instance = new PerforceChangeLogConsumer(); } /** * 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(); } ArrayList entries = new ArrayList(instance.getModifications()); assertEquals("Wrong number of entries returned", 7, entries.size()); ChangeLogEntry entry = (ChangeLogEntry) entries.get(0); assertEquals("Entry 0 was parsed incorrectly", "\t\n" + "\t\t2003-10-15\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\t//depot/test/junk/linefeed.txt\n" + "\t\t\t3\n" + "\t\t\n" + "\t\t\n" + "\t\n", entry.toXML()); entry = (ChangeLogEntry) entries.get(3); assertEquals("Entry 3 was parsed incorrectly", "\t\n" + "\t\t2003-10-01\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\t//depot/test/demo/demo.c\n" + "\t\t\t4\n" + "\t\t\n" + "\t\t\n" + "\t\n", entry.toXML()); entry = (ChangeLogEntry) entries.get(6); assertEquals("Entry 6 was parsed incorrectly", "\t\n" + "\t\t2003-08-07\n" + "\t\t\n" + "\t\t\n" + "\t\t\n" + "\t\t\t//depot/test/demo/demo.c\n" + "\t\t\t1\n" + "\t\t\n" + "\t\t\n" + "\t\t\t//depot/test/demo/dictcalls.txt\n" + "\t\t\t1\n" + "\t\t\n" + "\t\t\n" + "\t\t\t//depot/test/demo/dictwords.txt\n" + "\t\t\t1\n" + "\t\t\n" + "\t\t\n" + "\t\n", entry.toXML()); } } 1.1 maven-scm/generic-scm-providers/perforce/src/test/org/apache/maven/genericscm/provider/perforce/repository/PerforceRepositoryTest.java Index: PerforceRepositoryTest.java =================================================================== package org.apache.maven.genericscm.provider.perforce.repository; /* ==================================================================== * 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 * . * * ==================================================================== */ import junit.framework.TestCase; import org.apache.maven.genericscm.ScmException; /** * @author Emmanuel Venisse * @version $Id: PerforceRepositoryTest.java,v 1.1 2003/12/15 05:44:21 evenisse Exp $ */ public class PerforceRepositoryTest extends TestCase { public PerforceRepositoryTest(String name) { super(name); } public void setUp() throws Exception { } public void testParseConnection1() { try { PerforceRepository repo = new PerforceRepository(); repo.setDelimiter(":"); repo.setConnection("//depot/projects/pathname"); assertNull(repo.getUser()); assertNull(repo.getHost()); assertNull(repo.getPort()); assertEquals("//depot/projects/pathname", repo.getPath()); } catch(ScmException e) { fail(e.getMessage()); } } public void testParseConnection2() { try { PerforceRepository repo = new PerforceRepository(); repo.setDelimiter(":"); repo.setConnection("username@//depot/projects/pathname"); repo.setPassword("myPassword"); assertEquals("myPassword", repo.getPassword()); assertNull(repo.getHost()); assertNull(repo.getPort()); assertEquals("//depot/projects/pathname", repo.getPath()); assertEquals("username", repo.getUser()); } catch(ScmException e) { fail(e.getMessage()); } } public void testParseConnection3() { try { PerforceRepository repo = new PerforceRepository(); repo.setDelimiter(":"); repo.setConnection("host:port:username@//depot/projects/pathname"); assertEquals("//depot/projects/pathname", repo.getPath()); assertEquals("username", repo.getUser()); assertEquals("host", repo.getHost()); assertEquals("port", repo.getPort()); } catch(ScmException e) { fail(e.getMessage()); } } public void testParseConnection4() { try { PerforceRepository repo = new PerforceRepository(); repo.setDelimiter(":"); repo.setConnection("host:port://depot/projects/pathname"); assertEquals("//depot/projects/pathname", repo.getPath()); assertNull(repo.getUser()); assertEquals("host", repo.getHost()); assertEquals("port", repo.getPort()); } catch(ScmException e) { fail(e.getMessage()); } } public void testIncorrectConnection() { try { PerforceRepository repo = new PerforceRepository(); repo.setDelimiter(":"); repo.setConnection("aaa://depot/projects/pathname"); fail(); } catch(ScmException e) { } } public void testSetUser() { PerforceRepository repo = new PerforceRepository(); repo.setUser("myUsername"); assertEquals("myUsername", repo.getUser()); } public void testSetPath() { PerforceRepository repo = new PerforceRepository(); repo.setPath("//depot/projects/pathname"); assertEquals("//depot/projects/pathname", repo.getPath()); } }