diff --git a/java/src/org/openqa/selenium/logging/CompositeLocalLogs.java b/java/src/org/openqa/selenium/logging/CompositeLocalLogs.java deleted file mode 100644 index 0bbb1168fe85a..0000000000000 --- a/java/src/org/openqa/selenium/logging/CompositeLocalLogs.java +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import java.util.Set; -import java.util.TreeSet; -import org.jspecify.annotations.NullMarked; - -/** - * LocalLogs implementation that holds two other local logs. NOTE: The two local logs are not equal. - * The first LocalLogs instance is assumed to pre-define which log types it supports, so addEntry - * will not be called on the first instance unless it pre-declares what it supports. If the first - * LocalLogs instance does not support this log type, addEntry will be called on the second - * LocalLogs instance. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -class CompositeLocalLogs extends LocalLogs { - private final LocalLogs predefinedTypeLogger; - private final LocalLogs allTypesLogger; - - protected CompositeLocalLogs(LocalLogs predefinedTypeLogger, LocalLogs allTypesLogger) { - super(); - this.predefinedTypeLogger = predefinedTypeLogger; - this.allTypesLogger = allTypesLogger; - } - - @Override - @NullMarked - public LogEntries get(String logType) { - if (predefinedTypeLogger.getAvailableLogTypes().contains(logType)) { - return predefinedTypeLogger.get(logType); - } - - return allTypesLogger.get(logType); - } - - @Override - public Set getAvailableLogTypes() { - TreeSet toReturn = new TreeSet<>(); - toReturn.addAll(predefinedTypeLogger.getAvailableLogTypes()); - toReturn.addAll(allTypesLogger.getAvailableLogTypes()); - return toReturn; - } - - @Override - public void addEntry(String logType, LogEntry entry) { - if (predefinedTypeLogger.getAvailableLogTypes().contains(logType)) { - predefinedTypeLogger.addEntry(logType, entry); - } else { - allTypesLogger.addEntry(logType, entry); - } - } -} diff --git a/java/src/org/openqa/selenium/logging/HandlerBasedLocalLogs.java b/java/src/org/openqa/selenium/logging/HandlerBasedLocalLogs.java deleted file mode 100644 index 029bbfe6b5a99..0000000000000 --- a/java/src/org/openqa/selenium/logging/HandlerBasedLocalLogs.java +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import java.util.Collection; -import java.util.Collections; -import java.util.Set; -import org.jspecify.annotations.NullMarked; - -/** - * LocalLogs instance that extracts entries from a logging handler. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -class HandlerBasedLocalLogs extends LocalLogs { - private final LoggingHandler loggingHandler; - private final Set logTypesToInclude; - - protected HandlerBasedLocalLogs(LoggingHandler loggingHandler, Set logTypesToInclude) { - super(); - this.loggingHandler = loggingHandler; - this.logTypesToInclude = logTypesToInclude; - } - - @Override - @NullMarked - public LogEntries get(String logType) { - if (LogType.CLIENT.equals(logType) && logTypesToInclude.contains(logType)) { - Collection entries = loggingHandler.getRecords(); - loggingHandler.flush(); - return new LogEntries(entries); - } - return new LogEntries(Collections.emptyList()); - } - - @Override - public Set getAvailableLogTypes() { - return Collections.singleton(LogType.CLIENT); - } - - @Override - public void addEntry(String logType, LogEntry entry) { - throw new RuntimeException("Log to this instance of LocalLogs using standard Java logging."); - } -} diff --git a/java/src/org/openqa/selenium/logging/LocalLogs.java b/java/src/org/openqa/selenium/logging/LocalLogs.java deleted file mode 100644 index 1ccfaa3e25cc1..0000000000000 --- a/java/src/org/openqa/selenium/logging/LocalLogs.java +++ /dev/null @@ -1,88 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import java.util.Collections; -import java.util.Set; -import org.jspecify.annotations.NullMarked; - -/** - * Stores and retrieves logs in-process (i.e. without any RPCs). - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -public abstract class LocalLogs implements Logs { - - private static final LocalLogs NULL_LOGGER = - new LocalLogs() { - @Override - @NullMarked - public LogEntries get(String logType) { - return new LogEntries(Collections.emptyList()); - } - - @Override - public Set getAvailableLogTypes() { - return Collections.emptySet(); - } - - @Override - public void addEntry(String logType, LogEntry entry) {} - }; - - /** - * Logger which doesn't do anything. - * - * @return the null logger - */ - public static LocalLogs getNullLogger() { - return NULL_LOGGER; - } - - public static LocalLogs getStoringLoggerInstance(Set logTypesToIgnore) { - return new StoringLocalLogs(logTypesToIgnore); - } - - public static LocalLogs getHandlerBasedLoggerInstance( - LoggingHandler loggingHandler, Set logTypesToInclude) { - return new HandlerBasedLocalLogs(loggingHandler, logTypesToInclude); - } - - /** - * See documentation of CompositeLocalLogs about the difference between the first LocalLogs - * instance and the second one. - * - * @param predefinedTypeLogger LocalLogs which pre-defines the log types it stores. - * @param allTypesLogger LocalLogs which can store log entries for all log types. - * @return A LocalLogs instance. - */ - public static LocalLogs getCombinedLogsHolder( - LocalLogs predefinedTypeLogger, LocalLogs allTypesLogger) { - return new CompositeLocalLogs(predefinedTypeLogger, allTypesLogger); - } - - protected LocalLogs() {} - - @Override - @NullMarked - public abstract LogEntries get(String logType); - - public abstract void addEntry(String logType, LogEntry entry); -} diff --git a/java/src/org/openqa/selenium/logging/LogCombiner.java b/java/src/org/openqa/selenium/logging/LogCombiner.java deleted file mode 100644 index 27852d759c5b4..0000000000000 --- a/java/src/org/openqa/selenium/logging/LogCombiner.java +++ /dev/null @@ -1,45 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import java.util.Collection; -import java.util.Comparator; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * Combines multiple log entries into a single sorted list. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -public class LogCombiner { - private static final Comparator LOG_ENTRY_TIMESTAMP_COMPARATOR = - Comparator.comparingLong(LogEntry::getTimestamp); - - public static LogEntries combine(LogEntries... entries) { - - return new LogEntries( - Stream.of(entries) - .map(LogEntries::getAll) - .flatMap(Collection::stream) - .sorted(LOG_ENTRY_TIMESTAMP_COMPARATOR) - .collect(Collectors.toList())); - } -} diff --git a/java/src/org/openqa/selenium/logging/LogType.java b/java/src/org/openqa/selenium/logging/LogType.java index b29b276aa58c4..f01ae5bb68f67 100644 --- a/java/src/org/openqa/selenium/logging/LogType.java +++ b/java/src/org/openqa/selenium/logging/LogType.java @@ -23,33 +23,9 @@ public class LogType { /** This log type pertains to logs from the browser. */ public static final String BROWSER = "browser"; - /** - * This log type pertains to logs from the client. - * - * @deprecated logging is not in the W3C WebDriver spec and CLIENT type is no longer supported. - */ - @Deprecated(forRemoval = true) - public static final String CLIENT = "client"; - /** This log pertains to logs from the WebDriver implementation. */ public static final String DRIVER = "driver"; /** This log type pertains to logs relating to performance timings. */ public static final String PERFORMANCE = "performance"; - - /** - * This log type pertains to logs relating to profiler timings. - * - * @deprecated logging is not in the W3C WebDriver spec and PROFILER type is no longer supported. - */ - @Deprecated(forRemoval = true) - public static final String PROFILER = "profiler"; - - /** - * This log type pertains to logs from the remote server. - * - * @deprecated logging is not in the W3C WebDriver spec and SERVER type is no longer supported. - */ - @Deprecated(forRemoval = true) - public static final String SERVER = "server"; } diff --git a/java/src/org/openqa/selenium/logging/LoggingHandler.java b/java/src/org/openqa/selenium/logging/LoggingHandler.java deleted file mode 100644 index c1f9193f5393d..0000000000000 --- a/java/src/org/openqa/selenium/logging/LoggingHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import java.util.ArrayDeque; -import java.util.Collection; -import java.util.Collections; -import java.util.logging.Handler; -import java.util.logging.LogRecord; - -/** - * A custom handler used to record log entries. - * - *

This handler queues up log records as they come, up to MAX_RECORDS (currently 1000) records. - * If it reaches this capacity it will remove the older records from the queue before adding the - * next one. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -public class LoggingHandler extends Handler { - - private static final int MAX_RECORDS = 1000; - private ArrayDeque records = new ArrayDeque<>(); - private static final LoggingHandler INSTANCE = new LoggingHandler(); - - private LoggingHandler() {} - - public static LoggingHandler getInstance() { - return INSTANCE; - } - - /** - * @return an unmodifiable list of LogEntry. - */ - public synchronized Collection getRecords() { - return Collections.unmodifiableCollection(records); - } - - @Override - public synchronized void publish(LogRecord logRecord) { - if (isLoggable(logRecord)) { - if (records.size() > MAX_RECORDS) { - records.remove(); - } - records.add( - new LogEntry( - logRecord.getLevel(), - logRecord.getMillis(), - logRecord.getLoggerName() - + " " - + logRecord.getSourceClassName() - + "." - + logRecord.getSourceMethodName() - + " " - + logRecord.getMessage())); - } - } - - @Override - public synchronized void flush() { - records = new ArrayDeque<>(); - } - - @Override - public synchronized void close() throws SecurityException { - records.clear(); - } -} diff --git a/java/src/org/openqa/selenium/logging/NeedsLocalLogs.java b/java/src/org/openqa/selenium/logging/NeedsLocalLogs.java deleted file mode 100644 index 67e5c6390e689..0000000000000 --- a/java/src/org/openqa/selenium/logging/NeedsLocalLogs.java +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -/** - * Marker interface for executors that need local logs. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -public interface NeedsLocalLogs { - void setLocalLogs(LocalLogs logs); -} diff --git a/java/src/org/openqa/selenium/logging/SessionLogHandler.java b/java/src/org/openqa/selenium/logging/SessionLogHandler.java deleted file mode 100644 index ec57ae63cf5f4..0000000000000 --- a/java/src/org/openqa/selenium/logging/SessionLogHandler.java +++ /dev/null @@ -1,54 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import java.util.HashMap; -import java.util.Map; -import org.openqa.selenium.InvalidArgumentException; - -/** - * Utility for parsing session logs from Grid. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -public class SessionLogHandler { - - /** - * Creates a session logs map, with session logs mapped to session IDs, given a raw session log - * map as a JSON object. - * - * @param rawSessionMap The raw session map. - * @return The session logs mapped to session IDs. - */ - public static Map getSessionLogs(Map rawSessionMap) { - Map sessionLogsMap = new HashMap<>(); - for (Map.Entry entry : rawSessionMap.entrySet()) { - String sessionId = entry.getKey(); - if (!(entry.getValue() instanceof Map)) { - throw new InvalidArgumentException("Expected value to be an object: " + entry.getValue()); - } - @SuppressWarnings("unchecked") - Map value = (Map) entry.getValue(); - SessionLogs sessionLogs = SessionLogs.fromJSON(value); - sessionLogsMap.put(sessionId, sessionLogs); - } - return sessionLogsMap; - } -} diff --git a/java/src/org/openqa/selenium/logging/SessionLogs.java b/java/src/org/openqa/selenium/logging/SessionLogs.java deleted file mode 100644 index 6b65e31374219..0000000000000 --- a/java/src/org/openqa/selenium/logging/SessionLogs.java +++ /dev/null @@ -1,91 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.jspecify.annotations.NullMarked; -import org.jspecify.annotations.Nullable; -import org.openqa.selenium.Beta; -import org.openqa.selenium.internal.Require; - -/** - * Contains the logs for a session divided by supported log types. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Beta -@NullMarked -@Deprecated(forRemoval = true) -public class SessionLogs { - private final Map logTypeToEntriesMap; - - public SessionLogs() { - this.logTypeToEntriesMap = new HashMap<>(); - } - - public LogEntries getLogs(@Nullable String logType) { - if (logType == null || !logTypeToEntriesMap.containsKey(logType)) { - return new LogEntries(Collections.emptyList()); - } - return logTypeToEntriesMap.get(logType); - } - - public void addLog(String logType, LogEntries logEntries) { - logTypeToEntriesMap.put(logType, logEntries); - } - - public Set getLogTypes() { - return logTypeToEntriesMap.keySet(); - } - - public Map getAll() { - return Collections.unmodifiableMap(logTypeToEntriesMap); - } - - public static SessionLogs fromJSON(Map rawSessionLogs) { - SessionLogs sessionLogs = new SessionLogs(); - for (Map.Entry entry : rawSessionLogs.entrySet()) { - String logType = entry.getKey(); - Collection rawLogEntries = (Collection) entry.getValue(); - List logEntries = new ArrayList<>(); - for (Object o : rawLogEntries) { - @SuppressWarnings("unchecked") - Map rawEntry = (Map) o; - logEntries.add( - new LogEntry( - LogLevelMapping.toLevel(String.valueOf(rawEntry.get("level"))), - Require.nonNull("timestamp", (Number) rawEntry.get("timestamp")).longValue(), - String.valueOf(rawEntry.get("message")))); - } - sessionLogs.addLog(logType, new LogEntries(logEntries)); - } - return sessionLogs; - } - - @Beta - public Map toJson() { - return getAll(); - } -} diff --git a/java/src/org/openqa/selenium/logging/StoringLocalLogs.java b/java/src/org/openqa/selenium/logging/StoringLocalLogs.java deleted file mode 100644 index 45dfa9535f547..0000000000000 --- a/java/src/org/openqa/selenium/logging/StoringLocalLogs.java +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.jspecify.annotations.NullMarked; - -/** - * LocalLogs instance that has its own storage. This should be used for explicit storing of logs, - * such as for profiling. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -class StoringLocalLogs extends LocalLogs { - private final Map> localLogs = new HashMap<>(); - private final Set logTypesToInclude; - - public StoringLocalLogs(Set logTypesToInclude) { - this.logTypesToInclude = logTypesToInclude; - } - - @Override - @NullMarked - public LogEntries get(String logType) { - return new LogEntries(getLocalLogs(logType)); - } - - private Iterable getLocalLogs(String logType) { - if (localLogs.containsKey(logType)) { - List entries = localLogs.get(logType); - localLogs.put(logType, new ArrayList<>()); - return entries; - } - - return new ArrayList<>(); - } - - /** - * Add a new log entry to the local storage. - * - * @param logType the log type to store - * @param entry the entry to store - */ - @Override - public void addEntry(String logType, LogEntry entry) { - if (!logTypesToInclude.contains(logType)) { - return; - } - - if (!localLogs.containsKey(logType)) { - List entries = new ArrayList<>(); - entries.add(entry); - localLogs.put(logType, entries); - } else { - localLogs.get(logType).add(entry); - } - } - - @Override - public Set getAvailableLogTypes() { - return localLogs.keySet(); - } -} diff --git a/java/src/org/openqa/selenium/logging/profiler/EventType.java b/java/src/org/openqa/selenium/logging/profiler/EventType.java deleted file mode 100644 index a6ea8fe61e7b6..0000000000000 --- a/java/src/org/openqa/selenium/logging/profiler/EventType.java +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging.profiler; - -/** - * Event types for profiler log entries. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -public enum EventType { - HTTP_COMMAND, - YIELD_TO_PAGE_LOAD, -} diff --git a/java/src/org/openqa/selenium/logging/profiler/HttpProfilerLogEntry.java b/java/src/org/openqa/selenium/logging/profiler/HttpProfilerLogEntry.java deleted file mode 100644 index 241b1d28693f6..0000000000000 --- a/java/src/org/openqa/selenium/logging/profiler/HttpProfilerLogEntry.java +++ /dev/null @@ -1,40 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging.profiler; - -/** - * A log entry for HTTP command profiling. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -public class HttpProfilerLogEntry extends ProfilerLogEntry { - - public HttpProfilerLogEntry(String commandName, boolean isStart) { - super(EventType.HTTP_COMMAND, constructMessage(EventType.HTTP_COMMAND, commandName, isStart)); - } - - private static String constructMessage(EventType eventType, String commandName, boolean isStart) { - // We're going to make the assumption that command name is a simple string which doesn't need - // escaping. - return String.format( - "{\"event\": \"%s\", \"command\": \"%s\", \"startorend\": \"%s\"}", - eventType.toString(), commandName, isStart ? "start" : "end"); - } -} diff --git a/java/src/org/openqa/selenium/logging/profiler/ProfilerLogEntry.java b/java/src/org/openqa/selenium/logging/profiler/ProfilerLogEntry.java deleted file mode 100644 index a1f126ba0f9e2..0000000000000 --- a/java/src/org/openqa/selenium/logging/profiler/ProfilerLogEntry.java +++ /dev/null @@ -1,34 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging.profiler; - -import java.util.logging.Level; -import org.openqa.selenium.logging.LogEntry; - -/** - * A log entry for profiler events. - * - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. This class will - * be removed in a future release. - */ -@Deprecated(forRemoval = true) -public class ProfilerLogEntry extends LogEntry { - public ProfilerLogEntry(EventType eventType, String message) { - super(Level.INFO, System.currentTimeMillis(), message); - } -} diff --git a/java/src/org/openqa/selenium/logging/profiler/package-info.java b/java/src/org/openqa/selenium/logging/profiler/package-info.java deleted file mode 100644 index 3a75c30f614cf..0000000000000 --- a/java/src/org/openqa/selenium/logging/profiler/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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. - -@NullMarked -package org.openqa.selenium.logging.profiler; - -import org.jspecify.annotations.NullMarked; diff --git a/java/src/org/openqa/selenium/remote/HttpCommandExecutor.java b/java/src/org/openqa/selenium/remote/HttpCommandExecutor.java index 726d5177adb94..cac3ce418d859 100644 --- a/java/src/org/openqa/selenium/remote/HttpCommandExecutor.java +++ b/java/src/org/openqa/selenium/remote/HttpCommandExecutor.java @@ -34,17 +34,12 @@ import org.openqa.selenium.UnsupportedCommandException; import org.openqa.selenium.WebDriverException; import org.openqa.selenium.internal.Require; -import org.openqa.selenium.logging.LocalLogs; -import org.openqa.selenium.logging.LogEntry; -import org.openqa.selenium.logging.LogType; -import org.openqa.selenium.logging.NeedsLocalLogs; -import org.openqa.selenium.logging.profiler.HttpProfilerLogEntry; import org.openqa.selenium.remote.http.ClientConfig; import org.openqa.selenium.remote.http.HttpClient; import org.openqa.selenium.remote.http.HttpRequest; import org.openqa.selenium.remote.http.HttpResponse; -public class HttpCommandExecutor implements CommandExecutor, NeedsLocalLogs { +public class HttpCommandExecutor implements CommandExecutor { private final URL remoteServer; public final HttpClient client; @@ -53,9 +48,6 @@ public class HttpCommandExecutor implements CommandExecutor, NeedsLocalLogs { protected @Nullable CommandCodec commandCodec; protected @Nullable ResponseCodec responseCodec; - @SuppressWarnings("deprecation") - private LocalLogs logs = LocalLogs.getNullLogger(); - private static class DefaultClientFactoryHolder { static HttpClient.Factory defaultClientFactory = HttpClient.Factory.createDefault(); } @@ -155,27 +147,11 @@ protected void defineCommand(String commandName, CommandInfo info) { commandCodec.defineCommand(commandName, info.getMethod(), info.getUrl()); } - /** - * @deprecated logging is not in the W3C WebDriver spec and is no longer supported. - */ - @Override - @Deprecated(forRemoval = true) - @SuppressWarnings("deprecation") - public void setLocalLogs(LocalLogs logs) { - this.logs = logs; - } - - @SuppressWarnings("deprecation") - private void log(String logType, LogEntry entry) { - logs.addEntry(logType, entry); - } - public URL getAddressOfRemoteServer() { return remoteServer; } @Override - @SuppressWarnings("deprecation") public Response execute(Command command) throws IOException { if (command.getSessionId() == null) { if (QUIT.equals(command.getName())) { @@ -192,7 +168,6 @@ public Response execute(Command command) throws IOException { throw new SessionNotCreatedException("Session already exists"); } ProtocolHandshake handshake = new ProtocolHandshake(); - log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), true)); ProtocolHandshake.Result result = handshake.createSession(client, command); Dialect dialect = result.getDialect(); commandCodec = dialect.getCommandCodec(); @@ -200,7 +175,6 @@ public Response execute(Command command) throws IOException { defineCommand(entry.getKey(), entry.getValue()); } responseCodec = dialect.getResponseCodec(); - log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), false)); return result.createResponse(); } @@ -217,9 +191,7 @@ public Response execute(Command command) throws IOException { } try { - log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), true)); HttpResponse httpResponse = client.execute(httpRequest); - log(LogType.PROFILER, new HttpProfilerLogEntry(command.getName(), false)); Response response = responseCodec.decode(httpResponse); if (response.getSessionId() == null) { diff --git a/java/src/org/openqa/selenium/remote/RemoteLogs.java b/java/src/org/openqa/selenium/remote/RemoteLogs.java index 267558e892e14..d905d786f30bf 100644 --- a/java/src/org/openqa/selenium/remote/RemoteLogs.java +++ b/java/src/org/openqa/selenium/remote/RemoteLogs.java @@ -17,25 +17,16 @@ package org.openqa.selenium.remote; -import java.util.ArrayList; -import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.logging.Level; -import java.util.logging.Logger; import java.util.stream.Collectors; -import org.jspecify.annotations.Nullable; import org.openqa.selenium.Beta; import org.openqa.selenium.UnsupportedCommandException; -import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.logging.LocalLogs; -import org.openqa.selenium.logging.LogCombiner; import org.openqa.selenium.logging.LogEntries; import org.openqa.selenium.logging.LogEntry; import org.openqa.selenium.logging.LogLevelMapping; -import org.openqa.selenium.logging.LogType; import org.openqa.selenium.logging.Logs; @Beta @@ -44,64 +35,16 @@ public class RemoteLogs implements Logs { private static final String TIMESTAMP = "timestamp"; private static final String MESSAGE = "message"; - private static final Logger LOG = Logger.getLogger(RemoteLogs.class.getName()); - protected ExecuteMethod executeMethod; public static final String TYPE_KEY = "type"; - @Nullable private final LocalLogs localLogs; public RemoteLogs(ExecuteMethod executeMethod) { this.executeMethod = executeMethod; - this.localLogs = null; - } - - /** - * @deprecated logging is not in the W3C WebDriver spec and LocalLogs are no longer supported. Use - * {@link #RemoteLogs(ExecuteMethod)} instead. - */ - @Deprecated(forRemoval = true) - public RemoteLogs(ExecuteMethod executeMethod, LocalLogs localLogs) { - this.executeMethod = executeMethod; - this.localLogs = localLogs; } @Override - @SuppressWarnings("deprecation") public LogEntries get(String logType) { - if (LogType.CLIENT.equals(logType)) { - LOG.warning( - "LogType.CLIENT is deprecated and not part of the W3C WebDriver specification. " - + "Returning empty log entries."); - if (localLogs != null) { - return getLocalEntries(logType); - } - return new LogEntries(Collections.emptyList()); - } - if (LogType.PROFILER.equals(logType)) { - LOG.warning( - "LogType.PROFILER is deprecated and not part of the W3C WebDriver specification. " - + "Returning empty log entries."); - if (localLogs != null) { - LogEntries remoteEntries = new LogEntries(new ArrayList<>()); - try { - remoteEntries = getRemoteEntries(logType); - } catch (WebDriverException e) { - // An exception may be thrown if the WebDriver server does not recognize profiler logs. - // In this case, the user should be able to see the local profiler logs. - LOG.log( - Level.WARNING, "Remote profiler logs are not available and have been omitted.", e); - } - return LogCombiner.combine(remoteEntries, getLocalEntries(logType)); - } - return new LogEntries(Collections.emptyList()); - } - if (LogType.SERVER.equals(logType)) { - LOG.warning( - "LogType.SERVER is deprecated. Selenium Grid no longer supports server logs. " - + "Returning empty log entries."); - return new LogEntries(Collections.emptyList()); - } return getRemoteEntries(logType); } @@ -125,34 +68,9 @@ private LogEntry createLogEntry(Map obj) { (String) obj.get(MESSAGE)); } - /** - * @deprecated logging is not in the W3C WebDriver spec and LocalLogs are no longer supported. - */ - @Deprecated(forRemoval = true) - private LogEntries getLocalEntries(String logType) { - if (localLogs == null) { - return new LogEntries(Collections.emptyList()); - } - return localLogs.get(logType); - } - - /** - * @deprecated logging is not in the W3C WebDriver spec and LocalLogs are no longer supported. - */ - @Deprecated(forRemoval = true) - private Set getAvailableLocalLogs() { - if (localLogs == null) { - return Collections.emptySet(); - } - return localLogs.getAvailableLogTypes(); - } - @Override public Set getAvailableLogTypes() { List rawList = executeMethod.execute(DriverCommand.GET_AVAILABLE_LOG_TYPES); - Set builder = new LinkedHashSet<>(); - builder.addAll(rawList); - builder.addAll(getAvailableLocalLogs()); - return Set.copyOf(builder); + return Set.copyOf(new LinkedHashSet<>(rawList)); } } diff --git a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java index ab6cb2de68e4c..bce20adce45ee 100644 --- a/java/src/org/openqa/selenium/remote/RemoteWebDriver.java +++ b/java/src/org/openqa/selenium/remote/RemoteWebDriver.java @@ -87,10 +87,7 @@ import org.openqa.selenium.internal.Debug; import org.openqa.selenium.internal.Require; import org.openqa.selenium.io.Zip; -import org.openqa.selenium.logging.LocalLogs; -import org.openqa.selenium.logging.LoggingHandler; import org.openqa.selenium.logging.Logs; -import org.openqa.selenium.logging.NeedsLocalLogs; import org.openqa.selenium.print.PrintOptions; import org.openqa.selenium.remote.http.ClientConfig; import org.openqa.selenium.remote.http.ConnectionFailedException; @@ -141,9 +138,6 @@ public class RemoteWebDriver private final Logs remoteLogs = new RemoteLogs(executeMethod); - @SuppressWarnings("deprecation") - private LocalLogs localLogs; - @Nullable private Script remoteScript; @Nullable private Network remoteNetwork; @@ -152,7 +146,6 @@ public class RemoteWebDriver @SuppressWarnings("DataFlowIssue") protected RemoteWebDriver() { this.capabilities = new ImmutableCapabilities(); - this.localLogs = initLocalLogs(); this.clientConfig = ClientConfig.defaultConfig(); this.executor = null; } @@ -197,7 +190,6 @@ public RemoteWebDriver( clientConfig); } - @SuppressWarnings("deprecation") public RemoteWebDriver(CommandExecutor executor, Capabilities capabilities) { this(executor, capabilities, ClientConfig.defaultConfig()); } @@ -207,11 +199,6 @@ public RemoteWebDriver( this.clientConfig = Require.nonNull("Client config", clientConfig); this.executor = Require.nonNull("Command executor", executor); this.capabilities = requireNonNullElseGet(capabilities, () -> new ImmutableCapabilities()); - this.localLogs = initLocalLogs(); - - if (executor instanceof NeedsLocalLogs) { - ((NeedsLocalLogs) executor).setLocalLogs(localLogs); - } try { startSession(capabilities); @@ -255,18 +242,6 @@ public static RemoteWebDriverBuilder builder() { return new RemoteWebDriverBuilder(); } - @SuppressWarnings("deprecation") - private static LocalLogs initLocalLogs() { - LOG.addHandler(LoggingHandler.getInstance()); - - Set logTypesToIgnore = Set.of(); - - LocalLogs performanceLogger = LocalLogs.getStoringLoggerInstance(logTypesToIgnore); - LocalLogs clientLogs = - LocalLogs.getHandlerBasedLoggerInstance(LoggingHandler.getInstance(), logTypesToIgnore); - return LocalLogs.getCombinedLogsHolder(clientLogs, performanceLogger); - } - @Nullable public SessionId getSessionId() { return sessionId; diff --git a/java/src/org/openqa/selenium/remote/TracedCommandExecutor.java b/java/src/org/openqa/selenium/remote/TracedCommandExecutor.java index 960ea7f8e1501..89a51edfd2cbb 100644 --- a/java/src/org/openqa/selenium/remote/TracedCommandExecutor.java +++ b/java/src/org/openqa/selenium/remote/TracedCommandExecutor.java @@ -20,12 +20,10 @@ import java.io.IOException; import java.util.Map; import java.util.Objects; -import org.openqa.selenium.logging.LocalLogs; -import org.openqa.selenium.logging.NeedsLocalLogs; import org.openqa.selenium.remote.tracing.Span; import org.openqa.selenium.remote.tracing.Tracer; -public class TracedCommandExecutor implements CommandExecutor, NeedsLocalLogs { +public class TracedCommandExecutor implements CommandExecutor { private final CommandExecutor delegate; private final Tracer tracer; @@ -53,16 +51,4 @@ public Response execute(Command command) throws IOException { return delegate.execute(command); } } - - /** - * @deprecated logging is not in the W3C WebDriver spec and LocalLogs are no longer supported. - */ - @Override - @Deprecated(forRemoval = true) - @SuppressWarnings("deprecation") - public void setLocalLogs(LocalLogs logs) { - if (delegate instanceof NeedsLocalLogs) { - ((NeedsLocalLogs) delegate).setLocalLogs(logs); - } - } } diff --git a/java/test/org/openqa/selenium/json/JsonOutputTest.java b/java/test/org/openqa/selenium/json/JsonOutputTest.java index 1690ebf7e49e6..0c9c06532bb6d 100644 --- a/java/test/org/openqa/selenium/json/JsonOutputTest.java +++ b/java/test/org/openqa/selenium/json/JsonOutputTest.java @@ -30,9 +30,7 @@ import static org.openqa.selenium.internal.Sets.sortedSetOf; import static org.openqa.selenium.json.Json.MAP_TYPE; import static org.openqa.selenium.logging.LogType.BROWSER; -import static org.openqa.selenium.logging.LogType.CLIENT; import static org.openqa.selenium.logging.LogType.DRIVER; -import static org.openqa.selenium.logging.LogType.SERVER; import com.google.gson.JsonArray; import com.google.gson.JsonObject; @@ -488,22 +486,17 @@ void properlyConvertsNulls() { } @Test - @SuppressWarnings("deprecation") void convertLoggingPreferencesToJson() { LoggingPreferences prefs = new LoggingPreferences(); prefs.enable(LogType.BROWSER, Level.WARNING); - prefs.enable(LogType.CLIENT, Level.FINE); prefs.enable(LogType.DRIVER, Level.ALL); - prefs.enable(LogType.SERVER, Level.OFF); String json = convert(prefs); JsonObject converted = JsonParser.parseString(json).getAsJsonObject(); assertThat(converted.get(BROWSER).getAsString()).isEqualTo("WARNING"); - assertThat(converted.get(CLIENT).getAsString()).isEqualTo("DEBUG"); assertThat(converted.get(DRIVER).getAsString()).isEqualTo("ALL"); - assertThat(converted.get(SERVER).getAsString()).isEqualTo("OFF"); } @Test diff --git a/java/test/org/openqa/selenium/logging/AvailableLogsTest.java b/java/test/org/openqa/selenium/logging/AvailableLogsTest.java index 0e10eeca6fb9b..875ea54a55cea 100644 --- a/java/test/org/openqa/selenium/logging/AvailableLogsTest.java +++ b/java/test/org/openqa/selenium/logging/AvailableLogsTest.java @@ -40,16 +40,6 @@ void browserLogShouldBeEnabledByDefault() { .contains(LogType.BROWSER); } - @Test - @SuppressWarnings("deprecation") - void clientLogIsDeprecatedAndReturnsEmpty() { - driver.get(pages.formPage); - LogEntries clientLogs = driver.manage().logs().get(LogType.CLIENT); - assertThat(clientLogs.getAll()) - .describedAs("Client logs should be empty (deprecated)") - .isEmpty(); - } - @Test void driverLogShouldBeEnabledByDefault() { Set logTypes = driver.manage().logs().getAvailableLogTypes(); @@ -57,24 +47,4 @@ void driverLogShouldBeEnabledByDefault() { .describedAs("Remote driver logs should be enabled by default") .contains(LogType.DRIVER); } - - @Test - @SuppressWarnings("deprecation") - void profilerLogIsDeprecatedAndReturnsEmpty() { - // PROFILER log type is deprecated and no longer functional - LogEntries profilerLogs = driver.manage().logs().get(LogType.PROFILER); - assertThat(profilerLogs.getAll()) - .describedAs("Profiler logs should be empty (deprecated)") - .isEmpty(); - } - - @Test - @SuppressWarnings("deprecation") - void serverLogIsDeprecatedAndReturnsEmpty() { - // SERVER log type is deprecated - Grid no longer supports it - LogEntries serverLogs = driver.manage().logs().get(LogType.SERVER); - assertThat(serverLogs.getAll()) - .describedAs("Server logs should be empty (deprecated)") - .isEmpty(); - } } diff --git a/java/test/org/openqa/selenium/logging/BUILD.bazel b/java/test/org/openqa/selenium/logging/BUILD.bazel index ca046b0eba537..38e14dc58447d 100644 --- a/java/test/org/openqa/selenium/logging/BUILD.bazel +++ b/java/test/org/openqa/selenium/logging/BUILD.bazel @@ -2,7 +2,6 @@ load("//java:defs.bzl", "JUNIT5_DEPS", "artifact", "java_selenium_test_suite", " SMALL_TEST_SRCS = [ "LoggingTest.java", - "PerformanceLoggingMockTest.java", ] java_test_suite( diff --git a/java/test/org/openqa/selenium/logging/PerformanceLoggingMockTest.java b/java/test/org/openqa/selenium/logging/PerformanceLoggingMockTest.java deleted file mode 100644 index d333f4a085cfd..0000000000000 --- a/java/test/org/openqa/selenium/logging/PerformanceLoggingMockTest.java +++ /dev/null @@ -1,57 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import static java.util.Collections.singleton; -import static org.assertj.core.api.Assertions.assertThat; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import org.junit.jupiter.api.Test; -import org.openqa.selenium.remote.DriverCommand; -import org.openqa.selenium.remote.ExecuteMethod; -import org.openqa.selenium.remote.RemoteLogs; - -@SuppressWarnings("deprecation") -class PerformanceLoggingMockTest { - - @Test - void testMergesRemoteLogs() { - // This test verifies the deprecated LocalLogs behavior for backwards compatibility - final ExecuteMethod executeMethod = mock(ExecuteMethod.class); - - when(executeMethod.execute( - DriverCommand.GET_LOG, Map.of(RemoteLogs.TYPE_KEY, LogType.PROFILER))) - .thenReturn( - List.of(Map.of("level", Level.INFO.getName(), "timestamp", 1L, "message", "second"))); - - LocalLogs localLogs = LocalLogs.getStoringLoggerInstance(singleton(LogType.PROFILER)); - RemoteLogs logs = new RemoteLogs(executeMethod, localLogs); - localLogs.addEntry(LogType.PROFILER, new LogEntry(Level.INFO, 0, "first")); - localLogs.addEntry(LogType.PROFILER, new LogEntry(Level.INFO, 2, "third")); - - List entries = logs.get(LogType.PROFILER).getAll(); - assertThat(entries).hasSize(3); - for (int i = 0; i < entries.size(); ++i) { - assertThat(entries.get(i).getTimestamp()).isEqualTo(i); - } - } -} diff --git a/java/test/org/openqa/selenium/logging/PerformanceLoggingTest.java b/java/test/org/openqa/selenium/logging/PerformanceLoggingTest.java deleted file mode 100644 index 497d15e311511..0000000000000 --- a/java/test/org/openqa/selenium/logging/PerformanceLoggingTest.java +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed to the Software Freedom Conservancy (SFC) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The SFC licenses this file -// to you 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 org.openqa.selenium.logging; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.openqa.selenium.testing.drivers.Browser.FIREFOX; -import static org.openqa.selenium.testing.drivers.Browser.IE; -import static org.openqa.selenium.testing.drivers.Browser.SAFARI; - -import org.junit.jupiter.api.Test; -import org.openqa.selenium.WebDriver; -import org.openqa.selenium.testing.Ignore; -import org.openqa.selenium.testing.JupiterTestBase; - -@Ignore(IE) -@Ignore(SAFARI) -@Ignore(FIREFOX) -class PerformanceLoggingTest extends JupiterTestBase { - - @Test - @SuppressWarnings("deprecation") - void testProfilerLogIsDeprecatedAndReturnsEmpty() { - // PROFILER log type is deprecated and no longer functional - driver.get(pages.simpleTestPage); - assertThat(getProfilerEntries(driver).getAll()) - .describedAs("Profiler logs should be empty (deprecated)") - .isEmpty(); - } - - @SuppressWarnings("deprecation") - private LogEntries getProfilerEntries(WebDriver driver) { - return driver.manage().logs().get(LogType.PROFILER); - } -} diff --git a/java/test/org/openqa/selenium/remote/RemoteLogsTest.java b/java/test/org/openqa/selenium/remote/RemoteLogsTest.java index 39631bbabd5c0..5d690d52b59db 100644 --- a/java/test/org/openqa/selenium/remote/RemoteLogsTest.java +++ b/java/test/org/openqa/selenium/remote/RemoteLogsTest.java @@ -20,10 +20,8 @@ import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import java.util.ArrayList; import java.util.List; import java.util.Map; import java.util.Set; @@ -34,85 +32,31 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.openqa.selenium.WebDriverException; -import org.openqa.selenium.logging.LocalLogs; import org.openqa.selenium.logging.LogEntries; -import org.openqa.selenium.logging.LogEntry; import org.openqa.selenium.logging.LogType; @Tag("UnitTests") -@SuppressWarnings("deprecation") class RemoteLogsTest { @Mock private ExecuteMethod executeMethod; - @Mock private LocalLogs localLogs; - private RemoteLogs remoteLogs; @BeforeEach public void createMocksAndRemoteLogs() { MockitoAnnotations.initMocks(this); - remoteLogs = new RemoteLogs(executeMethod, localLogs); + remoteLogs = new RemoteLogs(executeMethod); } @Test - void canGetProfilerLogs() { - List entries = new ArrayList<>(); - entries.add(new LogEntry(Level.INFO, 0, "hello")); - when(localLogs.get(LogType.PROFILER)).thenReturn(new LogEntries(entries)); - - when(executeMethod.execute( - DriverCommand.GET_LOG, Map.of(RemoteLogs.TYPE_KEY, LogType.PROFILER))) + void canGetBrowserLogs() { + when(executeMethod.execute(DriverCommand.GET_LOG, Map.of(RemoteLogs.TYPE_KEY, LogType.BROWSER))) .thenReturn( singletonList( - Map.of("level", Level.INFO.getName(), "timestamp", 1L, "message", "world"))); - - LogEntries logEntries = remoteLogs.get(LogType.PROFILER); - List allLogEntries = logEntries.getAll(); - assertThat(allLogEntries).hasSize(2); - assertThat(allLogEntries.get(0).getMessage()).isEqualTo("hello"); - assertThat(allLogEntries.get(1).getMessage()).isEqualTo("world"); - } - - @Test - void canGetLocalProfilerLogsIfNoRemoteProfilerLogSupport() { - List entries = new ArrayList<>(); - entries.add(new LogEntry(Level.INFO, 0, "hello")); - when(localLogs.get(LogType.PROFILER)).thenReturn(new LogEntries(entries)); - - when(executeMethod.execute( - DriverCommand.GET_LOG, Map.of(RemoteLogs.TYPE_KEY, LogType.PROFILER))) - .thenThrow( - new WebDriverException("IGNORE THIS LOG MESSAGE AND STACKTRACE; IT IS EXPECTED.")); - - LogEntries logEntries = remoteLogs.get(LogType.PROFILER); - List allLogEntries = logEntries.getAll(); - assertThat(allLogEntries).hasSize(1); - assertThat(allLogEntries.get(0).getMessage()).isEqualTo("hello"); - } + Map.of("level", Level.INFO.getName(), "timestamp", 1L, "message", "hello"))); - @Test - void canGetClientLogs() { - List entries = new ArrayList<>(); - entries.add(new LogEntry(Level.SEVERE, 0, "hello")); - when(localLogs.get(LogType.CLIENT)).thenReturn(new LogEntries(entries)); - - LogEntries logEntries = remoteLogs.get(LogType.CLIENT); + LogEntries logEntries = remoteLogs.get(LogType.BROWSER); assertThat(logEntries.getAll()).hasSize(1); assertThat(logEntries.getAll().get(0).getMessage()).isEqualTo("hello"); - - // Client logs should not retrieve remote logs. - verifyNoMoreInteractions(executeMethod); - } - - @Test - void serverLogsAreDeprecatedAndReturnEmpty() { - // SERVER log type is deprecated - Grid no longer supports it - LogEntries logEntries = remoteLogs.get(LogType.SERVER); - assertThat(logEntries.getAll()).isEmpty(); - - // Should not call executeMethod or localLogs since SERVER is intercepted - verifyNoMoreInteractions(executeMethod); - verifyNoMoreInteractions(localLogs); } @Test @@ -126,22 +70,16 @@ void throwsOnBogusRemoteLogsResponse() { assertThatExceptionOfType(WebDriverException.class) .isThrownBy(() -> remoteLogs.get(LogType.BROWSER)); - - verifyNoMoreInteractions(localLogs); } @Test void canGetAvailableLogTypes() { - List remoteAvailableLogTypes = List.of(LogType.PROFILER, LogType.SERVER); + List remoteAvailableLogTypes = List.of(LogType.BROWSER, LogType.DRIVER); when(executeMethod.execute(DriverCommand.GET_AVAILABLE_LOG_TYPES)) .thenReturn(remoteAvailableLogTypes); - Set localAvailableLogTypes = Set.of(LogType.PROFILER, LogType.CLIENT); - when(localLogs.getAvailableLogTypes()).thenReturn(localAvailableLogTypes); - Set availableLogTypes = remoteLogs.getAvailableLogTypes(); - assertThat(availableLogTypes) - .containsExactlyInAnyOrder(LogType.CLIENT, LogType.PROFILER, LogType.SERVER); + assertThat(availableLogTypes).containsExactlyInAnyOrder(LogType.BROWSER, LogType.DRIVER); } }