{"id":19288238,"url":"https://github.com/openweb-nl/in-memory-jcr","last_synced_at":"2026-05-18T05:09:07.910Z","repository":{"id":57738031,"uuid":"93862843","full_name":"openweb-nl/in-memory-jcr","owner":"openweb-nl","description":"The goal of this project is to make it easier for developers to set up a full feature JCR repository (In this case Jackrabbit) for testing purposes.","archived":false,"fork":false,"pushed_at":"2020-11-26T16:29:58.000Z","size":49,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-05T19:25:18.986Z","etag":null,"topics":["jcr","mocking","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openweb-nl.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}},"created_at":"2017-06-09T13:44:45.000Z","updated_at":"2022-05-29T03:41:38.000Z","dependencies_parsed_at":"2022-08-24T14:42:27.113Z","dependency_job_id":null,"html_url":"https://github.com/openweb-nl/in-memory-jcr","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openweb-nl%2Fin-memory-jcr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openweb-nl%2Fin-memory-jcr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openweb-nl%2Fin-memory-jcr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openweb-nl%2Fin-memory-jcr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openweb-nl","download_url":"https://codeload.github.com/openweb-nl/in-memory-jcr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240392872,"owners_count":19794169,"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":["jcr","mocking","testing"],"created_at":"2024-11-09T22:08:27.674Z","updated_at":"2026-05-18T05:09:02.876Z","avatar_url":"https://github.com/openweb-nl.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# In Memory JCR\n\nThe goal of this project is to make it easier for developers to set up \na full feature JCR repository (In this case Jackrabbit) for testing purposes.\n \n \n# Usage\n\nThe first is to add this library to your project as a test dependency. If you are using Maven\nyou can do so by adding the following snippet to your pom.xml file\n\n```xml\n\u003cdependencies\u003e\n  ...\n  \u003cdependency\u003e\n    \u003cgroupId\u003enl.openweb.jcr\u003c/groupId\u003e\n    \u003cartifactId\u003ein-memory-jcr\u003c/artifactId\u003e\n    \u003cversion\u003e1.3.2\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n  \u003c/dependency\u003e\n  ...\n\u003c/dependencies\u003e\n```\n\nthen in your test you can instantiate a new repository simple by instantiating a new \ninstance of InMemoryJcrRepository class.\n```java\nInMemoryJcrRepository repository = new InMemoryJcrRepository();\n```\nto obtain an instance of java session via\n```java\nSession session = repository.login(new SimpleCredentials(\"admin\", \"admin\".toCharArray()));\n```\nPlease notice that you need to shutdown the repository at the end of your test. Because unlike\nwhat the name of this library might suggest the repository is not 100% in the memory. \nThe database and the indexes are indeed kept in memory, but it still places a couple of XML files in \na temporary folder. So shutting down the repository insures that these xml files are deleted. \nTo shutdown the repository you can use the following snippet\n\n```java\nrepository.shutdown();\n```\nPlease notice that InMemoryJcrRepository implements AutoCloseable. Therefore it can be in\na try with resources statement as well.\n```java\ntry (InMemoryJcrRepository repository = new InMemoryJcrRepository()) {\n\tSession session = repository.login(new SimpleCredentials(\"admin\", \"admin\".toCharArray()));\n\t// here is your test\n}\n```\n## Extra tools\n\nNode definition constrains and namespace definitions can be a headache during testing. To make\ntesting easier, there is a utility class that you can use to register your node types and mixin types \nfree of constrains. Let say I want to have a node of type \"mynamespace:mynode\" then I can \nsimple use\n```java\nNodeTypeDefUtils.createNodeType(session, \"mynamespace:mynode\");\n```\nPlease notice that you do not need to register \"mynamespace\". If \"mynamespace\" namespace is not \nregister the NodeTypeDefUtils is going to register it automatically.\n\nHere is a complete example\n\n```java\ntry (InMemoryJcrRepository repository = new InMemoryJcrRepository()) {\n    Session session = repository.login(new SimpleCredentials(\"admin\", \"admin\".toCharArray()));\n    NodeTypeDefUtils.createNodeType(session, \"mynamespace:mynode\");\n\n    Node node = session.getRootNode().addNode(\"nodeName\", \"mynamespace:mynode\");\n    session.save();\n    // your test\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenweb-nl%2Fin-memory-jcr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenweb-nl%2Fin-memory-jcr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenweb-nl%2Fin-memory-jcr/lists"}