Skip to content

Commit

Permalink
Test InJarResolver with pom retrieved locally or from external maven …
Browse files Browse the repository at this point in the history
…repository
  • Loading branch information
Alberto Fanjul committed Jul 23, 2024
1 parent 24de6fc commit ee35707
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package org.appformer.maven.integration;

import junit.framework.TestCase;
import org.appformer.maven.support.AFReleaseId;
import org.appformer.maven.support.AFReleaseIdImpl;
import org.junit.Assert;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Predicate;

public class ArtifactResolverTest extends TestCase {

public void testInJarResolverSnapshotLocal() {

ClassLoader classLoader = getClass().getClassLoader();
AFReleaseId releaseId = new AFReleaseIdImpl("org.jbpm", "kjar", "1.0.0-SNAPSHOT", "jar");

InJarArtifactResolver inJarArtifactResolver = new InJarArtifactResolver(classLoader, releaseId) {
@Override
protected List<URL> buildResources(Predicate<String> predicate) {
ArrayList<URL> urlArrayList = new ArrayList<URL>();

if (predicate.test("BOOT-INF/classes/KIE-INF/lib/kjar.pom")) {
urlArrayList.add(getClassLoader().getResource("BOOT-INF/classes/KIE-INF/lib/kjar-1.0.0-SNAPSHOT.pom"));
return urlArrayList;
}
return super.buildResources(predicate);
}

@Override
protected URL getURL(String path) {
path = path.replaceAll(".*/BOOT-INF", "BOOT-INF");
return super.getURL(path);
}
};

Assert.assertTrue(inJarArtifactResolver.isLoaded());
}

public void testInJarResolverSnapshotExternal() {

ClassLoader classLoader = getClass().getClassLoader();
AFReleaseId releaseId = new AFReleaseIdImpl("org.jbpm", "kjar", "1.0.0-SNAPSHOT", "jar");

InJarArtifactResolver inJarArtifactResolver = new InJarArtifactResolver(classLoader, releaseId) {
@Override
protected List<URL> buildResources(Predicate<String> predicate) {
ArrayList<URL> urlArrayList = new ArrayList<URL>();

if (predicate.test("BOOT-INF/classes/KIE-INF/lib/kjar.pom")) {
urlArrayList.add(getClassLoader().getResource("BOOT-INF/classes/KIE-INF/lib/kjar-1.0.0-20240717-143315-1.pom"));
return urlArrayList;
}
return super.buildResources(predicate);
}

@Override
protected URL getURL(String path) {
path = path.replaceAll(".*/BOOT-INF", "BOOT-INF");
return super.getURL(path);
}
};
Assert.assertTrue(inJarArtifactResolver.isLoaded());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.jbpm</groupId>
<artifactId>kjar</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

</project>

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>org.jbpm</groupId>
<artifactId>kjar</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>

</project>

0 comments on commit ee35707

Please sign in to comment.