@@ -18,15 +18,15 @@ public class RestChannelBulkPublishTest extends ParameterizedTest {
1818
1919 /**
2020 * Publish a single message on multiple channels
21- *
21+ *
2222 * The payload constructed has the form
2323 * [
2424 * {
2525 * channel: [ <channel 0>, <channel 1>, ... ],
2626 * message: [{ data: <message text> }]
2727 * }
2828 * ]
29- *
29+ *
3030 * It publishes the given message on all of the given channels.
3131 */
3232 @ Test
@@ -69,54 +69,54 @@ public void bulk_publish_multiple_channels_simple() {
6969 }
7070 }
7171
72- /**
73- * As above but with the param method
74- */
75- @ Test
76- public void bulk_publish_multiple_channels_param () {
77- try {
78- /* setup library instance */
79- ClientOptions opts = createOptions (testVars .keys [0 ].keyStr );
80- AblyRest ably = new AblyRest (opts );
72+ /**
73+ * As above but with the param method
74+ */
75+ @ Test
76+ public void bulk_publish_multiple_channels_param () {
77+ try {
78+ /* setup library instance */
79+ ClientOptions opts = createOptions (testVars .keys [0 ].keyStr );
80+ AblyRest ably = new AblyRest (opts );
8181
82- /* first, publish some messages */
83- int channelCount = 5 ;
84- ArrayList <String > channelIds = new ArrayList <String >();
85- for (int i = 0 ; i < channelCount ; i ++) {
86- channelIds .add ("persisted:" + randomString ());
87- }
82+ /* first, publish some messages */
83+ int channelCount = 5 ;
84+ ArrayList <String > channelIds = new ArrayList <String >();
85+ for (int i = 0 ; i < channelCount ; i ++) {
86+ channelIds .add ("persisted:" + randomString ());
87+ }
8888
89- Message message = new Message (null , "bulk_publish_multiple_channels_param" );
90- String messageId = message .id = randomString ();
91- Message .Batch payload = new Message .Batch (channelIds , Collections .singleton (message ));
89+ Message message = new Message (null , "bulk_publish_multiple_channels_param" );
90+ String messageId = message .id = randomString ();
91+ Message .Batch payload = new Message .Batch (channelIds , Collections .singleton (message ));
9292
93- Param [] params = new Param [] { new Param ("quickAck" , "true" ) };
93+ Param [] params = new Param []{ new Param ("quickAck" , "true" )};
9494
95- PublishResponse [] result = ably .publishBatch (new Message .Batch [] { payload }, null , params );
96- for (PublishResponse response : result ) {
97- assertEquals ("Verify expected response id" , response .messageId , messageId );
98- assertTrue ("Verify expected channel name" , channelIds .contains (response .channelId ));
99- assertNull ("Verify no publish error" , response .error );
100- }
95+ PublishResponse [] result = ably .publishBatch (new Message .Batch []{ payload }, null , params );
96+ for (PublishResponse response : result ) {
97+ assertEquals ("Verify expected response id" , response .messageId , messageId );
98+ assertTrue ("Verify expected channel name" , channelIds .contains (response .channelId ));
99+ assertNull ("Verify no publish error" , response .error );
100+ }
101101
102- /* get the history for this channel */
103- for (String channel : channelIds ) {
104- PaginatedResult <Message > messages = ably .channels .get (channel ).history (null );
105- assertNotNull ("Expected non-null messages" , messages );
106- assertEquals ("Expected 1 message" , messages .items ().length , 1 );
107- /* verify message contents */
108- assertEquals ("Expect message data to be expected String" , messages .items ()[0 ].data , message .data );
109- }
110- } catch (AblyException e ) {
111- e .printStackTrace ();
112- fail ("bulk_publish_multiple_channels_param: Unexpected exception" );
113- return ;
114- }
115- }
102+ /* get the history for this channel */
103+ for (String channel : channelIds ) {
104+ PaginatedResult <Message > messages = ably .channels .get (channel ).history (null );
105+ assertNotNull ("Expected non-null messages" , messages );
106+ assertEquals ("Expected 1 message" , messages .items ().length , 1 );
107+ /* verify message contents */
108+ assertEquals ("Expect message data to be expected String" , messages .items ()[0 ].data , message .data );
109+ }
110+ } catch (AblyException e ) {
111+ e .printStackTrace ();
112+ fail ("bulk_publish_multiple_channels_param: Unexpected exception" );
113+ return ;
114+ }
115+ }
116116
117117 /**
118118 * Publish a multiple messages on multiple channels
119- *
119+ *
120120 * The payload constructed has the form
121121 * [
122122 * {
@@ -139,7 +139,7 @@ public void bulk_publish_multiple_channels_param() {
139139 * },
140140 * ...
141141 * ]
142- *
142+ *
143143 * It publishes the given messages on the associated channels.
144144 */
145145 @ Test
0 commit comments