package org.apache.maven.vsslib; /* * ==================================================================== * Copyright 2001-2004 The Apache Software Foundation. * * Licensed 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.InputStream; import java.util.Collection; import junit.framework.TestCase; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.maven.changelog.ChangeLog; import org.apache.maven.changelog.ChangeLogEntry; import org.apache.maven.vsslib.VssChangeLogParser; /** * Test cases for {@link VssChangeLogParser} * * @author Freddy Mallet */ public class VssChangeLogParserTest extends TestCase { /** * Log */ private static Log LOG = LogFactory.getLog(VssChangeLogParserTest.class); /** * Example of VSS history feed */ private static String VSS_HISTORY_FEED_FILE = "/vsslib/vss_history_feed.txt"; /** * VSS history feed input stream */ private InputStream in; /** * Vss connection feed associated with the VSS history feed */ private String connection = "scm:vss:\\\\lancelot\\arthur\\" + ":malletf,passwd:/Security/card"; /** * VssChangeLogParser instance to test */ private VssChangeLogParser parser; /** * Load dummy vss hidtory fedd */ protected void setUp() throws Exception { super.setUp(); in = this.getClass().getResourceAsStream(VSS_HISTORY_FEED_FILE); if (in == null) { String message = "Unable to find " + VSS_HISTORY_FEED_FILE; LOG.fatal(message); throw (new Exception(message)); } ChangeLog changeLod = new ChangeLog(); changeLod.setRepositoryConnection(connection); parser = new VssChangeLogParser(); parser.init(changeLod); } public void testParseNumberItems() throws Exception { Collection collection = parser.parse(in); assertEquals(collection.size(), 5); } public void testParseAuthor() throws Exception { Collection collection = parser.parse(in); ChangeLogEntry entry = (ChangeLogEntry) (collection.toArray())[0]; assertEquals(entry.getAuthor(), "Malletf"); entry = (ChangeLogEntry) (collection.toArray())[1]; assertEquals(entry.getAuthor(), "Moraneg"); } public void testParseDate() throws Exception { Collection collection = parser.parse(in); ChangeLogEntry entry = (ChangeLogEntry) (collection.toArray())[0]; assertEquals(entry.getDateFormatted(), "2004-11-29"); entry = (ChangeLogEntry) (collection.toArray())[1]; assertEquals(entry.getDateFormatted(), "2004-11-24"); } }