Skip to content

Commit

Permalink
make IT compile and disable it
Browse files Browse the repository at this point in the history
The integration test already has a comment on it's current state.
Currently it does not even boot and the tested logic is probably not
worth major refactoring.

Make it compile and disable it with another comment.
  • Loading branch information
stklcode committed Aug 21, 2024
1 parent 72782eb commit 5e8a804
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 34 deletions.
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,7 @@ 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));
}
}

protected static StorageTx getStorageTx(final Repository repository) {
return repository.facet(StorageFacet.class).txSupplier().get();
public static Optional<FluentAsset> findAsset(Repository repository, String path) {
return repository.facet(ContentFacet.class).assets().path(path).find();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,42 @@
*/
package org.sonatype.nexus.repository.composer.internal;

import org.sonatype.goodies.httpfixture.server.fluent.Behaviours;
import org.sonatype.goodies.httpfixture.server.fluent.Server;
import org.sonatype.nexus.pax.exam.NexusPaxExamSupport;
import org.sonatype.nexus.repository.Repository;
import org.sonatype.nexus.repository.http.HttpStatus;
import org.sonatype.nexus.repository.storage.Asset;
import org.sonatype.nexus.testsuite.testsupport.NexusITSupport;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.sonatype.goodies.httpfixture.server.fluent.Behaviours;
import org.sonatype.goodies.httpfixture.server.fluent.Server;
import org.sonatype.nexus.pax.exam.NexusPaxExamSupport;
import org.sonatype.nexus.repository.Repository;
import org.sonatype.nexus.repository.content.fluent.FluentAsset;
import org.sonatype.nexus.repository.http.HttpStatus;
import org.sonatype.nexus.testsuite.testsupport.NexusITSupport;

import java.nio.charset.Charset;
import java.util.Optional;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.sonatype.nexus.testsuite.testsupport.FormatClientSupport.status;

/**
* Integration test for Composer proxy repositories.
*
* TODO: This test case does not start in it's current state.
* It requires some rework to provide valid test results again or should be removed, if this
* is not the case.
*/
@Ignore("this test should either be reworked or removed")
public class ComposerProxyIT
extends ComposerITSupport
{
Expand Down Expand Up @@ -132,10 +140,11 @@ public void unresponsiveRemoteProduces404() throws Exception {
public void retrievePackagesJSONFromProxyWhenRemoteOnline() throws Exception {
assertThat(status(proxyClient.get(FILE_PACKAGES)), is(HttpStatus.OK));

final Asset asset = findAsset(proxyRepo, FILE_PACKAGES);
assertThat(asset.name(), is(equalTo(FILE_PACKAGES)));
assertThat(asset.contentType(), is(equalTo(MIME_TYPE_JSON)));
assertThat(asset.format(), is(equalTo(FORMAT_NAME)));
final Optional<FluentAsset> asset = findAsset(proxyRepo, FILE_PACKAGES);
assertThat(asset.isPresent(), is(true));
assertThat(asset.get().path(), is(equalTo(FILE_PACKAGES)));
assertThat(asset.get(), is(equalTo(FILE_PACKAGES)));
assertThat(asset.get().component().isPresent(), is(false));
}

@Test
Expand All @@ -154,20 +163,18 @@ public void providersURLChangedToNXRM() throws Exception {
public void retrieveListJSONFromProxyWhenRemoteOnline() throws Exception {
assertThat(status(proxyClient.get(VALID_LIST_URL)), is(HttpStatus.OK));

final Asset asset = findAsset(proxyRepo, FILE_LIST);
assertThat(asset.name(), is(equalTo(FILE_LIST)));
assertThat(asset.contentType(), is(equalTo(MIME_TYPE_JSON)));
assertThat(asset.format(), is(equalTo(FORMAT_NAME)));
final Optional<FluentAsset> asset = findAsset(proxyRepo, FILE_LIST);
assertThat(asset.isPresent(), is(true));
assertThat(asset.get().path(), is(equalTo(FILE_LIST)));
}

@Test
public void retrieveProviderJSONFromProxyWhenRemoteOnline() throws Exception {
assertThat(status(proxyClient.get(VALID_PROVIDER_URL)), is(HttpStatus.OK));

final Asset asset = findAsset(proxyRepo, VALID_PROVIDER_URL);
assertThat(asset.name(), is(equalTo(VALID_PROVIDER_URL)));
assertThat(asset.contentType(), is(equalTo(MIME_TYPE_JSON)));
assertThat(asset.format(), is(equalTo(FORMAT_NAME)));
final Optional<FluentAsset> asset = findAsset(proxyRepo, VALID_PROVIDER_URL);
assertThat(asset.isPresent(), is(true));
assertThat(asset.get().path(), is(equalTo(VALID_PROVIDER_URL)));
}

// TODO: Dude, this test, what the heck! It's completely wacky, someone needs to look at this
Expand Down

0 comments on commit 5e8a804

Please sign in to comment.