Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
TestDBTClientServer22_SC0.java
Go to the documentation of this file.
1/**
2 * Author: Sven Gothel <sgothel@jausoft.com>
3 * Copyright (c) 2022 Gothel Software e.K.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25package trial.org.direct_bt;
26
27import org.direct_bt.BTSecurityLevel;
28import org.junit.FixMethodOrder;
29import org.junit.Test;
30import org.junit.runners.MethodSorters;
31
32/**
33 * Testing a full Bluetooth server and client lifecycle of operations, requiring two BT adapter:
34 * - operating in legacy non SC mode
35 * - start server advertising
36 * - start client discovery and connect to server when discovered
37 * - client/server processing of connection when ready
38 * - client disconnect
39 * - server stop advertising
40 * - security-level: NONE, ENC_ONLY freshly-paired and ENC_ONLY pre-paired
41 * - reuse server-adapter for client-mode discovery (just toggle on/off)
42 */
43@FixMethodOrder(MethodSorters.NAME_ASCENDING)
45 static final boolean serverSC = false;
46
47 @Test(timeout = 40000)
48 public final void test11_FullCycle_EncOnlyNo1() {
49 final ExpectedPairing serverExpPairing = ExpectedPairing.NEW_PAIRING;
50 final ExpectedPairing clientExpPairing = ExpectedPairing.NEW_PAIRING;
51 test8x_fullCycle(40000, "22", 1, false /* server_client_order */, serverSC,
52 BTSecurityLevel.ENC_ONLY, serverExpPairing, BTSecurityLevel.ENC_ONLY, clientExpPairing);
53 }
54
55 @Test(timeout = 40000)
56 public final void test21_FullCycle_EncOnlyNo2() {
57 final ExpectedPairing serverExpPairing = ExpectedPairing.PREPAIRED;
58 final ExpectedPairing clientExpPairing = ExpectedPairing.PREPAIRED;
59 test8x_fullCycle(40000, "23", 2, false /* server_client_order */, serverSC,
60 BTSecurityLevel.ENC_ONLY, serverExpPairing, BTSecurityLevel.ENC_ONLY, clientExpPairing);
61 }
62
63 public static void main(final String args[]) {
64 org.junit.runner.JUnitCore.main(TestDBTClientServer22_SC0.class.getName());
65 }
66}
Testing a full Bluetooth server and client lifecycle of operations, requiring two BT adapter:
Testing a full Bluetooth server and client lifecycle of operations, requiring two BT adapter:
Bluetooth Security Level.
ENC_ONLY
Encryption and no authentication (no MITM).