|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TransformResponse | Line # 34 | 8 | 0% | 6 | 4 | 75% |
0.75
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (16) | |||
| Result | |||
|
0.6875
|
net.sf.arestc.core.OverallDesignTest.testFileDownload
net.sf.arestc.core.OverallDesignTest.testFileDownload
|
1 PASS | |
|
0.4375
|
net.sf.arestc.core.OverallDesignTest.testTicketRetrieval
net.sf.arestc.core.OverallDesignTest.testTicketRetrieval
|
1 PASS | |
|
0.4375
|
net.sf.arestc.core.OverallDesignTest.testRepositoryRetrieval
net.sf.arestc.core.OverallDesignTest.testRepositoryRetrieval
|
1 PASS | |
|
0.4375
|
net.sf.arestc.core.OverallDesignTest.testRepositoryMultiPost
net.sf.arestc.core.OverallDesignTest.testRepositoryMultiPost
|
1 PASS | |
|
0.4375
|
net.sf.arestc.core.OverallDesignTest.testFileUpload
net.sf.arestc.core.OverallDesignTest.testFileUpload
|
1 PASS | |
|
0.4375
|
net.sf.arestc.core.OverallDesignTest.testTicketRetrievalWithTicketer
net.sf.arestc.core.OverallDesignTest.testTicketRetrievalWithTicketer
|
1 PASS | |
|
0.4375
|
net.sf.arestc.core.OverallDesignTest.testRepositoryCreate
net.sf.arestc.core.OverallDesignTest.testRepositoryCreate
|
1 PASS | |
|
0.4375
|
net.sf.arestc.core.OverallDesignTest.testRepositoryDelete
net.sf.arestc.core.OverallDesignTest.testRepositoryDelete
|
1 PASS | |
|
0.4375
|
net.sf.arestc.core.OverallDesignTest.testLoadResponseFromFile
net.sf.arestc.core.OverallDesignTest.testLoadResponseFromFile
|
1 PASS | |
|
0.125
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForDownloadFile
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForDownloadFile
|
1 PASS | |
|
0.125
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadMultipart
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadMultipart
|
1 PASS | |
|
0.125
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForLogin
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForLogin
|
1 PASS | |
|
0.125
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadFile
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForUploadFile
|
1 PASS | |
|
0.125
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeCreate
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeCreate
|
1 PASS | |
|
0.125
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeRetrieve
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeRetrieve
|
1 PASS | |
|
0.125
|
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeDelete
net.sf.arestc.core.commands.ChainBuilderTest.testGetDefaultChainForNodeDelete
|
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 | |
| 8 | it under the terms of the Lesser General Public License as published by | |
| 9 | the Free Software Foundation, either version 3 of the License, or | |
| 10 | (at your option) any later version. | |
| 11 | ||
| 12 | ARESTC is distributed in the hope that it will be useful, | |
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 15 | GNU General Public License for more details. | |
| 16 | ||
| 17 | You should have received a copy of the Lesser General Public License | |
| 18 | along with ARESTC. If not, see <http://www.gnu.org/licenses/>. | |
| 19 | ||
| 20 | */ | |
| 21 | package net.sf.arestc.core; | |
| 22 | ||
| 23 | import java.io.InputStream; | |
| 24 | ||
| 25 | ||
| 26 | import org.apache.commons.io.IOUtils; | |
| 27 | ||
| 28 | // TODO: Auto-generated Javadoc | |
| 29 | /** | |
| 30 | * The Class TransformResponse. | |
| 31 | * | |
| 32 | * @author georgosn | |
| 33 | */ | |
| 34 | public class TransformResponse extends BaseCommand { | |
| 35 | ||
| 36 | /** | |
| 37 | * Instantiates a new transform response. | |
| 38 | */ | |
| 39 | 0 |
public TransformResponse() { |
| 40 | 0 | super(); |
| 41 | } | |
| 42 | ||
| 43 | /** | |
| 44 | * Instantiates a new transform response. | |
| 45 | * | |
| 46 | * @param next the next | |
| 47 | */ | |
| 48 | 18 |
public TransformResponse(final ConnectorCommand next) { |
| 49 | 18 | super(next); |
| 50 | } | |
| 51 | ||
| 52 | /* | |
| 53 | * (non-Javadoc) | |
| 54 | * | |
| 55 | * @see | |
| 56 | * net.sf.arestc.core.BaseCommand#process(net.sf.arestc.core.ConnectorRequest | |
| 57 | * , net.sf.arestc.core.ConnectorContext) | |
| 58 | */ | |
| 59 | 11 |
@Override |
| 60 | public ConnectorContext process(final ConnectorRequest request, | |
| 61 | final ConnectorContext context) throws CommandException { | |
| 62 | 11 | context.setReturnedBody(request.getReturnTransformer().transform( |
| 63 | context.getReturnedBody())); | |
| 64 | 11 | if (context.isReturnStream()) { |
| 65 | 1 | transformStream(context); |
| 66 | } | |
| 67 | ||
| 68 | 11 | return super.process(request, context); |
| 69 | } | |
| 70 | ||
| 71 | /** | |
| 72 | * Transform stream. | |
| 73 | * | |
| 74 | * @param context | |
| 75 | * the context | |
| 76 | */ | |
| 77 | 1 |
private void transformStream(final ConnectorContext context) { |
| 78 | ||
| 79 | 1 | if (!InputStream.class.isAssignableFrom(context.getReturnedBody() |
| 80 | .getClass())) { | |
| 81 | 0 | context.setReturnedBody(IOUtils.toInputStream(context |
| 82 | .getReturnedBody().toString())); | |
| 83 | } | |
| 84 | ||
| 85 | } | |
| 86 | } | |
|
||||||||||||