Skip to content

Commit

Permalink
Replace deprecated MediaType.fullType() on MediaType.text() (helidon-…
Browse files Browse the repository at this point in the history
  • Loading branch information
Captain1653 authored and hrstoyanov committed Feb 23, 2024
1 parent 10e007b commit 567074f
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -44,6 +44,6 @@ static MediaType parse(String fullType, ParserMode parserMode) {

@Override
public String toString() {
return fullType();
return text();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -79,7 +79,7 @@ void testAllConstantsAreValid() throws NoSuchFieldException, IllegalAccessExcept

assertAll(
() -> assertThat(value, notNullValue()),
() -> assertThat(value.fullType(), notNullValue()),
() -> assertThat(value.text(), notNullValue()),
() -> assertThat(value.subtype(), notNullValue()),
() -> assertThat(value.type(), notNullValue())
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2022 Oracle and/or its affiliates.
* Copyright (c) 2019, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -72,7 +72,7 @@ public void testDataTimestamp() throws IOException {
.match(method(GET), uri("/application.properties"))
.then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT"),
stringContent(TEST_CONFIG)
);
Expand All @@ -98,7 +98,7 @@ public void testDoNotReloadSameContent() throws IOException {
match(method(HEAD), uri("/application.properties")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT"),
stringContent(TEST_CONFIG)
);
Expand All @@ -107,7 +107,7 @@ public void testDoNotReloadSameContent() throws IOException {
match(get("/application.properties")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT"),
stringContent(TEST_CONFIG)
);
Expand Down Expand Up @@ -139,7 +139,7 @@ public void testDoReloadChangedContent() throws IOException {
match(method(HEAD), uri("/application.properties")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT"),
stringContent(TEST_CONFIG)
);
Expand All @@ -148,7 +148,7 @@ public void testDoReloadChangedContent() throws IOException {
match(get("/application.properties")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT"),
stringContent(TEST_CONFIG)
);
Expand All @@ -166,7 +166,7 @@ public void testDoReloadChangedContent() throws IOException {
match(method(HEAD), uri("/application.properties")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:03 GMT"),
stringContent(TEST_CONFIG)
);
Expand All @@ -192,7 +192,7 @@ public void testContentMediaTypeSet() throws IOException {
match(get("/application.properties")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(TEST_CONFIG)
);

Expand All @@ -218,7 +218,7 @@ public void testContentMediaTypeFromResponse() throws IOException {
match(get("/application.properties")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(TEST_CONFIG)
);

Expand All @@ -243,7 +243,7 @@ public void testContentMediaTypeGuessed() throws IOException {
match(get("/application.properties")).
then(
status(OK_200),
contentType(TEST_MEDIA_TYPE.fullType()),
contentType(TEST_MEDIA_TYPE.text()),
stringContent(TEST_CONFIG)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, 2023 Oracle and/or its affiliates.
* Copyright (c) 2020, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -85,14 +85,14 @@ public void testWildcards() throws MalformedURLException, InterruptedException {
match(method(HEAD), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT")
);
whenHttp(server).
match(method(GET), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT"),
stringContent(WILDCARDS)
);
Expand All @@ -118,14 +118,14 @@ public void testMultipleMatchingWildcards() throws MalformedURLException, Interr
match(method(HEAD), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT")
);
whenHttp(server).
match(method(GET), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT"),
stringContent(MULTIPLE_WILDCARDS)
);
Expand All @@ -150,14 +150,14 @@ public void testMultipleMatchingWildcardsAnotherOrdering() throws MalformedURLEx
match(method(HEAD), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT")
);
whenHttp(server).
match(method(GET), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
header("Last-Modified", "Sat, 10 Jun 2017 10:14:02 GMT"),
stringContent(MULTIPLE_WILDCARDS_ANOTHER_ORDERING)
);
Expand All @@ -182,15 +182,15 @@ public void testWildcardsChanges() throws MalformedURLException {
match(method(GET), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(WILDCARDS)
);

whenHttp(server).
match(method(GET), uri("/config")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(CONFIG)
);

Expand All @@ -213,7 +213,7 @@ public void testWildcardsChanges() throws MalformedURLException {
match(method(GET), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(NEW_WILDCARDS)
);

Expand All @@ -232,15 +232,15 @@ public void testWildcardsSupplier() throws MalformedURLException, InterruptedExc
match(method(GET), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(WILDCARDS)
);

whenHttp(server).
match(method(GET), uri("/config")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(CONFIG)
);

Expand All @@ -259,7 +259,7 @@ public void testWildcardsSupplier() throws MalformedURLException, InterruptedExc
match(custom(call -> call.getMethod().equals(GET) || call.getMethod().equals(HEAD)), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(NO_WILDCARDS)
);

Expand All @@ -274,15 +274,15 @@ public void testConfigChangingWithOverrideSource() throws MalformedURLException,
match(method(GET), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(WILDCARDS)
);

whenHttp(server).
match(method(GET), uri("/config")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(CONFIG)
);

Expand All @@ -303,7 +303,7 @@ public void testConfigChangingWithOverrideSource() throws MalformedURLException,
match(method(GET), uri("/config")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(CONFIG2)
);

Expand All @@ -318,15 +318,15 @@ public void testConfigChangingWithFilters() throws MalformedURLException, Interr
match(method(GET), uri("/override")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(WILDCARDS)
);

whenHttp(server).
match(method(GET), uri("/config")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(CONFIG)
);

Expand All @@ -350,7 +350,7 @@ public void testConfigChangingWithFilters() throws MalformedURLException, Interr
match(method(GET), uri("/config")).
then(
status(OK_200),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.fullType()),
contentType(MEDIA_TYPE_TEXT_JAVA_PROPERTIES.text()),
stringContent(CONFIG2)
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, 2023 Oracle and/or its affiliates.
* Copyright (c) 2022, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -107,7 +107,7 @@ public boolean test(MediaType mediaType) {

@Override
public String text() {
StringBuilder result = new StringBuilder(mediaType.fullType());
StringBuilder result = new StringBuilder(mediaType.text());
for (Map.Entry<String, String> param : parameters.entrySet()) {
result.append("; ")
.append(param.getKey())
Expand Down

0 comments on commit 567074f

Please sign in to comment.