Skip to content

Commit

Permalink
Nessie: Avoid usage of deprecated APIs in test (apache#6656)
Browse files Browse the repository at this point in the history
* Nessie: Avoid usage of deprecated APIs in test

* Address comments
  • Loading branch information
ajantha-bhat authored Jan 30, 2023
1 parent 9490393 commit 89e7e50
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,16 @@
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.io.TempDir;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.http.HttpClientBuilder;
import org.projectnessie.client.ext.NessieApiVersion;
import org.projectnessie.client.ext.NessieApiVersions;
import org.projectnessie.client.ext.NessieClientFactory;
import org.projectnessie.client.ext.NessieClientUri;
import org.projectnessie.error.NessieConflictException;
import org.projectnessie.error.NessieNotFoundException;
import org.projectnessie.jaxrs.ext.NessieJaxRsExtension;
import org.projectnessie.jaxrs.ext.NessieUri;
import org.projectnessie.model.Branch;
import org.projectnessie.model.Reference;
import org.projectnessie.model.Tag;
import org.projectnessie.server.store.TableCommitMetaStoreWorker;
import org.projectnessie.versioned.persist.adapter.DatabaseAdapter;
import org.projectnessie.versioned.persist.inmem.InmemoryDatabaseAdapterFactory;
import org.projectnessie.versioned.persist.inmem.InmemoryTestConnectionProviderSource;
Expand All @@ -70,13 +71,14 @@
@ExtendWith(DatabaseAdapterExtension.class)
@NessieDbAdapterName(InmemoryDatabaseAdapterFactory.NAME)
@NessieExternalDatabase(InmemoryTestConnectionProviderSource.class)
@NessieApiVersions(versions = NessieApiVersion.V1)
public abstract class BaseTestIceberg {

@NessieDbAdapter(storeWorker = TableCommitMetaStoreWorker.class)
static DatabaseAdapter databaseAdapter;
@NessieDbAdapter static DatabaseAdapter databaseAdapter;

@RegisterExtension
static NessieJaxRsExtension server = new NessieJaxRsExtension(() -> databaseAdapter);
static NessieJaxRsExtension server =
NessieJaxRsExtension.jaxRsExtensionForDatabaseAdapter(() -> databaseAdapter);

private static final Logger LOG = LoggerFactory.getLogger(BaseTestIceberg.class);

Expand Down Expand Up @@ -114,9 +116,10 @@ private void resetData() throws NessieConflictException, NessieNotFoundException
}

@BeforeEach
public void beforeEach(@NessieUri URI nessieUri) throws IOException {
this.uri = nessieUri.toString();
this.api = HttpClientBuilder.builder().withUri(this.uri).build(NessieApiV1.class);
public void beforeEach(NessieClientFactory clientFactory, @NessieClientUri URI nessieUri)
throws IOException {
this.uri = nessieUri.toASCIIString();
this.api = clientFactory.make();

Branch defaultBranch = api.getDefaultBranch();
initialHashOfDefaultBranch = defaultBranch.getHash();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@
import org.junit.jupiter.api.extension.RegisterExtension;
import org.junit.jupiter.api.io.TempDir;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.http.HttpClientBuilder;
import org.projectnessie.client.ext.NessieApiVersion;
import org.projectnessie.client.ext.NessieApiVersions;
import org.projectnessie.client.ext.NessieClientFactory;
import org.projectnessie.client.ext.NessieClientUri;
import org.projectnessie.error.NessieConflictException;
import org.projectnessie.error.NessieNotFoundException;
import org.projectnessie.jaxrs.ext.NessieJaxRsExtension;
import org.projectnessie.jaxrs.ext.NessieUri;
import org.projectnessie.model.Branch;
import org.projectnessie.model.Reference;
import org.projectnessie.model.Tag;
import org.projectnessie.server.store.TableCommitMetaStoreWorker;
import org.projectnessie.versioned.persist.adapter.DatabaseAdapter;
import org.projectnessie.versioned.persist.inmem.InmemoryDatabaseAdapterFactory;
import org.projectnessie.versioned.persist.inmem.InmemoryTestConnectionProviderSource;
Expand All @@ -53,13 +54,14 @@
@ExtendWith(DatabaseAdapterExtension.class)
@NessieDbAdapterName(InmemoryDatabaseAdapterFactory.NAME)
@NessieExternalDatabase(InmemoryTestConnectionProviderSource.class)
@NessieApiVersions(versions = NessieApiVersion.V1)
public class TestNessieCatalog extends CatalogTests<NessieCatalog> {

@NessieDbAdapter(storeWorker = TableCommitMetaStoreWorker.class)
static DatabaseAdapter databaseAdapter;
@NessieDbAdapter static DatabaseAdapter databaseAdapter;

@RegisterExtension
static NessieJaxRsExtension server = new NessieJaxRsExtension(() -> databaseAdapter);
static NessieJaxRsExtension server =
NessieJaxRsExtension.jaxRsExtensionForDatabaseAdapter(() -> databaseAdapter);

@TempDir public Path temp;

Expand All @@ -70,12 +72,11 @@ public class TestNessieCatalog extends CatalogTests<NessieCatalog> {
private String uri;

@BeforeEach
public void beforeEach(@NessieUri URI nessieUri) throws IOException {
this.uri = nessieUri.toString();
this.api = HttpClientBuilder.builder().withUri(this.uri).build(NessieApiV1.class);

public void setUp(NessieClientFactory clientFactory, @NessieClientUri URI nessieUri)
throws NessieNotFoundException {
api = clientFactory.make();
initialHashOfDefaultBranch = api.getDefaultBranch().getHash();

uri = nessieUri.toASCIIString();
hadoopConfig = new Configuration();
catalog = initNessieCatalog("main");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.projectnessie.client.ext.NessieClientFactory;
import org.projectnessie.client.ext.NessieClientUri;
import org.projectnessie.error.NessieConflictException;
import org.projectnessie.error.NessieNotFoundException;
import org.projectnessie.jaxrs.ext.NessieUri;
import org.projectnessie.model.Branch;
import org.projectnessie.model.CommitMeta;
import org.projectnessie.model.ContentKey;
Expand Down Expand Up @@ -89,8 +90,9 @@ public TestNessieTable() {

@Override
@BeforeEach
public void beforeEach(@NessieUri URI uri) throws IOException {
super.beforeEach(uri);
public void beforeEach(NessieClientFactory clientFactory, @NessieClientUri URI nessieUri)
throws IOException {
super.beforeEach(clientFactory, nessieUri);
this.tableLocation =
catalog.createTable(TABLE_IDENTIFIER, schema).location().replaceFirst("file:", "");
}
Expand Down

0 comments on commit 89e7e50

Please sign in to comment.