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.FileReader;
24  import java.util.List;
25  
26  import org.apache.maven.model.Developer;
27  import org.apache.maven.model.Model;
28  import org.apache.maven.model.Organization;
29  import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
30  import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
31  
32  /**
33   * @author ltheussl
34   * @version $Id: ModelBuilderMavenProjectStub.java 787562 2009-06-23 06:40:57Z ltheussl $
35   */
36  public class ModelBuilderMavenProjectStub
37      extends MavenProjectStub
38  {
39      /**
40       * Stub to test the DocumentModelBuilder.
41       */
42      public ModelBuilderMavenProjectStub()
43      {
44          try
45          {
46              Model model = new MavenXpp3Reader().read(
47                      new FileReader( new File( getBasedir() + "/pom_model_builder.xml" ) ) );
48              setModel( model );
49  
50              setGroupId( model.getGroupId() );
51              setArtifactId( model.getArtifactId() );
52              setVersion( model.getVersion() );
53              setName( model.getName() );
54              setDescription( model.getDescription() );
55              setDevelopers( model.getDevelopers() );
56              setOrganization( model.getOrganization() );
57          }
58          catch ( Exception e )
59          {
60              throw new RuntimeException( e );
61          }
62      }
63  
64      /** {@inheritDoc}
65       * @return the test base dir: "/target/test-classes/unit/pdf/".
66       */
67      public File getBasedir()
68      {
69          return new File( super.getBasedir() + "/target/test-classes/unit/pdf/" );
70      }
71  
72      /** {@inheritDoc}
73       * @param developer
74       */
75      public void addDeveloper( Developer developer )
76      {
77          getModel().addDeveloper( developer );
78      }
79  
80      /** {@inheritDoc}
81       * @return
82       */
83      public List getDevelopers()
84      {
85          return getModel().getDevelopers();
86      }
87  
88      /** {@inheritDoc}
89       * @return
90       */
91      public Organization getOrganization()
92      {
93          return getModel().getOrganization();
94      }
95  
96      /** {@inheritDoc}
97       * @param list
98       */
99      public void setDevelopers( List list )
100     {
101         getModel().setDevelopers( list );
102     }
103 
104     /** {@inheritDoc}
105      * @param organization
106      */
107     public void setOrganization( Organization organization )
108     {
109         getModel().setOrganization( organization );
110     }
111 }