View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.scm.tck.command.info;
20  
21  import java.io.File;
22  import java.time.OffsetDateTime;
23  import java.time.ZoneOffset;
24  
25  import org.apache.maven.scm.ScmFileSet;
26  import org.apache.maven.scm.ScmTckTestCase;
27  import org.apache.maven.scm.command.info.InfoItem;
28  import org.apache.maven.scm.command.info.InfoScmResult;
29  import org.apache.maven.scm.provider.ScmProvider;
30  import org.junit.Test;
31  
32  import static org.junit.Assert.assertEquals;
33  
34  /**
35   * This test tests the info command.
36   */
37  public abstract class InfoCommandTckTest extends ScmTckTestCase {
38  
39      @Test
40      public void testInfoCommandWithJustBasedir() throws Exception {
41          ScmProvider scmProvider = getScmManager().getProviderByUrl(getScmUrl());
42          InfoScmResult result = scmProvider.info(getScmRepository().getProviderRepository(), getScmFileSet(), null);
43          assertResultIsSuccess(result);
44          assertEquals(1, result.getInfoItems().size());
45          InfoItem item = result.getInfoItems().get(0);
46          assertEquals("Mark Struberg <struberg@yahoo.de>", item.getLastChangedAuthor());
47          assertEquals("92f139dfec4d1dfb79c3cd2f94e83bf13129668b", item.getRevision());
48          assertEquals(
49                  OffsetDateTime.of(2009, 3, 15, 19, 14, 2, 0, ZoneOffset.ofHours(1)), item.getLastChangedDateTime());
50      }
51  
52      @Test
53      public void testInfoCommandFromBasedirDifferentFromWorkingCopyDirectory() throws Exception {
54          ScmProvider scmProvider = getScmManager().getProviderByUrl(getScmUrl());
55          ScmFileSet fileSet = new ScmFileSet(new File(getWorkingCopy(), "src/main"), new File("java/Application.java"));
56          InfoScmResult result = scmProvider.info(getScmRepository().getProviderRepository(), fileSet, null);
57          assertResultIsSuccess(result);
58          assertEquals(1, result.getInfoItems().size());
59          InfoItem item = result.getInfoItems().get(0);
60          assertEquals("Mark Struberg <struberg@yahoo.de>", item.getLastChangedAuthor());
61          assertEquals("92f139dfec4d1dfb79c3cd2f94e83bf13129668b", item.getRevision());
62          assertEquals(
63                  OffsetDateTime.of(2009, 3, 15, 19, 14, 2, 0, ZoneOffset.ofHours(1)), item.getLastChangedDateTime());
64      }
65  }