View Javadoc

1   /*
2    *  soapUI, copyright (C) 2006 eviware.com 
3    *
4    *  soapUI is free software; you can redistribute it and/or modify it under the 
5    *  terms of the GNU Lesser General Public License as published by the Free Software Foundation; 
6    *  either version 2.1 of the License, or (at your option) any later version.
7    *
8    *  soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 
9    *  even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
10   *  See the GNU Lesser General Public License for more details at gnu.org.
11   */
12  
13  package com.eviware.soapui.impl.wsdl.support;
14  
15  import java.io.File;
16  import java.io.IOException;
17  
18  import com.eviware.soapui.config.AttachmentConfig;
19  import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
20  
21  /***
22   * Attachments cached locally for each request
23   * 
24   * @author Ole.Matzura
25   */
26  
27  public class MockFileAttachment extends FileAttachment
28  {
29  	private final WsdlMockResponse mockResponse;
30  
31  	public MockFileAttachment( AttachmentConfig config, WsdlMockResponse mockResponse )
32  	{
33  		super( config );
34  		this.mockResponse = mockResponse;
35  	}
36  
37  	public MockFileAttachment( File file, boolean cache, WsdlMockResponse response ) throws IOException
38  	{
39  		super(file, cache, response.getConfig().addNewAttachment());
40  		mockResponse = response;
41  	}
42  
43  	@Override
44  	public AttachmentType getAttachmentType()
45  	{
46  		if( getPart() == null || mockResponse.getAttachmentPart( getPart() ) == null )
47  			return AttachmentType.UNKNOWN;
48  		else
49  			return mockResponse.getAttachmentPart( getPart() ).getAttachmentType();
50  	}
51  }