testsuite/integration-tests/src/test/java/org/jboss/resteasy/test/providers/sse/SseReconnectTest.java
@Test
   public void testSseEndpointUnavailable() throws Exception {
      final CountDownLatch latch = new CountDownLatch(1);
      final AtomicInteger errors = new AtomicInteger(0);
      final List<String> results = new ArrayList<String>();
      Client client = ClientBuilder.newBuilder().build();
      try {
         WebTarget target = client.target(generateURL("/reconnect/unavailable"));
         SseEventSource msgEventSource = SseEventSource.target(target).build();
         try (SseEventSource eventSource = msgEventSource) {
            eventSource.register(event -> {
               results.add(event.readData(String.class));
               latch.countDown();
            }, ex -> {
                  errors.incrementAndGet();
                  Assert.assertTrue("ServiceUnavalile exception is expected", ex instanceof ServiceUnavailableException);
               });
            eventSource.open();

            boolean waitResult = latch.await(30, TimeUnit.SECONDS);
            Assert.assertEquals(1, errors.get());
            Assert.assertTrue("Waiting for event to be delivered has timed out.", waitResult);
         }
         Assert.assertTrue("ServiceAvailable message is expected", results.get(0).equals("ServiceAvailable"));
      } finally {
         client.close();
      }
   }
/**
    * @tpTestDetails SseEventSource receives HTTP 503 + "Retry-After" from the SSE endpoint. Check that SseEventSource
    * retries after the specified period
    * @tpInfo RESTEASY-1680
    * @tpSince RESTEasy 3.5.0
    */
@tpTestDetails SseEventSource receives HTTP 503 + "Retry-After" from the SSE endpoint. Check that SseEventSource
retries after the specified period
@tpInfo RESTEASY-1680
@tpSince RESTEasy 3.5.0
@tpTestDetails SseEventSource receives HTTP 503 + " Retry - After " from the SSE endpoint . Check that SseEventSource retries after the specified period @tpInfo RESTEASY - 1680 @tpSince RESTEasy 3 . 5 . 0
@Test
   public void testSseEndpointUnavailable() throws Exception {
      final CountDownLatch latch = new CountDownLatch(1);
      final AtomicInteger errors = new AtomicInteger(0);
      final List<String> results = new ArrayList<String>();
      Client client = ClientBuilder.newBuilder().build();
      try {
         WebTarget target = client.target(generateURL("/reconnect/unavailable"));
         SseEventSource msgEventSource = SseEventSource.target(target).build();
         try (SseEventSource eventSource = msgEventSource) {
            eventSource.register(event -> {
               results.add(event.readData(String.class));
               latch.countDown();
            }, ex -> {
                  errors.incrementAndGet();
                  Assert.assertTrue("ServiceUnavalile exception is expected", ex instanceof ServiceUnavailableException);
               });
            eventSource.open();
            boolean waitResult = latch.await(30, TimeUnit.SECONDS);
            Assert.assertEquals(1, errors.get());
            Assert.assertTrue("Waiting for event to be delivered has timed out.", waitResult);
         }
         Assert.assertTrue("ServiceAvailable message is expected", results.get(0).equals("ServiceAvailable"));
      } finally {
         client.close();
      }
   }
@ Test public void testSseEndpointUnavailable ( ) throws Exception { final CountDownLatch latch = new CountDownLatch ( 1 ) ; final AtomicInteger errors = new AtomicInteger ( 0 ) ; final List < String > results = new ArrayList < String > ( ) ; Client client = ClientBuilder . newBuilder ( ) . build ( ) ; try { WebTarget target = client . target ( generateURL ( "/reconnect/unavailable" ) ) ; SseEventSource msgEventSource = SseEventSource . target ( target ) . build ( ) ; try ( SseEventSource eventSource = msgEventSource ) { eventSource . register ( event -> { results . add ( event . readData ( String . class ) ) ; latch . countDown ( ) ; } , ex -> { errors . incrementAndGet ( ) ; Assert . assertTrue ( "ServiceUnavalile exception is expected" , ex instanceof ServiceUnavailableException ) ; } ) ; eventSource . open ( ) ; boolean waitResult = latch . await ( 30 , TimeUnit . SECONDS ) ; Assert . assertEquals ( 1 , errors . get ( ) ) ; Assert . assertTrue ( "Waiting for event to be delivered has timed out." , waitResult ) ; } Assert . assertTrue ( "ServiceAvailable message is expected" , results . get ( 0 ) . equals ( "ServiceAvailable" ) ) ; } finally { client . close ( ) ; } }
@tpTestDetails SseEventSource receives HTTP 503 + "Retry-After" from the SSE endpoint.
@tpTestDetails SseEventSource receives HTTP 503 + " Retry - After " from the SSE endpoint .