Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DefaultArtifactHandlerStub |
|
| 1.2777777777777777;1,278 |
1 | package org.apache.maven.plugin.testing.stubs; | |
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 org.apache.maven.artifact.handler.ArtifactHandler; | |
23 | ||
24 | /** | |
25 | * Minimal artifact handler used by the stub factory to create unpackable archives. | |
26 | * | |
27 | * @author <a href="mailto:brianf@apache.org">Brian Fox</a> | |
28 | * @version $Id: DefaultArtifactHandlerStub.java 638332 2008-03-18 11:39:00Z bentmann $ | |
29 | */ | |
30 | public class DefaultArtifactHandlerStub | |
31 | implements ArtifactHandler | |
32 | { | |
33 | private String extension; | |
34 | ||
35 | private String type; | |
36 | ||
37 | private String classifier; | |
38 | ||
39 | private String directory; | |
40 | ||
41 | private String packaging; | |
42 | ||
43 | private boolean includesDependencies; | |
44 | ||
45 | private String language; | |
46 | ||
47 | private boolean addedToClasspath; | |
48 | ||
49 | /** | |
50 | * @param t the artifact handler type | |
51 | * @param c the artifact handler classifier | |
52 | */ | |
53 | public DefaultArtifactHandlerStub( String t, String c ) | |
54 | 4 | { |
55 | 4 | type = t; |
56 | 4 | classifier = c; |
57 | 4 | if ( t.equals( "test-jar" ) ) |
58 | { | |
59 | 0 | extension = "jar"; |
60 | } | |
61 | ||
62 | 4 | } |
63 | ||
64 | /** | |
65 | * @param type the artifact handler type | |
66 | */ | |
67 | public DefaultArtifactHandlerStub( String type ) | |
68 | 0 | { |
69 | 0 | this.type = type; |
70 | 0 | } |
71 | ||
72 | /** {@inheritDoc} */ | |
73 | public String getExtension() | |
74 | { | |
75 | 0 | if ( extension == null ) |
76 | { | |
77 | 0 | extension = type; |
78 | } | |
79 | 0 | return extension; |
80 | } | |
81 | ||
82 | /** | |
83 | * @return the artifact handler type | |
84 | */ | |
85 | public String getType() | |
86 | { | |
87 | 0 | return type; |
88 | } | |
89 | ||
90 | /** {@inheritDoc} */ | |
91 | public String getClassifier() | |
92 | { | |
93 | 0 | return classifier; |
94 | } | |
95 | ||
96 | /** {@inheritDoc} */ | |
97 | public String getDirectory() | |
98 | { | |
99 | 0 | if ( directory == null ) |
100 | { | |
101 | 0 | directory = getPackaging() + "s"; |
102 | } | |
103 | 0 | return directory; |
104 | } | |
105 | ||
106 | /** {@inheritDoc} */ | |
107 | public String getPackaging() | |
108 | { | |
109 | 0 | if ( packaging == null ) |
110 | { | |
111 | 0 | packaging = getType(); |
112 | } | |
113 | 0 | return packaging; |
114 | } | |
115 | ||
116 | /** {@inheritDoc} */ | |
117 | public boolean isIncludesDependencies() | |
118 | { | |
119 | 0 | return includesDependencies; |
120 | } | |
121 | ||
122 | /** {@inheritDoc} */ | |
123 | public String getLanguage() | |
124 | { | |
125 | 0 | if ( language == null ) |
126 | { | |
127 | 0 | language = "none"; |
128 | } | |
129 | ||
130 | 0 | return language; |
131 | } | |
132 | ||
133 | /** {@inheritDoc} */ | |
134 | public boolean isAddedToClasspath() | |
135 | { | |
136 | 0 | return addedToClasspath; |
137 | } | |
138 | ||
139 | /** | |
140 | * @param theAddedToClasspath The addedToClasspath to set. | |
141 | */ | |
142 | public void setAddedToClasspath( boolean theAddedToClasspath ) | |
143 | { | |
144 | 0 | this.addedToClasspath = theAddedToClasspath; |
145 | 0 | } |
146 | ||
147 | /** | |
148 | * @param theClassifier The classifier to set. | |
149 | */ | |
150 | public void setClassifier( String theClassifier ) | |
151 | { | |
152 | 0 | this.classifier = theClassifier; |
153 | 0 | } |
154 | ||
155 | /** | |
156 | * @param theDirectory The directory to set. | |
157 | */ | |
158 | public void setDirectory( String theDirectory ) | |
159 | { | |
160 | 0 | this.directory = theDirectory; |
161 | 0 | } |
162 | ||
163 | /** | |
164 | * @param theExtension The extension to set. | |
165 | */ | |
166 | public void setExtension( String theExtension ) | |
167 | { | |
168 | 0 | this.extension = theExtension; |
169 | 0 | } |
170 | ||
171 | /** | |
172 | * @param theIncludesDependencies The includesDependencies to set. | |
173 | */ | |
174 | public void setIncludesDependencies( boolean theIncludesDependencies ) | |
175 | { | |
176 | 0 | this.includesDependencies = theIncludesDependencies; |
177 | 0 | } |
178 | ||
179 | /** | |
180 | * @param theLanguage The language to set. | |
181 | */ | |
182 | public void setLanguage( String theLanguage ) | |
183 | { | |
184 | 0 | this.language = theLanguage; |
185 | 0 | } |
186 | ||
187 | /** | |
188 | * @param thePackaging The packaging to set. | |
189 | */ | |
190 | public void setPackaging( String thePackaging ) | |
191 | { | |
192 | 0 | this.packaging = thePackaging; |
193 | 0 | } |
194 | ||
195 | /** | |
196 | * @param theType The type to set. | |
197 | */ | |
198 | public void setType( String theType ) | |
199 | { | |
200 | 0 | this.type = theType; |
201 | 0 | } |
202 | } |