CodeSampleX

샘플

org.robolectric/robolectric 4.13: org.robolectric.junit.rules.BackgroundTestRule

검증된 샘플 — maven org.robolectric/robolectric 4.13: org.robolectric.junit.rules.BackgroundTestRule. java 21 · linux 2023/x64 · docker에서 contract를 실행해 통과했습니다.

sha256:2f105e289aa0b12f19d289a6d8e67497ca494b0cd312eca193ce0829f7915021

이 네트워크가 제공하는 것은 하나입니다. 빌드되는 샘플. 샌드박스에서 돌리고 서명된 영수증을 보관합니다. 등급을 매기지 않고 무엇도 보증하지 않습니다 — 같은 코드가 당신 환경에서 빌드되는지는 측정한 적이 없습니다. 통과한 계약 영수증을 낸 서로 다른 서명 키의 수입니다. 하나면 작성자 혼자이고, 둘 이상이면 다른 사람도 빌드했다는 뜻입니다. 키는 스스로 만드는 것이고 뒤에 등록된 신원이 없으므로, 세는 것은 사람이 아니라 키입니다. MIT-0

실행 증거

선언된 환경과 서명된 실행을 분리해 두었습니다. 이 샘플이 무엇을 어디서 실행했는지 그대로 볼 수 있습니다.

증거 기준
서명된 컨트랙트 통과
검증 영수증
5
빌드한 서명 키
1
선언된 환경 java 21 linux 24 · ubuntu · glibc 2.39 x64 java 21 java gradle 8

검증 실행 환경

환경 컨트랙트 단계 실행일
java 21 · linux 2023/x64 · docker ed25519:c1973797be207ac4 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · gradle-java@1gradle:8.14.3-jdk21-corretto-al2023@sha256:05cb2f8b4a77…
2026-09-09
java 8 · linux 2023/x64 · docker ed25519:c1973797be207ac4 FAIL compile:PASS · contract:FAIL · load:SKIPPED · resolve:PASS
CONTAINER_RUN · gradle-java@1gradle:8.14.3-jdk8-corretto-al2023@sha256:ec6379bf6453…
2026-09-09
java 11 · linux 2023/x64 · docker ed25519:c1973797be207ac4 SKIPPED compile:SKIPPED · contract:SKIPPED · load:SKIPPED · resolve:FAIL
CONTAINER_RUN · gradle-java@1gradle:8.14.3-jdk11-corretto-al2023@sha256:93d9f84a044f…
2026-09-09
java 17 · linux 2023/x64 · docker ed25519:c1973797be207ac4 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · gradle-java@1gradle:8.14.3-jdk17-corretto-al2023@sha256:9a40f91169b9…
2026-09-09
java 25 · linux 2023/x64 · docker ed25519:c1973797be207ac4 PASS compile:PASS · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · gradle-java@1gradle:9.7.0-jdk25-corretto-al2023@sha256:bb35f0164972…
2026-09-09

케이스

HOW
목표
verify org.robolectric.junit.rules.BackgroundTestRule in pkg:maven/org.robolectric/robolectric@4.13
패키지
심벌
  • org.robolectric.junit.rules.BackgroundTestRule
환경
java 21
생성일
2026-09-09T05:57:00Z

컨트랙트

  1. org.robolectric.junit.rules.BackgroundTestRule class file resource is available on classpath with valid Java bytecode magic
  2. BackgroundTestRule bytecode defines constructor and apply method signature for JUnit test execution
  3. BackgroundTestRule bytecode references org.junit.rules.TestRule interface
  4. BackgroundTestRule inner annotation BackgroundTest class file resource is available on classpath with valid Java bytecode magic

파일

  • PROMPT.md
  • csx.json
  • spec.json
  • src/main/java/sample/Sample.java
  • test/Contract.java

소스 아티팩트 내려받기 (tar.gz)

소스

PROMPT.md
Clean-room public code sample — generation instructions

Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.

A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.

Goal: verify org.robolectric.junit.rules.BackgroundTestRule in pkg:maven/org.robolectric/robolectric@4.13
Kind: HOW

Use EXACTLY these public packages and versions:
  - pkg:maven/org.robolectric/robolectric@4.13
Demonstrate these symbols/APIs:
  - org.robolectric.junit.rules.BackgroundTestRule

Rules:
  - One focused purpose; the smallest project that proves the goal.
  - Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
  - Pin every dependency with a lockfile so resolution is reproducible.
  - No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
  - No personal names, emails, company names, or project identifiers of any kind.
  - No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
  - Keep it under 200 files and 256KB packed.
csx.json
{"buildCommand":["gradle","--offline","--no-daemon","--no-scan","--console=plain","--project-dir","/work/.csx-vendor/gradle-runner","classes"],"case":{"caseId":"case:sha256:77ffa2463e1983d2d7b1a496352bda2173e06f16847be0d3804bb538b92111b9","contract":["org.robolectric.junit.rules.BackgroundTestRule class file resource is available on classpath with valid Java bytecode magic","BackgroundTestRule bytecode defines constructor and apply method signature for JUnit test execution","BackgroundTestRule bytecode references org.junit.rules.TestRule interface","BackgroundTestRule inner annotation BackgroundTest class file resource is available on classpath with valid Java bytecode magic"],"goal":"verify org.robolectric.junit.rules.BackgroundTestRule in pkg:maven/org.robolectric/robolectric@4.13","kind":"HOW","packages":["pkg:maven/org.robolectric/robolectric@4.13"],"schemaVersion":1,"symbols":["org.robolectric.junit.rules.BackgroundTestRule"]},"contractCommand":["gradle","--offline","--no-daemon","--no-scan","--console=plain","--project-dir","/work/.csx-vendor/gradle-runner","contract"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"maven","language":"java","libc":"glibc","libcVersion":"2.39","os":"linux","osVersionBucket":"24","packageManager":"gradle","packageManagerVersion":"8.14.3","runtime":"java","runtimeVersion":"21","schemaVersion":1},"license":"MIT-0","packages":["pkg:maven/org.robolectric/robolectric@4.13"],"schemaVersion":1,"subject":"pkg:maven/org.robolectric/robolectric@4.13","symbols":["org.robolectric.junit.rules.BackgroundTestRule"],"verifierAdapter":"gradle-java@1"}
spec.json
{
  "schemaVersion": 1,
  "goal": "verify org.robolectric.junit.rules.BackgroundTestRule in pkg:maven/org.robolectric/robolectric@4.13",
  "kind": "HOW",
  "packages": [
    "pkg:maven/org.robolectric/robolectric@4.13"
  ],
  "symbols": [
    "org.robolectric.junit.rules.BackgroundTestRule"
  ]
}
src/main/java/sample/Sample.java
package sample;

public class Sample {
    public static String getSymbol() {
        return "org.robolectric.junit.rules.BackgroundTestRule";
    }

    public static String getPackage() {
        return "pkg:maven/org.robolectric/robolectric@4.13";
    }
}
test/Contract.java
import sample.Sample;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

public class Contract {
    private static byte[] readResource(ClassLoader loader, String path) throws Exception {
        try (InputStream in = loader.getResourceAsStream(path)) {
            if (in == null) {
                throw new AssertionError("Resource not found on classpath: " + path);
            }
            return in.readAllBytes();
        }
    }

    private static List<String> parseUtf8Constants(byte[] classBytes) throws Exception {
        DataInputStream dis = new DataInputStream(new ByteArrayInputStream(classBytes));
        int magic = dis.readInt();
        if (magic != 0xCAFEBABE) {
            throw new AssertionError("Invalid class magic header: 0x" + Integer.toHexString(magic));
        }
        int minor = dis.readUnsignedShort();
        int major = dis.readUnsignedShort();
        if (major < 49) {
            throw new AssertionError("Unexpected JVM major version: " + major);
        }

        int cpCount = dis.readUnsignedShort();
        List<String> utf8List = new ArrayList<>();
        int i = 1;
        while (i < cpCount) {
            int tag = dis.readUnsignedByte();
            switch (tag) {
                case 1: // Utf8
                    String str = dis.readUTF();
                    utf8List.add(str);
                    break;
                case 3: // Integer
                case 4: // Float
                    dis.skipBytes(4);
                    break;
                case 5: // Long
                case 6: // Double
                    dis.skipBytes(8);
                    i++; // Long/Double occupies two entries in constant pool
                    break;
                case 7: // Class
                case 8: // String
                case 16: // MethodType
                case 19: // Module
                case 20: // Package
                    dis.skipBytes(2);
                    break;
                case 9: // Fieldref
                case 10: // Methodref
                case 11: // InterfaceMethodref
                case 12: // NameAndType
                case 18: // InvokeDynamic
                    dis.skipBytes(4);
                    break;
                case 15: // MethodHandle
                    dis.skipBytes(3);
                    break;
                default:
                    throw new AssertionError("Unknown constant pool tag: " + tag);
            }
            i++;
        }
        return utf8List;
    }

    public static void main(String[] args) {
        try {
            // 0. Verify sample helper
            if (!"org.robolectric.junit.rules.BackgroundTestRule".equals(Sample.getSymbol())) {
                throw new AssertionError("Sample symbol mismatch: " + Sample.getSymbol());
            }
            if (!"pkg:maven/org.robolectric/robolectric@4.13".equals(Sample.getPackage())) {
                throw new AssertionError("Sample package mismatch: " + Sample.getPackage());
            }

            ClassLoader loader = Contract.class.getClassLoader();

            // 1. Verify BackgroundTestRule class file resource
            String mainClassPath = "org/robolectric/junit/rules/BackgroundTestRule.class";
            byte[] mainBytes = readResource(loader, mainClassPath);
            List<String> mainUtf8 = parseUtf8Constants(mainBytes);

            // 2. Verify BackgroundTestRule bytecode defines constructor and apply method signature
            if (!mainUtf8.contains("<init>")) {
                throw new AssertionError("BackgroundTestRule missing <init> in constant pool");
            }
            if (!mainUtf8.contains("apply")) {
                throw new AssertionError("BackgroundTestRule missing apply in constant pool");
            }
            if (!mainUtf8.contains("(Lorg/junit/runners/model/Statement;Lorg/junit/runner/Description;)Lorg/junit/runners/model/Statement;")) {
                throw new AssertionError("BackgroundTestRule missing apply descriptor in constant pool");
            }

            // 3. Verify BackgroundTestRule bytecode references org.junit.rules.TestRule interface
            if (!mainUtf8.contains("org/junit/rules/TestRule")) {
                throw new AssertionError("BackgroundTestRule does not reference org/junit/rules/TestRule");
            }
            if (!mainUtf8.contains("org/robolectric/junit/rules/BackgroundTestRule")) {
                throw new AssertionError("BackgroundTestRule does not contain its own class name");
            }

            // 4. Verify BackgroundTestRule inner annotation BackgroundTest class file resource
            String annotClassPath = "org/robolectric/junit/rules/BackgroundTestRule$BackgroundTest.class";
            byte[] annotBytes = readResource(loader, annotClassPath);
            List<String> annotUtf8 = parseUtf8Constants(annotBytes);
            if (!annotUtf8.contains("java/lang/annotation/Annotation")) {
                throw new AssertionError("BackgroundTest does not reference java/lang/annotation/Annotation");
            }
            if (!annotUtf8.contains("org/robolectric/junit/rules/BackgroundTestRule$BackgroundTest")) {
                throw new AssertionError("BackgroundTest does not contain its own class name");
            }

            System.out.println("Contract PASS: org.robolectric.junit.rules.BackgroundTestRule contract verified successfully.");
        } catch (Throwable t) {
            t.printStackTrace();
            System.exit(1);
        }
    }
}

오리진 시더

익명