org.apache.maven.plugin.testing.SilentLog Java Examples
The following examples show how to use
org.apache.maven.plugin.testing.SilentLog.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractXmlMojoTestCase.java From xml-maven-plugin with Apache License 2.0 | 5 votes |
protected AbstractXmlMojo newMojo( String pDir ) throws Exception { File testPom = new File( new File( getBasedir(), pDir ), "pom.xml" ); MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest(); ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class); MavenProject project = projectBuilder.build(testPom, buildingRequest).getProject(); // final Build build = new Build(); // build.setDirectory( "target" ); // project.setBuild(build); project.getBuild().setDirectory("target"); AbstractXmlMojo vm = (AbstractXmlMojo) lookupConfiguredMojo(project, getGoal()); setVariableValueToObject( vm, "basedir", new File( getBasedir(), pDir ) ); final Log log = new SilentLog(); DefaultResourceManager rm = new DefaultResourceManager(); setVariableValueToObject( rm, "logger", log ); setVariableValueToObject( vm, "locator", rm ); final Map<String, ResourceLoader> resourceLoaders = new HashMap<String, ResourceLoader>(); resourceLoaders.put( "file", new FileResourceLoader() ); resourceLoaders.put( "jar", new JarResourceLoader() ); resourceLoaders.put( "classloader", new ThreadContextClasspathResourceLoader() ); URLResourceLoader url = new URLResourceLoader(); setVariableValueToObject( url, "logger", log ); resourceLoaders.put( "url", url ); setVariableValueToObject( rm, "resourceLoaders", resourceLoaders ); // MavenProjectStub project = new MavenProjectStub() // { // public Build getBuild() // { // return build; // } // }; // setVariableValueToObject( vm, "project", project ); return vm; }
Example #2
Source File: ByteBuddyMojoTest.java From byte-buddy with Apache License 2.0 | 5 votes |
private void execute(String goal, String target) throws Exception { InputStream in = ByteBuddyMojoTest.class.getResourceAsStream("/net/bytebuddy/test/" + target + ".pom.xml"); if (in == null) { throw new AssertionError("Cannot find resource for: " + target); } try { File pom = File.createTempFile("maven", ".pom"); OutputStream out = new FileOutputStream(pom); try { byte[] buffer = new byte[1024]; int length; while ((length = in.read(buffer)) != -1) { out.write(buffer, 0, length); } } finally { out.close(); } Mojo mojo = mojoRule.lookupMojo(goal, pom); if (goal.equals("transform")) { mojoRule.setVariableValueToObject(mojo, "outputDirectory", project.getAbsolutePath()); mojoRule.setVariableValueToObject(mojo, "compileClasspathElements", Collections.emptyList()); } else if (goal.equals("transform-test")) { mojoRule.setVariableValueToObject(mojo, "testOutputDirectory", project.getAbsolutePath()); mojoRule.setVariableValueToObject(mojo, "testClasspathElements", Collections.emptyList()); } else { throw new AssertionError("Unknown goal: " + goal); } mojoRule.setVariableValueToObject(mojo, "repositorySystem", repositorySystem); mojoRule.setVariableValueToObject(mojo, "groupId", FOO); mojoRule.setVariableValueToObject(mojo, "artifactId", BAR); mojoRule.setVariableValueToObject(mojo, "version", QUX); mojoRule.setVariableValueToObject(mojo, "packaging", JAR); mojo.setLog(new SilentLog()); mojo.execute(); } finally { in.close(); } }
Example #3
Source File: SwaggerHubClientTest.java From swaggerhub-maven-plugin with Apache License 2.0 | 4 votes |
private SwaggerHubClient buildSwaggerHubClient(String basePath){ return new SwaggerHubClient("localhost", wireMockServer.port(), "http", "fake_token", new SilentLog(), basePath); }