@Override protected void setUp() throws Exception { super.setUp(); String dataPath = new File("target/test-harness/elasticsearch-data").getAbsolutePath(); Map<ElasticsearchPort, Integer> esPorts = NetUtil.findOpenPortsForElasticsearch(); int httpPort = esPorts.get(ElasticsearchPort.HTTP); int tcpPort = esPorts.get(ElasticsearchPort.TCP); elasticsearchNode = ElasticsearchNode.start(dataPath, httpPort, tcpPort); // Configure mojo with context File testPom = new File(getBasedir(), "src/test/resources/goals/stop/pom.xml"); mojo = (StopElasticsearchNodeMojo) lookupMojo("stop", testPom); mojo.setPluginContext(new HashMap()); mojo.getPluginContext().put("test", elasticsearchNode); }