@Test public void get() { try { fileSystemTestingUtils.setup(); ioService = fileSystemTestingUtils.getIoService(); final String repoName = "myrepo"; final JGitFileSystem fs = (JGitFileSystem) ioService.newFileSystem(URI.create("git: new HashMap<String, Object>() {{ put("init", Boolean.TRUE); put("internal", Boolean.TRUE); }}); ioService.startBatch(fs); String pom = "target/test-classes/kjar-2-single-resources/pom.xml"; if (!runIntoMavenCLI) { pom = "kie-wb-common-services/kie-wb-common-compiler/kie-wb-common-compiler-distribution/target/test-classes/kjar-2-single-resources/pom.xml"; } ioService.write(fs.getPath("/kjar-2-single-resources/pom.xml"), new String(java.nio.file.Files.readAllBytes(new File(pom).toPath()))); String personDotJava = "target/test-classes/kjar-2-single-resources/src/main/java/org/kie/maven/plugin/test/Person.java"; if (!runIntoMavenCLI) { personDotJava = "kie-wb-common-services/kie-wb-common-compiler/kie-wb-common-compiler-distribution/target/test-classes/kjar-2-single-resources/src/main/java/org/kie/maven/plugin/test/Person.java"; } ioService.write(fs.getPath("/kjar-2-single-resources/src/main/java/org/kie/maven/plugin/test/Person.java"), new String(java.nio.file.Files.readAllBytes(new File(personDotJava).toPath()))); String simpleRulesDotDRL = "target/test-classes/kjar-2-single-resources/src/main/resources/AllResourcesTypes/simple-rules.drl"; if (!runIntoMavenCLI) { simpleRulesDotDRL = "kie-wb-common-services/kie-wb-common-compiler/kie-wb-common-compiler-distribution/target/test-classes/kjar-2-single-resources/src/main/resources/AllResourceTypes/simple-rules.drl"; } ioService.write(fs.getPath("/kjar-2-single-resources/src/main/resources/AllResourcesTypes/simple-rules.drl"), new String(java.nio.file.Files.readAllBytes(new File(simpleRulesDotDRL).toPath()))); String kmodule = "target/test-classes/kjar-2-single-resources/src/main/resources/META-INF/kmodule.xml"; if (!runIntoMavenCLI) { kmodule = "kie-wb-common-services/kie-wb-common-compiler/kie-wb-common-compiler-distribution/target/test-classes/kjar-2-single-resources/src/main/resources/META-INF/kmodule.xml"; } ioService.write(fs.getPath("/kjar-2-single-resources/src/main/resources/META-INF/kmodule.xml"), new String(java.nio.file.Files.readAllBytes(new File(kmodule).toPath()))); ioService.endBatch(); java.nio.file.Path tmpRootCloned = java.nio.file.Files.createTempDirectory("cloned"); java.nio.file.Path tmpCloned = java.nio.file.Files.createDirectories(java.nio.file.Paths.get(tmpRootCloned.toString(), "dummy")); final File gitClonedFolder = new File(tmpCloned.toFile(), ".clone.git"); final Git cloned = Git.cloneRepository().setURI(fs.getGit().getRepository().getDirectory().toURI().toString()).setBare(false).setDirectory(gitClonedFolder).call(); assertThat(cloned).isNotNull(); mavenRepoPath = java.nio.file.Paths.get(System.getProperty("user.home"), ".m2", "repository"); tmpRoot = java.nio.file.Paths.get(gitClonedFolder + "/dummy/"); Dispatcher dispatcher = MockDispatcherFactory.createDispatcher(); POJOResourceFactory noDefaults = new POJOResourceFactory(MavenRestHandler.class); dispatcher.getRegistry().addResourceFactory(noDefaults); MockHttpRequest request = MockHttpRequest.get("build/maven/"); MockHttpResponse response = new MockHttpResponse(); dispatcher.invoke(request, response); assertThat(response.getStatus()).isEqualTo(200); assertThat(response.getContentAsString()).isEqualTo("Apache Maven"); tearDown(); } catch (Exception e) { logger.error(e.getMessage()); } finally { fileSystemTestingUtils.cleanup(); } }
@GET @Produces("text/plain") public String get() { return maven; }
MavenRestHandler extends Application { @GET @Produces("text/plain") public String get() { return maven; } }
MavenRestHandler extends Application { @GET @Produces("text/plain") public String get() { return maven; } MavenRestHandler(); }
MavenRestHandler extends Application { @GET @Produces("text/plain") public String get() { return maven; } MavenRestHandler(); @GET @Produces("text/plain") String get(); @POST @Produces(MediaType.APPLICATION_OCTET_STREAM) void postAsync(@Suspended AsyncResponse ar, @HeaderParam("project") String projectRepo, @HeaderParam("mavenrepo") String mavenRepoPath, @HeaderParam("settings_xml") String settingsXmlPath); }
MavenRestHandler extends Application { @GET @Produces("text/plain") public String get() { return maven; } MavenRestHandler(); @GET @Produces("text/plain") String get(); @POST @Produces(MediaType.APPLICATION_OCTET_STREAM) void postAsync(@Suspended AsyncResponse ar, @HeaderParam("project") String projectRepo, @HeaderParam("mavenrepo") String mavenRepoPath, @HeaderParam("settings_xml") String settingsXmlPath);  }