o little test for the embedder

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@291700 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2005-09-26 18:21:30 +00:00
parent e1391f016b
commit b48e582fb3
3 changed files with 109 additions and 0 deletions

20
maven-embedder-it/pom.xml Normal file
View File

@ -0,0 +1,20 @@
<project>
<parent>
<artifactId>maven</artifactId>
<groupId>org.apache.maven</groupId>
<version>2.0-beta-2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder-it</artifactId>
<name>Maven Embedder Integration Tests</name>
<version>2.0-beta-2-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
<version>2.0-beta-2-SNAPSHOT</version>
<classifier>dep</classifier>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,49 @@
package org.apache.maven.embedder.it;
import org.apache.maven.embedder.MavenEmbedder;
import org.apache.maven.model.Model;
import java.io.File;/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A mock tool plugin that uses the Maven Embedder API
*
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id:$
*/
public class MockPlugin
{
private MavenEmbedder maven;
public MockPlugin()
throws Exception
{
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
maven = new MavenEmbedder();
maven.setClassLoader( classLoader );
maven.start();
}
public Model readModel( File model )
throws Exception
{
return maven.readModel( model );
}
}

View File

@ -0,0 +1,40 @@
package org.apache.maven.embedder.it;
import junit.framework.TestCase;
import org.apache.maven.model.Model;
import java.io.File;/*
* Copyright 2001-2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
* @version $Id:$
*/
public class MockPluginTest
extends TestCase
{
public void testMockPlugin()
throws Exception
{
MockPlugin plugin = new MockPlugin();
String basedir = System.getProperty( "basedir" );
Model model = plugin.readModel( new File( basedir, "pom.xml" ) );
assertEquals( "org.apache.maven", model.getGroupId() );
}
}