Skip to content

Commit

Permalink
Test using local repository is passing
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Jul 2, 2013
1 parent 3bfa372 commit 044e639
Show file tree
Hide file tree
Showing 16 changed files with 132 additions and 74 deletions.

This file was deleted.

2 changes: 0 additions & 2 deletions addon-manager/example/src/main/resources/META-INF/beans.xml

This file was deleted.

This file was deleted.

2 changes: 0 additions & 2 deletions addon-manager/example2/src/main/resources/META-INF/beans.xml

This file was deleted.

2 changes: 0 additions & 2 deletions addon-manager/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
<module>impl</module>
<module>addon</module>
<module>tests</module>
<module>example</module>
<module>example2</module>
</modules>


Expand Down
71 changes: 64 additions & 7 deletions addon-manager/tests/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jboss.forge</groupId>
Expand Down Expand Up @@ -29,12 +30,6 @@
<version>${project.version}</version>
<classifier>forge-addon</classifier>
</dependency>
<dependency>
<groupId>org.jboss.forge.addon</groupId>
<artifactId>example</artifactId>
<version>${project.version}</version>
<classifier>forge-addon</classifier>
</dependency>

<dependency>
<groupId>org.jboss.forge.test</groupId>
Expand All @@ -47,4 +42,66 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>default-testResources</id>
<phase>process-test-resources</phase>
<goals>
<goal>testResources</goal>
</goals>
<configuration>
<nonFilteredFileExtensions>
<nonFilteredFileExtension>jar</nonFilteredFileExtension>
</nonFilteredFileExtensions>
</configuration>
</execution>
<execution>
<id>copy-repository</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/repository</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/test/resources/repository</directory>
<filtering>false</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-settings</id>
<phase>process-test-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/settings/profiles</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/test/resources/profiles</directory>
<filtering>true</filtering>
</resource>
</resources>
<escapeString>\</escapeString>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,41 @@

package org.jboss.forge.addon.manager;

import org.jboss.forge.addon.dependencies.AddonDependencyResolver;
import java.net.URL;

import org.jboss.forge.addon.dependencies.Coordinate;
import org.jboss.forge.addon.dependencies.Dependency;
import org.jboss.forge.addon.manager.impl.AddonManagerImpl;
import org.jboss.forge.addon.manager.request.InstallRequest;
import org.jboss.forge.addon.maven.dependencies.MavenDependencyResolver;
import org.jboss.forge.furnace.Furnace;
import org.jboss.forge.furnace.FurnaceImpl;
import org.jboss.forge.furnace.addons.AddonId;
import org.jboss.shrinkwrap.resolver.impl.maven.bootstrap.MavenSettingsBuilder;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

public abstract class AddonManagerTest
public class AddonManagerTest
{

@BeforeClass
public static void setRemoteRepository()
{
System.setProperty(MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION, "target/settings/profiles/settings.xml");
System.setProperty(MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION, getAbsolutePath("profiles/settings.xml"));
System.setProperty(MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION, "target/the-other-repository");
}

private static String getAbsolutePath(String path)
{
URL resource = Thread.currentThread().getContextClassLoader().getResource(path);
if (resource == null)
throw new IllegalStateException(path + " does not exist");
return resource.getFile();
}

@AfterClass
public static void clearRemoteRepository()
{
Expand All @@ -36,18 +50,26 @@ public static void clearRemoteRepository()
}

private AddonManager addonManager;
private MavenDependencyResolver resolver;

@Before
public void setUp()
{
Furnace furnace = new FurnaceImpl();
AddonDependencyResolver resolver = new MavenDependencyResolver();
resolver = new MavenDependencyResolver();
addonManager = new AddonManagerImpl(furnace, resolver);
}

@Test
public void testResolution() throws Exception
{

AddonId addon = AddonId.from("test:one_dep", "1.0.0.Final");
InstallRequest request = addonManager.install(addon);
Assert.assertNotNull(request);
Assert.assertEquals(1, request.getRequiredAddons().size());
Dependency dependency = request.getRequiredAddons().get(0).getDependency();
Coordinate coordinate = dependency.getCoordinate();
Assert.assertEquals("test", coordinate.getGroupId());
Assert.assertEquals("no_dep", coordinate.getArtifactId());
}
}
4 changes: 3 additions & 1 deletion addon-manager/tests/src/test/resources/profiles/settings.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

<profiles>
<profile>
<id>supertest</id>
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jboss.forge</groupId>
<artifactId>forge-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<groupId>org.jboss.forge.addon</groupId>
<artifactId>example</artifactId>
<groupId>test</groupId>
<artifactId>no_dep</artifactId>
<version>1.0.0.Final</version>
<name>Forge - Example Addon</name>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>test</groupId>
<artifactId>no_dep</artifactId>
<versioning>
<release>1.0.0.Final</release>
<versions>
<version>1.0.0.Final</version>
</versions>
<lastUpdated>20130310152137</lastUpdated>
</versioning>
</metadata>

Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jboss.forge</groupId>
<artifactId>forge-parent</artifactId>
<version>2.0.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<groupId>org.jboss.forge.addon</groupId>
<artifactId>example2</artifactId>
<name>Forge - Example Addon 2</name>
<groupId>test</groupId>
<artifactId>one_dep</artifactId>
<version>1.0.0.Final</version>
<name>Forge - Example Addon</name>

<dependencies>
<dependency>
<groupId>org.jboss.forge.furnace</groupId>
<artifactId>furnace-api</artifactId>
<scope>provided</scope>
</dependency>
<!-- Just added for testing dependency resolution -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<groupId>test</groupId>
<artifactId>no_dep</artifactId>
<version>1.0.0.Final</version>
<classifier>forge-addon</classifier>
</dependency>
</dependencies>
<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<metadata>
<groupId>test</groupId>
<artifactId>one_dep</artifactId>
<versioning>
<release>1.0.0.Final</release>
<versions>
<version>1.0.0.Final</version>
</versions>
<lastUpdated>20130310152137</lastUpdated>
</versioning>
</metadata>

0 comments on commit 044e639

Please sign in to comment.