Skip to content

Commit

Permalink
test: fix integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stklcode committed Aug 26, 2024
1 parent f1e159b commit 3224e70
Show file tree
Hide file tree
Showing 5 changed files with 186 additions and 99 deletions.
151 changes: 105 additions & 46 deletions nexus-repository-composer-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>composer-parent</artifactId>
<version>0.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>nexus-repository-composer-it</artifactId>
Expand All @@ -20,96 +21,152 @@
<artifactId>nexus-pax-exam</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-features</artifactId>
<type>xml</type>
</dependency>
<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest-client</artifactId>
</dependency>
<!--
Pax-Exam test driver - end
-->

<!--
only needed due to testsupport reference to: org.sonatype.nexus.repository.maven.VersionPolicy
Allow tests access to these APIs/helpers
-->
<dependency>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-repository-maven</artifactId>
<scope>provided</scope>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.testsuite</groupId>
<artifactId>nexus-repository-testsupport</artifactId>
<version>${nxrm-version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.testsuite</groupId>
<artifactId>nexus-repository-testsupport</artifactId>
<version>${nxrm-version}</version>
<type>xml</type>
<classifier>features</classifier>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-bootstrap</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.testsuite</groupId>
<artifactId>nexus-it-suite-data</artifactId>
<version>${nxrm-version}</version>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rapture</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-repository-content</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest-client</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-rest-jackson2</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-script</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-extdirect</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus</groupId>
<artifactId>nexus-test-common</artifactId>
</dependency>

<!--
Allow tests access to these plugins
-->

<dependency>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-repository-composer</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<!--
Distributions to be tested
-->

<dependency>
<groupId>org.sonatype.nexus.assemblies</groupId>
<artifactId>nexus-base-template</artifactId>
<version>${nxrm-version}</version>
<type>zip</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.plugins</groupId>
<artifactId>nexus-repository-composer</artifactId>
<version>${project.version}</version>
<artifactId>nexus-blobstore-tasks</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.sonatype.nexus.testsuite</groupId>
<artifactId>nexus-it-suite-data</artifactId>
<version>${nxrm-version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<!--
ensure runtime dependencies required by ITs are in the local .m2/repository
Allow use of 'versionAsInProject' in Pax-Exam configuration
-->
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>get</goal>
</goals>
<configuration>
<groupId>org.sonatype.nexus.buildsupport</groupId>
<artifactId>nexus-buildsupport-it-deps</artifactId>
<version>${nxrm-version}</version>
<packaging>pom</packaging>
</configuration>
</execution>
</executions>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
</plugin>

<!--
Allow use of 'versionAsInProject' in Pax-Exam configuration
Pre-fetch all the bundles listed in pax-exam-features
-->
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<version>1.3</version>
<groupId>org.apache.karaf.tooling</groupId>
<artifactId>karaf-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-depends-file</id>
<id>fetch-pax-exam-features</id>
<phase>generate-resources</phase>
<goals>
<goal>generate-depends-file</goal>
<goal>features-add-to-repository</goal>
</goals>
<configuration>
<descriptors>
<descriptor>file:${project.artifactMap(org.ops4j.pax.exam:pax-exam-features).file}</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
Expand All @@ -125,16 +182,18 @@
</goals>
<configuration>
<target>
<unzip src="${org.sonatype.nexus.testsuite:nexus-it-suite-data:jar}" dest="${project.build.directory}/it-resources">
<unzip src="${org.sonatype.nexus.testsuite:nexus-it-suite-data:jar}"
dest="${project.build.directory}/it-resources">
<patternset>
<exclude name="META-INF/**" />
<exclude name="META-INF/**"/>
</patternset>
</unzip>
</target>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
}
],
"dist": {
"url": "/repository/composer-test-proxy/rjkip/ftp-php/dev-master/rjkip-ftp-php-dev-master.zip",
"url": "/rjkip/ftp-php/dev-master/rjkip-ftp-php-dev-master.zip",
"type": "zip",
"reference": "69869b3fe417172f3481e6245494843c31037366",
"shasum": ""
Expand Down Expand Up @@ -56,7 +56,7 @@
}
],
"dist": {
"url": "/repository/composer-test-proxy/rjkip/ftp-php/v1.0.0/rjkip-ftp-php-v1.0.0.zip",
"url": "/rjkip/ftp-php/v1.0.0/rjkip-ftp-php-v1.0.0.zip",
"type": "zip",
"reference": "f71bb2a8646f210f439ca96488ea37f74866e5d1",
"shasum": ""
Expand Down Expand Up @@ -92,7 +92,7 @@
}
],
"dist": {
"url": "/repository/composer-test-proxy/rjkip/ftp-php/v1.0.1/rjkip-ftp-php-v1.0.1.zip",
"url": "/rjkip/ftp-php/v1.0.1/rjkip-ftp-php-v1.0.1.zip",
"type": "zip",
"reference": "8767a90886226bbfd9d12c61b0cf51ab171d814d",
"shasum": ""
Expand Down Expand Up @@ -128,7 +128,7 @@
}
],
"dist": {
"url": "/repository/composer-test-proxy/rjkip/ftp-php/v1.1.0/rjkip-ftp-php-v1.1.0.zip",
"url": "/rjkip/ftp-php/v1.1.0/rjkip-ftp-php-v1.1.0.zip",
"type": "zip",
"reference": "69869b3fe417172f3481e6245494843c31037366",
"shasum": ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,15 @@
package org.sonatype.nexus.repository.composer.internal;

import java.net.URL;
import java.util.Optional;

import javax.annotation.Nonnull;

import org.sonatype.nexus.pax.exam.NexusPaxExamSupport;
import org.sonatype.nexus.repository.Repository;
import org.sonatype.nexus.repository.composer.internal.fixtures.RepositoryRuleComposer;
import org.sonatype.nexus.repository.storage.Asset;
import org.sonatype.nexus.repository.storage.MetadataNodeEntityAdapter;
import org.sonatype.nexus.repository.storage.StorageFacet;
import org.sonatype.nexus.repository.storage.StorageTx;
import org.sonatype.nexus.repository.content.facet.ContentFacet;
import org.sonatype.nexus.repository.content.fluent.FluentAsset;
import org.sonatype.nexus.testsuite.testsupport.RepositoryITSupport;

import org.junit.Rule;
Expand Down Expand Up @@ -58,14 +57,10 @@ protected ComposerClient composerClient(final URL repositoryUrl) throws Exceptio
);
}

public static Asset findAsset(Repository repository, String path) {
try (StorageTx tx = getStorageTx(repository)) {
tx.begin();
return tx.findAssetWithProperty(MetadataNodeEntityAdapter.P_NAME, path, tx.findBucket(repository));
public static Optional<FluentAsset> findAsset(Repository repository, String path) {
if (!path.startsWith("/")) {
path = "/" + path;
}
}

protected static StorageTx getStorageTx(final Repository repository) {
return repository.facet(StorageFacet.class).txSupplier().get();
return repository.facet(ContentFacet.class).assets().path(path).find();
}
}
Loading

0 comments on commit 3224e70

Please sign in to comment.