// Copyright 2020 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at:
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package io.nats.client.impl;

import io.nats.client.JetStream;
import io.nats.client.Message;
import org.junit.jupiter.api.Test;

import java.nio.charset.StandardCharsets;

public class JetStreamPubTests extends JetStreamTestBase {

    @Test
    public void testPub() throws Exception {
        int COUNT = 10000;

        runAgainstServer(nc -> {
            JetStream js = nc.jetStream();
            // create the stream.
            createMemoryStream(nc, STREAM, SUBJECT);

            long timer = 0;
            for (int x = 0; x < COUNT; x++) {
                Message msg = NatsMessage.builder()
                        .subject(SUBJECT)
                        .data((data(x)).getBytes(StandardCharsets.US_ASCII))
                        .build();
                long now = System.currentTimeMillis();
                js.publish(msg);
                timer += (System.currentTimeMillis() - now);
                int y = x + 1;
                if (y == 100 || (y % 500 == 0)) {
                    System.out.println("Time for " + y + " messages: " + timer);
                }
            }
        });
    }
}

@@ -912,15 +912,12 @@
  run
-Against
+InJs
 Serv

fix test