GithubHelp home page GithubHelp logo

eo-cqrs / xfake Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 1.0 92 KB

XML In-Memory Storage for your Fake Objects

Home Page: https://eo-cqrs.github.io/xfake

License: MIT License

Java 100.00%
fake-objects java oop xml

xfake's Introduction

logo

Managed By Self XDSD

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

mvn maven central javadoc codecov

Hits-of-Code Lines-of-Code PDD status License

Project architect: @h1alexbel

XML In-Memory Storage for your Fake Objects.

Read about Fake Objects pattern and Watch Why Mocking Frameworks are Evil by @yegor256.

Motivation. To create a fake objects, we need to introduce some place where data will be stored.
We're not happy with creating this one again and again.

Principles. These are the design principles behind eo-kafka.

How to use. All you need is this (get the latest version here):

Maven:

<dependency>
  <groupId>io.github.eo-cqrs</groupId>
  <artifactId>xfake</artifactId>
</dependency>

Gradle:

dependencies {
    compile 'io.github.eo-cqrs:xfake:<version>'
}

Constructing Storage

To create an in-memory storage, we need to provide the name of the file to create and root XML node.

final FkStorage storage = new InFile("fake-test", "<fake/>");
storage.xml();

The output of storage.xml() will be:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<fake/>

After an object will be destroyed, the file will be deleted.

Applying Directives

final FkStorage storage = new InFile("fake-test", "<fake/>");
storage.apply(
  new Directives()
  .xpath("/fake")
  .addIf("servers")
);

The result of the applying will be:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<fake>
  <servers/>
</fake>

Synchronized Storage

Also, you can create a synchronized storage:

final FkStorage storage = 
  new Synchronized(
    new InFile("fake-synchronized", "<fake/>")
);

In this case reads xml() and writes apply(dirs) will be synchronized, and it will be possible to use it in multithreading environment.

Logging Storage

final FkStorage storage =
  new Logged(
    new Synchronized(
      new InFile("logged-test", "<fake/>")
    ),
  Level.INFO
);

This is the use-case of FkStorage in eo-kafka.

How to Contribute

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run full Maven build:

$ mvn clean install

You will need Maven 3.8.7+ and Java 17+.

If you want to contribute to the next release version of eo-kafka, please check the project board.

Our rultor image for CI/CD.

xfake's People

Contributors

h1alexbel avatar l3r8yj avatar renovate[bot] avatar rultor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

l3r8yj

xfake's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/codecov.yml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/cache v4
  • codecov/codecov-action v4
  • ubuntu 22.04
.github/workflows/mvn.yaml
  • actions/checkout v4
  • actions/setup-java v4
  • actions/cache v4
.github/workflows/pdd.yml
  • actions/checkout v4
  • ubuntu 22.04
.github/workflows/xcop.yml
  • actions/checkout v4
  • ubuntu 22.04
maven
pom.xml
  • com.jcabi:parent 0.67.0
  • org.cactoos:cactoos 0.55.0
  • com.jcabi.incubator:xembly 0.31.1
  • org.projectlombok:lombok 1.18.30
  • org.junit.jupiter:junit-jupiter-api 5.10.2
  • org.junit.jupiter:junit-jupiter-params 5.10.2
  • org.assertj:assertj-core 3.25.3
  • org.mockito:mockito-core 5.10.0
  • org.mockito:mockito-junit-jupiter 5.10.0
  • org.slf4j:slf4j-api 2.0.12
  • org.slf4j:slf4j-simple 2.0.12
  • org.apache.maven.plugins:maven-surefire-plugin 3.2.5
  • org.apache.maven.plugins:maven-verifier-plugin 1.1
  • com.github.volodya-lombrozo:jtcop-maven-plugin 1.2.0
  • ru.l3r8y:sa-tan 0.1.5
  • org.apache.maven.plugins:maven-checkstyle-plugin 3.3.1
  • com.puppycrawl.tools:checkstyle 10.13.0
  • org.apache.maven.plugins:maven-source-plugin 3.3.0
  • org.apache.maven.plugins:maven-gpg-plugin 3.1.0
  • org.sonatype.plugins:nexus-staging-maven-plugin 1.6.13

  • Check this box to trigger a request for Renovate to run again on this repository

Read Performance concurrency issue

public XML xml() throws Exception {
synchronized (this.name) {
return new XMLDocument(
new TextOf(
new File(
this.name
)
).asString()
);
}
}

better replace to

...
final ReentrantReadWriteLock rwlock = new ReentrantReadWriteLock();
...
 public XML xml() throws Exception { 
   this.rwlock.readLock().lock()
     try {
       return new XMLDocument( 
         new TextOf( 
           new File( 
             this.name 
           ) 
         ).asString() 
       ); 
     } finally {
       this.rwlock.readLock.unlock();
     }
   }
 } 

Hello from Self XDSD!

@h1alexbel Thank you for the invitation, your repo is all set up and I will manage it starting now.

I will take care of tickets' assignment, payments and more, automatically.

If you don't want me to handle a certain Issue or PR, add the no-task label when creating it. You can also say deregister to me (if it's already in scope) and I will forget about it.

InFile.java:37-38: Test Thread safety We need to...

The puzzle 22-576a91fb from #22 has to be resolved:

* @todo #22:45m/DEV Test Thread safety
* We need to introduce tests for Thread safety

The puzzle was created by @rultor on 26-May-23.

Estimate: 45 minutes, role: DEV.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.