Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
TestDBTProvokeClientServer_i470.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.BTMode;
28import org.direct_bt.BTSecurityLevel;
29import org.direct_bt.DiscoveryPolicy;
30import org.jau.net.EUI48;
31import org.junit.FixMethodOrder;
32import org.junit.Test;
33import org.junit.runners.MethodSorters;
34
35/**
36 * Testing w/o client filtering processing device and hence not blocking deviceFound.
37 *
38 * In other words, relying on BTAdapter to filter out:
39 * - already discovered devices
40 * - already connected devices
41 *
42 * Further, the server will issue a disconnect once only 300 ms after 1st MTU exchange,
43 * disrupting the client's getGATTServices().
44 */
45@FixMethodOrder(MethodSorters.NAME_ASCENDING)
47
48 @Test(timeout = 10000)
49 public final void test_i470_a()
50 {
51 final boolean serverSC = true;
52 final String suffix = "i470_a";
53 final int protocolSessionCount = 10;
54 final int max_connections_per_session = 200;
55 final boolean expSuccess = false;
56 final boolean server_client_order = true;
57 final ExpectedPairing serverExpPairing = ExpectedPairing.DONT_CARE;
58 final ExpectedPairing clientExpPairing = ExpectedPairing.DONT_CARE;
59 final boolean client_do_disconnect_randomly = true;
60 final boolean server_do_disconnect_randomly = false;
61
62 final DBTServerTest server = new DBTServer01("S-"+suffix, EUI48.ALL_DEVICE, BTMode.DUAL, serverSC, BTSecurityLevel.ENC_ONLY, server_do_disconnect_randomly);
63 final DBTClientTest client = new DBTClient01("C-"+suffix, EUI48.ALL_DEVICE, BTMode.DUAL, client_do_disconnect_randomly);
64
65 server.setProtocolSessionsLeft( protocolSessionCount );
66
67 client.setProtocolSessionsLeft( protocolSessionCount );
68 client.setDisconnectDeviceed( true ); // default, auto-disconnect after work is done
69 client.setRemoveDevice( false ); // default, test side-effects
71
72 test8x_fullCycle(10000, suffix,
73 max_connections_per_session, expSuccess, server_client_order,
74 server,
75 BTSecurityLevel.ENC_ONLY, serverExpPairing, client,
76 BTSecurityLevel.ENC_ONLY, clientExpPairing);
77 }
78
79 @Test(timeout = 10000)
80 public final void test_i470_b()
81 {
82 final boolean serverSC = true;
83 final String suffix = "i470_b";
84 final int protocolSessionCount = 10;
85 final int max_connections_per_session = 200;
86 final boolean expSuccess = false;
87 final boolean server_client_order = true;
88 final ExpectedPairing serverExpPairing = ExpectedPairing.DONT_CARE;
89 final ExpectedPairing clientExpPairing = ExpectedPairing.DONT_CARE;
90 final boolean client_do_disconnect_randomly = false;
91 final boolean server_do_disconnect_randomly = true;
92
93 final DBTServerTest server = new DBTServer01("S-"+suffix, EUI48.ALL_DEVICE, BTMode.DUAL, serverSC, BTSecurityLevel.ENC_ONLY, server_do_disconnect_randomly);
94 final DBTClientTest client = new DBTClient01("C-"+suffix, EUI48.ALL_DEVICE, BTMode.DUAL, client_do_disconnect_randomly);
95
96 server.setProtocolSessionsLeft( protocolSessionCount );
97
98 client.setProtocolSessionsLeft( protocolSessionCount );
99 client.setDisconnectDeviceed( true ); // default, auto-disconnect after work is done
100 client.setRemoveDevice( false ); // default, test side-effects
102
103 test8x_fullCycle(10000, suffix,
104 max_connections_per_session, expSuccess, server_client_order,
105 server,
106 BTSecurityLevel.ENC_ONLY, serverExpPairing, client,
107 BTSecurityLevel.ENC_ONLY, clientExpPairing);
108 }
109
110 public static void main(final String args[]) {
111 org.junit.runner.JUnitCore.main(TestDBTProvokeClientServer_i470.class.getName());
112 }
113}
This central BTRole::Master participant works with DBTServer00.
Testing a full Bluetooth server and client lifecycle of operations, requiring two BT adapter:
This peripheral BTRole::Slave test participant works with DBTClient00.
Testing w/o client filtering processing device and hence not blocking deviceFound.
Bluetooth adapter operating mode.
Definition: BTMode.java:34
DUAL
Dual Bluetooth mode, i.e.
Definition: BTMode.java:38
Bluetooth Security Level.
ENC_ONLY
Encryption and no authentication (no MITM).
Discovery policy defines the BTAdapter discovery mode after connecting a remote BTDevice:
PAUSE_CONNECTED_UNTIL_DISCONNECTED
Pause discovery until all connected BTDevice become disconnected, effectively until AdapterStatusList...
void setDisconnectDeviceed(final boolean v)
Set disconnect after processing.
void setRemoveDevice(final boolean v)
Set remove device when disconnecting.
void setDiscoveryPolicy(final DiscoveryPolicy v)
Set DiscoveryPolicy.
void setProtocolSessionsLeft(final int v)