View Javadoc
1   package org.apache.maven.plugins.ear;
2   
3   import java.util.Objects;
4   import java.util.Set;
5   import java.util.TreeSet;
6   
7   import org.apache.maven.artifact.Artifact;
8   import org.apache.maven.artifact.DefaultArtifact;
9   import org.apache.maven.plugins.ear.stub.ArtifactHandlerTestStub;
10  
11  /*
12   * Licensed to the Apache Software Foundation (ASF) under one
13   * or more contributor license agreements.  See the NOTICE file
14   * distributed with this work for additional information
15   * regarding copyright ownership.  The ASF licenses this file
16   * to you under the Apache License, Version 2.0 (the
17   * "License"); you may not use this file except in compliance
18   * with the License.  You may obtain a copy of the License at
19   *
20   *  http://www.apache.org/licenses/LICENSE-2.0
21   *
22   * Unless required by applicable law or agreed to in writing,
23   * software distributed under the License is distributed on an
24   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
25   * KIND, either express or implied.  See the License for the
26   * specific language governing permissions and limitations
27   * under the License.
28   */
29  
30  /**
31   * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
32   */
33  public abstract class AbstractEarTestBase
34  {
35  
36      protected static final String DEFAULT_GROUPID = "eartest";
37  
38      private static final String DEFAULT_TYPE = "jar";
39  
40      protected void setUri( EarModule module, String uri )
41      {
42          ( (AbstractEarModule) module ).setUri( uri );
43      }
44  
45      protected Set<Artifact> createArtifacts( String[] artifactIds )
46      {
47          return createArtifacts( artifactIds, null );
48      }
49  
50      protected Set<Artifact> createArtifacts( String[] artifactIds, String[] classifiers )
51      {
52          Set<Artifact> result = new TreeSet<Artifact>();
53          ArtifactHandlerTestStub artifactHandler = new ArtifactHandlerTestStub( "jar" );
54          for ( int i = 0; i < artifactIds.length; i++ )
55          {
56              String artifactId = artifactIds[i];
57              String classifier = classifiers == null ? null : classifiers[i];
58              Artifact artifactTestStub = new DefaultArtifact(
59                  DEFAULT_GROUPID, artifactId, "1.0", "compile", DEFAULT_TYPE, classifier, artifactHandler );
60              result.add( artifactTestStub );
61          }
62          return result;
63      }
64  
65      protected Artifact createArtifact( String artifactId, String type )
66      {
67          Artifact artifactTestStub = new DefaultArtifact(
68              DEFAULT_GROUPID, artifactId, "1.0", "compile", Objects.toString( type, DEFAULT_TYPE ),
69              null, new ArtifactHandlerTestStub( "jar" ) );
70          
71          return artifactTestStub;
72      }
73  }