Coder Social home page Coder Social logo

junit-server-cmis's Introduction

JUnit Runner for CMIS

Build Status Codacy Badge License Maven Central

This project was developed to help starts a CMIS InMemory Server (described here) in a JUnit Test Case Class.

Using this module you need just annotate the Test Class with the @RunWith(CmisInMemoryRunner.class) Java annotation and the CMIS InMemory will starts itself before first method execution and stop after the last method was executed.

As this module use the CMIS InMemory, all content inserted, deleted or modifyed in a executed class cannot be used in another, because on server shutdown all data will be lost.

Build

To create your own build on JUnit Runner for CMIS, you can execute the follow commands.

To clone project and access the project directory execute:

git clone https://github.com/gsdenys/junit-server-cmis.git

cd junit-server-cmis

To generate the project dist (.jar) you can use a gradle local installation. Execute the follow command:

gradle build -x signArchives

In contrast of local gradle you also can use the wrapper way executing the command:

./gradlew build -x signArchives

this will download and install gradle locally and use it to build the project. After build the .jar file will be created at <project_home>/build/junit-server-cmis-<version>.jar

Notes: Before execute the gradle build command, put in your env the USER and PASSWORD variable initialized with any value.

Usage

To use the JUnit Runner for CMIS you need to import the required libs.

with Gradle

testCompile group: 'com.github.gsdenys', name: 'junit-server-cmis', version: '1.1.2'

with Maven

<dependency>
    <groupId>com.github.gsdenys</groupId>
    <artifactId>junit-server-cmis</artifactId>
    <version>1.1.2</version>
</dependency>

after import, create the test case for your application. To start the CMIS server you just want to add the @RunWith(CmisInMemoryRunner.class) annotation to your test class'.

@RunWith(CmisInMemoryRunner.class)
public class UsageTest {
    @Test
    public void someTest() throws Exception {
        //TODO: Your test code here
    }
}

Once running the Junit Test Case will starts a Jetty server with a deployed CMIS InMemory Server at localhost you can make use of a set of static method that can help diring the test development. Follow you can see all of them:

  • CmisInMemoryRunner.getCmisURI(): returns the CMIS server URI.
  • CmisInMemoryRunner.getCmisPort(): returns the CMIS server port
  • CmisInMemoryRunner.getSession(): returns the CMIS Session for default repository (A1).
  • CmisInMemoryRunner.getSession(String repositoryId): returns the CMIS Session for a repository id passed by parameter. In case of repositoryId was null this method call CmisInMemoryRunner.getSession().

Optionally, you also can define the port that the server will be initiated, the version of CMIS and the Document type that will be used during your tests. To meke these configuration you needs to use the @Configure annotation, that was introduced in 1.1.1 version and upgraded at 2.0.0 version.

Follow you hava a simple example of how to user the @Configure annotation.

@RunWith(CmisInMemoryRunner.class)
@Configure(
    port = 9090,
    cmisVersion = CmisVersion.CMIS_1_1,
    docTypes = {
        @TypeDescriptor(
            file = "cmis-type.json",
            loader = TypeLoader.JSON
        )
    }
)
public class UsageTest {
    @Test
    public void someTest() throws Exception {
        //TODO: Your test code here
    }
}

For now, the unic way to add a document type at Junit Runner for CMIS is using JSON descriptor. Future more will be possible to use Alfresco and Nuxeo model definition.

junit-server-cmis's People

Contributors

gsdenys avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

junit-server-cmis's Issues

Not work in a Windows env

When run in a windows envirownment the cmis server do not start. May be because the classpath parser.

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.