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   */
38  public abstract class InfoCommandTckTest extends ScmTckTestCase {
39  
40      @Test
41      public void testInfoCommandWithJustBasedir() throws Exception {
42          ScmProvider scmProvider = getScmManager().getProviderByUrl(getScmUrl());
43          InfoScmResult result = scmProvider.info(getScmRepository().getProviderRepository(), getScmFileSet(), null);
44          assertResultIsSuccess(result);
45          assertEquals(1, result.getInfoItems().size());
46          InfoItem item = result.getInfoItems().get(0);
47          assertEquals("Mark Struberg <struberg@yahoo.de>", item.getLastChangedAuthor());
48          assertEquals("92f139dfec4d1dfb79c3cd2f94e83bf13129668b", item.getRevision());
49          assertEquals(
50                  OffsetDateTime.of(2009, 03, 15, 19, 14, 02, 0, ZoneOffset.ofHours(1)), item.getLastChangedDateTime());
51      }
52  
53      @Test
54      public void testInfoCommandFromBasedirDifferentFromWorkingCopyDirectory() throws Exception {
55          ScmProvider scmProvider = getScmManager().getProviderByUrl(getScmUrl());
56          ScmFileSet fileSet = new ScmFileSet(new File(getWorkingCopy(), "src/main"), new File("java/Application.java"));
57          InfoScmResult result = scmProvider.info(getScmRepository().getProviderRepository(), fileSet, null);
58          assertResultIsSuccess(result);
59          assertEquals(1, result.getInfoItems().size());
60          InfoItem item = result.getInfoItems().get(0);
61          assertEquals("Mark Struberg <struberg@yahoo.de>", item.getLastChangedAuthor());
62          assertEquals("92f139dfec4d1dfb79c3cd2f94e83bf13129668b", item.getRevision());
63          assertEquals(
64                  OffsetDateTime.of(2009, 03, 15, 19, 14, 02, 0, ZoneOffset.ofHours(1)), item.getLastChangedDateTime());
65      }
66  }