Skip to content

Commit

Permalink
change unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
shibd committed May 14, 2022
1 parent 4edad96 commit 139b485
Showing 1 changed file with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
import org.apache.pulsar.client.admin.PulsarAdminException;
import org.apache.pulsar.client.admin.PulsarAdminException.NotFoundException;
import org.apache.pulsar.client.admin.internal.BaseResource;
import org.apache.pulsar.client.admin.internal.NamespacesImpl;
import org.apache.pulsar.client.api.Consumer;
import org.apache.pulsar.client.api.ConsumerBuilder;
import org.apache.pulsar.client.api.Producer;
Expand Down Expand Up @@ -1329,21 +1328,28 @@ public void close() {

@Test
public void testOperationNamespaceMessageTTL() throws Exception {
String namespace = NamespaceName.get(this.testTenant, "ttlnamespace").toString();
org.apache.pulsar.client.admin.Namespaces namespaces = admin.namespaces();
namespaces.createNamespace(namespace);
String namespace = "ttlnamespace";

namespaces.setNamespaceMessageTTL(namespace, 100);
int namespaceMessageTTL = namespaces.getNamespaceMessageTTL(namespace);
asyncRequests(response -> namespaces.createNamespace(response, this.testTenant, this.testLocalCluster,
namespace, BundlesData.builder().build()));

asyncRequests(response -> namespaces.setNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
namespace, 100));

int namespaceMessageTTL = (Integer) asyncRequests(response -> namespaces.getNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
namespace));
Assert.assertEquals(100, namespaceMessageTTL);
namespaces.removeNamespaceMessageTTL(namespace);
Assert.assertNull(namespaces.getNamespaceMessageTTL(namespace));

asyncRequests(response -> namespaces.removeNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster, namespace));
Assert.assertNull(asyncRequests(response -> namespaces.getNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
namespace)));

try {
namespaces.setNamespaceMessageTTL(namespace, -1);
asyncRequests(response -> namespaces.setNamespaceMessageTTL(response, this.testTenant, this.testLocalCluster,
namespace, -1));
fail("should have failed");
} catch (PulsarAdminException e) {
Assert.assertEquals(e.getStatusCode(), Status.PRECONDITION_FAILED.getStatusCode());
} catch (RestException e) {
Assert.assertEquals(e.getResponse().getStatus(), Status.PRECONDITION_FAILED.getStatusCode());
}
}

Expand Down

0 comments on commit 139b485

Please sign in to comment.