{"id":16119325,"url":"https://github.com/cescoffier/loom-unit","last_synced_at":"2025-10-11T03:46:41.074Z","repository":{"id":138394641,"uuid":"546025696","full_name":"cescoffier/loom-unit","owner":"cescoffier","description":"A Junit5 Extension to check if virtual threads are pinning the carrier thread","archived":false,"fork":false,"pushed_at":"2024-03-13T12:13:33.000Z","size":40,"stargazers_count":38,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-28T03:22:27.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cescoffier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-05T11:49:44.000Z","updated_at":"2024-12-14T23:40:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"7140a054-c337-41ef-8169-cbac14545b6d","html_url":"https://github.com/cescoffier/loom-unit","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"9c15756063879751e10b9b22c435a64decc0cfe2"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cescoffier%2Floom-unit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cescoffier%2Floom-unit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cescoffier%2Floom-unit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cescoffier%2Floom-unit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cescoffier","download_url":"https://codeload.github.com/cescoffier/loom-unit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243878439,"owners_count":20362432,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T20:53:53.884Z","updated_at":"2025-10-11T03:46:36.038Z","avatar_url":"https://github.com/cescoffier.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":[],"readme":"# Loom-Unit\n\nA Junit 5 extension capturing weather a virtual threads _pins_ the carrier thread during the execution of the test.\n\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/cescoffier/loom-unit/Build?style=for-the-badge) ![Maven Central](https://img.shields.io/maven-central/v/me.escoffier.loom/loom-unit?style=for-the-badge)\n\n## Usage\n\n1. Add the following dependency to your project:\n\n```xml\n\u003cdependency\u003e    \n  \u003cgroupId\u003eme.escoffier.loom\u003c/groupId\u003e\n  \u003cartifactId\u003eloom-unit\u003c/artifactId\u003e\n  \u003cversion\u003eVERSION\u003c/version\u003e\n  \u003cscope\u003etest\u003c/scope\u003e  \n\u003c/dependency\u003e\n```\n\n**IMPORTANT**: You need to use Java 19+. \n\n2. Extends your test class with the `me.escoffier.loom.loomunit.LoomUnitExtension` extension:\n\n```java\n@ExtendWith(LoomUnitExtension.class) \npublic class LoomUnitExampleTest {\n    // ...\n}\n```\n\n3. Use the `me.escoffier.loom.loomunit.ShouldNotPin` or `me.escoffier.loom.loomunit.ShouldPin` annotation on your test.\n\n## Complete example\n\n```java\npackage me.escoffier.loom.loomunit.snippets;\nimport me.escoffier.loom.loomunit.LoomUnitExtension;\nimport me.escoffier.loom.loomunit.ThreadPinnedEvents;\nimport me.escoffier.loom.loomunit.ShouldNotPin;\nimport me.escoffier.loom.loomunit.ShouldPin;\nimport org.junit.jupiter.api.Assertions;\nimport org.junit.jupiter.api.Test;\nimport org.junit.jupiter.api.extension.ExtendWith;\n\nimport static org.awaitility.Awaitility.await;\n\n\n@ExtendWith(LoomUnitExtension.class) // Use the extension\npublic class LoomUnitExampleTest {\n\n    CodeUnderTest codeUnderTest = new CodeUnderTest();\n\n    @Test\n    @ShouldNotPin\n    public void testThatShouldNotPin() {\n        // ...\n    }\n\n    @Test\n    @ShouldPin(atMost = 1)\n    public void testThatShouldPinAtMostOnce() {\n        codeUnderTest.pin();\n    }\n\n    @Test\n    public void testThatShouldNotPin(ThreadPinnedEvents events) { // Inject an object to check the pin events\n        Assertions.assertTrue(events.getEvents().isEmpty());\n        codeUnderTest.pin();\n        await().until(() -\u003e events.getEvents().size() \u003e 0);\n        Assertions.assertEquals(events.getEvents().size(), 1);\n    }\n\n}\n```\n\nYou can also use the `@ShouldPin` and `@ShouldNotPin` annotations on the class:\n\n```java\n@ExtendWith(LoomUnitExtension.class) // Use the extension\n@ShouldNotPin // You can use @ShouldNotPin or @ShouldPin on the class itself, it's applied to each method.\npublic class LoomUnitExampleOnClassTest {\n\n\tCodeUnderTest codeUnderTest = new CodeUnderTest();\n\n\t@Test\n\tpublic void testThatShouldNotPin() {\n\t\t// ...\n\t}\n\n\t@Test\n\t@ShouldPin(atMost = 1) // Method annotation overrides the class annotation\n\tpublic void testThatShouldPinAtMostOnce() {\n\t\tcodeUnderTest.pin();\n\t}\n\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcescoffier%2Floom-unit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcescoffier%2Floom-unit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcescoffier%2Floom-unit/lists"}