{"id":26496828,"url":"https://github.com/xcancloud/jmock","last_synced_at":"2025-09-10T08:04:00.324Z","repository":{"id":267808292,"uuid":"902420227","full_name":"xcancloud/JMock","owner":"xcancloud","description":"JMock is a high-performance data generation and simulation component library implemented in Java.","archived":false,"fork":false,"pushed_at":"2025-03-20T08:17:35.000Z","size":352,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T09:27:24.952Z","etag":null,"topics":["dataset","functions","mock","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xcancloud.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2024-12-12T14:31:20.000Z","updated_at":"2025-03-20T08:17:39.000Z","dependencies_parsed_at":"2024-12-12T15:38:07.978Z","dependency_job_id":"d87370f7-934b-4bbf-a0d2-e64a45e3376e","html_url":"https://github.com/xcancloud/JMock","commit_stats":null,"previous_names":["xcancloud/jmock"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcancloud%2FJMock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcancloud%2FJMock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcancloud%2FJMock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xcancloud%2FJMock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xcancloud","download_url":"https://codeload.github.com/xcancloud/JMock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244618429,"owners_count":20482316,"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":["dataset","functions","mock","testing-tools"],"created_at":"2025-03-20T12:59:38.732Z","updated_at":"2025-09-10T08:04:00.280Z","avatar_url":"https://github.com/xcancloud.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JMock\n\n[English](README.md) | [中文](README_zh.md)\n\n## Introduction\n\nJMock is a high-performance data generation and simulation library implemented in Java. It generates\ndata that more closely resembles real business data characteristics compared to random data\ngeneration.\n\n## Core Features\n\n- **High-performance data generation**:  \n  Generates 2M+ user records per second (single thread). Each record contains 10+ attributes\n  totaling 200+ bytes.\n- **Business-realistic data with i18n support**:  \n  Produces data that accurately simulates real-world business scenarios with internationalization\n  capabilities.\n- **Dual definition approaches**:\n    - *Annotation-based*: Applied to class fields\n    - *Function-based*: Used in script files (txt, json, yml, etc.)\n- **Multiple storage options**:  \n  Supports JDBC, in-memory, and local filesystem persistence for batch data.\n- **Extensible architecture**:  \n  Plugin-based system for custom mock data functions.\n\n## Function Expressions\n\n### Expression Formats\n\n| Type           | Parameterless Form | Parameterized Form                                         |\n|----------------|--------------------|------------------------------------------------------------|\n| **Annotation** | `@Annotation`      | `@Annotation(param1=value1, param2=value2)`                |\n| **Function**   | `@Function()`      | `@Function(param1, param2)` or `@Function(param1,,param3)` |\n\n### Syntax Rules\n\n1. **Core Symbols**\n    - `@` - Marks expression start\n    - `()` - Encloses parameters\n    - `,` - Separates parameters\n    - `|` - Delimits array elements (array parameters only)\n    - `\\` - Escapes special characters (`@`, `,`, `|`)\n\n2. **Naming Conventions**\n    - **Annotation/Function Names**: UpperCamelCase  \n      *Example: `EmailValidator`, `RandomNumber`*\n    - **Parameter Names**: lowerCamelCase  \n      *Example: `minValue`, `maxLength`*\n\n3. **Parameter Rules**\n    - Parameterless calls: Omit parentheses (annotations) or use empty `()` (functions)\n    - Parameterized calls:\n        - Annotation: `param=value` key-value pairs\n        - Function: Positional values\n    - Omitted parameters: Preserve commas  \n      *Example: `@Generate(1,,3)` indicates empty second parameter*\n\n4. **Special Character Handling**  \n   Escape `@`, `,`, `|` in parameter values:  \n   *Example: `@String(\"tom\\@domain.com\\|nick\\@domain.com\")`*\n\n## Usage Example\n\n1. **Add Maven Dependency**\n\n```xml\n\u003cdependency\u003e\n   \u003cgroupId\u003ecloud.xcan.jmock\u003c/groupId\u003e\n   \u003cartifactId\u003excan-jmock.core\u003c/artifactId\u003e\n   \u003cversion\u003e1.0.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n2. **Generate Sample Data**\n\n```java\n// Define template\nString content = \"\"\"\n    {\n      \"name\": \"@Name()\",\n      \"email\": \"@Email()\",\n      \"phone\": \"@Mobile()\",\n      \"address\": \"@Address()\",\n      \"hobbies\": [ \"reading\", \"hiking\",  \"cooking\" ]\n    }\"\"\";\n    \n// Process mock functions\nString result = new DefaultMockTextReplacer().replace(content);\n\n// Output result\nSystem.out.println(result);\n```\n\n***Output:***\n\n```json\n{\n  \"name\": \"Durfee Jacob\",\n  \"email\": \"9alJWYsUGJuJZtGuXT@yahoo.com.cn\",\n  \"phone\": \"15292153757\",\n  \"address\": \"ul. Akademika Pavlova, 12к3, Moskva\",\n  \"hobbies\": [ \"reading\", \"hiking\",  \"cooking\" ]\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcancloud%2Fjmock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxcancloud%2Fjmock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxcancloud%2Fjmock/lists"}