2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.vdr.internal;
15 import static org.junit.jupiter.api.Assertions.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.vdr.internal.svdrp.SVDRPException;
20 import org.openhab.binding.vdr.internal.svdrp.SVDRPParseResponseException;
21 import org.openhab.binding.vdr.internal.svdrp.SVDRPVolume;
22 import org.openhab.binding.vdr.internal.svdrp.SVDRPWelcome;
25 * Specific unit tests to check if {@link SVDRPWelcome} parses SVDRP responses correctly
27 * @author Matthias Klocke - Initial contribution
31 public class SVDRPWelcomeTest {
32 private final String welcomeResponseOk = "srv SVDRP VideoDiskRecorder 2.5.1; Mon Jan 11 19:46:54 2021; UTF-8";
33 private final String welcomeResponseParseError1 = "srv SVDRP VideoDiskRecorder 2.5.1; Mon Jan 11 19:46:54 2021 UTF-8";
34 private final String welcomeResponseParseError2 = "srv SVDRP VideoDiskRecorder2.5.1; Mon Jan 11 19:46:54 2021 UTF-8";
37 public void testParseWelcomeData() throws SVDRPException {
38 SVDRPWelcome welcome = SVDRPWelcome.parse(welcomeResponseOk);
39 assertEquals("UTF-8", welcome.getCharset());
40 assertEquals("2.5.1", welcome.getVersion());
41 assertEquals("Mon Jan 11 19:46:54 2021", welcome.getDateAndTime());
45 public void testParseExceptionVolumeData() {
46 assertThrows(SVDRPParseResponseException.class, () -> {
47 SVDRPVolume.parse(welcomeResponseParseError1);
49 assertThrows(SVDRPParseResponseException.class, () -> {
50 SVDRPVolume.parse(welcomeResponseParseError2);