01: /*
02: * soapUI, copyright (C) 2004-2007 eviware.com
03: *
04: * soapUI is free software; you can redistribute it and/or modify it under the
05: * terms of version 2.1 of the GNU Lesser General Public License as published by
06: * the Free Software Foundation.
07: *
08: * soapUI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
09: * 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.panels.mockoperation;
14:
15: import java.beans.PropertyChangeEvent;
16: import java.beans.PropertyChangeListener;
17:
18: import org.apache.xmlbeans.SchemaTypeSystem;
19: import org.apache.xmlbeans.XmlBeans;
20:
21: import com.eviware.soapui.SoapUI;
22: import com.eviware.soapui.impl.wsdl.WsdlInterface;
23: import com.eviware.soapui.impl.wsdl.WsdlOperation;
24: import com.eviware.soapui.impl.wsdl.mock.WsdlMockResponse;
25: import com.eviware.soapui.impl.wsdl.panels.request.components.editor.support.AbstractXmlDocument;
26: import com.eviware.soapui.impl.wsdl.support.wsdl.WsdlContext;
27:
28: /**
29: * XmlDocument for a WsdlMockResponse
30: *
31: * @author ole.matzura
32: */
33:
34: public class MockResponseXmlDocument extends AbstractXmlDocument
35: implements PropertyChangeListener {
36: private final WsdlMockResponse mockResponse;
37:
38: public MockResponseXmlDocument(WsdlMockResponse response) {
39: this .mockResponse = response;
40:
41: mockResponse.addPropertyChangeListener(
42: WsdlMockResponse.RESPONSECONTENT_PROPERTY, this );
43: }
44:
45: public SchemaTypeSystem getTypeSystem() {
46: try {
47: WsdlOperation operation = mockResponse.getMockOperation()
48: .getOperation();
49: if (operation != null) {
50: WsdlInterface iface = operation.getInterface();
51: WsdlContext wsdlContext = iface.getWsdlContext();
52: return wsdlContext.getSchemaTypeSystem();
53: }
54: } catch (Exception e1) {
55: SoapUI.logError(e1);
56: }
57:
58: return XmlBeans.getBuiltinTypeSystem();
59: }
60:
61: public String getXml() {
62: return mockResponse.getResponseContent();
63: }
64:
65: public void setXml(String xml) {
66: mockResponse.setResponseContent(xml);
67: }
68:
69: public void propertyChange(PropertyChangeEvent arg0) {
70: fireXmlChanged((String) arg0.getOldValue(), (String) arg0
71: .getNewValue());
72: }
73:
74: @Override
75: public void release() {
76: mockResponse.removePropertyChangeListener(
77: WsdlMockResponse.RESPONSECONTENT_PROPERTY, this);
78: }
79: }
|