-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #205 from ZettaScaleLabs/fix/scouting
fix(scout): error when closing scout + API rework
- Loading branch information
Showing
5 changed files
with
80 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// Copyright (c) 2023 ZettaScale Technology | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Eclipse Public License 2.0 which is available at | ||
// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 | ||
// which is available at https://www.apache.org/licenses/LICENSE-2.0. | ||
// | ||
// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 | ||
// | ||
// Contributors: | ||
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
package io.zenoh | ||
|
||
import io.zenoh.scouting.Hello | ||
import kotlinx.coroutines.channels.Channel | ||
import kotlin.test.Test | ||
import kotlin.test.assertNotNull | ||
|
||
class ScoutTest { | ||
|
||
@Test | ||
fun `scouting is declared and undeclared properly test`() { | ||
val scout = Zenoh.scout(Channel()).getOrThrow() | ||
scout.close() | ||
} | ||
|
||
@Test | ||
fun `scouting detects session test`() { | ||
|
||
val config = Config.fromJson(""" | ||
{ | ||
"mode": "peer", | ||
"connect": { | ||
"endpoints": ["tcp/localhost:7450"] | ||
}, | ||
} | ||
""".trimIndent()).getOrThrow() | ||
|
||
val session = Session.open(config).getOrThrow() | ||
|
||
var hello: Hello? = null | ||
Zenoh.scout(callback = { | ||
hello = it | ||
}).getOrThrow() | ||
|
||
Thread.sleep(1000) | ||
|
||
assertNotNull(hello) | ||
session.close() | ||
} | ||
} |