# Overview

Test suite for MicroEJ's Serial Communication API (v3.0.0). This test suite validates the Java library and the port of
its abstraction layer.

# Usage

Add the following line to your `module.ivy`:

    <dependency org="com.microej.pack.serial" name="serial-testsuite" rev="1.0.0"/>

## Running the Tests

Tests are JUnit-based and require two serial ports connected together (e.g. via a crossed cable or virtual ports). Bytes written to the TX port must arrive on the RX port.

### Required Properties

| Property | Description |
|----------|-------------|
| `serial.port.rx` | RX port name |
| `serial.port.tx` | TX port name |

### Optional Properties

| Property | Default | Description |
|----------|---------|-------------|
| `serial.port.baudrate` | `115200` | Baud rate |
| `serial.port.bitsperchar` | `8` (DATABITS_8) | Data bits per character |
| `serial.port.stopbits` | `1` (STOPBITS_1) | Stop bits |
| `serial.port.parity` | `0` (PARITY_NONE) | Parity mode |
| `serial.tests.buffer.size` | `4096` | Buffer size for large transfer tests |

## Test Classes

| Class | Description |
|-------|-------------|
| `TestConfigurationValidation` | Verifies that the constructor and `configure()` reject invalid parameters with `IllegalArgumentException`. |
| `TestConfiguration` | Verifies that the constructor and `configure()` accept all valid parameter combinations. Hardware that does not support a given combination may throw a `RuntimeException`. |
| `TestInvalidPort` | Verifies that appropriate exceptions are thrown when opening an invalid or unavailable port. |
| `TestConnectionState` | Verifies the observable state of a connection: `isClosed()` tracking, stream lifecycle (singleton guarantee, close propagation), and I/O behaviour on a closed connection. |
| `TestConnectionLifecycle` | Verifies connection resource management: open/close cycles, port reuse, and concurrent access patterns. |
| `TestDataTransfer` | Verifies end-to-end data transfer over two connected ports: correctness, ordering, bulk and streaming modes, blocking semantics, and `available()`. Requires both `serial.port.rx` and `serial.port.tx`. |

# Requirements

This library requires the following Foundation Libraries:

    EDC-1.3, SERIAL-3.0

# Dependencies

_All dependencies are retrieved transitively by MicroEJ Module Manager_.

# Source

N/A.

# Restrictions

None.
---
_Copyright 2022-2026 MicroEJ Corp. All rights reserved._  
_Use of this source code is governed by a BSD-style license that can be found with this software._  