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 61108 invoked from network); 3 Dec 2003 21:23:26 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 3 Dec 2003 21:23:26 -0000 Received: (qmail 46820 invoked by uid 1238); 3 Dec 2003 21:23:49 -0000 Date: 3 Dec 2003 21:23:49 -0000 Message-ID: <20031203212349.46819.qmail@minotaur.apache.org> From: evenisse@apache.org To: maven-scm-cvs@apache.org Subject: cvs commit: maven-scm/generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/repository StarteamRepositoryTest.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N evenisse 2003/12/03 13:23:49 Added: generic-scm-providers/starteam .cvsignore project.properties project.xml generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command AbstractStarteamCommand.java generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/changelog StarteamChangeLogCommand.java StarteamChangeLogConsumer.java generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/repository StarteamRepository.java generic-scm-providers/starteam/src/test-resources/starteam/changelog starteamlog.txt generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/repository StarteamRepositoryTest.java Log: initial version of starteam provider Revision Changes Path 1.1 maven-scm/generic-scm-providers/starteam/.cvsignore Index: .cvsignore =================================================================== .project maven.log .classpath target 1.1 maven-scm/generic-scm-providers/starteam/project.properties Index: project.properties =================================================================== maven.junit.fork=true 1.1 maven-scm/generic-scm-providers/starteam/project.xml Index: project.xml =================================================================== 3 Generic SCM API for svn genericscm genericscm-starteam genericscm-starteam 1.0-beta1-SNAPSHOT Generic SCM Tools - Starteam Generic SCM Tools - Starteam 2003 org.apache.maven.genericscm Emmanuel Venisse evenisse emmanuel@venisse.net Creator Project Leader Release Manager genericscm genericscm-api 1.0-beta1-SNAPSHOT regexp regexp 1.2 src/java src/test **/*Test.java src/test-resources **/*.* src/resources **/*.* 1.1 maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/AbstractStarteamCommand.java Index: AbstractStarteamCommand.java =================================================================== package org.apache.maven.genericscm.provider.starteam.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 org.apache.maven.genericscm.ScmException; import org.apache.maven.genericscm.command.AbstractCommand; import org.apache.maven.genericscm.provider.starteam.repository.StarteamRepository; import org.apache.maven.genericscm.repository.Repository; import org.apache.maven.genericscm.util.Commandline; import org.apache.maven.genericscm.util.StreamConsumer; /** * @author Emmanuel Venisse * @version $Id: AbstractStarteamCommand.java,v 1.1 2003/12/03 21:23:49 evenisse Exp $ */ public abstract class AbstractStarteamCommand extends AbstractCommand { private StarteamRepository repository; private String tagName; /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#setRepository(org.apache.maven.genericscm.repository.Repository) */ public void setRepository(Repository repository) throws ScmException { if (repository instanceof StarteamRepository) { this.repository = (StarteamRepository)repository; } else { throw new ScmException("Invalid repository format"); } } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#getRepository() */ public Repository getRepository() { return repository; } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#setBranch(java.lang.String) */ public void setBranch(String branchName) { setTag(branchName); } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#getBranch() */ public String getBranch() { return getTag(); } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#setTag(java.lang.String) */ public void setTag(String tagName) { this.tagName = tagName; } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#getTag() */ public String getTag() { return tagName; } } 1.1 maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/changelog/StarteamChangeLogCommand.java Index: StarteamChangeLogCommand.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 * . * * ==================================================================== */ import java.text.SimpleDateFormat; import java.util.Date; import org.apache.maven.genericscm.ScmException; import org.apache.maven.genericscm.command.changelog.ChangeLogCommand; import org.apache.maven.genericscm.command.changelog.ChangeLogConsumer; import org.apache.maven.genericscm.provider.starteam.command.AbstractStarteamCommand; import org.apache.maven.genericscm.provider.starteam.repository.StarteamRepository; import org.apache.maven.genericscm.util.Commandline; import org.apache.maven.genericscm.util.StreamConsumer; /** * @author Emmanuel Venisse * @version $Id: StarteamChangeLogCommand.java,v 1.1 2003/12/03 21:23:49 evenisse Exp $ */ public class StarteamChangeLogCommand extends AbstractStarteamCommand implements ChangeLogCommand { private ChangeLogConsumer consumer; private Date startDate; private Date endDate; /* (non-Javadoc) * @see org.apache.maven.genericscm.command.changelog.ChangeLogCommand#setStartDate(java.util.Date) */ public void setStartDate(Date startDate) { this.startDate = startDate; } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.changelog.ChangeLogCommand#getStartDate() */ public Date getStartDate() { return startDate; } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.changelog.ChangeLogCommand#setEndDate(java.util.Date) */ public void setEndDate(Date endDate) { this.endDate = endDate; } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.changelog.ChangeLogCommand#getEndDate() */ public Date getEndDate() { return endDate; } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.changelog.ChangeLogCommand#setRange(int) */ public void setRange(int 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) * @see org.apache.maven.genericscm.command.Command#getName() */ public String getName() { return NAME; } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#getDisplayName() */ public String getDisplayName() throws Exception { return "ChangeLog"; } public Commandline getCommandLine() throws ScmException { Commandline command = new Commandline(); command.setExecutable("stcmd"); command.createArgument().setValue("hist"); command.createArgument().setValue("-x"); command.createArgument().setValue("-nologo"); command.createArgument().setValue("-is"); command.createArgument().setValue("-p"); command.createArgument().setValue(((StarteamRepository)getRepository()).getUrl()); if (getTag() != null) { command.createArgument().setValue("-vl"); command.createArgument().setValue(getTag()); } return command; } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#setConsumer(org.apache.maven.genericscm.util.StreamConsumer) */ public void setConsumer(StreamConsumer consumer) throws ScmException { if (consumer instanceof ChangeLogConsumer) { this.consumer = (ChangeLogConsumer)consumer; } else { throw new ScmException("Unsupported consumer for this command"); } } /* (non-Javadoc) * @see org.apache.maven.genericscm.command.Command#getConsumer() */ public StreamConsumer getConsumer() { return consumer; } } 1.1 maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/command/changelog/StarteamChangeLogConsumer.java Index: StarteamChangeLogConsumer.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 * . * * ==================================================================== */ import java.text.SimpleDateFormat; import java.text.ParseException; import java.util.Date; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.TreeMap; import org.apache.maven.genericscm.command.changelog.ChangeLogConsumer; import org.apache.maven.genericscm.command.changelog.ChangeLogEntry; import org.apache.maven.genericscm.command.changelog.ChangeLogFile; /** * @author Emmanuel Venisse * @version $Id: StarteamChangeLogConsumer.java,v 1.1 2003/12/03 21:23:49 evenisse Exp $ */ public class StarteamChangeLogConsumer implements ChangeLogConsumer { /** * Custom date/time formatter. Rounds ChangeLogEntry times to the nearest * minute. */ private static final SimpleDateFormat ENTRY_KEY_TIMESTAMP_FORMAT = new SimpleDateFormat("yyyyMMddHHmm"); private SimpleDateFormat localFormat = new SimpleDateFormat(); /** * rcs entries, in reverse (date, time, author, comment) order */ private Map entries = new TreeMap(Collections.reverseOrder()); // state machine constants for reading Starteam output /** expecting file information */ private static final int GET_FILE = 1; /** expecting date */ private static final int GET_AUTHOR = 2; /** expecting comments */ private static final int GET_COMMENT = 3; /** expecting revision */ private static final int GET_REVISION = 4; /** Marks start of file data*/ private static final String START_FILE = "History for: "; /** Marks end of file */ private static final String END_FILE = "===================================" + "=========================================="; /** Marks start of revision */ private static final String START_REVISION = "----------------------------"; /** Marks revision data */ private static final String REVISION_TAG = "Branch Revision: "; /** Marks author data */ private static final String AUTHOR_TAG = "Author: "; /** Marks date data */ private static final String DATE_TAG = " Date: "; /** current status of the parser */ private int status = GET_FILE; /** the current log entry being processed by the parser*/ private ChangeLogEntry currentLogEntry = null; /** the current file being processed by the parser */ private ChangeLogFile currentFile = null; /** the before date */ private Date beforeDate; /** the to date */ private Date toDate; /** the test mode (In test mode, we dont't use the date range*/ private boolean testMode = false; /* (non-Javadoc) * @see org.apache.maven.genericscm.command.changelog.ChangeLogConsumer#getModifications() */ public Collection getModifications() { return entries.values(); } /* (non-Javadoc) * @see org.apache.maven.genericscm.util.StreamConsumer#consumeLine(java.lang.String) */ public void consumeLine(String line) { // current state transitions in the state machine - starts with Get File // Get File -> Get Revision // Get Revision -> Get Date or Get File // Get Date -> Get Comment // Get Comment -> Get Comment or Get Revision switch (getStatus()) { case GET_FILE: processGetFile(line); break; case GET_REVISION: processGetRevision(line); break; case GET_AUTHOR: processGetAuthor(line); break; case GET_COMMENT: processGetComment(line); break; default: throw new IllegalStateException("Unknown state: " + status); } } /** * Add a change log entry to the list (if it's not already there) * with the given file. * @param entry a {@link ChangeLogEntry} to be added to the list if another * with the same key doesn't exist already. If the entry's author * is null, the entry wont be added * @param file a {@link ChangeLogFile} to be added to the entry */ private void addEntry(ChangeLogEntry entry, ChangeLogFile file) { // do not add if entry is not populated if (entry.getAuthor() == null) { return; } // do not add if entry is out of date range if (!testMode) { if (beforeDate != null && toDate != null) { if (entry.getDate().before(beforeDate) || entry.getDate().after(toDate)) { return; } } } String key = ENTRY_KEY_TIMESTAMP_FORMAT.format(entry.getDate()) + entry.getAuthor() + entry.getComment(); if (!entries.containsKey(key)) { entry.addFile(file); entries.put(key, entry); } else { ChangeLogEntry existingEntry = (ChangeLogEntry) entries.get(key); existingEntry.addFile(file); } } /** * Process the current input line in the Get File state. * @param line a line of text from the Starteam log output */ private void processGetFile(String line) { if (line.startsWith(START_FILE)) { setCurrentLogEntry(new ChangeLogEntry()); setCurrentFile(new ChangeLogFile(line.substring(START_FILE.length(), line.length()))); setStatus(GET_REVISION); } } /** * Process the current input line in the Get Revision state. * @param line a line of text from the Starteam log output */ private void processGetRevision(String line) { int pos; if ((pos=line.indexOf(REVISION_TAG)) != -1) { getCurrentFile().setRevision(line.substring(pos + REVISION_TAG.length())); setStatus(GET_AUTHOR); } else if (line.startsWith(END_FILE)) { // If we encounter an end of file line, it means there // are no more revisions for the current file. // there could also be a file still being processed. setStatus(GET_FILE); addEntry(getCurrentLogEntry(), getCurrentFile()); } } /** * Process the current input line in the Get Author/Date state. * @param line a line of text from the Starteam log output */ private void processGetAuthor(String line) { if (line.startsWith(AUTHOR_TAG)) { int posDateTag = line.indexOf(DATE_TAG); String author = line.substring(AUTHOR_TAG.length(), posDateTag); getCurrentLogEntry().setAuthor(author); String date = line.substring(posDateTag + DATE_TAG.length()); getCurrentLogEntry().setDate(parseDate(date)); setStatus(GET_COMMENT); } } /** * Process the current input line in the Get Comment state. * @param line a line of text from the Starteam log output */ private void processGetComment(String line) { if (line.startsWith(START_REVISION)) { // add entry, and set state to get revision addEntry(getCurrentLogEntry(), getCurrentFile()); // new change log entry setCurrentLogEntry(new ChangeLogEntry()); // same file name, but different rev setCurrentFile(new ChangeLogFile(getCurrentFile().getName())); setStatus(GET_REVISION); } else if (line.startsWith(END_FILE)) { addEntry(getCurrentLogEntry(), getCurrentFile()); setStatus(GET_FILE); } else { // keep gathering comments //getCurrentLogEntry().setComment( // getCurrentLogEntry().getComment() + line + "\n"); } } /** * Getter for property currentFile. * @return Value of property currentFile. */ private ChangeLogFile getCurrentFile() { return currentFile; } /** * Setter for property currentFile. * @param currentFile New value of property currentFile. */ private void setCurrentFile(ChangeLogFile currentFile) { this.currentFile = currentFile; } /** * Getter for property currentLogEntry. * @return Value of property currentLogEntry. */ private ChangeLogEntry getCurrentLogEntry() { return currentLogEntry; } /** * Setter for property currentLogEntry. * @param currentLogEntry New value of property currentLogEntry. */ private void setCurrentLogEntry(ChangeLogEntry currentLogEntry) { this.currentLogEntry = currentLogEntry; } /** * Getter for property status. * @return Value of property status. */ private int getStatus() { return status; } /** * Setter for property status. * @param status New value of property status. */ private void setStatus(int status) { this.status = status; } /** * Converts the date timestamp from the svn output into a date * object. * * @return A date representing the timestamp of the log entry. */ private Date parseDate(String date) { try { return localFormat.parse(date.toString()); } catch (ParseException e) { //LOG.error("ParseException Caught", e); return null; } } /** * Set the beforeDate and toDate member based on the number of days * obtained from the ChangeLog. * * @param numDaysString The number of days of log output to * generate. */ private void setDateRange(String numDaysString) { int days = Integer.parseInt(numDaysString); beforeDate = new Date( System.currentTimeMillis() - (long) days * 24 * 60 * 60 * 1000); toDate = new Date( System.currentTimeMillis() + (long) 1 * 24 * 60 * 60 * 1000); } } 1.1 maven-scm/generic-scm-providers/starteam/src/java/org/apache/maven/genericscm/provider/starteam/repository/StarteamRepository.java Index: StarteamRepository.java =================================================================== package org.apache.maven.genericscm.provider.starteam.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 org.apache.maven.genericscm.ScmException; import org.apache.maven.genericscm.repository.AbstractRepository; /** * @author Emmanuel Venisse * @version $Id: StarteamRepository.java,v 1.1 2003/12/03 21:23:49 evenisse Exp $ */ public class StarteamRepository extends AbstractRepository { private String password; private String starteamUrl; private String user; /* (non-Javadoc) * @see org.apache.maven.genericscm.repository.Repository#setPassword(java.lang.String) */ public void setPassword(String password) { this.password = password; } /* (non-Javadoc) * @see org.apache.maven.genericscm.repository.Repository#getPassword() */ public String getPassword() { return password; } /* (non-Javadoc) * @see org.apache.maven.genericscm.repository.Repository#parseConnection() */ public void parseConnection() throws ScmException { starteamUrl = getConnection(); if (getConnection().indexOf("@") >= 1) { String userAndPassword = getConnection().substring(0, getConnection().indexOf("@")); if (userAndPassword.indexOf(":") >=1) { user = userAndPassword.substring(0, userAndPassword.indexOf(":")); setPassword(userAndPassword.substring(userAndPassword.indexOf(":")+1)); } } else { throw new ScmException("Starteam URL doesn't respect the format : username[:password]@hostname:port/projectName/[viewName/][folderHierarchy/]"); } } public String getUser() throws ScmException { parseConnection(); return user; } public String getUrl() throws ScmException { parseConnection(); return starteamUrl; } } 1.1 maven-scm/generic-scm-providers/starteam/src/test-resources/starteam/changelog/starteamlog.txt Index: starteamlog.txt =================================================================== Folder: maven (working dir: C:\Test\maven) Folder: src (working dir: C:\Test\maven\src) History for: File2.java Description: First release Locked by: Status: Current ---------------------------- Revision: 2 View: GRP_Dev Branch Revision: 1.1 Author: Emmanuel VENISSE Date: 11/09/02 15:08:20 GMT+02:00 Add method print ---------------------------- Revision: 1 View: GRP_Dev Branch Revision: 1.0 Author: Emmanuel VENISSE Date: 11/09/02 15:06:55 GMT+02:00 ============================================================================= History for: File1.java Description: First release Locked by: Status: Current ---------------------------- Revision: 2 View: GRP_Dev Branch Revision: 1.1 Author: Emmanuel VENISSE Date: 11/09/02 15:08:41 GMT+02:00 Add method main ---------------------------- Revision: 1 View: GRP_Dev Branch Revision: 1.0 Author: Emmanuel VENISSE Date: 11/09/02 15:06:55 GMT+02:00 ============================================================================= Folder: test (working dir: C:\Test\maven\test) History for: TestFile1.java Description: First release Locked by: Status: Current ---------------------------- Revision: 2 View: GRP_Dev Branch Revision: 1.1 Author: Emmanuel VENISSE Date: 11/09/02 15:08:42 GMT+02:00 Add method main ---------------------------- Revision: 1 View: GRP_Dev Branch Revision: 1.0 Author: Emmanuel VENISSE Date: 11/09/02 15:06:55 GMT+02:00 ============================================================================= 1.1 maven-scm/generic-scm-providers/starteam/src/test/org/apache/maven/genericscm/provider/starteam/repository/StarteamRepositoryTest.java Index: StarteamRepositoryTest.java =================================================================== package org.apache.maven.genericscm.provider.starteam.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: StarteamRepositoryTest.java,v 1.1 2003/12/03 21:23:49 evenisse Exp $ */ public class StarteamRepositoryTest extends TestCase { public StarteamRepositoryTest(String name) { super(name); } public void testParseConnection() { try { StarteamRepository repo = new StarteamRepository(); repo.setDelimiter(":"); repo.setConnection("myusername:mypassword@myhost:1234/projecturl"); assertEquals("myusername", repo.getUser()); assertEquals("mypassword", repo.getPassword()); assertEquals("myusername:mypassword@myhost:1234/projecturl", repo.getUrl()); } catch (ScmException e) { fail(e.getMessage()); } } }