8335530: Java file extension missing in AuthenticatorTest

Reviewed-by: cstein, jpai
This commit is contained in:
Daniel Fuchs 2024-07-02 11:50:21 +00:00
parent 4060b35b1d
commit a537e87d2d

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2020, 2024, 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
@ -25,36 +25,36 @@
* @test
* @bug 8251496
* @summary Tests for methods in Authenticator
* @run testng/othervm AuthenticatorTest
* @run junit AuthenticatorTest
*/
import com.sun.net.httpserver.Authenticator;
import com.sun.net.httpserver.BasicAuthenticator;
import com.sun.net.httpserver.HttpPrincipal;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class AuthenticatorTest {
@Test
public void testFailure() {
var failureResult = new Authenticator.Failure(666);
assertEquals(failureResult.getResponseCode(), 666);
assertEquals(666, failureResult.getResponseCode());
}
@Test
public void testRetry() {
var retryResult = new Authenticator.Retry(333);
assertEquals(retryResult.getResponseCode(), 333);
assertEquals(333, retryResult.getResponseCode());
}
@Test
public void TestSuccess() {
public void testSuccess() {
var principal = new HttpPrincipal("test", "123");
var successResult = new Authenticator.Success(principal);
assertEquals(successResult.getPrincipal(), principal);
assertEquals("test", principal.getName());
assertEquals(principal, successResult.getPrincipal());
assertEquals("test", principal.getUsername());
assertEquals("123", principal.getRealm());
}
}