< prev index next >

test/jdk/java/net/httpclient/websocket/Support.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -77,20 +77,36 @@
         src.position(p).limit(l);
         return copy;
     }
 
     public static DummyWebSocketServer serverWithCannedData(int... data) {
+        return serverWithCannedDataAndAuthentication(null, null, data);
+    }
+
+    public static DummyWebSocketServer serverWithCannedDataAndAuthentication(
+            String username,
+            String password,
+            int... data)
+    {
         byte[] copy = new byte[data.length];
         for (int i = 0; i < data.length; i++) {
             copy[i] = (byte) data[i];
         }
-        return serverWithCannedData(copy);
+        return serverWithCannedDataAndAuthentication(username, password, copy);
     }
 
     public static DummyWebSocketServer serverWithCannedData(byte... data) {
+       return serverWithCannedDataAndAuthentication(null, null, data);
+    }
+
+    public static DummyWebSocketServer serverWithCannedDataAndAuthentication(
+            String username,
+            String password,
+            byte... data)
+    {
         byte[] copy = Arrays.copyOf(data, data.length);
-        return new DummyWebSocketServer() {
+        return new DummyWebSocketServer(username, password) {
             @Override
             protected void write(SocketChannel ch) throws IOException {
                 int off = 0; int n = 1; // 1 byte at a time
                 while (off + n < copy.length + n) {
 //                    try {
< prev index next >