]> git.basschouten.com Git - openhab-addons.git/blob
3871d8ed03284f8ac39cc9d4f8c4dc11d2300462
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.fmiweather;
14
15 import java.io.IOException;
16 import java.nio.file.Path;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.Test;
20 import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
21 import org.xml.sax.SAXParseException;
22
23 /**
24  * Test cases for AbstractWeatherHandler. The tests provide mocks for supporting entities using Mockito.
25  *
26  * @author Sami Salonen - Initial contribution
27  */
28 @NonNullByDefault
29 public class FMIResponseParsingInvalidOrUnexpectedXmlTest extends AbstractFMIResponseParsingTest {
30
31     private Path observations1 = getTestResource("observations_single_place.xml");
32
33     @Test(expected = SAXParseException.class)
34     public void testInvalidXml() throws IOException, Throwable {
35         parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<<"));
36     }
37
38     @Test(expected = FMIResponseException.class)
39     public void testUnexpectedXml() throws IOException, Throwable {
40         parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<foo>4</foo>"));
41     }
42 }