]> git.basschouten.com Git - openhab-addons.git/blob
b1c659ebf619392d7bb9325a205082c2e7d61a1e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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 static org.junit.jupiter.api.Assertions.assertThrows;
16
17 import java.nio.file.Path;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
22 import org.xml.sax.SAXParseException;
23
24 /**
25  * Test cases for AbstractWeatherHandler. The tests provide mocks for supporting entities using Mockito.
26  *
27  * @author Sami Salonen - Initial contribution
28  */
29 @NonNullByDefault
30 public class FMIResponseParsingInvalidOrUnexpectedXmlTest extends AbstractFMIResponseParsingTest {
31
32     private Path observations1 = getTestResource("observations_single_place.xml");
33
34     @Test
35     public void testInvalidXml() {
36         assertThrows(SAXParseException.class,
37                 () -> parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<<")));
38     }
39
40     @Test
41     public void testUnexpectedXml() {
42         assertThrows(FMIResponseException.class,
43                 () -> parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<foo>4</foo>")));
44     }
45 }