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