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 [4/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/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevStatTest.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/AccuRevStatTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevStatTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevStatTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,103 @@
+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.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.maven.scm.provider.accurev.AccuRevStat;
+import org.junit.Test;
+
+public class AccuRevStatTest
+{
+
+    private static final String[] STAT_RESULTS;
+
+    static
+    {
+        String defunct = "./defunct.xml            maventst_ggardner/3 (2/3) (defunct) (kept) (member)";
+        String modified = "./src/main/java/Modified.java  maventst_ggardner/2 (2/2) (modified) (member)";
+        String kept = "./src/main/java/Kept.java  maventst_ggardner/3 (2/3) (kept) (member)";
+        String external = "./src/test/java/External.java  (external)";
+        String missing = "./Missing.jpg            maventst/1 (2/1) (missing)";
+
+        STAT_RESULTS = new String[] { defunct, modified, kept, external, missing };
+    }
+
+    @Test
+    public void testDEFUNCT()
+        throws Exception
+    {
+        assertStatType( AccuRevStat.DEFUNCT, "-D", "./defunct.xml" );
+    }
+
+    @Test
+    public void testEXTERNAL()
+        throws Exception
+    {
+        assertStatType( AccuRevStat.EXTERNAL, "-x", "./src/test/java/External.java" );
+    }
+
+    @Test
+    public void testKEPT()
+        throws Exception
+    {
+        assertStatType( AccuRevStat.KEPT, "-k", "./src/main/java/Kept.java", "./defunct.xml" );
+    }
+
+    @Test
+    public void testMISSING()
+        throws Exception
+    {
+        assertStatType( AccuRevStat.MISSING, "-M", "./Missing.jpg" );
+    }
+
+    @Test
+    public void testMODIFIED()
+        throws Exception
+    {
+        assertStatType( AccuRevStat.MODIFIED, "-m", "./src/main/java/Modified.java" );
+    }
+
+    private void assertStatType( AccuRevStat accuRevStat, String expectedStatArg, String... expectedMatches )
+    {
+        assertThat( accuRevStat.getStatArg(), is( expectedStatArg ) );
+        Pattern matchPattern = accuRevStat.getMatchPattern();
+
+        int matchCount = 0;
+
+        for ( String stat : STAT_RESULTS )
+        {
+
+            Matcher matcher = matchPattern.matcher( stat );
+
+            if ( matcher.matches() )
+            {
+                String matched = matcher.group( 1 );
+                assertThat( matched, isOneOf( expectedMatches ) );
+                matchCount++;
+            }
+        }
+        assertThat( matchCount, is( expectedMatches.length ) );
+    }
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevStatTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AccuRevStatTest.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/AuthTokenConsumerTest.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/AuthTokenConsumerTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AuthTokenConsumerTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AuthTokenConsumerTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,52 @@
+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.Matchers.*;
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+public class AuthTokenConsumerTest
+{
+
+    @Test
+    public void testConsumeLineWithPasswordPrefix()
+    {
+        AuthTokenConsumer consumer = new AuthTokenConsumer();
+        consumer.consumeLine( "Password:  abcdef123456" );
+        assertThat( consumer.getAuthToken(), is( "abcdef123456" ) );
+
+        consumer.consumeLine( "A different line" );
+        assertThat( consumer.getAuthToken(), is( "abcdef123456" ) );
+    }
+
+    @Test
+    public void testConsumeLineWithoutPasswordPrefix()
+    {
+        AuthTokenConsumer consumer = new AuthTokenConsumer();
+        consumer.consumeLine( "abcdef123456" );
+        assertThat( consumer.getAuthToken(), is( "abcdef123456" ) );
+
+        consumer.consumeLine( "A different line" );
+        assertThat( consumer.getAuthToken(), is( "abcdef123456" ) );
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AuthTokenConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/AuthTokenConsumerTest.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/FileConsumerTest.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/FileConsumerTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/FileConsumerTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/FileConsumerTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,86 @@
+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.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.junit.Test;
+
+public class FileConsumerTest {
+
+    @Test
+    public void testConsumeAdd() {
+	List<File> extractedFiles = new ArrayList<File>();
+
+	StreamConsumer consumer = new FileConsumer(extractedFiles, FileConsumer.ADD_PATTERN);
+
+	consumer.consumeLine("Added and kept element /./src/main/java/Application.java");
+	consumer.consumeLine("Added and kept element \\.\\src\\main\\java\\Windows.java");
+
+	assertThat(extractedFiles.size(), is(2));
+	assertThat(extractedFiles, hasItem(new File("src/main/java/Application.java")));
+	assertThat(extractedFiles, hasItem(new File("src\\main\\java\\Windows.java")));
+    }
+
+    @Test
+    public void testConsumeUpdate() {
+	List<File> extractedFiles = new ArrayList<File>();
+	StreamConsumer consumer = new FileConsumer(extractedFiles, FileConsumer.UPDATE_PATTERN);
+
+	consumer.consumeLine("Content (1 K) of \"readme.txt\" - ok");
+	consumer.consumeLine("Creating dir \"src/main/java/org\" .");
+	consumer.consumeLine("Updating (creating) dir /./src/test/java");
+	consumer.consumeLine("Updating element \\.\\src\\main\\java\\Application.java");
+
+	assertThat(extractedFiles.size(), is(2));
+	assertThat(extractedFiles, hasItem(new File("readme.txt")));
+	assertThat(extractedFiles, hasItem(new File("src\\main\\java\\Application.java")));
+    }
+
+    @Test
+    public void testConsumePromoted() {
+	List<File> extractedFiles = new ArrayList<File>();
+
+	StreamConsumer consumer = new FileConsumer(extractedFiles, FileConsumer.PROMOTE_PATTERN);
+
+	consumer.consumeLine("Promoted element /./src/main/java/Application.java");
+	consumer.consumeLine("Promoted element \\.\\src\\main\\java\\Windows.java");
+
+	assertThat(extractedFiles.size(), is(2));
+	assertThat(extractedFiles, hasItem(new File("src/main/java/Application.java")));
+	assertThat(extractedFiles, hasItem(new File("src\\main\\java\\Windows.java")));
+    }
+
+    @Test
+    public void testConsumeRemoved() {
+	List<File> extractedFiles = new ArrayList<File>();
+	StreamConsumer consumer = new FileConsumer(extractedFiles, FileConsumer.DEFUNCT_PATTERN);
+
+	consumer.consumeLine("Recursively removing \"tcktests/src\" .");
+	consumer.consumeLine("Removing \"tcktests/src/main/java/Application.java\" .");
+	consumer.consumeLine("Removing \"tcktests/src/main/java\" .");
+	consumer.consumeLine("Removing \"tcktests/src/main\" .");
+	consumer.consumeLine("Removing \"tcktests/src\" .");
+
+	assertThat(extractedFiles.size(), is(4));
+	assertThat(extractedFiles, hasItem(new File("tcktests/src")));
+	assertThat(extractedFiles, hasItem(new File("tcktests/src/main/java/Application.java")));
+    }
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/FileConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/FileConsumerTest.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/HistoryConsumerTest.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/HistoryConsumerTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/HistoryConsumerTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/HistoryConsumerTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,104 @@
+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.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.provider.accurev.Transaction;
+import org.apache.maven.scm.provider.accurev.Transaction.Version;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeMatcher;
+import org.junit.Test;
+
+public class HistoryConsumerTest
+{
+
+    public class VersionMatcher
+        extends TypeSafeMatcher<Version>
+    {
+
+        private Long elementId;
+
+        private String path;
+
+        private String virtual;
+
+        private String real;
+
+        public VersionMatcher( Long elementId, String path, String virtual, String real )
+        {
+            this.elementId = elementId;
+            this.path = path;
+            this.virtual = virtual;
+            this.real = real;
+        }
+
+        @Override
+        public boolean matchesSafely( Version v )
+        {
+            return elementId.equals( v.getElementId() ) && path.equals( v.getElementName() )
+                && virtual.equals( v.getVirtualSpec() ) && real.equals( v.getRealSpec() );
+        }
+
+        public void describeTo( Description desc )
+        {
+            desc.appendText( "version with id=" + elementId + " virtual=" + virtual + " real=" + real + " path=" + path );
+
+        }
+    }
+
+    @Test
+    public void testConsumeStreamHistory()
+        throws IOException
+    {
+        List<Transaction> transactions = new ArrayList<Transaction>();
+        XppStreamConsumer consumer = new HistoryConsumer( new DefaultLog(), transactions );
+        AccuRevJUnitUtil.consume( "/streamHistory.xml", consumer );
+
+        assertThat( transactions.size(), is( 4 ) );
+        Transaction t = transactions.get( 0 );
+        assertThat( t.getTranType(), is( "promote" ) );
+        assertThat( t.getWhen(), is( new Date( 1233782838000L ) ) );
+        assertThat( t.getAuthor(), is( "ggardner" ) );
+        assertThat( t.getId(), is( 50L ) );
+        assertThat( t.getVersions().size(), is( 2 ) );
+
+        assertThat( t.getVersions(),
+                    hasItem( version( 8L, "/./tcktests/src/main/java/Application.java", "1/1", "2/3" ) ) );
+
+        t = transactions.get( 1 );
+        assertThat( t.getComment(), is( "hpromoting" ) );
+
+    }
+
+    private Matcher<? extends Version> version( Long elementId, String path, String virtual, String real )
+    {
+        return new VersionMatcher( elementId, path, virtual, real );
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/HistoryConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/HistoryConsumerTest.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/InfoConsumerTest.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/InfoConsumerTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/InfoConsumerTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/InfoConsumerTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,83 @@
+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 java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.provider.accurev.AccuRevInfo;
+import org.apache.maven.scm.provider.accurev.cli.InfoConsumer;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.junit.Test;
+
+public class InfoConsumerTest
+{
+
+    @Test
+    public void testConsumeOutsideWorkspace()
+        throws Exception
+    {
+
+        AccuRevInfo info = consume( "/info.outsideworkspace.txt" );
+
+        assertNull( info.getBasis() );
+        assertNull( info.getTop() );
+        assertNull( info.getWorkSpace() );
+        assertThat( info.getUser(), is( "ggardner" ) );
+
+    }
+
+    @Test
+    public void testConsumeInsideWorkspace()
+        throws Exception
+    {
+        AccuRevInfo info = consume( "/info.inworkspace.txt" );
+
+        assertThat( info.getBasis(), is( "maventst" ) );
+        assertThat( info.getTop(), is( "/home/ggardner/accurev/ws/maventst" ) );
+        assertThat( info.getWorkSpace(), is( "maventst_ggardner" ) );
+        assertThat( info.getUser(), is( "ggardner" ) );
+
+    }
+
+    private AccuRevInfo consume( String resource )
+        throws IOException
+    {
+        AccuRevInfo info = new AccuRevInfo( new File( "/my/project/dir" ) );
+        StreamConsumer consumer = new InfoConsumer( info );
+
+        BufferedReader reader =
+            new BufferedReader( new InputStreamReader( this.getClass().getResourceAsStream( resource ) ) );
+
+        String line = reader.readLine();
+        while ( line != null )
+        {
+            consumer.consumeLine( line );
+            line = reader.readLine();
+        }
+        return info;
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/InfoConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/InfoConsumerTest.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/StatBackingConsumerTest.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/StatBackingConsumerTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/StatBackingConsumerTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/StatBackingConsumerTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,60 @@
+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.junit.Assert.*;
+import static org.hamcrest.Matchers.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.junit.Test;
+
+public class StatBackingConsumerTest
+{
+
+    @Test
+    public void testConsumeLine()
+    {
+        Collection<File> nonMemberElements = new ArrayList<File>();
+        Collection<File> memberElements = new ArrayList<File>();
+
+        String line1 = "./hello.world  maventst/1 (2/1) (member)";
+        String line2 = "./tcktests/readme.txt  (no such elem)";
+        String line3 = "./src      maventst/1 (2/1) (member)";
+        String line4 = "./target   (no such elem)";
+
+        StatBackingConsumer consumer = new StatBackingConsumer( memberElements, nonMemberElements );
+
+        consumer.consumeLine( line1 );
+        consumer.consumeLine( line2 );
+        consumer.consumeLine( line3 );
+        consumer.consumeLine( line4 );
+
+        assertThat( memberElements.size(), is( 2 ) );
+        assertThat( nonMemberElements.size(), is( 2 ) );
+        assertThat( memberElements, hasItem( new File( "./hello.world" ) ) );
+        assertThat( memberElements, hasItem( new File( "./src" ) ) );
+        assertThat( nonMemberElements, hasItem( new File( "./tcktests/readme.txt" ) ) );
+        assertThat( nonMemberElements, hasItem( new File( "./target" ) ) );
+
+    }
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/StatBackingConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/StatBackingConsumerTest.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/StatConsumerTest.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/StatConsumerTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/StatConsumerTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/StatConsumerTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,67 @@
+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.junit.Assert.*;
+
+import java.io.IOException;
+
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.log.ScmLogger;
+import org.junit.Test;
+
+public class StatConsumerTest
+{
+
+    @Test
+    public void testIgnored()
+        throws Exception
+    {
+        // At this stage we do not actually need to know the status apart from a file/directory
+        // being ignored.
+        assertNull( consume( "/stat.ignored.xml" ) );
+    }
+
+    @Test
+    public void testBacked()
+        throws Exception
+    {
+        assertNotNull( consume( "/stat.backed.xml" ) );
+    };
+
+    @Test
+    public void testNoWorkspace()
+        throws Exception
+    {
+        // We don't care about files outside a workspace
+        consume( "/stat.noworkspace.xml" );
+    }
+
+    private String consume( String resource )
+        throws IOException
+    {
+        ScmLogger logger = new DefaultLog();
+        StatConsumer consumer = new StatConsumer( logger );
+
+        AccuRevJUnitUtil.consume( resource, consumer );
+        return consumer.getStatus();
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/StatConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/StatConsumerTest.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/WorkSpaceConsumerTest.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/WorkSpaceConsumerTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/WorkSpaceConsumerTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/WorkSpaceConsumerTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,90 @@
+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.junit.Assert.*;
+import static org.hamcrest.Matchers.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.accurev.WorkSpace;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith( JUnit4.class )
+public class WorkSpaceConsumerTest
+    extends ScmTestCase
+{
+
+    private ScmLogger logger;
+
+    @Override
+    protected InputStream getCustomConfiguration()
+        throws Exception
+    {
+        return AccuRevJUnitUtil.getPlexusConfiguration();
+    }
+
+    @Before
+    public void setup()
+        throws Exception
+    {
+        setUp();
+        logger = AccuRevJUnitUtil.getLogger( getContainer() );
+    }
+
+    @Test
+    public void testConsumeShowWorkSpaces()
+        throws IOException
+    {
+
+        Map<String, WorkSpace> wsMap = new HashMap<String, WorkSpace>();
+        XppStreamConsumer consumer = new WorkSpaceConsumer( logger, wsMap );
+        AccuRevJUnitUtil.consume( "/showworkspaces.xml", consumer );
+
+        WorkSpace ws = wsMap.get( "maventst_ggardner" );
+        assertThat( ws, notNullValue() );
+        assertThat( ws.getTransactionId(), is( 49L ) );
+
+    }
+
+    @Test
+    public void testConsumeShowRefTrees()
+        throws IOException
+    {
+
+        Map<String, WorkSpace> wsMap = new HashMap<String, WorkSpace>();
+        XppStreamConsumer consumer = new WorkSpaceConsumer( logger, wsMap );
+        AccuRevJUnitUtil.consume( "/showrefs.xml", consumer );
+
+        WorkSpace ws = wsMap.get( "maven-scm-INT-reftree" );
+        assertThat( ws, notNullValue() );
+        assertThat( ws.getTransactionId(), is( 12L ) );
+
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/WorkSpaceConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/cli/WorkSpaceConsumerTest.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/command/AbstractAccuRevCommandTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,86 @@
+package org.apache.maven.scm.provider.accurev.command;
+
+/*
+ * 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 org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.accurev.AccuRev;
+import org.apache.maven.scm.provider.accurev.AccuRevInfo;
+import org.jmock.Expectations;
+import org.jmock.Mockery;
+import org.jmock.Sequence;
+import org.junit.Before;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+@RunWith( JUnit4.class )
+public abstract class AbstractAccuRevCommandTest
+    extends ScmTestCase
+{
+
+    protected Mockery context;
+
+    protected AccuRev accurev;
+
+    protected File basedir;
+
+    protected AccuRevInfo info;
+
+    protected Sequence sequence;
+
+    private ScmLogger logger = new DefaultLog(); // TODO switch between Debug and DefaultLog by property.
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        context = new Mockery();
+        accurev = context.mock( AccuRev.class );
+
+        basedir = getWorkingCopy();
+        sequence = context.sequence( "accurev" );
+
+        info = new AccuRevInfo( basedir );
+        info.setUser( "me" );
+
+        context.checking( new Expectations()
+        {
+            {
+                atLeast( 1 ).of( accurev ).reset();
+
+                allowing( accurev ).getCommandLines();
+                will( returnValue( "accurev mock" ) );
+
+                allowing( accurev ).getErrorOutput();
+                will( returnValue( "accurev mock" ) );
+            }
+        } );
+
+    }
+
+    protected ScmLogger getLogger()
+    {
+        return logger;
+    }
+
+}
\ No newline at end of file

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AbstractAccuRevCommandTest.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/command/AccuRevTckUtil.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AccuRevTckUtil.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AccuRevTckUtil.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AccuRevTckUtil.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,226 @@
+package org.apache.maven.scm.provider.accurev.command;
+
+/*
+ * 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 static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.accurev.AccuRevInfo;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProvider;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.cli.AccuRevCommandLine;
+import org.apache.maven.scm.provider.accurev.cli.AccuRevJUnitUtil;
+import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.util.StringUtils;
+
+public class AccuRevTckUtil {
+
+    private String depotName = null;
+
+    private AccuRevCommandLine accurevCL;
+
+    private AccuRevInfo info;
+
+    private String url;
+
+    private ScmLogger logger;
+
+    private String tckBaseDir;
+
+    public static String getSystemProperty(String name, String defaultValue) {
+	String mavenProperty = "${" + name + "}";
+	String result = System.getProperty(name, mavenProperty);
+	if (mavenProperty.equals(result)) {
+	    result = defaultValue;
+	}
+	return result;
+    }
+
+    public String getScmUrl() throws Exception {
+	if (url == null) {
+
+	    // Either tckUrlPrefix or tckAllowImpliedConnection must be set.
+	    // This is to prevent accidentally running the tck tests against say your production accurev server
+
+	    String tckUrlPrefix = getSystemProperty("tckUrlPrefix", "");
+
+	    if (StringUtils.isBlank(tckUrlPrefix)) {
+		assertThat("Property \"tckUrlPrefix\" is not set."
+			+ " To enable tck tests against an externally logged in accurev session,"
+			+ " please set property \"tckAllowImpliedLogin\" to \"true\"", getSystemProperty("tckAllowImpliedLogin",
+			"false"), is("true"));
+	    } else {
+		assertThat("tckUrlPrefix must of the form [[user[/pass]]@host[:port]", tckUrlPrefix, containsString("@"));
+	    }
+
+	    url = "scm:accurev:" + tckUrlPrefix + ":" + getDepotName();
+
+	    getLogger().debug("Using scmURL=" + url);
+	}
+
+	return url;
+
+    }
+
+    private void setLogger(PlexusContainer plexusContainer) throws Exception {
+	this.logger = AccuRevJUnitUtil.getLogger(plexusContainer);
+    }
+
+    public void initRepo(PlexusContainer container) throws Exception {
+	setLogger(container);
+	initRepo();
+    }
+
+    @SuppressWarnings("unchecked")
+    private void initRepo() throws Exception {
+
+	assertLoggedInOK();
+
+	assertThat("Can't execute TckTests in an accurev workspace, please set 'tckBaseDir' property", getAccuRevInfo()
+		.isWorkSpace(), is(false));
+
+	File initDir = ScmTestCase.getTestFile(getTckBaseDir(), "target/" + getDepotName() + "/init");
+
+	assertThat("AccuRev workspace path limit of 127 characters execeeded, please set 'basedir' property", initDir
+		.getAbsolutePath().length(), lessThan(127));
+
+	getAccuRevCL().mkdepot(getDepotName());
+
+	/*
+	 * Since scmFileNames is not populated before this is called... we get to duplicate some code here.TODO raise patch to fix
+	 * this.
+	 */
+
+	List<String> scmFileNames = new ArrayList(4);
+	scmFileNames.add("/pom.xml");
+	scmFileNames.add("/readme.txt");
+	scmFileNames.add("/src/main/java/Application.java");
+	scmFileNames.add("/src/test/java/Test.java");
+
+	for (String filename : scmFileNames) {
+	    ScmTestCase.makeFile(initDir, filename, filename);
+	}
+
+	String initWorkSpace = getDepotName() + "_initRepo";
+	getAccuRevCL().mkws(getDepotName(), initWorkSpace, initDir);
+
+	getAccuRevCL().add(initDir, null, "initial version", new ArrayList<File>());
+	getAccuRevCL().promoteAll(initDir, "initial version", new ArrayList<File>());
+
+	getAccuRevCL().rmws(initWorkSpace + "_" + getAccuRevInfo().getUser());
+    }
+
+    private String getTckBaseDir() {
+	if (tckBaseDir == null) {
+	    tckBaseDir = getSystemProperty("tckBaseDir", "");
+	    if (StringUtils.isBlank(tckBaseDir)) {
+		tckBaseDir = ScmTestCase.getBasedir();
+	    }
+	    getLogger().debug("tckBaseDir=" + tckBaseDir);
+
+	}
+
+	return tckBaseDir;
+    }
+
+    private void assertLoggedInOK() throws Exception {
+
+	assertThat(getAccuRevInfo().getUser(), notNullValue());
+	assertThat(getAccuRevInfo().getUser(), is(not("(not logged in)")));
+    }
+
+    public void tearDown() throws Exception {
+	// nothing left...
+    }
+
+    public String getDepotName() {
+	if (depotName == null) {
+	    depotName = "mvnscm_" + (System.currentTimeMillis() / 1000);
+	}
+	return depotName;
+    }
+
+    public ScmLogger getLogger() {
+	if (logger == null) {
+	    logger = new DefaultLog();
+	}
+
+	return logger;
+    }
+
+    public AccuRevCommandLine getAccuRevCL() throws Exception {
+	if (accurevCL == null) {
+	    AccuRevScmProvider provider = new AccuRevScmProvider();
+	    provider.addListener(getLogger());
+	    AccuRevScmProviderRepository repo = (AccuRevScmProviderRepository) provider.makeProviderScmRepository(getScmUrl(), ':');
+	    getLogger().debug(repo.toString());
+	    accurevCL = (AccuRevCommandLine) repo.getAccuRev();
+
+	    if (!StringUtils.isEmpty(repo.getUser())) {
+		accurevCL.login(repo.getUser(), repo.getPassword());
+	    }
+
+	}
+
+	return accurevCL;
+    }
+
+    public void removeWorkSpace(File basedir) throws Exception {
+	try {
+	    assertLoggedInOK();
+	} catch (AssertionError e) {
+	    return;
+	}
+	if (basedir.exists()) {
+	    AccuRevInfo bdInfo = accurevCL.info(basedir);
+	    if (bdInfo.isWorkSpaceTop()) {
+		accurevCL.promoteAll(basedir, "clear default group", new ArrayList<File>());
+		accurevCL.rmws(bdInfo.getWorkSpace());
+	    }
+	}
+    }
+
+    public AccuRevInfo getAccuRevInfo() throws Exception {
+	if (info == null) {
+	    File basedir = new File(getTckBaseDir());
+	    info = getAccuRevCL().info(basedir);
+	}
+
+	return info;
+
+    }
+
+    /*
+     * Need to put this in a sub directory because you can't re-use workspace directories And for some stupid reason we only have
+     * 127 characters available for the path name
+     */
+    public File getWorkingCopy() {
+	return ScmTestCase.getTestFile(getTckBaseDir(), "target/" + getDepotName() + "/co");
+    }
+
+    public File getAssertionCopy() {
+	return ScmTestCase.getTestFile(getTckBaseDir(), "target/" + getDepotName() + "/as");
+    }
+
+    public File getUpdatingCopy() {
+	return ScmTestCase.getTestFile(getTckBaseDir(), "target/" + getDepotName() + "/up");
+    }
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AccuRevTckUtil.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/AccuRevTckUtil.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/command/add/AccuRevAddCommandTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommandTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommandTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommandTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,115 @@
+package org.apache.maven.scm.provider.accurev.command.add;
+
+/*
+ * 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.ScmFileMatcher.*;
+import static org.apache.maven.scm.provider.accurev.AddElementsAction.*;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameter;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.command.add.AddScmResult;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest;
+import org.jmock.Expectations;
+import org.junit.Test;
+
+public class AccuRevAddCommandTest
+    extends AbstractAccuRevCommandTest
+{
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testAdd()
+        throws Exception
+    {
+        final ScmFileSet testFileSet = new ScmFileSet( basedir, new File( "src/main/java/Foo.java" ) );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).add( with( basedir ), with( testFileSet.getFileList() ), with( "A new file" ),
+                                    with( any( List.class ) ) );
+                will( doAll( addElementsTo( 3, new File( "added/file" ) ), returnValue( true ) ) );
+                inSequence( sequence );
+
+            }
+        } );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevAddCommand command = new AccuRevAddCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.MESSAGE, "A new file" );
+        AddScmResult result = command.add( repo, testFileSet, commandParameters );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( true ) );
+        assertThat( result.getAddedFiles().size(), is( 1 ) );
+        assertHasScmFile( result.getAddedFiles(), "added/file", ScmFileStatus.ADDED );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testAddFailed()
+        throws Exception
+    {
+        final ScmFileSet testFileSet = new ScmFileSet( basedir, new File( "src/main/java/Foo.java" ) );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).add( with( basedir ), with( testFileSet.getFileList() ), with( "A new file" ),
+                                    with( any( List.class ) ) );
+                will( returnValue( false ) );
+                inSequence( sequence );
+
+            }
+        } );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevAddCommand command = new AccuRevAddCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.MESSAGE, "A new file" );
+        AddScmResult result = command.add( repo, testFileSet, commandParameters );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( false ) );
+        assertThat( result.getProviderMessage(), notNullValue() );
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/add/AccuRevAddCommandTest.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/command/changelog/AccuRevChangeLogCommandTckTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTckTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTckTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTckTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,115 @@
+package org.apache.maven.scm.provider.accurev.command.changelog;
+
+/*
+ * 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.io.InputStream;
+
+import org.apache.maven.scm.provider.accurev.cli.AccuRevJUnitUtil;
+import org.apache.maven.scm.provider.accurev.command.AccuRevTckUtil;
+import org.apache.maven.scm.tck.command.changelog.ChangeLogCommandTckTest;
+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 AccuRevChangeLogCommandTckTest
+    extends ChangeLogCommandTckTest
+{
+
+    protected AccuRevTckUtil accurevTckTestUtil = new AccuRevTckUtil();
+
+    @Override
+    @Test
+    public void testChangeLogCommand()
+        throws Exception
+    {
+        super.testChangeLogCommand();
+    }
+
+    @Override
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+    }
+
+    @Override
+    protected File getWorkingCopy()
+    {
+        return accurevTckTestUtil.getWorkingCopy();
+    }
+
+    @Override
+    protected File getAssertionCopy()
+    {
+        return accurevTckTestUtil.getAssertionCopy();
+    }
+
+    @Override
+    protected File getUpdatingCopy()
+    {
+        return accurevTckTestUtil.getUpdatingCopy();
+    }
+
+    @Override
+    public String getScmUrl()
+        throws Exception
+    {
+        return accurevTckTestUtil.getScmUrl();
+    }
+
+    @Override
+    public void initRepo()
+        throws Exception
+    {
+        accurevTckTestUtil.initRepo( getContainer() );
+
+    }
+
+    @Override
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        try
+        {
+            accurevTckTestUtil.tearDown();
+            accurevTckTestUtil.removeWorkSpace( getWorkingCopy() );
+            accurevTckTestUtil.removeWorkSpace( getAssertionCopy() );
+        }
+        finally
+        {
+            super.tearDown();
+        }
+    }
+
+    @Override
+    protected InputStream getCustomConfiguration()
+        throws Exception
+
+    {
+        return AccuRevJUnitUtil.getPlexusConfiguration();
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTckTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTckTest.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/command/changelog/AccuRevChangeLogCommandTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,180 @@
+package org.apache.maven.scm.provider.accurev.command.changelog;
+
+/*
+ * 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.AddElementsAction.*;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.scm.ChangeFile;
+import org.apache.maven.scm.ChangeSet;
+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.ScmRevision;
+import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.Transaction;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest;
+import org.jmock.Expectations;
+import org.junit.Test;
+
+public class AccuRevChangeLogCommandTest
+    extends AbstractAccuRevCommandTest
+{
+    @Test
+    public void testChangeLogBetweenStreamsUnsupported()
+        throws Exception
+    {
+        final ScmFileSet testFileSet = new ScmFileSet( new File( basedir, "project/dir" ) );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevChangeLogCommand command = new AccuRevChangeLogCommand( getLogger() );
+
+        CommandParameters params = new CommandParameters();
+        params.setScmVersion( CommandParameter.START_SCM_VERSION, new ScmRevision( "aStream/12" ) );
+        params.setScmVersion( CommandParameter.END_SCM_VERSION, new ScmRevision( "anotherStream/20" ) );
+
+        try
+        {
+            command.changelog( repo, testFileSet, params );
+            fail( "Expected accurev exception" );
+        }
+        catch ( ScmException e )
+        {
+            // Expected
+        }
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testSimpleCase()
+        throws Exception
+    {
+        // Workspace to root stream, keeps and promotes
+
+        // Setup test data so that the checkin area is the repo's project path.
+        final ScmFileSet testFileSet = new ScmFileSet( new File( basedir, "project/dir" ) );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        // getDate uses calendar's zero indexed months
+        final Date dateFrom = getDate( 2009, 0, 1, 10, 0, 0, null );
+        final Date dateTo = getDate( 2009, 0, 12, 13, 0, 0, null );
+        final Date keepWhen = getDate( 2009, 0, 2, 9, 0, 0, null );
+        final Date promoteWhen = getDate( 2009, 0, 4, 23, 0, 0, null );
+
+        context.checking( new Expectations()
+        {
+            {
+
+                Transaction keep = new Transaction( 10L, keepWhen, "keep", "aUser" );
+                keep.addVersion( 5L, "/./kept/file", "10/5", "10/5", "3/2" );
+                keep.setComment( "a Comment" );
+
+                Transaction promote = new Transaction( 12L, promoteWhen, "promote", "anOther" );
+                promote.addVersion( 10L, "/./promoted/file", "10/5", "4/2", null );
+                promote.setComment( "my Promotion" );
+
+                one( accurev ).history( with( "myStream" ), with( "2009/01/01 10:00:00" ),
+                                        with( "2009/01/12 13:00:00" ), with( 0 ), with( any( List.class ) ) );
+                will( doAll( addElementsTo( 4, keep, promote ), returnValue( true ) ) );
+            }
+        } );
+
+        AccuRevChangeLogCommand command = new AccuRevChangeLogCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.MESSAGE, "A commit message" );
+        commandParameters.setDate( CommandParameter.START_DATE, dateFrom );
+        commandParameters.setDate( CommandParameter.END_DATE, dateTo );
+        ChangeLogScmResult result = command.changelog( repo, testFileSet, commandParameters );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( true ) );
+        assertThat( result.getChangeLog().getChangeSets().size(), is( 2 ) );
+        ChangeSet cs = (ChangeSet) result.getChangeLog().getChangeSets().get( 0 );
+        assertThat( cs.getAuthor(), is( "aUser" ) );
+        assertThat( cs.getComment(), is( "a Comment" ) );
+        assertThat( cs.getDate(), is( keepWhen ) );
+        assertThat( cs.getFiles().size(), is( 1 ) );
+        ChangeFile cf = (ChangeFile) cs.getFiles().get( 0 );
+
+        assertThat( cf.getName(), is( "/./kept/file" ) );
+        assertThat( cf.getRevision(), is( "10/5 (10/5)" ) );
+
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testChangeLogFailed()
+        throws Exception
+    {
+        // Workspace to root stream, keeps and promotes
+
+        // Setup test data so that the checkin area is the repo's project path.
+        final ScmFileSet testFileSet = new ScmFileSet( new File( basedir, "project/dir" ) );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        final Date dateFrom = getDate( 2009, 01, 01, 10, 00, 00, null );
+        final Date dateTo = getDate( 2009, 01, 12, 13, 00, 00, null );
+
+        context.checking( new Expectations()
+        {
+            {
+
+                one( accurev ).history( with( "myStream" ), with( any( String.class ) ), with( any( String.class ) ),
+                                        with( 0 ), with( any( List.class ) ) );
+                will( returnValue( false ) );
+            }
+        } );
+
+        AccuRevChangeLogCommand command = new AccuRevChangeLogCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.MESSAGE, "A commit message" );
+        commandParameters.setDate( CommandParameter.START_DATE, dateFrom );
+        commandParameters.setDate( CommandParameter.END_DATE, dateTo );
+        ChangeLogScmResult result = command.changelog( repo, testFileSet, commandParameters );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( false ) );
+        assertThat( result.getProviderMessage(), notNullValue() );
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/changelog/AccuRevChangeLogCommandTest.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/command/checkin/AccuRevCheckInCommandTckTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTckTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTckTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTckTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,123 @@
+package org.apache.maven.scm.provider.accurev.command.checkin;
+
+/*
+ * 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.io.InputStream;
+
+import org.apache.maven.scm.provider.accurev.cli.AccuRevJUnitUtil;
+import org.apache.maven.scm.provider.accurev.command.AccuRevTckUtil;
+import org.apache.maven.scm.tck.command.checkin.CheckInCommandTckTest;
+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 AccuRevCheckInCommandTckTest
+    extends CheckInCommandTckTest
+{
+
+    private AccuRevTckUtil accurevTckTestUtil = new AccuRevTckUtil();
+
+    @Override
+    protected InputStream getCustomConfiguration()
+        throws Exception
+
+    {
+        return AccuRevJUnitUtil.getPlexusConfiguration();
+    }
+
+    @Override
+    @Test
+    public void testCheckInCommandPartialFileset()
+        throws Exception
+    {
+        super.testCheckInCommandPartialFileset();
+    }
+
+    @Override
+    @Test
+    public void testCheckInCommandTest()
+        throws Exception
+    {
+        super.testCheckInCommandTest();
+    }
+
+    @Override
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+    }
+
+    @Override
+    protected File getWorkingCopy()
+    {
+        return accurevTckTestUtil.getWorkingCopy();
+    }
+
+    @Override
+    protected File getAssertionCopy()
+    {
+        return accurevTckTestUtil.getAssertionCopy();
+    }
+
+    @Override
+    protected File getUpdatingCopy()
+    {
+        return accurevTckTestUtil.getUpdatingCopy();
+    }
+
+    @Override
+    public String getScmUrl()
+        throws Exception
+    {
+        return accurevTckTestUtil.getScmUrl();
+    }
+
+    @Override
+    public void initRepo()
+        throws Exception
+    {
+        accurevTckTestUtil.initRepo( getContainer() );
+
+    }
+
+    @Override
+    @After
+    public void tearDown()
+        throws Exception
+    {
+        try
+        {
+            accurevTckTestUtil.tearDown();
+            accurevTckTestUtil.removeWorkSpace( getWorkingCopy() );
+            accurevTckTestUtil.removeWorkSpace( getAssertionCopy() );
+        }
+        finally
+        {
+            super.tearDown();
+        }
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTckTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTckTest.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/command/checkin/AccuRevCheckInCommandTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,218 @@
+package org.apache.maven.scm.provider.accurev.command.checkin;
+
+/*
+ * 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.ScmFileMatcher.*;
+import static org.apache.maven.scm.provider.accurev.AddElementsAction.*;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+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.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+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.AbstractAccuRevCommandTest;
+import org.jmock.Expectations;
+import org.junit.Test;
+
+public class AccuRevCheckInCommandTest
+    extends AbstractAccuRevCommandTest
+{
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testCheckInRecursive()
+        throws Exception
+    {
+        // Setup test data so that the checkin area is the repo's project path.
+        final ScmFileSet testFileSet = new ScmFileSet( new File( basedir, "project/dir" ) );
+        final File basedir = testFileSet.getBasedir();
+
+        final AccuRevInfo info = new AccuRevInfo( basedir );
+        info.setTop( basedir.getAbsolutePath() );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).info( with( basedir ) );
+                will( returnValue( info ) );
+                inSequence( sequence );
+
+                one( accurev ).promoteAll( with( basedir ), with( "A commit message" ), with( any( List.class ) ) );
+                will( doAll( addElementsTo( 2, new File( "kept/file" ), new File( "promoted/file" ) ),
+                             returnValue( true ) ) );
+                inSequence( sequence );
+
+            }
+        } );
+
+        AccuRevCheckInCommand command = new AccuRevCheckInCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.MESSAGE, "A commit message" );
+        CheckInScmResult result = command.checkIn( repo, testFileSet, commandParameters );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( true ) );
+        assertThat( result.getCheckedInFiles().size(), is( 2 ) );
+        assertHasScmFile( result.getCheckedInFiles(), "kept/file", ScmFileStatus.CHECKED_IN );
+        assertHasScmFile( result.getCheckedInFiles(), "promoted/file", ScmFileStatus.CHECKED_IN );
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testCheckInFailure()
+        throws Exception
+    {
+        // Setup test data so that the checkin area is the repo's project path.
+        final ScmFileSet testFileSet = new ScmFileSet( new File( basedir, "project/dir" ) );
+        final File basedir = testFileSet.getBasedir();
+
+        final AccuRevInfo info = new AccuRevInfo( basedir );
+        info.setTop( basedir.getAbsolutePath() );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).info( with( basedir ) );
+                will( returnValue( info ) );
+                inSequence( sequence );
+
+                one( accurev ).promoteAll( with( basedir ), with( "A commit message" ), with( any( List.class ) ) );
+                will( returnValue( false ) );
+                inSequence( sequence );
+
+            }
+        } );
+
+        AccuRevCheckInCommand command = new AccuRevCheckInCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.MESSAGE, "A commit message" );
+        CheckInScmResult result = command.checkIn( repo, testFileSet, commandParameters );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( false ) );
+        assertThat( result.getProviderMessage(), notNullValue() );
+    }
+
+    public void testCheckinRecursiveSubDirectoryNotSupported()
+        throws AccuRevException, ScmException
+    {
+        final ScmFileSet testFileSet = new ScmFileSet( basedir );
+        final AccuRevInfo info = new AccuRevInfo( basedir );
+        info.setTop( basedir.getParent() );
+
+        // TODO test basedir is top + project path. is OK.
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).info( with( basedir ) );
+                will( returnValue( info ) );
+
+            }
+        } );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevCheckInCommand command = new AccuRevCheckInCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.MESSAGE, "Commit message" );
+        try
+        {
+            command.checkIn( repo, testFileSet, commandParameters );
+            fail( "Expected ScmException" );
+        }
+        catch ( ScmException ex )
+        {
+            // expected
+        }
+
+        context.assertIsSatisfied();
+    }
+
+    @SuppressWarnings( "unchecked" )
+    public void testCheckinExplicitFiles()
+        throws Exception
+    {
+        final List<File> files = new ArrayList<File>();
+
+        files.add( new File( "project/dir/pom.xml" ) );
+        files.add( new File( "project/dir/src/main/java/Bar.java" ) );
+
+        final ScmFileSet testFileSet = new ScmFileSet( basedir, files );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).promote( with( basedir ), with( files ), with( "A commit message" ),
+                                        with( any( List.class ) ) );
+                will( doAll( addElementsTo( 3, files.get( 0 ), files.get( 1 ) ), returnValue( true ) ) );
+                inSequence( sequence );
+
+            }
+        } );
+
+        AccuRevCheckInCommand command = new AccuRevCheckInCommand( getLogger() );
+
+        CommandParameters commandParameters = new CommandParameters();
+        commandParameters.setString( CommandParameter.MESSAGE, "A commit message" );
+        CheckInScmResult result = command.checkIn( repo, testFileSet, commandParameters );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( true ) );
+        assertThat( result.getCheckedInFiles().size(), is( 2 ) );
+        assertHasScmFile( result.getCheckedInFiles(), "project/dir/pom.xml", ScmFileStatus.CHECKED_IN );
+        assertHasScmFile( result.getCheckedInFiles(), "project/dir/src/main/java/Bar.java", ScmFileStatus.CHECKED_IN );
+
+    }
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkin/AccuRevCheckInCommandTest.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/command/checkout/AccuRevCheckOutCommandTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java?rev=897510&view=auto
==============================================================================
--- maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java (added)
+++ maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java Sat Jan  9 18:23:30 2010
@@ -0,0 +1,268 @@
+package org.apache.maven.scm.provider.accurev.command.checkout;
+
+/*
+ * 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.ScmFileMatcher.*;
+import static org.apache.maven.scm.provider.accurev.AddElementsAction.*;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.io.File;
+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.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmTag;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.command.AbstractAccuRevCommandTest;
+import org.jmock.Expectations;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * checkout a revision or branch (stream/tranid)-> make workspace. If basedir is empty and represents the top of an
+ * existing workspace, then reparent the workspace if necessary and repopulate missing file, and update If basedir is
+ * not empty or is a subdirectory of an existing workspace throw exception. Otherwise make a workspace and update
+ * Special case for release plugin - checkout a tag to an ignored and empty subdirectory of an existing workspace. Treat
+ * as an export. deactivate the workspace, export with pop -v -L then reactivate the workspace.
+ * 
+ * @author ggardner
+ */
+public class AccuRevCheckOutCommandTest
+    extends AbstractAccuRevCommandTest
+{
+
+    @Before
+    public void setUp()
+        throws Exception
+    {
+        super.setUp();
+        context.checking( new Expectations()
+        {
+            {
+
+                one( accurev ).info( basedir );
+                will( returnValue( info ) );
+                inSequence( sequence );
+
+            }
+        } );
+
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testCheckout()
+        throws Exception
+    {
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).mkws( "myStream", AccuRevCheckOutCommand.getWorkSpaceName( basedir, "myStream" ),
+                                     basedir );
+                will( returnValue( true ) );
+                inSequence( sequence );
+
+                one( accurev ).update( with( basedir ), with( (String) null ), with( any( List.class ) ) );
+                will( doAll( addElementsTo( 2, new File( "updated/file" ) ), returnValue( true ) ) );
+                // will(returnValue(true));
+                inSequence( sequence );
+            }
+        } );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevCheckOutCommand command = new AccuRevCheckOutCommand( getLogger() );
+
+        CheckOutScmResult result = command.checkout( repo, new ScmFileSet( basedir ), new CommandParameters() );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( true ) );
+        assertThat( result.getRelativePathProjectDirectory(), is( "/project/dir" ) );
+        List checkedOutFiles = result.getCheckedOutFiles();
+        assertThat( checkedOutFiles.size(), is( 1 ) );
+        assertHasScmFile( checkedOutFiles, "updated/file", ScmFileStatus.CHECKED_OUT );
+
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testCheckoutFailure()
+        throws Exception
+    {
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).mkws( "myStream", AccuRevCheckOutCommand.getWorkSpaceName( basedir, "myStream" ),
+                                     basedir );
+                will( returnValue( true ) );
+                inSequence( sequence );
+
+                one( accurev ).update( with( basedir ), with( (String) null ), with( any( List.class ) ) );
+                will( returnValue( false ) );
+                // will(returnValue(true));
+                inSequence( sequence );
+            }
+        } );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevCheckOutCommand command = new AccuRevCheckOutCommand( getLogger() );
+
+        CheckOutScmResult result = command.checkout( repo, new ScmFileSet( basedir ), new CommandParameters() );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( false ) );
+        assertThat( result.getProviderMessage(), notNullValue() );
+
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testReCheckoutExistingWorkspaceSameBasis()
+        throws Exception
+    {
+
+        // Set the info result to return a workspace that already exists
+        info.setWorkSpace( "someOldStream_someUser" );
+        info.setBasis( "myStream" );
+        info.setTop( basedir.getAbsolutePath() );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).pop( with( basedir ), with( (List) null ), with( any( List.class ) ) );
+                will( returnValue( true ) );
+                inSequence( sequence );
+
+                one( accurev ).update( with( basedir ), with( (String) null ), with( any( List.class ) ) );
+                will( returnValue( true ) );
+                inSequence( sequence );
+            }
+        } );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevCheckOutCommand command = new AccuRevCheckOutCommand( getLogger() );
+
+        CheckOutScmResult result = command.checkout( repo, new ScmFileSet( basedir ), new CommandParameters() );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( true ) );
+        assertThat( result.getRelativePathProjectDirectory(), is( "/project/dir" ) );
+
+    }
+
+    @SuppressWarnings( "unchecked" )
+    @Test
+    public void testReCheckoutExistingWorkspaceDifferentBasis()
+        throws Exception
+    {
+        // Set the info result to return a workspace that already exists
+        info.setWorkSpace( "someOldStream_someUser" );
+        info.setBasis( "myStream" );
+        info.setTop( basedir.getAbsolutePath() );
+
+        context.checking( new Expectations()
+        {
+            {
+                one( accurev ).chws( with( basedir ), with( "someOldStream_someUser" ), with( "mySnapShot" ) );
+                will( returnValue( true ) );
+                inSequence( sequence );
+
+                one( accurev ).pop( with( basedir ), with( (List) null ), with( any( List.class ) ) );
+                will( returnValue( true ) );
+                inSequence( sequence );
+
+                one( accurev ).update( with( basedir ), with( (String) null ), with( any( List.class ) ) );
+                will( returnValue( true ) );
+                inSequence( sequence );
+            }
+        } );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevCheckOutCommand command = new AccuRevCheckOutCommand( getLogger() );
+
+        CommandParameters params = new CommandParameters();
+        params.setScmVersion( CommandParameter.SCM_VERSION, new ScmTag( "mySnapShot" ) );
+
+        CheckOutScmResult result = command.checkout( repo, new ScmFileSet( basedir ), params );
+
+        context.assertIsSatisfied();
+
+        assertThat( result.isSuccess(), is( true ) );
+        assertThat( result.getRelativePathProjectDirectory(), is( "/project/dir" ) );
+
+    }
+
+    @Test
+    public void testReCheckoutSubdirectoryOfExistingWorkspaceThrowsException()
+        throws Exception
+    {
+        // Set the info result to return a workspace that already exists
+        info.setWorkSpace( "someOldStream_someUser" );
+        info.setBasis( "myStream" );
+        info.setTop( basedir.getParentFile().getAbsolutePath() );
+
+        AccuRevScmProviderRepository repo = new AccuRevScmProviderRepository();
+        repo.setStreamName( "myStream" );
+        repo.setAccuRev( accurev );
+        repo.setProjectPath( "/project/dir" );
+
+        AccuRevCheckOutCommand command = new AccuRevCheckOutCommand( getLogger() );
+
+        CommandParameters params = new CommandParameters();
+        params.setScmVersion( CommandParameter.SCM_VERSION, new ScmTag( "mySnapShot" ) );
+
+        try
+        {
+            command.checkout( repo, new ScmFileSet( basedir ), params );
+            fail( "Expected exception" );
+        }
+        catch ( ScmException e )
+        {
+            context.assertIsSatisfied();
+        }
+
+    }
+
+}

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/sandbox/trunk/scm/maven-scm-provider-accurevnew/src/test/java/org/apache/maven/scm/provider/accurev/command/checkout/AccuRevCheckOutCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision