@@ -707,7 +707,7 @@ public void testDoubleSubscribeWithCustomHandler() throws IOException, Interrupt
707707 Dispatcher d = nc .createDispatcher ((msg ) -> {});
708708
709709 d .subscribe ("subject" , (msg ) -> { count .incrementAndGet (); });
710- d .subscribe ("subject" , (msg ) -> { count .incrementAndGet (); });
710+ d .subscribe ("subject" , "queue" , (msg ) -> { count .incrementAndGet (); });
711711 d .subscribe ("done" , (msg ) -> { done .complete (Boolean .TRUE ); });
712712
713713 nc .flush (Duration .ofSeconds (5 )); // wait for them to go through
@@ -769,4 +769,43 @@ public void testDoubleSubscribeWithUnsubscribeAfterWithCustomHandler() throws IO
769769 }
770770 }
771771
772+ @ Test (expected =IllegalArgumentException .class )
773+ public void testThrowOnEmptySubjectWithMessageHandler () throws IOException , InterruptedException , TimeoutException {
774+ try (NatsTestServer ts = new NatsTestServer (false );
775+ Connection nc = Nats .connect (ts .getURI ())) {
776+ Dispatcher d = nc .createDispatcher ((msg ) -> {});
777+ d .subscribe ("" , (msg ) -> {});
778+ assertFalse (true );
779+ }
780+ }
781+
782+ @ Test (expected =IllegalArgumentException .class )
783+ public void testThrowOnEmptyQueueWithMessageHandler () throws IOException , InterruptedException , TimeoutException {
784+ try (NatsTestServer ts = new NatsTestServer (false );
785+ Connection nc = Nats .connect (ts .getURI ())) {
786+ Dispatcher d = nc .createDispatcher ((msg ) -> {});
787+ d .subscribe ("subject" , "" , (msg ) -> {});
788+ assertFalse (true );
789+ }
790+ }
791+
792+ @ Test (expected =IllegalArgumentException .class )
793+ public void testThrowOnNullSubjectWithQueueWithMessageHandler () throws IOException , InterruptedException , TimeoutException {
794+ try (NatsTestServer ts = new NatsTestServer (false );
795+ Connection nc = Nats .connect (ts .getURI ())) {
796+ Dispatcher d = nc .createDispatcher ((msg ) -> {});
797+ d .subscribe (null , "quque" , (msg ) -> {});
798+ assertFalse (true );
799+ }
800+ }
801+
802+ @ Test (expected =IllegalArgumentException .class )
803+ public void testThrowOnEmptySubjectWithQueueWithMessageHandler () throws IOException , InterruptedException , TimeoutException {
804+ try (NatsTestServer ts = new NatsTestServer (false );
805+ Connection nc = Nats .connect (ts .getURI ())) {
806+ Dispatcher d = nc .createDispatcher ((msg ) -> {});
807+ d .subscribe ("" , "quque" , (msg ) -> {});
808+ assertFalse (true );
809+ }
810+ }
772811}
0 commit comments