]> git.basschouten.com Git - openhab-addons.git/blob
24c4b97f147ebb91d59d189663974edc1d15dc66
[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.livisismarthome.internal.client;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19
20 /**
21  * @author Sven Strohschein - Initial contribution
22  */
23 @NonNullByDefault
24 public class URLCreatorTest {
25
26     @Test
27     public void testCreateEventsURL() {
28         String url = URLCreator.createEventsURL("localhost", "token+123/456", false);
29         // The token should be URL encoded
30         assertEquals("ws://localhost:9090/events?token=token%2B123%2F456", url);
31     }
32
33     @Test
34     public void testCreateEventsURLClassicController() {
35         String url = URLCreator.createEventsURL("localhost", "token123", true);
36         assertEquals("ws://localhost:8080/events?token=token123", url);
37     }
38
39     @Test
40     public void testCreateEventsURLGen2Controller() {
41         String url = URLCreator.createEventsURL("localhost", "token123", false);
42         assertEquals("ws://localhost:9090/events?token=token123", url);
43     }
44 }