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.lcn.internal.pchkdiscovery;
15 import static org.hamcrest.MatcherAssert.assertThat;
16 import static org.hamcrest.Matchers.is;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
23 * Test class for {@link LcnPchkDiscoveryService}.
25 * @author Fabian Wolter - Initial contribution
28 public class LcnPchkDiscoveryServiceTest {
29 private LcnPchkDiscoveryService s = new LcnPchkDiscoveryService();
30 private ServicesResponse r = s.xmlToServiceResponse(RESPONSE);
31 private static final String RESPONSE = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?><ServicesResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"servicesresponse.xsd\"><Version major=\"1\" minor=\"0\" /><Server requestId=\"1548\" machineId=\"b8:27:eb:fe:a4:bb\" machineName=\"raspberrypi\" osShort=\"Unix/Linux\" osLong=\"Unix/Linux\">LCN-PCHK 3.2.2 running on Unix/Linux</Server><Services /><ExtServices><ExtService name=\"LcnPchkBus\" major=\"1\" minor=\"0\" prot=\"TCP\" localPort=\"4114\">PCHK 3.2.2 bus</ExtService></ExtServices></ServicesResponse>";
35 s = new LcnPchkDiscoveryService();
36 r = s.xmlToServiceResponse(RESPONSE);
40 public void testXmlMachineId() {
41 assertThat(r.getServer().getMachineId(), is("b8:27:eb:fe:a4:bb"));
45 public void testXmlMachineName() {
46 assertThat(r.getServer().getMachineName(), is("raspberrypi"));
50 public void testXmlServerContent() {
51 assertThat(r.getServer().getContent(), is("LCN-PCHK 3.2.2 running on Unix/Linux"));
55 public void testXmlPort() {
56 assertThat(r.getExtServices().getExtService().getLocalPort(), is(4114));