-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
166,319 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
model/src/main/java/io/wcm/devops/conga/model/util/YamlUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* #%L | ||
* wcm.io | ||
* %% | ||
* Copyright (C) 2023 wcm.io | ||
* %% | ||
* Licensed 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. | ||
* #L% | ||
*/ | ||
package io.wcm.devops.conga.model.util; | ||
|
||
import org.yaml.snakeyaml.LoaderOptions; | ||
|
||
/** | ||
* Helper methods for SnakeYAML. | ||
*/ | ||
public final class YamlUtil { | ||
|
||
/* | ||
* Increase default codepoint limit from 3MB to 64MB. | ||
*/ | ||
private static final int YAML_CODEPOINT_LIMIT = 64 * 1024 * 1024; | ||
|
||
private YamlUtil() { | ||
// static methods only | ||
} | ||
|
||
/** | ||
* Create a new loader options instances with default configuration. | ||
* @return SnakeYAML loader option.s | ||
*/ | ||
public static LoaderOptions createLoaderOptions() { | ||
LoaderOptions options = new LoaderOptions(); | ||
options.setCodePointLimit(YAML_CODEPOINT_LIMIT); | ||
return options; | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
model/src/test/java/io/wcm/devops/conga/model/util/YamlUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* #%L | ||
* wcm.io | ||
* %% | ||
* Copyright (C) 2023 wcm.io | ||
* %% | ||
* Licensed 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. | ||
* #L% | ||
*/ | ||
package io.wcm.devops.conga.model.util; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.yaml.snakeyaml.Yaml; | ||
|
||
class YamlUtilTest { | ||
|
||
@Test | ||
void testLoadSmallYamlFile() throws IOException { | ||
Yaml yaml = new Yaml(YamlUtil.createLoaderOptions()); | ||
try (InputStream is = YamlUtilTest.class.getResourceAsStream("/role.yaml")) { | ||
assertNotNull(yaml.load(is)); | ||
} | ||
} | ||
|
||
@Test | ||
void testLoadHugeYamlFile() throws IOException { | ||
Yaml yaml = new Yaml(YamlUtil.createLoaderOptions()); | ||
try (InputStream is = YamlUtilTest.class.getResourceAsStream("/hugefile.yaml")) { | ||
assertNotNull(yaml.load(is)); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.