Skip to content

paulo-murer-movile/mycontainer

 
 

Repository files navigation

Mycontainer

Build Status

Purpose

Mycontainer is a generic test and development enviroment. Check it out.

Since 1.4.4

You need to change maven-mycontainer-plugin to mycontainer-maven-plugin (thanks maven 3.x)

@Before

You will need java and maven

Embedding Mycontainer to do some Java EE stuff

Configure InitialContext. You can do with jndi.properties

Code like MycontainerTestHelper.java to embed anywhere.

Here is a junit sample: AbstractWebBaseTestCase.java / MycontainerWebTest.java

  • Embeddable on any java application (junit tests, jetty, tomcat, and any others)
  • Programmatic configuration and deploy
  • Light weight
  • Fast boot
  • No hijack the Java Virtual Machine (real embeddable):
    • No change JVM URL protocols configs
    • No dynamic classloader
    • No classloader isolation

Embedding Mycontainer to do some GAE stuff

Configure pom.xml to Google App Engine

Use GAETestHelper.java or code like that.

Google has LocalServiceTestHelper to do unit tests, but it requires a thread environment. It means we need to keep the env to each request thread. This filter LocalServiceTestHelperFilter.java does the job using a non-documented google class ApiProxy.

Starting all modules from maven

Configure mycontainer maven plugin: pom.xml

Write the beanshell: mycontainer-start.bsh. You can write this in any java class and just use that in beanshell

mvn mycontainer:start

Start a local web server

No pom.xml required. And it is nice to quick start html, javascript and css projects.

$ mvn com.googlecode.mycontainer:mycontainer-maven-plugin:web -Dmycontainer.web.port=8080

TCP Tunnels

Mycontainer can start multiple tcp tunnels. You can do this using java -cp or mvn (pom.xml is not required)

$ java -cp mycontainer-util.jar com.googlecode.mycontainer.util.tunnel.Tunnels Redirect 0.0.0.0:6667:chat.freenode.net:6667 5080:google.com:80

You can get this jar here

The first argument can be Console (System.out) or Log (slf4j/jdk-logging) to show transfered data. Or Redirect to just redirect it silently.

Others arguments describes tunnels to startup. [local-host]:local-port:remote-host:remote-port.

local-host is not required (default 127.0.0.1). Use 0.0.0.0 to bind on all interfaces.

local-port can be zero to bind on a free random port.

You can also start it by maven (pom.xml is not required). It is an aggregator plugin.

$  mvn com.googlecode.mycontainer:mycontainer-maven-plugin:tunnels -Dmycontainer.tunnels.list=5000:localhost:6000,0.0.0.0:6667:chat.freenode.net:6667 -Dmycontainer.tunnels.handler=Console

Like the java -cp you need to tell Redirect, Console or Log (mycontainer.tunnels.handler) and tunnels (mycontainer.tunnels.list) separeted by comma.

Checking for non us-ascii files

Checking recursively for non-ascii files (pom.xml is not required):

$ mvn com.googlecode.mycontainer:mycontainer-maven-plugin:us-ascii

You can configure your pom.xml to check it on test maven phase like we do pom.xml. Use <inherited>false</inherited> if you are configuring your root pom.xml at multi modules project.

Installing PhantomJS

Mycontainer has a plugin to install PhantomJS.

  • Download packages from original host: http://code.google.com/p/phantomjs/downloads/
  • Install the correct package (windows, macosx, linux).
  • No pom.xml required
  • It set a maven property to the phantomjs executable: mycontainer.phantomjs.executable

Maven command:

$ mvn com.googlecode.mycontainer:mycontainer-maven-plugin:phantomjs-install -Dmycontainer.phantomjs.dest=target/phantomjs -Dmycontainer.phantomjs.version=1.9.2

Maven Repository

This project is deployed to maven central repository. Example:

<dependency>
    <groupId>com.googlecode.mycontainer</groupId>
    <artifactId>mycontainer-web</artifactId>
    <version>${mycontainer.version}</version>
</dependency>

Not all versions are deployed to central. But you can find them all at my private repository http://repo.pyrata.org/release/maven2/com/googlecode/mycontainer/

It is highly recommended that you avoid linking this repository in your pom.xml since I can not ensure it's availability.

Building Mycontainer

mvn clean install

Use -Ddist to assembly a all-in-one jar and a binary zip.

About

Test Light Weight Container

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 50.1%
  • JavaScript 49.5%
  • Other 0.4%