|
32 | 32 | import static org.mockito.Mockito.verify;
|
33 | 33 | import static org.mockito.Mockito.when;
|
34 | 34 | import static org.testng.Assert.assertEquals;
|
| 35 | +import static org.testng.Assert.assertNotNull; |
35 | 36 | import static org.testng.Assert.assertSame;
|
36 | 37 | import static org.testng.Assert.assertTrue;
|
37 | 38 | import java.lang.reflect.Field;
|
|
53 | 54 | import javax.ws.rs.core.UriInfo;
|
54 | 55 | import lombok.Cleanup;
|
55 | 56 | import lombok.extern.slf4j.Slf4j;
|
| 57 | +import org.apache.bookkeeper.mledger.ManagedCursor; |
| 58 | +import org.apache.commons.collections4.MapUtils; |
56 | 59 | import org.apache.pulsar.broker.BrokerTestUtil;
|
57 | 60 | import org.apache.pulsar.broker.admin.v2.ExtPersistentTopics;
|
58 | 61 | import org.apache.pulsar.broker.admin.v2.NonPersistentTopics;
|
|
65 | 68 | import org.apache.pulsar.broker.resources.TopicResources;
|
66 | 69 | import org.apache.pulsar.broker.service.BrokerService;
|
67 | 70 | import org.apache.pulsar.broker.service.Topic;
|
| 71 | +import org.apache.pulsar.broker.service.persistent.PersistentSubscription; |
| 72 | +import org.apache.pulsar.broker.service.persistent.PersistentTopic; |
68 | 73 | import org.apache.pulsar.broker.web.PulsarWebResource;
|
69 | 74 | import org.apache.pulsar.broker.web.RestException;
|
70 | 75 | import org.apache.pulsar.client.admin.LongRunningProcessStatus;
|
|
76 | 81 | import org.apache.pulsar.client.api.Message;
|
77 | 82 | import org.apache.pulsar.client.api.MessageId;
|
78 | 83 | import org.apache.pulsar.client.api.Producer;
|
| 84 | +import org.apache.pulsar.client.api.Reader; |
79 | 85 | import org.apache.pulsar.client.api.Schema;
|
80 | 86 | import org.apache.pulsar.client.api.interceptor.ProducerInterceptor;
|
81 | 87 | import org.apache.pulsar.client.impl.BatchMessageIdImpl;
|
@@ -1773,4 +1779,36 @@ public void testNamespaceResources() throws Exception {
|
1773 | 1779 | assertTrue(namespaces.contains(ns1V2));
|
1774 | 1780 | assertTrue(namespaces.contains(ns1V1));
|
1775 | 1781 | }
|
| 1782 | + |
| 1783 | + @Test |
| 1784 | + public void testUpdatePropertiesOnNonDurableSub() throws Exception { |
| 1785 | + String topic = "persistent://" + testTenant + "/" + testNamespaceLocal + "/testUpdatePropertiesOnNonDurableSub"; |
| 1786 | + String subscription = "sub"; |
| 1787 | + admin.topics().createNonPartitionedTopic(topic); |
| 1788 | + |
| 1789 | + @Cleanup |
| 1790 | + Reader<String> __ = pulsarClient.newReader(Schema.STRING) |
| 1791 | + .startMessageId(MessageId.earliest) |
| 1792 | + .subscriptionName(subscription) |
| 1793 | + .topic(topic) |
| 1794 | + .create(); |
| 1795 | + |
| 1796 | + PersistentTopic persistentTopic = |
| 1797 | + (PersistentTopic) pulsar.getBrokerService().getTopic(topic, false).get().get(); |
| 1798 | + PersistentSubscription subscription1 = persistentTopic.getSubscriptions().get(subscription); |
| 1799 | + assertNotNull(subscription1); |
| 1800 | + ManagedCursor cursor = subscription1.getCursor(); |
| 1801 | + |
| 1802 | + Map<String, String> properties = admin.topics().getSubscriptionProperties(topic, subscription); |
| 1803 | + assertEquals(properties.size(), 0); |
| 1804 | + assertTrue(MapUtils.isEmpty(cursor.getCursorProperties())); |
| 1805 | + |
| 1806 | + admin.topics().updateSubscriptionProperties(topic, subscription, Map.of("foo", "bar")); |
| 1807 | + properties = admin.topics().getSubscriptionProperties(topic, subscription); |
| 1808 | + assertEquals(properties.size(), 1); |
| 1809 | + assertEquals(properties.get("foo"), "bar"); |
| 1810 | + |
| 1811 | + assertEquals(cursor.getCursorProperties().size(), 1); |
| 1812 | + assertEquals(cursor.getCursorProperties().get("foo"), "bar"); |
| 1813 | + } |
1776 | 1814 | }
|
0 commit comments