View Javadoc
1   package org.apache.maven.plugins.pdf.stubs;
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.File;
23  import java.io.Reader;
24  import java.util.Collections;
25  import java.util.List;
26  
27  import org.apache.maven.artifact.repository.ArtifactRepository;
28  import org.apache.maven.artifact.repository.MavenArtifactRepository;
29  import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout;
30  import org.apache.maven.model.Model;
31  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
32  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
33  import org.codehaus.plexus.util.ReaderFactory;
34  
35  /**
36   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
37   */
38  public class ITextMavenProjectStub
39      extends MavenProjectStub
40  {
41      public ITextMavenProjectStub()
42      {
43          MavenXpp3Reader pomReader = new MavenXpp3Reader();
44  
45          try ( Reader reader = ReaderFactory.newXmlReader( getFile() ) )
46          {
47              final Model model = pomReader.read( reader );
48              setModel( model );
49          }
50          catch ( Exception e )
51          {
52              throw new RuntimeException( e );
53          }
54      }
55  
56      /** {@inheritDoc} */
57      public File getBasedir()
58      {
59          return new File( super.getBasedir(), "target/test-classes/unit/pdf/" );
60      }
61  
62      /** {@inheritDoc} */
63      public List<ArtifactRepository> getRemoteArtifactRepositories()
64      {
65          ArtifactRepository repository =
66              new MavenArtifactRepository( "central", "https://repo.maven.apache.org/maven2",
67                          new DefaultRepositoryLayout(), null, null );
68  
69          return Collections.singletonList( repository );
70      }
71  
72      /** {@inheritDoc} */
73      public File getFile()
74      {
75          return new File( getBasedir(), "iText_pom.xml" );
76      }
77  }