View Javadoc
1   package org.apache.maven.scm.provider.vss.commands.status;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.BufferedReader;
23  import java.io.IOException;
24  import java.io.InputStreamReader;
25  
26  import org.apache.maven.scm.ScmFileSet;
27  import org.apache.maven.scm.ScmTestCase;
28  import org.apache.maven.scm.manager.NoSuchScmProviderException;
29  import org.apache.maven.scm.manager.ScmManager;
30  import org.apache.maven.scm.manager.plexus.PlexusLogger;
31  import org.apache.maven.scm.provider.vss.repository.VssScmProviderRepository;
32  import org.apache.maven.scm.repository.ScmRepository;
33  import org.apache.maven.scm.repository.ScmRepositoryException;
34  import org.codehaus.plexus.util.IOUtil;
35  
36  /**
37   * @author <a href="mailto:matpimenta@gmail.com">Mateus Pimenta</a>
38   * 
39   */
40  public class VssStatusConsumerTest
41      extends ScmTestCase
42  {
43  
44      private ScmManager scmManager;
45  
46      private org.codehaus.plexus.logging.Logger logger;
47  
48      public void setUp()
49          throws Exception
50      {
51          super.setUp();
52          scmManager = getScmManager();
53          logger = getContainer().getLogger();
54      }
55  
56      public void testConsumeLine()
57          throws ScmRepositoryException, NoSuchScmProviderException, IOException
58      {
59          BufferedReader reader = new BufferedReader( new InputStreamReader( this.getResourceAsStream( "/test.txt" ),
60                                                                             "UTF-8" ) );
61          try
62          {
63              ScmRepository repository = scmManager
64                  .makeScmRepository( "scm:vss|username|password@C:/Program File/Visual Source Safe|D:/myProject" );
65              ScmFileSet fileSet = new ScmFileSet( getTestFile( "target" ) );
66  
67              VssStatusConsumer consumer = new VssStatusConsumer( (VssScmProviderRepository) repository
68                  .getProviderRepository(), new PlexusLogger( logger ), fileSet );
69  
70              String line = reader.readLine();
71              while ( line != null )
72              {
73                  consumer.consumeLine( line );
74                  line = reader.readLine();
75              }
76          }
77          finally
78          {
79              IOUtil.close( reader );
80          }
81      }
82  
83  }