001package org.apache.maven.scm.provider.accurev.cli; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import static org.apache.maven.scm.provider.accurev.VersionMatcher.version; 023import static org.hamcrest.Matchers.is; 024import static org.junit.Assert.assertThat; 025 026import java.io.IOException; 027import java.util.ArrayList; 028import java.util.Date; 029import java.util.List; 030 031import org.apache.maven.scm.log.DefaultLog; 032import org.apache.maven.scm.provider.accurev.Transaction; 033import org.hamcrest.Matchers; 034import org.junit.Test; 035 036public class HistoryConsumerTest 037{ 038 039 @Test 040 public void testConsumeStreamHistory() 041 throws IOException 042 { 043 List<Transaction> transactions = new ArrayList<Transaction>(); 044 XppStreamConsumer consumer = new HistoryConsumer( new DefaultLog(), transactions ); 045 AccuRevJUnitUtil.consume( "/streamHistory.xml", consumer ); 046 047 assertThat( transactions.size(), is( 4 ) ); 048 Transaction t = transactions.get( 0 ); 049 assertThat( t.getTranType(), is( "promote" ) ); 050 assertThat( t.getWhen(), is( new Date( 1233782838000L ) ) ); 051 assertThat( t.getAuthor(), is( "ggardner" ) ); 052 assertThat( t.getId(), is( 50L ) ); 053 assertThat( t.getVersions().size(), is( 2 ) ); 054 055 assertThat( t.getVersions(), 056 Matchers.<Transaction.Version>hasItem( version( 8L, "/./tcktests/src/main/java/Application.java", 057 "1/1", "2/3" ) ) ); 058 059 t = transactions.get( 1 ); 060 assertThat( t.getComment(), is( "hpromoting" ) ); 061 062 } 063 064}