    1   package org.apache.felix.bundleplugin;
    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.IOException;
    24  import java.util.LinkedHashSet;
    25  import java.util.Set;
    26
    27  import org.apache.maven.artifact.Artifact;
    28
    29  /**
    30   * Fixed version of class that uses stable set ordering for reliable testing.
    31   */
    32  @SuppressWarnings( { "rawtypes", "unchecked" } )
    33  class ArtifactStubFactory extends org.apache.maven.plugin.testing.ArtifactStubFactory
    34  {
    35
    36      public ArtifactStubFactory( File workingDir, boolean createFiles )
    37      {
    38          super( workingDir, createFiles );
    39      }
    40
    41      @Override
    42      public Set getClassifiedArtifacts() throws IOException
    43      {
    44          Set set = new LinkedHashSet();
    45          set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "jar", "one" ) );
    46          set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", "two" ) );
    47          set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "jar", "three" ) );
    48          set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "jar", "four" ) );
    49          return set;
    50      }
    51
    52      @Override
    53      public Set getScopedArtifacts() throws IOException
    54      {
    55          Set set = new LinkedHashSet();
    56          set.add( createArtifact( "g", "compile", "1.0", Artifact.SCOPE_COMPILE ) );
    57          set.add( createArtifact( "g", "provided", "1.0", Artifact.SCOPE_PROVIDED ) );
    58          set.add( createArtifact( "g", "test", "1.0", Artifact.SCOPE_TEST ) );
    59          set.add( createArtifact( "g", "runtime", "1.0", Artifact.SCOPE_RUNTIME ) );
    60          set.add( createArtifact( "g", "system", "1.0", Artifact.SCOPE_SYSTEM ) );
    61          return set;
    62      }
    63
    64      @Override
    65      public Set getTypedArtifacts() throws IOException
    66      {
    67          Set set = new LinkedHashSet();
    68          set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "war", null ) );
    69          set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", null ) );
    70          set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "sources", null ) );
    71          set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "zip", null ) );
    72          set.add( createArtifact( "g", "e", "1.0", Artifact.SCOPE_COMPILE, "rar", null ) );
    73          return set;
    74      }
    75
    76  }