1   package org.apache.maven.ejb;
2   
3   /* ====================================================================
4    *   Licensed to the Apache Software Foundation (ASF) under one or more
5    *   contributor license agreements.  See the NOTICE file distributed with
6    *   this work for additional information regarding copyright ownership.
7    *   The ASF licenses this file to You under the Apache License, Version 2.0
8    *   (the "License"); you may not use this file except in compliance with
9    *   the License.  You may obtain a copy of the License at
10   *
11   *       http://www.apache.org/licenses/LICENSE-2.0
12   *
13   *   Unless required by applicable law or agreed to in writing, software
14   *   distributed under the License is distributed on an "AS IS" BASIS,
15   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   *   See the License for the specific language governing permissions and
17   *   limitations under the License.
18   * ====================================================================
19   */
20  
21  import org.apache.maven.MavenException;
22  import org.apache.maven.project.Project;
23  import org.apache.maven.repository.ArtifactTypeHandler;
24  
25  import junit.framework.TestCase;
26  
27  /**
28   *  This will do until wagon debuts.
29   * 
30   * @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
31   * @version $Id: EJBArtifactTypeHandlerTest.java 533617 2007-04-30 07:41:05Z ltheussl $
32   */
33  public class EJBArtifactTypeHandlerTest extends TestCase
34  {
35      private Project project;
36      private ArtifactTypeHandler handler;
37      private static final String VERSION = "VERSION";
38  
39      public void setUp() throws Exception
40      {
41          project = new Project();
42          project.setGroupId("groupId");
43          project.setArtifactId("artifactId");
44          handler = new EJBArtifactTypeHandler();
45      }
46  
47      public void testConstructRepositoryDirectoryPath() throws Exception
48      {
49          assertEquals("check artifact directory", "groupId/ejbs/",
50              handler.constructRepositoryDirectoryPath("ejb", project));
51          assertEquals("check artifact directory", "groupId/ejbs/",
52              handler.constructRepositoryDirectoryPath("ejb-client", project));
53      }
54  
55      public void testConstructRepositoryFullPath() throws Exception
56      {
57          assertEquals("check artifact path", "groupId/ejbs/artifactId-VERSION.jar",
58              handler.constructRepositoryFullPath("ejb", project, VERSION));
59          assertEquals("check artifact path", "groupId/ejbs/artifactId-VERSION-client.jar",
60              handler.constructRepositoryFullPath("ejb-client", project, VERSION));
61      }
62  
63      public void testConstructRepositoryFullPathWithInvalidType() throws Exception
64      {
65          try {
66              handler.constructRepositoryFullPath("foo", project, VERSION);
67              fail("expected exception");
68          }
69          catch (MavenException expected) {
70              assertEquals("Unrecognised ejb type (is foo)", expected.getMessage());
71          }
72      }
73  }