| /*=============================================================================# |
| # Copyright (c) 2019, 2020 Stephan Wahlbrink <sw@wahlbrink.eu> and others. |
| # |
| # This program and the accompanying materials are made available under the |
| # terms of the Eclipse Public License 2.0 which is available at |
| # https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 |
| # which is available at https://www.apache.org/licenses/LICENSE-2.0. |
| # |
| # SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 |
| # |
| # Contributors: |
| # Stephan Wahlbrink <sw@wahlbrink.eu> - initial API and implementation |
| #=============================================================================*/ |
| |
| package org.eclipse.statet.internal.rhelp.core.server; |
| |
| import static org.junit.jupiter.api.Assertions.assertEquals; |
| import static org.junit.jupiter.api.Assertions.assertNotNull; |
| |
| import java.util.Arrays; |
| import java.util.List; |
| |
| import org.junit.jupiter.api.Test; |
| |
| import org.eclipse.statet.jcommons.lang.NonNullByDefault; |
| |
| import org.eclipse.statet.internal.rhelp.core.http.HttpHeaderUtils; |
| import org.eclipse.statet.internal.rhelp.core.http.HttpHeaderUtils.MediaTypeEntry; |
| import org.eclipse.statet.internal.rhelp.core.http.HttpHeaderUtils.ParseException; |
| |
| |
| @NonNullByDefault |
| public class ServerREnvHelpAccessTest { |
| |
| |
| public static String getVersionedDS_AccessHeader() { |
| return ServerREnvHelpAccess.DS_VERSIONED_ACCEPT_HEADER; |
| } |
| |
| public static String getModestDS_AccessHeader() { |
| return ServerREnvHelpAccess.DS_MODEST_ACCEPT_HEADER; |
| } |
| |
| |
| @Test |
| public void DS_VERSIONED_AcceptHeader_valid() throws ParseException { |
| final List<MediaTypeEntry> entries= HttpHeaderUtils.readMediaTypeEntries(Arrays.asList(getVersionedDS_AccessHeader()), null); |
| |
| for (final MediaTypeEntry entry : entries) { |
| assertEquals(ServerApi.APPLICATION_MEDIA_TYPE, entry.getType()); |
| assertEquals(ServerApi.DS_MEDIA_SUBTYPE, entry.getSubtype()); |
| assertNotNull(entry.getParameterValue(ServerApi.DS_SER_VERSION)); |
| } |
| } |
| |
| @Test |
| public void DS_MODEST_AcceptHeader_valid() throws ParseException { |
| final List<MediaTypeEntry> entries= HttpHeaderUtils.readMediaTypeEntries(Arrays.asList(getModestDS_AccessHeader()), null); |
| |
| for (final MediaTypeEntry entry : entries) { |
| assertEquals(ServerApi.APPLICATION_MEDIA_TYPE, entry.getType()); |
| assertEquals(ServerApi.DS_MEDIA_SUBTYPE, entry.getSubtype()); |
| } |
| } |
| |
| |
| } |