Commit 75c19890 authored by Noel Alonso's avatar Noel Alonso
Browse files

Añade excepciones propias

parent 873ff490
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -37,7 +37,8 @@ import es.redmic.atlascommands.mapper.ContactMapper;
import es.redmic.atlascommands.mapper.LayerWMSMapper;
import es.redmic.atlaslib.dto.layer.ContactDTO;
import es.redmic.atlaslib.dto.layerwms.LayerWMSDTO;
import es.redmic.exception.custom.ResourceNotFoundException;
import es.redmic.exception.custom.URLException;
import es.redmic.exception.utils.ExternalResourceException;

public abstract class Capabilities {

@@ -49,8 +50,7 @@ public abstract class Capabilities {
			serverURL = new URL(url.split("\\?")[0]);
		} catch (MalformedURLException e) {
			e.printStackTrace();
			// TODO: excepción propia
			throw new ResourceNotFoundException();
			throw new URLException(e, url);
		}

		WebMapServer wms;
@@ -59,8 +59,7 @@ public abstract class Capabilities {
			wms = new WebMapServer(serverURL);
		} catch (ServiceException | IOException e) {
			e.printStackTrace();
			// TODO: excepción propia
			throw new ResourceNotFoundException();
			throw new ExternalResourceException(e, url);
		}

		return getLayers(url, wms.getCapabilities());
+4 −5
Original line number Diff line number Diff line
@@ -41,7 +41,8 @@ import es.redmic.atlascommands.mapper.ContactMapper;
import es.redmic.atlascommands.mapper.LayerWMSMapper;
import es.redmic.atlascommands.utils.Capabilities;
import es.redmic.atlaslib.dto.layerwms.LayerWMSDTO;
import es.redmic.exception.custom.ResourceNotFoundException;
import es.redmic.exception.custom.URLException;
import es.redmic.exception.utils.ExternalResourceException;
import es.redmic.jts4jackson.module.JTSModule;
import es.redmic.testutils.utils.JsonToBeanTestUtil;

@@ -67,15 +68,13 @@ public class CapabilitiesTest {
				URL_CAPABILITIES + "?request=GetLegendGraphic&version=1.0.0&format=image/png&layer=topp:states");
	}

	// TODO: cambiar excepción
	@Test(expected = ResourceNotFoundException.class)
	@Test(expected = URLException.class)
	public void getCapabilities_ThrowException_IfUrlIsMalformed() throws IOException, ServiceException {

		Capabilities.getCapabilities("wms.xml");
	}

	// TODO: cambiar excepción
	@Test(expected = ResourceNotFoundException.class)
	@Test(expected = ExternalResourceException.class)
	public void getCapabilities_ThrowException_IfServiceIsInaccessible() throws IOException, ServiceException {

		Capabilities.getCapabilities(new File("wms.xml").toURI().toString());