1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.plugin.eclipse;
20  
21  import org.apache.maven.model.Dependency;
22  
23  /**
24   * @author Fabrizio Giustina
25   * @version $Id: MakeArtifactsTest.java 595476 2007-11-15 22:21:55Z aheritier $
26   * @deprecated use {@link EclipseToMavenTest}
27   */
28  public class MakeArtifactsTest
29      extends EclipseToMavenTest
30  {
31  
32      /**
33       * @see junit.framework.TestCase#setUp()
34       */
35      protected void setUp()
36          throws Exception
37      {
38          super.setUp();
39          mojo = new MakeArtifactsMojo();
40      }
41  
42      /**
43       * Tests the parsing of the "Require-Bundle" entry from a manifest.
44       */
45      public void testParseDependencies()
46      {
47          Dependency[] deps =
48              mojo.parseDependencies( "org.eclipse.ui;bundle-version=\"[3.2.0,4.0.0)\","
49                  + "org.eclipse.ui.console;resolution:=\"optional\";bundle-version=\"[3.1.100,4.0.0)\",org.eclipse.help;"
50                  + "bundle-version=\"[3.2.0,4.0.0)\",org.eclipse.core.expressions;bundle-version=\"[3.2.0,4.0.0)\"" );
51  
52          assertEquals( 4, deps.length );
53          assertEquals( "org.eclipse.ui", deps[0].getArtifactId() );
54          assertEquals( "[3.2.0,4.0.0)", deps[0].getVersion() );
55          assertEquals( "org.eclipse.ui.console", deps[1].getArtifactId() );
56          assertEquals( "[3.1.100,4.0.0)", deps[1].getVersion() );
57          assertEquals( "org.eclipse.help", deps[2].getArtifactId() );
58          assertEquals( "[3.2.0,4.0.0)", deps[2].getVersion() );
59          assertEquals( "org.eclipse.core.expressions", deps[3].getArtifactId() );
60          assertEquals( "[3.2.0,4.0.0)", deps[3].getVersion() );
61      }
62  
63      /**
64       * Tests the parsing of the "Require-Bundle" entry from a manifest.
65       */
66      public void testParseDependenciesWithQualifier()
67      {
68          Dependency[] deps =
69              mojo.parseDependencies( "org.eclipse.ui;bundle-version=\"[3.2.0.0,4.0.0.0)\","
70                  + "org.eclipse.ui.console;resolution:=\"optional\";bundle-version=\"[3.1.100.0,4.0.0.0)\",org.eclipse.help;"
71                  + "bundle-version=\"[3.2.0.1,4.0.0.2)\",org.eclipse.core.expressions;bundle-version=\"[3.2.0.0,4.0.0.0)\"" );
72  
73          assertEquals( 4, deps.length );
74          assertEquals( "org.eclipse.ui", deps[0].getArtifactId() );
75          assertEquals( "[3.2.0-0,4.0.0-0)", deps[0].getVersion() );
76          assertEquals( "org.eclipse.ui.console", deps[1].getArtifactId() );
77          assertEquals( "[3.1.100-0,4.0.0-0)", deps[1].getVersion() );
78          assertEquals( "org.eclipse.help", deps[2].getArtifactId() );
79          assertEquals( "[3.2.0-1,4.0.0-2)", deps[2].getVersion() );
80          assertEquals( "org.eclipse.core.expressions", deps[3].getArtifactId() );
81          assertEquals( "[3.2.0-0,4.0.0-0)", deps[3].getVersion() );
82      }
83  
84      /**
85       * Test the generation of a groupId from a bundle symbolic name.
86       */
87      public void testCreateGroupId()
88      {
89          assertEquals( "test", mojo.createGroupId( "test" ) );
90          assertEquals( "org.eclipse", mojo.createGroupId( "org.eclipse" ) );
91          assertEquals( "org.eclipse.jdt", mojo.createGroupId( "org.eclipse.jdt" ) );
92          assertEquals( "org.eclipse.jdt", mojo.createGroupId( "org.eclipse.jdt.apt" ) );
93          assertEquals( "org.eclipse.jdt", mojo.createGroupId( "org.eclipse.jdt.apt.core" ) );
94      }
95  
96      /**
97       * Test the generation of a artifactId from a bundle symbolic name.
98       */
99      public void testCreateArtifactId()
100     {
101         assertEquals( "test", mojo.createArtifactId( "test" ) );
102         assertEquals( "org.eclipse", mojo.createArtifactId( "org.eclipse" ) );
103         assertEquals( "org.eclipse.jdt", mojo.createArtifactId( "org.eclipse.jdt" ) );
104         assertEquals( "org.eclipse.jdt.apt", mojo.createArtifactId( "org.eclipse.jdt.apt" ) );
105         assertEquals( "org.eclipse.jdt.apt.core", mojo.createArtifactId( "org.eclipse.jdt.apt.core" ) );
106     }
107 
108 }