|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HTTPMethods | Line # 34 | 13 | 0% | 7 | 0 | 100% |
1.0
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (8) | |||
| Result | |||
|
0.75
|
net.sf.arestc.communication.HTTPMethodsTest.testGetMethod
net.sf.arestc.communication.HTTPMethodsTest.testGetMethod
|
1 PASS | |
|
0.375
|
net.sf.arestc.core.OverallDesignTest.testFileDownload
net.sf.arestc.core.OverallDesignTest.testFileDownload
|
1 PASS | |
|
0.375
|
net.sf.arestc.core.OverallDesignTest.testRepositoryCreate
net.sf.arestc.core.OverallDesignTest.testRepositoryCreate
|
1 PASS | |
|
0.375
|
net.sf.arestc.core.OverallDesignTest.testRepositoryMultiPost
net.sf.arestc.core.OverallDesignTest.testRepositoryMultiPost
|
1 PASS | |
|
0.375
|
net.sf.arestc.core.OverallDesignTest.testRepositoryRetrieval
net.sf.arestc.core.OverallDesignTest.testRepositoryRetrieval
|
1 PASS | |
|
0.375
|
net.sf.arestc.core.OverallDesignTest.testRepositoryDelete
net.sf.arestc.core.OverallDesignTest.testRepositoryDelete
|
1 PASS | |
|
0.375
|
net.sf.arestc.core.OverallDesignTest.testFileUpload
net.sf.arestc.core.OverallDesignTest.testFileUpload
|
1 PASS | |
|
0.375
|
net.sf.arestc.core.OverallDesignTest.testTicketRetrieval
net.sf.arestc.core.OverallDesignTest.testTicketRetrieval
|
1 PASS | |
| 1 | /* | |
| 2 | * | |
| 3 | * (C)opyright 2010, Nikolaos Georgosopoulos | |
| 4 | * | |
| 5 | * This file is part of ARESTC. | |
| 6 | * | |
| 7 | * ARESTC is free software: you can redistribute it and/or modify it under the | |
| 8 | * terms of the Lesser General Public License as published by the Free Software | |
| 9 | * Foundation, either version 3 of the License, or (at your option) any later | |
| 10 | * version. | |
| 11 | * | |
| 12 | * ARESTC is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 13 | * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |
| 14 | * A PARTICULAR PURPOSE. See the GNU General Public License for more details. | |
| 15 | * | |
| 16 | * You should have received a copy of the Lesser General Public License along | |
| 17 | * with ARESTC. If not, see <http://www.gnu.org/licenses/>. | |
| 18 | */ | |
| 19 | ||
| 20 | package net.sf.arestc.core; | |
| 21 | ||
| 22 | import org.apache.commons.httpclient.HttpMethod; | |
| 23 | import org.apache.commons.httpclient.methods.DeleteMethod; | |
| 24 | import org.apache.commons.httpclient.methods.GetMethod; | |
| 25 | import org.apache.commons.httpclient.methods.HeadMethod; | |
| 26 | import org.apache.commons.httpclient.methods.PostMethod; | |
| 27 | import org.apache.commons.httpclient.methods.PutMethod; | |
| 28 | ||
| 29 | /** | |
| 30 | * The Enum HTTPMethods. | |
| 31 | * | |
| 32 | * @author georgosn | |
| 33 | */ | |
| 34 | public enum HTTPMethods { | |
| 35 | ||
| 36 | /** The HEAD. */ | |
| 37 | HEAD("{0}?{1}"), /** The HEAD method enum. */ | |
| 38 | GET("{0}?{1}"), /** The Get method enum. */ | |
| 39 | POST("{0}"), /** The Post method enum. */ | |
| 40 | DELETE("{0}?{1}"), /** The Delete method enum. */ | |
| 41 | PUT("{0}"), /** the Put method enum */ | |
| 42 | ; | |
| 43 | ||
| 44 | private String urlPattern; | |
| 45 | ||
| 46 | 5 |
private HTTPMethods(final String pattern) { |
| 47 | 5 | urlPattern = pattern; |
| 48 | } | |
| 49 | ||
| 50 | 14 |
public HttpMethod getMethod(final String source) { |
| 51 | 14 | switch (this) { |
| 52 | 6 | case GET: |
| 53 | 6 | return new GetMethod(source); |
| 54 | 2 | case PUT: |
| 55 | 2 | return new PutMethod(source); |
| 56 | 3 | case POST: |
| 57 | 3 | return new PostMethod(source); |
| 58 | 2 | case DELETE: |
| 59 | 2 | return new DeleteMethod(source); |
| 60 | 1 | default: |
| 61 | 1 | return new HeadMethod(source); |
| 62 | } | |
| 63 | } | |
| 64 | ||
| 65 | 9 |
public String getURLPattern() { |
| 66 | 9 | return urlPattern; |
| 67 | } | |
| 68 | } | |
|
||||||||||||