svn-gvsig-desktop / branches / v10 / extensions / extPublish / src-test / org / gvsig / publish / serversmodel / RemoteResourceTest.java @ 22616
History | View | Annotate | Download (5.85 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004-2006 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Iba?ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.publish.serversmodel; |
42 |
|
43 |
import java.net.MalformedURLException; |
44 |
import java.net.URL; |
45 |
|
46 |
import junit.framework.TestCase; |
47 |
|
48 |
import org.gvsig.publish.PublishRegister; |
49 |
import org.gvsig.publish.exceptions.InvalidRemoteResourceException; |
50 |
import org.gvsig.publish.exceptions.PublishException; |
51 |
import org.gvsig.publish.infoproject.ILayerInfo; |
52 |
import org.gvsig.publish.infoproject.IProjectInfo; |
53 |
import org.gvsig.publish.infoproject.IViewInfo; |
54 |
import org.gvsig.publish.infoproject.ProjectInfoFactory; |
55 |
import org.gvsig.publish.util.LocalResourcesTestUtilities; |
56 |
|
57 |
import com.iver.utiles.XMLEntity; |
58 |
|
59 |
public abstract class RemoteResourceTest extends TestCase { |
60 |
protected Server server = null; |
61 |
protected Service service = null; |
62 |
protected RemoteResource parent = null; |
63 |
protected RemoteResource child = null; |
64 |
protected LocalResourcesTestUtilities util = null; |
65 |
|
66 |
public abstract String getRemoteResourceRegisterTag(); |
67 |
public abstract Class getRemoteResourceClass(); |
68 |
public abstract String getServiceRegisterTag(); |
69 |
public abstract Class getServiceClass(); |
70 |
public abstract String getServerRegisterTag(); |
71 |
public abstract Class getServerClass(); |
72 |
|
73 |
public RemoteResourceTest() throws InvalidRemoteResourceException { |
74 |
super();
|
75 |
//create utilities
|
76 |
try {
|
77 |
util = new LocalResourcesTestUtilities();
|
78 |
} catch (Exception e) { |
79 |
// TODO Auto-generated catch block
|
80 |
e.printStackTrace(); |
81 |
} |
82 |
//register server
|
83 |
PublishRegister.register().addServer(getServerRegisterTag(), getServerClass()); |
84 |
server = PublishRegister.register().getServer(getServerRegisterTag()); |
85 |
try {
|
86 |
server.setServerURL(new URL("http://server")); |
87 |
} catch (MalformedURLException e) { |
88 |
fail("I can't set the server URL");
|
89 |
} |
90 |
|
91 |
assertNotNull(server); |
92 |
//register service
|
93 |
PublishRegister.register().addService(getServerRegisterTag(),getServiceRegisterTag(), getServiceClass()); |
94 |
service = PublishRegister.register().getService(server, getServiceRegisterTag()); |
95 |
assertNotNull(service); |
96 |
server.addService(service); |
97 |
//register remote resource
|
98 |
PublishRegister.register().addRemoteResource(getServerRegisterTag(), getServiceRegisterTag(), getRemoteResourceRegisterTag(), getRemoteResourceClass()); |
99 |
parent = PublishRegister.register().getRemoteResource(service, getRemoteResourceRegisterTag()); |
100 |
assertNotNull(parent); |
101 |
child = PublishRegister.register().getRemoteResource(service, getRemoteResourceRegisterTag()); |
102 |
assertNotNull(child); |
103 |
|
104 |
//init parent
|
105 |
IProjectInfo proj = ProjectInfoFactory.getProjectInfo(util.getProject_shape()); |
106 |
IViewInfo[] views = proj.getViewsInfo();
|
107 |
ILayerInfo[] layers = views[0].getLayers(); |
108 |
parent.setLayerInfo(layers[0]);
|
109 |
//I need to set the layerinfo before add the remote resource
|
110 |
service.addRemoteResource(parent); |
111 |
|
112 |
//init child
|
113 |
proj = ProjectInfoFactory.getProjectInfo(util.getProject_shape()); |
114 |
views = proj.getViewsInfo(); |
115 |
layers = views[0].getLayers();
|
116 |
child.setLayerInfo(layers[1]);
|
117 |
} |
118 |
|
119 |
// public abstract RemoteResource getRemoteResource();
|
120 |
// public abstract RemoteResource getChild();
|
121 |
|
122 |
// public void testRemoteResource() {
|
123 |
// fail("Not yet implemented");
|
124 |
// }
|
125 |
|
126 |
public void testGetId() { |
127 |
assertNotNull(parent.getId()); |
128 |
} |
129 |
|
130 |
public void testGetRegisterTag() { |
131 |
assertNotNull(parent.getRegisterTag()); |
132 |
} |
133 |
|
134 |
public void testGetService() { |
135 |
assertNotNull(parent.getService()); |
136 |
} |
137 |
|
138 |
public void testGetLayerInfo() { |
139 |
assertNotNull(parent.getLayerInfo()); |
140 |
} |
141 |
|
142 |
public void testGetChildsCount() { |
143 |
int c = parent.getChildsCount();
|
144 |
parent.addChild(child); |
145 |
assertEquals(c+1, parent.getChildsCount());
|
146 |
} |
147 |
|
148 |
public void testGetChild() { |
149 |
int c = parent.getChildsCount();
|
150 |
parent.addChild(child); |
151 |
assertEquals(child, parent.getChild(c)); |
152 |
} |
153 |
|
154 |
public void testAddChild() { |
155 |
int c = parent.getChildsCount();
|
156 |
parent.addChild(child); |
157 |
assertEquals(c+1, parent.getChildsCount());
|
158 |
} |
159 |
|
160 |
public void testRemove() { |
161 |
RemoteResource r = parent; |
162 |
Service s = parent.getService(); |
163 |
int c = s.getRemoteResourcesCount();
|
164 |
r.remove(); |
165 |
assertEquals(c-1, s.getRemoteResourcesCount());
|
166 |
} |
167 |
|
168 |
public void testPublish() throws PublishException { |
169 |
parent.publish(); |
170 |
} |
171 |
|
172 |
public void testSetLayerInfo() throws Exception { |
173 |
LocalResourcesTestUtilities util = new LocalResourcesTestUtilities();
|
174 |
IProjectInfo proj = ProjectInfoFactory.getProjectInfo(util.getProject_shape()); |
175 |
IViewInfo[] views = proj.getViewsInfo();
|
176 |
ILayerInfo[] layers = views[0].getLayers(); |
177 |
parent.setLayerInfo(layers[0]);
|
178 |
assertEquals(layers[0].getName(),parent.getLayerInfo().getName());
|
179 |
} |
180 |
|
181 |
public void testGetXMLEntity() { |
182 |
assertNotNull(parent.getXMLEntity()); |
183 |
} |
184 |
|
185 |
public void testSetXMLEntity() { |
186 |
XMLEntity xml = parent.getXMLEntity(); |
187 |
parent.setXMLEntity(xml); |
188 |
//assertEquals(xml, parent.getXMLEntity());
|
189 |
} |
190 |
|
191 |
} |