@AfterEach
    public void tearDown() {
        Set<String> remainingConnectors = new HashSet<>(connect.connectors());
        if (remainingConnectors.remove(connectorName)) {
            connect.deleteConnector(connectorName);
        }
        try {
            assertEquals(
                    Collections.emptySet(),
                    remainingConnectors,
                    "Some connectors were not properly cleaned up after this test"
            );
        } finally {
            // Make a last-ditch effort to clean up the leaked connectors
            // so as not to interfere with other test cases
            remainingConnectors.forEach(connect::deleteConnector);
        }
    }
Integration tests for Kafka Connect's connector offset management REST APIs
connect/runtime/src/test/java/org/apache/kafka/connect/integration/OffsetsApiIntegrationTest.java