Skip to content

Commit

Permalink
Drop dependency to jguru-shared-algorithms-api and replace usages of …
Browse files Browse the repository at this point in the history
…PropertyResources
  • Loading branch information
slachiewicz committed Apr 14, 2024
1 parent f7ba1bf commit 66c9257
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 15 deletions.
11 changes: 3 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,6 @@
<version>${jaxb.version}</version>
</dependency>

<dependency>
<groupId>se.jguru.shared.algorithms.api</groupId>
<artifactId>jguru-shared-algorithms-api</artifactId>
<version>0.12.0</version>
</dependency>

<dependency>
<groupId>org.jvnet.staxex</groupId>
<artifactId>stax-ex</artifactId>
Expand Down Expand Up @@ -258,8 +252,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>se.jguru.shared.algorithms.api</groupId>
<artifactId>jguru-shared-algorithms-api</artifactId>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.16.1</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
36 changes: 36 additions & 0 deletions src/test/java/org/codehaus/mojo/jaxb2/PropertyResources.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.codehaus.mojo.jaxb2;

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF 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.
*/

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

import static java.nio.charset.StandardCharsets.UTF_8;

public class PropertyResources {

public static String readFully(String s) throws IOException {
File file =
new File(PropertyResources.class.getClassLoader().getResource(s).getFile());
return FileUtils.readFileToString(file, UTF_8);
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.codehaus.mojo.jaxb2.schemageneration.postprocessing;

import java.io.File;
import java.io.IOException;
import java.io.StringReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.codehaus.mojo.jaxb2.BufferingLog;
import org.codehaus.mojo.jaxb2.PropertyResources;
import org.codehaus.mojo.jaxb2.schemageneration.XsdGeneratorHelper;
import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.JavaDocExtractor;
import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.SearchableDocumentation;
Expand All @@ -17,7 +19,6 @@
import org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter;
import org.junit.jupiter.api.BeforeEach;
import org.w3c.dom.Document;
import se.jguru.shared.algorithms.api.resources.PropertyResources;

import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand Down Expand Up @@ -84,7 +85,7 @@ protected SearchableDocumentation processSources() {
return extractor.process();
}

protected Document createDocumentFrom(final String resource) {
protected Document createDocumentFrom(final String resource) throws IOException {

// Check sanity
Validate.notEmpty(resource, "resource");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import org.apache.maven.plugin.MojoExecutionException;
import org.codehaus.mojo.jaxb2.BufferingLog;
import org.codehaus.mojo.jaxb2.PropertyResources;
import org.codehaus.mojo.jaxb2.schemageneration.XsdGeneratorHelper;
import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.AbstractSourceCodeAwareNodeProcessingTest;
import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.JavaDocExtractor;
Expand All @@ -39,7 +40,6 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import se.jguru.shared.algorithms.api.resources.PropertyResources;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import java.util.Map;
import java.util.TreeMap;

import org.codehaus.mojo.jaxb2.PropertyResources;
import org.codehaus.mojo.jaxb2.schemageneration.XsdGeneratorHelper;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import se.jguru.shared.algorithms.api.resources.PropertyResources;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.Marshaller;
import org.codehaus.mojo.jaxb2.PropertyResources;
import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.AbstractSourceCodeAwareNodeProcessingTest;
import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.JavaDocRenderer;
import org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.NoAuthorJavaDocRenderer;
Expand All @@ -17,7 +18,6 @@
import org.w3c.dom.Node;
import org.xmlunit.builder.DiffBuilder;
import org.xmlunit.diff.Diff;
import se.jguru.shared.algorithms.api.resources.PropertyResources;

import static org.junit.jupiter.api.Assertions.assertFalse;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@

import org.codehaus.mojo.jaxb2.AbstractJaxbMojo;
import org.codehaus.mojo.jaxb2.BufferingLog;
import org.codehaus.mojo.jaxb2.PropertyResources;
import org.codehaus.mojo.jaxb2.shared.filters.Filter;
import org.codehaus.mojo.jaxb2.shared.filters.Filters;
import org.codehaus.mojo.jaxb2.shared.filters.pattern.PatternFileFilter;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import se.jguru.shared.algorithms.api.resources.PropertyResources;

import static org.junit.jupiter.api.Assertions.*;

Expand Down Expand Up @@ -381,7 +381,7 @@ void validateGettingFileForClassURL() {

// Assemble
final URL streamingDhURL =
PropertyResources.class.getProtectionDomain().getCodeSource().getLocation();
Test.class.getProtectionDomain().getCodeSource().getLocation();
assertNotNull(streamingDhURL);

// Act
Expand Down

0 comments on commit 66c9257

Please sign in to comment.