Search in sources :

Example 16 with RetentionPolicies

use of org.apache.pulsar.common.policies.data.RetentionPolicies in project incubator-pulsar by apache.

the class NamespacesTest method testRetention.

@Test
public void testRetention() throws Exception {
    try {
        URL localWebServiceUrl = new URL(pulsar.getWebServiceAddress());
        String bundledNsLocal = "test-bundled-namespace-1";
        BundlesData bundleData = new BundlesData(Lists.newArrayList("0x00000000", "0xffffffff"));
        createBundledTestNamespaces(this.testProperty, this.testLocalCluster, bundledNsLocal, bundleData);
        final NamespaceName testNs = NamespaceName.get(this.testProperty, this.testLocalCluster, bundledNsLocal);
        mockWebUrl(localWebServiceUrl, testNs);
        OwnershipCache MockOwnershipCache = spy(pulsar.getNamespaceService().getOwnershipCache());
        doNothing().when(MockOwnershipCache).disableOwnership(any(NamespaceBundle.class));
        Field ownership = NamespaceService.class.getDeclaredField("ownershipCache");
        ownership.setAccessible(true);
        ownership.set(pulsar.getNamespaceService(), MockOwnershipCache);
        RetentionPolicies retention = new RetentionPolicies(10, 10);
        namespaces.setRetention(this.testProperty, this.testLocalCluster, bundledNsLocal, retention);
        RetentionPolicies retention2 = namespaces.getRetention(this.testProperty, this.testLocalCluster, bundledNsLocal);
        assertEquals(retention, retention2);
    } catch (RestException e) {
        fail("ValidateNamespaceOwnershipWithBundles failed");
    }
}
Also used : NamespaceBundle(org.apache.pulsar.common.naming.NamespaceBundle) RetentionPolicies(org.apache.pulsar.common.policies.data.RetentionPolicies) NamespaceName(org.apache.pulsar.common.naming.NamespaceName) Field(java.lang.reflect.Field) OwnershipCache(org.apache.pulsar.broker.namespace.OwnershipCache) BundlesData(org.apache.pulsar.common.policies.data.BundlesData) RestException(org.apache.pulsar.broker.web.RestException) URL(java.net.URL) Test(org.testng.annotations.Test) MockedPulsarServiceBaseTest(org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)

Aggregations

RetentionPolicies (org.apache.pulsar.common.policies.data.RetentionPolicies)16 Test (org.testng.annotations.Test)11 MockedPulsarServiceBaseTest (org.apache.pulsar.broker.auth.MockedPulsarServiceBaseTest)6 PulsarAdminException (org.apache.pulsar.client.admin.PulsarAdminException)5 Message (org.apache.pulsar.client.api.Message)5 PersistencePolicies (org.apache.pulsar.common.policies.data.PersistencePolicies)5 Policies (org.apache.pulsar.common.policies.data.Policies)4 PulsarServerException (org.apache.pulsar.broker.PulsarServerException)3 RestException (org.apache.pulsar.broker.web.RestException)3 KeeperException (org.apache.zookeeper.KeeperException)3 Stat (org.apache.zookeeper.data.Stat)3 IOException (java.io.IOException)2 Field (java.lang.reflect.Field)2 URL (java.net.URL)2 PulsarAdmin (org.apache.pulsar.client.admin.PulsarAdmin)2 PulsarClient (org.apache.pulsar.client.api.PulsarClient)2 PulsarClientException (org.apache.pulsar.client.api.PulsarClientException)2 NamespaceBundle (org.apache.pulsar.common.naming.NamespaceBundle)2 NamespaceName (org.apache.pulsar.common.naming.NamespaceName)2 TopicName (org.apache.pulsar.common.naming.TopicName)2