You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2010/01/09 19:23:37 UTC
svn commit: r897510 [3/5] - in /maven/sandbox/trunk/scm: ./
maven-scm-provider-accurevnew/ maven-scm-provider-accurevnew/src/
maven-scm-provider-accurevnew/src/main/
maven-scm-provider-accurevnew/src/main/java/
maven-scm-provider-accurevnew/src/main/ja...
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,87 @@
+package org.apache.maven.scm.provider.accurev.command.remove;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.remove.RemoveScmResult;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.provider.accurev.AccuRevException;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
+
+public class AccuRevRemoveCommand
+ extends AbstractAccuRevCommand
+{
+
+ public AccuRevRemoveCommand( ScmLogger logger )
+ {
+ super( logger );
+ }
+
+ @Override
+ protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
+ CommandParameters parameters )
+ throws ScmException, AccuRevException
+ {
+ final List<File> removedFiles = new ArrayList<File>();
+
+ AccuRev accuRev = repository.getAccuRev();
+
+ String message = parameters.getString( CommandParameter.MESSAGE, "" );
+
+ boolean success = true;
+
+ File basedir = fileSet.getBasedir();
+
+ @SuppressWarnings( "unchecked" )
+ List<File> relativeFiles = fileSet.getFileList();
+
+ success = accuRev.defunct( basedir, relativeFiles, message, removedFiles );
+
+ List<ScmFile> resultFiles = getScmFiles( removedFiles, ScmFileStatus.DELETED );
+
+ if ( success )
+ {
+ return new RemoveScmResult( accuRev.getCommandLines(), resultFiles );
+ }
+ else
+ {
+ return new RemoveScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
+ }
+ }
+
+ public RemoveScmResult remove( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+ throws ScmException
+ {
+ return (RemoveScmResult) execute( repository, fileSet, parameters );
+ }
+
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/remove/AccuRevRemoveCommand.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,114 @@
+package org.apache.maven.scm.provider.accurev.command.status;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.provider.accurev.AccuRevException;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevStat;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
+
+public class AccuRevStatusCommand
+ extends AbstractAccuRevCommand
+{
+
+ public AccuRevStatusCommand( ScmLogger logger )
+ {
+ super( logger );
+ }
+
+ @Override
+ protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
+ CommandParameters parameters )
+ throws ScmException, AccuRevException
+ {
+
+ boolean success = true;
+ AccuRev accuRev = repository.getAccuRev();
+
+ File basedir = fileSet.getBasedir();
+ @SuppressWarnings( "unchecked" )
+ List<File> elements = fileSet.getFileList();
+
+ List<File> defunctElements = new ArrayList<File>();
+ List<File> modOrAddedElements = new ArrayList<File>();
+ List<File> modifiedElements = new ArrayList<File>();
+ List<File> addedElements = new ArrayList<File>();
+ List<File> missingElements = new ArrayList<File>();
+ List<File> externalElements = new ArrayList<File>();
+
+ success = success && accuRev.stat( basedir, elements, AccuRevStat.DEFUNCT, defunctElements );
+
+ success = success && accuRev.stat( basedir, elements, AccuRevStat.KEPT, modOrAddedElements );
+
+ // Defunct elements are also listed as kept (AccuRev 4.7.1), exclude those here.
+ Iterator<File> iter = modOrAddedElements.iterator();
+ while ( iter.hasNext() )
+ {
+ if ( defunctElements.contains( iter.next() ) )
+ {
+ iter.remove();
+ }
+ }
+
+ success = success && accuRev.stat( basedir, elements, AccuRevStat.MODIFIED, modOrAddedElements );
+ success = success && accuRev.statBackingStream( basedir, modOrAddedElements, modifiedElements, addedElements );
+
+ success = success && accuRev.stat( basedir, elements, AccuRevStat.MISSING, missingElements );
+ success = success && accuRev.stat( basedir, elements, AccuRevStat.EXTERNAL, externalElements );
+
+ List<ScmFile> resultFiles = getScmFiles( defunctElements, ScmFileStatus.DELETED );
+ resultFiles.addAll( getScmFiles( modifiedElements, ScmFileStatus.MODIFIED ) );
+ resultFiles.addAll( getScmFiles( addedElements, ScmFileStatus.ADDED ) );
+ resultFiles.addAll( getScmFiles( missingElements, ScmFileStatus.MISSING ) );
+ resultFiles.addAll( getScmFiles( externalElements, ScmFileStatus.UNKNOWN ) );
+
+ if ( success )
+ {
+ return new StatusScmResult( accuRev.getCommandLines(), resultFiles );
+ }
+ else
+ {
+ return new StatusScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
+ }
+
+ }
+
+ public StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+ throws ScmException
+ {
+ return (StatusScmResult) execute( repository, fileSet, parameters );
+ }
+
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/status/AccuRevStatusCommand.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,92 @@
+package org.apache.maven.scm.provider.accurev.command.tag;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+
+import org.apache.maven.scm.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.provider.accurev.AccuRevException;
+import org.apache.maven.scm.provider.accurev.AccuRevInfo;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
+
+public class AccuRevTagCommand
+ extends AbstractAccuRevCommand
+{
+
+ public AccuRevTagCommand( ScmLogger logger )
+ {
+ super( logger );
+ }
+
+ @Override
+ protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
+ CommandParameters parameters )
+ throws ScmException, AccuRevException
+ {
+
+ ArrayList<File> taggedFiles = new ArrayList<File>();
+
+ AccuRev accuRev = repository.getAccuRev();
+
+ String tagName = parameters.getString( CommandParameter.TAG_NAME );
+
+ tagName = repository.getExtendedTagName( tagName );
+
+ File basedir = fileSet.getBasedir();
+ boolean success = true;
+
+ AccuRevInfo info = accuRev.info( basedir );
+
+
+
+ success = accuRev.mksnap( tagName, info.getBasis() );
+ if ( success )
+ {
+ success = accuRev.statTag( tagName, taggedFiles );
+ }
+
+ if ( success )
+ {
+ return new TagScmResult( accuRev.getCommandLines(), getScmFiles( taggedFiles, ScmFileStatus.TAGGED ) );
+ }
+ else
+ {
+ return new TagScmResult( accuRev.getCommandLines(), "AccuRev error", accuRev.getErrorOutput(), false );
+ }
+ }
+
+ public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+ throws ScmException
+ {
+ return (TagScmResult) execute( repository, fileSet, parameters );
+ }
+
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/tag/AccuRevTagCommand.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateCommand.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateCommand.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateCommand.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateCommand.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,195 @@
+package org.apache.maven.scm.provider.accurev.command.update;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.scm.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.command.update.UpdateScmResult;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.provider.accurev.AccuRevException;
+import org.apache.maven.scm.provider.accurev.AccuRevInfo;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevVersion;
+import org.apache.maven.scm.provider.accurev.WorkSpace;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommand;
+import org.codehaus.plexus.util.StringUtils;
+
+public class AccuRevUpdateCommand
+ extends AbstractAccuRevCommand
+{
+
+ public AccuRevUpdateCommand( ScmLogger logger )
+ {
+ super( logger );
+ }
+
+ @Override
+ protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
+ CommandParameters parameters )
+ throws ScmException, AccuRevException
+ {
+
+ ArrayList<File> updatedFiles = new ArrayList<File>();
+
+ AccuRev accuRev = repository.getAccuRev();
+
+ File basedir = fileSet.getBasedir();
+
+ AccuRevInfo info = accuRev.info( basedir );
+
+ if ( !info.isWorkSpace() )
+ {
+ throw new AccuRevException( "No workspace at " + basedir.getAbsolutePath() );
+ }
+
+ boolean success = true;
+
+ AccuRevVersion startVersion = getStartVersion( repository, parameters, info );
+
+ AccuRevVersion endVersion = getEndVersion( repository, parameters, info );
+
+ String newBasisStream = endVersion.getBasisStream();
+ if ( newBasisStream != null && !newBasisStream.equals( info.getBasis() ) )
+ {
+ getLogger().info( "Reparenting " + info.getWorkSpace() + " to " + newBasisStream );
+ success = accuRev.chws( basedir, info.getWorkSpace(), newBasisStream );
+ }
+
+ success = success && accuRev.update( basedir, endVersion.getTimeSpec(), updatedFiles );
+
+ if ( success )
+ {
+ return new AccuRevUpdateScmResult( startVersion, endVersion, accuRev.getCommandLines(),
+ getScmFiles( updatedFiles, ScmFileStatus.UPDATED ) );
+ }
+ else
+ {
+ return new UpdateScmResult( accuRev.getCommandLines(), "AccuRev error", accuRev.getErrorOutput(), false );
+ }
+ }
+
+ /*
+ * If we are not capturing info for a changelog, return null. If start date is supplied then start version is the
+ * current workspace basis stream / start_date Otherwise get the current high water mark for the workspace as the
+ * start version.
+ */
+ private AccuRevVersion getStartVersion( AccuRevScmProviderRepository repository, CommandParameters parameters,
+ AccuRevInfo info )
+ throws ScmException, AccuRevException
+ {
+ AccuRevVersion startVersion = null;
+
+ AccuRev accuRev = repository.getAccuRev();
+
+ boolean runChangeLog = parameters.getBoolean( CommandParameter.RUN_CHANGELOG_WITH_UPDATE );
+ Date startDate = parameters.getDate( CommandParameter.START_DATE, null );
+
+ if ( runChangeLog )
+ {
+ if ( startDate == null )
+ {
+ // Get tran id before the update, and add one.
+ startVersion =
+ new AccuRevVersion( info.getBasis(), 1 + getCurrentTransactionId( info.getWorkSpace(), accuRev ) );
+ }
+ else
+ {
+ // Use the supplied date (assume same basis, TODO not strictly correct)
+ startVersion = new AccuRevVersion( info.getBasis(), startDate );
+ }
+ }
+ return startVersion;
+ }
+
+ /*
+ * End version timespec is used as the -t parameter to update. If a version is specified in parameters then we use
+ * that. If "now" or "highest" is specified as the timespec it is replaced with the "now" as a date, so that we can
+ * be 100% accurate in terms of the changelog. If no version is specified then we use the current workspace basis
+ * stream and "now" as a date.
+ */
+ private AccuRevVersion getEndVersion( AccuRevScmProviderRepository repository, CommandParameters parameters,
+ AccuRevInfo info )
+ throws ScmException
+ {
+ AccuRevVersion endVersion = null;
+ ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null );
+
+ if ( scmVersion != null )
+ {
+ endVersion = repository.getAccuRevVersion( scmVersion );
+ }
+ else
+ {
+ endVersion = new AccuRevVersion( info.getBasis(), (String) null );
+ }
+ return endVersion;
+ }
+
+ private long getCurrentTransactionId( String workSpaceName, AccuRev accuRev )
+ throws AccuRevException
+ {
+ // AccuRev does not have a way to get at this workspace info by name.
+ // So we have to do it the hard way...
+
+ Map<String, WorkSpace> workSpaces = new HashMap<String, WorkSpace>();
+
+ accuRev.showWorkSpaces( workSpaces );
+
+ WorkSpace workspace = workSpaces.get( workSpaceName );
+
+ if ( workspace == null )
+ {
+ // Must be a reftree
+ accuRev.showRefTrees( workSpaces );
+ workspace = workSpaces.get( workSpaceName );
+ }
+
+ if ( workspace == null )
+ {
+ getLogger().warn( "Can't find workspace " + workSpaceName );
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().warn( StringUtils.join( workSpaces.values().iterator(), "\n" ) );
+ }
+ return 0;
+ }
+ return workspace.getTransactionId();
+ }
+
+ public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+ throws ScmException
+ {
+ return (UpdateScmResult) execute( repository, fileSet, parameters );
+ }
+
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateCommand.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateScmResult.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateScmResult.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateScmResult.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateScmResult.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,63 @@
+package org.apache.maven.scm.provider.accurev.command.update;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.util.List;
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.command.update.UpdateScmResult;
+import org.apache.maven.scm.provider.accurev.AccuRevVersion;
+
+/**
+ * Carry information about before and after transaction ids so we can run the changelog
+ *
+ * @author ggardner
+ */
+public class AccuRevUpdateScmResult
+ extends UpdateScmResult
+{
+
+ private AccuRevVersion fromVersion;
+
+ private AccuRevVersion toVersion;
+
+ public AccuRevUpdateScmResult( String commandLine, String providerMessage, String commandOutput, boolean success )
+ {
+ super( commandLine, providerMessage, commandOutput, success );
+ }
+
+ public AccuRevUpdateScmResult( AccuRevVersion startVersion, AccuRevVersion endVersion, String commandLines,
+ List<ScmFile> updatedFiles )
+ {
+ super( commandLines, updatedFiles );
+ this.fromVersion = startVersion;
+ this.toVersion = endVersion;
+ }
+
+ public AccuRevVersion getFromVersion()
+ {
+ return fromVersion;
+ }
+
+ public AccuRevVersion getToVersion()
+ {
+ return toVersion;
+ }
+}
\ No newline at end of file
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateScmResult.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/main/java/org/apache/maven/scm/provider/accurev/command/update/AccuRevUpdateScmResult.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/index.apt?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/index.apt (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/index.apt Sat Jan 9 18:23:30 2010
@@ -0,0 +1,231 @@
+--------------
+ Maven SCM AccuRev provider
+ --------------
+ Grant Gardner
+ --------------
+ January 2009
+ --------------
+
+ The AccuRev provider implements Maven's generic SCM API for the AccuRev SCM system.
+
+Use Cases
+
+ The provider must handle a number of different use cases:
+
+ * DONE Label a source tree and check out that label to a temp directory (the release plugin)
+
+ * DONE: Check out to a directory or update that source regularly as part of a build server (Continuum)
+
+ * MOST: Map a number of commands designed for CVS/SVN onto the semantics provided by AccuRev (the scm plugin)
+
+Details
+
+
+ The main semantic issue faced by the provider is CVS/SVN's concept of a working copy versus AccuRev's concept of a
+ workspace.
+
+ CVS/SVN allow the user to checkout any repository location to any local directory at will and tracks this
+ by keeping metadata in a CVS/.svn directory. AccuRev uses a "workspace" concept whereby it keeps track of
+ the physical filesystem locations within the server. This necessarily creates restrictions on where projects
+ may be checked out to, in that overlapping workspaces are not allowed.
+
+ The other major constraint is the uniqueness of workspace and tag names which cannot be reused. It is up to the
+ user to implement some namespace standards to manage this.
+
+URLS
+
+ <<<scm:accurev:[user/pass[@host[:port]]][:streamName][:/project/path]>>>
+
+ * <user/pass> See login below.
+
+ * <@host:port> Specify the accurev server to connect to. If used all accurev commands will include a
+ <<<-H host:port>>> argument.
+
+ * <<TODO>> SystemProperty - "accuRevReplicas", host:port=replicaHost:port,..
+
+ * <streamName> is only useful to provide a "version" for initial checkouts. Only really required for HEAD/trunk type
+ checkout such as done by the tck tests.
+
+ * </project/path> is the relative path of your project within AccuRev. Note that AccuRev has no concept of checking
+ out a sub-directory so checkouts always create this physical path under the working directory.
+
+
+ NOTE: There is no specification of depot as it is not required by any of the commands.
+
+SCM Commands
+
+* Login
+
+ The recommended method is to run <<<accurev login>>> externally. For automated SCM operations (e.g. Continuum),
+ suggest using <<<accurev login -n>>> to create a persistent login that won't expire in the middle of your build.
+
+ But if you really want to embed this information in URLS and config files, read on.
+
+ Username and password can either come from the URL, or from a <<< <server> >>> section in a settings.xml file.
+
+ If supplied then we will login to the server with <<< accurev login <user> -A >>>. This returns an
+ authentication token to the process which is used in subsequent command invocations by passing
+
+ <<< -A <authtoken> >>> to the accurev cli.
+
+ * <<Warning>> this method will expose your accurev session token to anyone snooping command lines (eg via ps)
+ and will be exposed in debug output
+
+ * <<Warning>> under Windows the user's password is passed on the command line, and will be exposed in debug output
+
+ * <<Note>> We never logout. AccuRev returns the same session id for a user anyway, and unused sessions will expire.
+
+* Checkout
+
+ * Persistent checkout (<<<isPersistCheckout() == true>>>)
+
+ The basic premise is to end up with a workspace rooted at the checkout directory with contents as at the specified
+ version.
+
+ Versions are of the form [basisStream/[tranid|timestamp]]. If a version is not supplied, the streamName from the url
+ is used as the basisStream for the workspace.
+
+ A non-empty checkout directory is not allowed. It will be created if it does not exist.
+
+ If the checkout directory is a subdirectory of an existing workspace other than the <<</project/path>>> specified in
+ the URL then the checkout will be aborted.
+
+ If a workspace exists at the checkout location then it will be reused. If necessary the basisStream of the workspace
+ will be reparented (with <<<accurev chws -b>>>).
+
+ If the checkout location is not an existing workspace then a new one is created. (with <<<accurev mkws>>>)
+
+ Workspace names are generated by concatenating the basis stream and the base name of the checkout directory unless the
+ basis stream contains the base name or vice versa, in which case the longer one is used.
+
+ If the generated workspace name already exists as stream name elsewhere in AccuRev then the checkout will fail.
+
+ The final step is to update the workspace to the tranid/timestamp specified in the supplied version (or "highest" if
+ not specified). Note that workspaces cannot go backwards, even when reparented or repopulated and you will get
+ "transaction out of range" errors if you try.
+
+ * <<TODO>> consider using a property to specify workspace name. (or pattern %s replaced with basisStream+baseName)
+
+ * <<TODO>> Create workspaces with include rules to only include /project/path.
+
+ * <<TODO>> Property switch so reftrees are used instead of workspaces. At first glance reftrees suit the Continuum use
+ case. However many a failed build is fixed in the build environment and then promoted. So reftrees are just a workspace
+ without that capability.
+
+ * Non persistent checkout
+
+ If the persistCheckout flag is false, the provider redirects the checkout to the export command as below.
+
+ <<TODO>> raise JIRA to propose equivalence of non-persistent checkout and "export"
+ Only seems to impact Perforce + AccuRev but all downstream use must "set" a flag on the repository. Would prefer they
+ retrieved a flag and then choose whether to call checkout or export.
+
+ <<TODO>> raise JIRA against maven-scm to have the tck tests support this properly
+ or change the default of persistCheckout to true.
+
+* Export
+
+ A populate outside of a workspace <<<accurev pop -V -l >>> If the checkout directory exists
+ within a subdirectory of a workspace AccuRev would normally generate an error. To work around this restriction
+ the existing workspace is temporarily deactivated during the export.
+
+ <<TODO>> raise case with AccuRev to allow an external populate to an ignored sub directory of a workspace.
+
+ <<TODO>> raise JIRA for Export to support a projectPath like checkout does.
+
+* Tag
+
+ Creates a snapshot <<< accurev mksnap >>> for the basis stream of the workspace specified by the working directory.
+ A system property "accuRevTagPrefix" can be used to specify a fixed prefix for a tag. Required for the tck tests, but
+ also useful for the release plugin.
+
+ <<TODO>> Consider moving this system property into the URL.
+
+* Update
+
+ Equivalent to <<<accurev update>>>. The working directory must be in a workspace (or reftree) and that whole
+ workspace is updated.
+
+ A version of the form basisStream/timeSpec can be supplied (tag/branch/revision). If the basis stream of this version
+ is different to the current basis of the workspace, then a <<<accurev chws>>> is performed. The timespec component
+ is passed as the <<< -t >>> option to the update command. If not supplied the timespec is set to "highest".
+
+ Changelog with update is supported. If no start_date for the changelog is supplied, then we start from the
+ transaction id of the workspace before the update. The end version for the changelog is the supplied version as
+ above (defaulting to "now").
+
+ If the start and end versions refer to the same basis stream, then a changelog is performed using the changelog
+ command described below. If the streams are different, then a dummy changeset is synthesised to simply list the
+ updated files.
+
+* Add
+
+ Equivalent to <<<accurev add>>>
+
+* Checkin
+
+ Keep and promote any pending files. <<< accurev promote -K >>>
+
+* Status
+
+ Runs a series of <<<accurev stat>>> calls to identify various types of modifications.
+
+ * <<<accurev stat -D>>> defunct files => "DELETED" status
+
+ * <<<accurev stat -k>>> kept files
+
+ * <<<accurev stat -m>>> modified files
+
+ * <<<accurev stat -b>>> to find state of kept and modified files in the backing stream to determine
+ whether their Maven ScmFileStatus is "ADDED" or "MODIFIED"
+
+ * <<<accurev stat -M>>> missing files => "MISSING" status
+
+ * <<<accurev stat -x>>> external files => "UNKNOWN" status
+
+* Changelog
+
+ List the changes promoted into a stream between timestamps.
+
+ <<<accurev hist -s <stream> -t T1-T2>>>>
+
+ <<NOTE>> This will not pickup changes promoted into a parent stream
+
+ <<TODO>> Filter results based on supplied fileSet.
+
+ <<TODO>> Filter results based on URL's project path.
+
+* Diff
+
+ <<Not yet implemented>>
+
+ Diff between versions. If only a base directory supplied in the fileset will diff the whole workspace.
+
+ If both version specified
+ * <<< accurev diff -v <start> -V <end> >>>
+
+ If only one version specified then comparison is against workspace filesystem
+ * <<< accurev diff -v <start|end> >>>
+
+ If no versions specified and stream is in URL, then compare workspace to that stream
+ * <<< accurev diff -v <urlStream> >>>
+
+ If no versions specified and no strema in URL, then compare workspace to basis stream
+ * <<< accurev diff -b >>>
+
+
+* Remove
+
+ <<<accurev defunct>>> the elements specified in the fileset, or the whole basedir
+
+* Branch
+
+ Not implemented.
+
+ The Maven SCM branch concept possibly could be represented as some form of <<<accurev mkstream>>> but not sure
+ this really does the stream concept justice.
+
+Troubleshooting
+
+ Generally to get yourself out of trouble you'll need to manipulate AccuRev externally by moving workspaces around
+ bumping versions, reparenting streams.
\ No newline at end of file
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/index.apt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/index.apt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/tcktests.apt
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/tcktests.apt?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/tcktests.apt (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/tcktests.apt Sat Jan 9 18:23:30 2010
@@ -0,0 +1,51 @@
+ --------------
+ Maven SCM AccuRev provider - Test approach
+ --------------
+ Grant Gardner
+ --------------
+ January 2009
+ --------------
+
+Junit4 + JMock
+
+ I simply couldn't bring myself to go back to Java 1.4, so this provider requires Java 1.5 and generally
+ uses Junit4 annotations and <<<assertThat>>> syntax with {{{http://hamcrest.org}Hamcrest}} matchers.
+
+ The commands are written against an AccuRev interface and tested using JMock.
+
+ AccuRevCommandLine then implements that interface and has its own tests to check the expected calls to accurev.
+
+ The various StreamConsumers that parse AccuRev output also have their own tests.
+
+ Watch out for issue between Eclipse and Sun compilers where generics can lead to unresolved symbols.
+ Mostly this is factored out to the ScmFileMatcher class.
+
+TCK Tests
+
+ AccuRev creates some challenges for the existing TCK tests.
+
+ * Logging in. Use *tckUrlPrefix* system property to specify "user/pass@host:port". To run tests using implicit (external) login
+ set *tckAllowImpliedLogin*=true instead.
+
+ * In setup (initRepo) a new depot is created with the appropriate files. This depot is named using
+ <<<System.currentTimeMillis()>>> as part of the name to guarantee uniqueness. A depot is created for
+ each individual test that is run.
+
+ * You can't create a workspace in a subdirectory of another workspace. If the project itself is in AccuRev then
+ this means the standard /target directory. Either configure maven to use a different build directory, or a set the
+ *tckBaseDir* system property.
+
+ * getWorkingCopy() etc.. are overriden as necessary so the checkout directory is prefixed with the
+ depot name and tckBaseDir as above.
+
+ * AccuRev has a 127 character limit on the workspace path so you need to make sure the tckBaseDir is not
+ too deep in your filesystem.
+
+
+ * We attempt to remove the created workspaces in teardown, but there's no guarantee. Depots can only
+ be removed with a <<<maintain>>> command while the server is stopped so this is not attempted. Probably
+ easiest to use a separate Accurev instance and periodically blow it away completely.
+
+ * TckTagTest uses a fixed tag name "tag-test". The Tag command uses a system property "accuRevTagPrefix"
+ to generate a unique tag name. This is set to the depot name to guarantee uniqueness. (TODO - raise JIRA
+ to factor that into a protected method)
\ No newline at end of file
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/tcktests.apt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/apt/tcktests.apt
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/site.xml?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/site.xml (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/site/site.xml Sat Jan 9 18:23:30 2010
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one
+ ~ or more contributor license agreements. See the NOTICE file
+ ~ distributed with this work for additional information
+ ~ regarding copyright ownership. The ASF licenses this file
+ ~ to you 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.
+ -->
+
+<project name="Maven SCM AccuRev Provider">
+ <body>
+ <menu ref="parent" />
+
+ <menu name="Overview">
+ <item name="Introduction" href="index.html"/>
+ </menu>
+
+ <menu ref="reports" inherit="bottom" />
+ </body>
+</project>
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/ScmFileMatcher.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/ScmFileMatcher.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/ScmFileMatcher.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/ScmFileMatcher.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,59 @@
+package org.apache.maven.scm;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.
+ */
+
+import static org.hamcrest.Matchers.*;
+
+import java.io.File;
+import java.util.List;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+
+public class ScmFileMatcher extends TypeSafeMatcher<ScmFile> {
+
+ public static Matcher<ScmFile> scmFile(String fileName, ScmFileStatus status) {
+ return new ScmFileMatcher(fileName, status);
+ }
+
+ @SuppressWarnings("unchecked")
+ public static void assertHasScmFile(List<?> actualFiles, String fileName, ScmFileStatus status) {
+ org.junit.Assert.assertThat((List<ScmFile>) actualFiles, hasItem(scmFile(fileName, status)));
+ }
+
+ private ScmFileStatus status;
+
+ private String filePath;
+
+ public ScmFileMatcher(String filePath, ScmFileStatus status) {
+ // Convert to OS specific path...
+ this.filePath = new File(filePath).getPath();
+ this.status = status;
+ }
+
+ public void describeTo(Description desc) {
+ desc.appendValue("ScmFile [");
+ desc.appendValue(filePath);
+ desc.appendText(",");
+ desc.appendValue(status);
+ desc.appendValue("]");
+ }
+
+ @Override
+ public boolean matchesSafely(ScmFile scmFile) {
+ return scmFile.getPath().equals(filePath) && scmFile.getStatus().equals(status);
+ }
+
+}
\ No newline at end of file
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/ScmFileMatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/ScmFileMatcher.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryMatcher.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryMatcher.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryMatcher.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryMatcher.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,96 @@
+package org.apache.maven.scm.provider.accurev;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.codehaus.plexus.util.StringUtils;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+
+public class AccuRevScmProviderRepositoryMatcher
+ extends TypeSafeMatcher<ScmProviderRepository>
+{
+
+ public static Matcher<ScmProviderRepository> isRepo( String user, String pass, String host, int port,
+ String stream, String projectPath )
+
+ {
+ return new AccuRevScmProviderRepositoryMatcher( user, pass, host, port, stream, projectPath );
+ }
+
+ private String user;
+
+ private String pass;
+
+ private String host;
+
+ private String projectPath;
+
+ private String stream;
+
+ private int port;
+
+ public AccuRevScmProviderRepositoryMatcher( String user, String pass, String host, int port, String stream,
+ String projectPath )
+ {
+ this.user = user;
+ this.pass = pass;
+ this.host = host;
+ this.port = port;
+ this.stream = stream;
+ this.projectPath = projectPath;
+
+ }
+
+ public void describeTo( Description desc )
+ {
+ desc.appendText( "an AccuRev repo with" );
+ desc.appendText( " user=" );
+ desc.appendValue( user );
+ desc.appendText( " pass=" );
+ desc.appendValue( pass );
+ desc.appendText( " host=" );
+ desc.appendValue( host );
+ desc.appendText( " port=" );
+ desc.appendValue( port );
+ desc.appendText( " stream=" );
+ desc.appendValue( stream );
+ desc.appendText( " projectPath=" );
+ desc.appendValue( projectPath );
+
+ }
+
+ @Override
+ public boolean matchesSafely( ScmProviderRepository repo )
+ {
+ if ( !( repo instanceof AccuRevScmProviderRepository ) )
+ {
+ return false;
+ }
+ AccuRevScmProviderRepository accuRevRepo = (AccuRevScmProviderRepository) repo;
+ return StringUtils.equals( user, accuRevRepo.getUser() )
+ && StringUtils.equals( pass, accuRevRepo.getPassword() )
+ && StringUtils.equals( host, accuRevRepo.getHost() ) && port == accuRevRepo.getPort()
+ && StringUtils.equals( stream, accuRevRepo.getStreamName() )
+ && StringUtils.equals( projectPath, accuRevRepo.getProjectPath() );
+
+ }
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryMatcher.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryMatcher.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryTest.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,50 @@
+package org.apache.maven.scm.provider.accurev;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.junit.Assert.*;
+import static org.hamcrest.CoreMatchers.*;
+
+import java.io.File;
+
+import org.junit.Test;
+
+public class AccuRevScmProviderRepositoryTest
+{
+
+ @Test
+ public void testIsBasedirTheWorkspaceRoot()
+ {
+ // basedir is workspace root if it is the "top" of the workspace
+ // or it is top/projectPath
+
+ AccuRevInfo info = new AccuRevInfo( new File( "/my/workspace/project/path" ) );
+ info.setTop( "/my/workspace" );
+
+ AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+ repo.setProjectPath( "/project/path" );
+
+ assertThat( repo.isWorkSpaceRoot( info ), is( true ) );
+
+ info = new AccuRevInfo( new File( "/my/workspace/project/path/subdir" ) );
+ info.setTop( "/my/workspace" );
+ assertThat( repo.isWorkSpaceRoot( info ), is( false ) );
+ }
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepositoryTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,116 @@
+package org.apache.maven.scm.provider.accurev;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import static org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepositoryMatcher.*;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.junit.Test;
+
+public class AccurevScmProviderTest
+{
+
+ @Test
+ public void testMakeProviderScmRepository()
+ throws Exception
+ {
+
+ // [:stream][:/project/dir]
+ assertAccurevRepo( "", null, null );
+ assertAccurevRepo( "aStream:/project/dir", "aStream", "project/dir" );
+ assertAccurevRepo( "/project/dir", null, "project/dir" );
+ assertAccurevRepo( "my_QA_Stream", "my_QA_Stream", null );
+
+ }
+
+ private static void assertAccurevRepo( String url, String expStream, String expPath )
+ throws ScmRepositoryException
+ {
+ AccuRevScmProvider provider = new AccuRevScmProvider();
+
+ AccuRevScmProviderRepository repository =
+ (AccuRevScmProviderRepository) provider.makeProviderScmRepository( url, ':' );
+
+ assertThat( repository,
+ isRepo( null, null, null, AccuRevScmProviderRepository.DEFAULT_PORT, expStream, expPath ) );
+
+ }
+
+ @Test
+ public void testMakeProviderWithBothKindsOfDirectorySeparators()
+ throws ScmRepositoryException
+ {
+ assertThat( getRepo( "aStream:\\project\\dir" ), isRepo( null, null, null, 5050, "aStream", "project\\dir" ) );
+ }
+
+ @Test
+ public void testProviderWithHostPort()
+ throws Exception
+ {
+
+ assertThat( getRepo( "@myHost:aStream:/project/dir" ), isRepo( null, null, "myHost",
+ AccuRevScmProviderRepository.DEFAULT_PORT,
+ "aStream", "project/dir" ) );
+ assertThat( getRepo( "@myHost:5051:/project/dir" ), isRepo( null, null, "myHost", 5051, null, "project/dir" ) );
+ }
+
+ @Test
+ public void testBlankAsUsedInTckTests()
+ throws ScmRepositoryException
+ {
+ assertThat( getRepo( ":aDepotStream" ), isRepo( null, null, null, 5050, "aDepotStream", null ) );
+ }
+
+ @Test
+ public void testProviderWithUserPass()
+ throws Exception
+ {
+ assertThat( getRepo( "aUser/theirPassword:/project/dir" ), isRepo( "aUser", "theirPassword", null,
+ AccuRevScmProviderRepository.DEFAULT_PORT,
+ null, "project/dir" ) );
+
+ assertThat( getRepo( "aUser/theirPassword@theHost:5051:aStream:/project/dir" ), isRepo( "aUser",
+ "theirPassword",
+ "theHost", 5051,
+ "aStream",
+ "project/dir" ) );
+
+ assertThat( getRepo( "aUser@theHost:5050:aStream" ), isRepo( "aUser", null, "theHost", 5050, "aStream", null ) );
+
+ assertThat( getRepo( "aUser/" ), isRepo( "aUser", null, null, 5050, null, null ) );
+ }
+
+ private static ScmProviderRepository getRepo( String url )
+ throws ScmRepositoryException
+ {
+ ScmProviderRepository repo = new AccuRevScmProvider().makeProviderScmRepository( url, ':' );
+ return repo;
+ }
+
+ @Test
+ public void testGetSCMType()
+ {
+
+ assertThat( ( new AccuRevScmProvider() ).getScmType(), is( "accurev" ) );
+ }
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AddElementsAction.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AddElementsAction.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AddElementsAction.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AddElementsAction.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,59 @@
+package org.apache.maven.scm.provider.accurev;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import org.hamcrest.Description;
+import org.jmock.api.Action;
+import org.jmock.api.Invocation;
+
+public class AddElementsAction<T>
+ implements Action
+{
+ private Collection<T> elements;
+
+ private int parameter;
+
+ public AddElementsAction( Collection<T> elements, int parameter )
+ {
+ this.elements = elements;
+ this.parameter = parameter;
+ }
+
+ public void describeTo( Description description )
+ {
+ description.appendText( "adds " ).appendValueList( "", ", ", "", elements ).appendText( " to a collection" );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Object invoke( Invocation invocation )
+ throws Throwable
+ {
+ ( (Collection<T>) invocation.getParameter( parameter ) ).addAll( elements );
+ return null;
+ }
+
+ public static <T> Action addElementsTo( int parameter, T... newElements )
+ {
+ return new AddElementsAction<T>( Arrays.asList( newElements ), parameter );
+ }
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AddElementsAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/AddElementsAction.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/PutMapEntryAction.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/PutMapEntryAction.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/PutMapEntryAction.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/PutMapEntryAction.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,66 @@
+package org.apache.maven.scm.provider.accurev;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.util.Map;
+
+import org.hamcrest.Description;
+import org.jmock.api.Action;
+import org.jmock.api.Invocation;
+
+public class PutMapEntryAction<K, V>
+ implements Action
+{
+
+ private K key;
+
+ private V value;
+
+ private int parameter;
+
+ public PutMapEntryAction( K key, V value, int parameter )
+ {
+ this.key = key;
+ this.value = value;
+ this.parameter = parameter;
+ }
+
+ public void describeTo( Description description )
+ {
+ description.appendText( "puts [" );
+ description.appendValue( key );
+ description.appendText( "," );
+ description.appendValue( value );
+ description.appendText( "] into a map" );
+ }
+
+ @SuppressWarnings( "unchecked" )
+ public Object invoke( Invocation invocation )
+ throws Throwable
+ {
+ ( (Map<K, V>) invocation.getParameter( parameter ) ).put( key, value );
+ return null;
+ }
+
+ public static <K, V> Action putEntryTo( int parameter, K key, V value )
+ {
+ return new PutMapEntryAction<K, V>( key, value, parameter );
+ }
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/PutMapEntryAction.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/PutMapEntryAction.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,410 @@
+package org.apache.maven.scm.provider.accurev.cli;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you 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.
+ */
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.*;
+import static org.junit.Assume.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.provider.accurev.AccuRevStat;
+import org.codehaus.plexus.util.Os;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith(JUnit4.class)
+public class AccuRevCommandLineTest extends ScmTestCase {
+
+ public class AccuRevCommandLineTester extends AccuRevCommandLine {
+
+ private BufferedReader stdinReader;
+
+ private String response;
+
+ public BufferedReader getStdinReader() {
+ return stdinReader;
+ }
+
+ private ScmLogger initLog() throws Exception {
+
+ return AccuRevJUnitUtil.getLogger(getContainer());
+ }
+
+ public AccuRevCommandLineTester() throws Exception {
+ setLogger(initLog());
+ }
+
+ public AccuRevCommandLineTester(String host, int port) throws Exception {
+ super(host, port);
+ setLogger(initLog());
+ }
+
+ @Override
+ protected int executeCommandLine(Commandline cl, InputStream stdin, CommandOutputConsumer stdout, StreamConsumer stderr)
+ throws CommandLineException {
+ if (stdin != null) {
+ stdinReader = new BufferedReader(new InputStreamReader(stdin));
+ } else {
+ stdinReader = null;
+ }
+ try {
+ if (response != null) {
+ BufferedReader reader = new BufferedReader(new StringReader(response));
+ String line = reader.readLine();
+ while (line != null) {
+ stdout.consumeLine(line);
+ line = reader.readLine();
+ }
+ }
+ } catch (IOException e) {
+ throw new CommandLineException("Unexpected error", e);
+ }
+ return 0;
+ }
+
+ public void setResponse(String response) {
+ this.response = response;
+
+ }
+
+ }
+
+ @Before
+ @Override
+ public void setUp() throws Exception {
+ super.setUp();
+ }
+
+ @After
+ @Override
+ public void tearDown() throws Exception {
+ super.tearDown();
+ }
+
+ @Override
+ protected InputStream getCustomConfiguration() throws Exception {
+ return AccuRevJUnitUtil.getPlexusConfiguration();
+ }
+
+ @Test
+ public void testPromoteAll() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+
+ assertThat(accuRevCL.promoteAll(new File("/my/workspace"), "cmt msg", new ArrayList<File>()), is(true));
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(new File("/my/workspace").getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "promote", "-p", "-K", "-c", "cmt msg" }));
+
+ }
+
+ @Test
+ public void testPromote() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ List<File> files = new ArrayList<File>();
+ File testfile = new File("my/test/file");
+ files.add(testfile);
+
+ assertThat(accuRevCL.promote(new File("/my/workspace"), files, "cmt msg", new ArrayList<File>()), is(true));
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(new File("/my/workspace").getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "promote", "-K", "-c", "cmt msg", testfile.getPath() }));
+
+ }
+
+ @Test
+ public void testLogin() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.setResponse("Password: a124235bacc3ff");
+ accuRevCL.setExecutable("accurev.exe");
+ accuRevCL.login("aUser", "topSecret");
+ Commandline lastCL = accuRevCL.getCommandline();
+
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+ assertThat(lastCL.getArguments(), is(new String[] { "login", "-A", "aUser", "topSecret" }));
+ assertThat(accuRevCL.getStdinReader(), is(nullValue()));
+ } else {
+ assertThat(lastCL.getArguments(), is(new String[] { "login", "-A", "aUser" }));
+ assertThat(accuRevCL.getStdinReader().readLine(), is("topSecret"));
+ }
+
+ accuRevCL.info(null);
+ assertThat(lastCL.getArguments(), is(new String[] { "info", "-A", "a124235bacc3ff" }));
+
+ assumeTrue(!Os.isFamily(Os.FAMILY_WINDOWS));
+
+ accuRevCL.login("anOther", "opensaysme");
+ assertThat(lastCL.getArguments(), is(new String[] { "login", "-A", "anOther" }));
+ assertThat(accuRevCL.getStdinReader().readLine(), is("opensaysme"));
+
+ accuRevCL.login("AUser", null);
+ assertThat(lastCL.getArguments(), is(new String[] { "login", "-A", "AUser" }));
+ assertThat(accuRevCL.getStdinReader().readLine(), is(""));
+
+ }
+
+ @Test
+ public void testPop() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester("aHost", 5051);
+ accuRevCL.setExecutable("accurev.exe");
+ File testfile = new File("/my/export");
+ File projectDir = new File("/./project/dir");
+ accuRevCL.pop(testfile, "stream/12", Collections.singleton(projectDir), new ArrayList<File>());
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getExecutable(), is("accurev.exe"));
+ assertThat(lastCL.getArguments(), is(new String[] { "pop", "-H", "aHost:5051", "-v", "stream/12", "-L",
+ testfile.getAbsolutePath(), "-R", projectDir.getPath() }));
+
+ }
+
+ @Test
+ public void testPopWorkSpace() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.setExecutable("accurev.exe");
+
+ File testFile = new File("project/dir");
+ accuRevCL.pop(new File("/home/workspace"), Collections.singleton(testFile), new ArrayList<File>());
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getExecutable(), is("accurev.exe"));
+ assertThat(lastCL.getWorkingDirectory(), is(new File("/home/workspace").getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "pop", "-R", testFile.getPath() }));
+
+ }
+
+ @Test
+ public void testMkws() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.setExecutable("accurev2.exe");
+ File workspaceFile = new File("/my/workspace/location");
+ accuRevCL.mkws("myStream", "myWorkSpaceName", workspaceFile);
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getExecutable(), is("accurev2.exe"));
+ assertThat(lastCL.getWorkingDirectory(), is(workspaceFile.getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "mkws", "-b", "myStream", "-w", "myWorkSpaceName", "-l",
+ workspaceFile.getAbsolutePath() }));
+
+ }
+
+ @Test
+ public void testUpdate() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ File workspaceFile = new File("/my/ws/loc");
+ accuRevCL.update(workspaceFile, "highest", new ArrayList<File>());
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(workspaceFile.getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "update", "-t", "highest" }));
+
+ }
+
+ @Test
+ public void testInfo() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.info(new File("/my/base/dir"));
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(new File("/my/base/dir").getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "info" }));
+
+ }
+
+ @Test
+ public void testRemoveWorkspace() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.rmws("myWorkspaceName");
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getArguments(), is(new String[] { "rmws", "-s", "myWorkspaceName" }));
+
+ }
+
+ @Test
+ public void testStatIgnored() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ File testFile = new File("/my/base/dir");
+ accuRevCL.stat(testFile);
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getArguments(), is(new String[] { "stat", "-fx", testFile.getAbsolutePath() }));
+
+ }
+
+ @Test
+ public void testReactivate() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.reactivate("ArANdomWorkspaceName");
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getArguments(), is(new String[] { "reactivate", "wspace", "ArANdomWorkspaceName" }));
+
+ }
+
+ @Test
+ public void testReset() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ Commandline cl = accuRevCL.getCommandline();
+ String[] shellCmds = cl.getShellCommandline();
+ accuRevCL.reset();
+ assertThat(accuRevCL.getCommandline().getShellCommandline(), is(shellCmds));
+ assertThat(accuRevCL.getCommandline().getShell().getExecutable(), is("accurev"));
+ }
+
+ @Test
+ public void testAdd() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ List<File> files = new ArrayList<File>();
+ File testFile = new File("my/test/file");
+ files.add(testFile);
+ assertThat(accuRevCL.add(new File("/workspace"), files, "my commit message", new ArrayList<File>()), is(true));
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(new File("/workspace").getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "add", "-c", "my commit message", testFile.getPath() }));
+
+ assertThat(accuRevCL.add(new File("/workspace"), files, "", new ArrayList<File>()), is(true));
+ assertThat(lastCL.getArguments(), is(new String[] { "add", "-c", AccuRev.DEFAULT_ADD_MESSAGE, testFile.getPath() }));
+
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testRemove() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ List<File> files = new ArrayList<File>();
+ File testFile = new File("my/test/file");
+ files.add(testFile);
+ File workspaceFile = new File("/workspace");
+ assertThat(accuRevCL.defunct(workspaceFile, files, "my commit message", new ArrayList<File>()), is(true));
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(workspaceFile.getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "defunct", "-c", "my commit message", testFile.getPath() }));
+
+ assertThat(accuRevCL.defunct(workspaceFile, files, "", new ArrayList<File>()), is(true));
+ assertThat(lastCL.getArguments(), is(new String[] { "defunct", "-c", AccuRev.DEFAULT_REMOVE_MESSAGE, testFile.getPath() }));
+
+ assertThat(accuRevCL.defunct(workspaceFile, Collections.EMPTY_LIST, "", new ArrayList<File>()), is(true));
+ assertThat(lastCL.getArguments(), is(new String[] { "defunct", "-c", AccuRev.DEFAULT_REMOVE_MESSAGE, "." }));
+
+ assertThat(accuRevCL.defunct(workspaceFile, null, "", new ArrayList<File>()), is(true));
+ assertThat(lastCL.getArguments(), is(new String[] { "defunct", "-c", AccuRev.DEFAULT_REMOVE_MESSAGE, "." }));
+
+ }
+
+ @Test
+ public void testChangeWorkspace() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.chws(new File("/my/workspace"), "the_workspace_name_me", "a-snapshot");
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(new File("/my/workspace").getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "chws", "-s", "the_workspace_name_me", "-b", "a-snapshot", "-l", "." }));
+
+ }
+
+ @Test
+ public void testMkSnap() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.mksnap("a-snapshot", "basisStream");
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getArguments(), is(new String[] { "mksnap", "-s", "a-snapshot", "-b", "basisStream", "-t", "now" }));
+
+ }
+
+ @Test
+ public void testStatTag() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.statTag("a-snapshot", new ArrayList<File>());
+
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getArguments(), is(new String[] { "stat", "-a", "-ffl", "-s", "a-snapshot" }));
+
+ }
+
+ @Test
+ public void testStatBackingStream() throws Exception {
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+
+ File basedir = new File("/my/workspace");
+ List<File> elements = new ArrayList<File>(1);
+ File addedOrModifiedFile = new File("addedOrModified/file");
+ elements.add(addedOrModifiedFile);
+ List<File> memberElements = new ArrayList<File>();
+ List<File> nonMemberElements = new ArrayList<File>();
+
+ accuRevCL.statBackingStream(basedir, elements, memberElements, nonMemberElements);
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(basedir.getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "stat", "-b", "-ffr", addedOrModifiedFile.getPath() }));
+
+ }
+
+ @Test
+ public void testStatRecursive() throws Exception {
+
+ File basedir = new File("/my/workspace");
+ List<File> noFiles = new ArrayList<File>();
+
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.stat(basedir, noFiles, AccuRevStat.KEPT, new ArrayList<File>());
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(basedir.getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "stat", "-ffr", "-k", "-R", "." }));
+
+ noFiles.add(new File("."));
+ accuRevCL.stat(basedir, noFiles, AccuRevStat.DEFUNCT, new ArrayList<File>());
+ lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(basedir.getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "stat", "-ffr", "-D", "-R", "." }));
+ }
+
+ @Test
+ public void testStatSpecificFilesAndDirectories() throws Exception {
+
+ File basedir = new File("/my/workspace");
+ List<File> files = new ArrayList<File>();
+ File testDir = new File("a/dir");
+ files.add(testDir);
+ File testFile = new File("a/dir/a.file");
+ files.add(testFile);
+
+ AccuRevCommandLineTester accuRevCL = new AccuRevCommandLineTester();
+ accuRevCL.stat(basedir, files, AccuRevStat.MISSING, new ArrayList<File>());
+ Commandline lastCL = accuRevCL.getCommandline();
+ assertThat(lastCL.getWorkingDirectory(), is(basedir.getCanonicalFile()));
+ assertThat(lastCL.getArguments(), is(new String[] { "stat", "-ffr", "-M", testDir.getPath(), testFile.getPath() }));
+
+ }
+
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevCommandLineTest.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevJUnitUtil.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevJUnitUtil.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevJUnitUtil.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevJUnitUtil.java Sat Jan 9 18:23:30 2010
@@ -0,0 +1,71 @@
+package org.apache.maven.scm.provider.accurev.cli;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.manager.plexus.PlexusLogger;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.LoggerManager;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+public class AccuRevJUnitUtil
+{
+
+ public static void consume( String resource, StreamConsumer consumer )
+ throws IOException
+ {
+ BufferedReader reader =
+ new BufferedReader( new InputStreamReader( consumer.getClass().getResourceAsStream( resource ) ) );
+
+ String line = reader.readLine();
+ while ( line != null )
+ {
+ consumer.consumeLine( line );
+ line = reader.readLine();
+ }
+
+ if ( consumer instanceof XppStreamConsumer )
+ {
+ ( (XppStreamConsumer) consumer ).waitComplete();
+ }
+ }
+
+ public static ScmLogger getLogger( PlexusContainer plexusContainer )
+ throws ComponentLookupException
+ {
+ LoggerManager loggerManager = (LoggerManager) plexusContainer.lookup( LoggerManager.ROLE );
+ Logger logger = loggerManager.getLoggerForComponent( ScmManager.ROLE );
+ return new PlexusLogger( logger );
+ }
+
+ public static InputStream getPlexusConfiguration()
+ {
+ return AccuRevJUnitUtil.class.getResourceAsStream( "/PlexusTestContainerConfig.xml" );
+ }
+
+}
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevJUnitUtil.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevJUnitUtil.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision