-
-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a test to read the custom sort order file. Updated the fileUtil…
… tests
- Loading branch information
Showing
5 changed files
with
138 additions
and
8 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
58 changes: 58 additions & 0 deletions
58
sorter/src/test/java/sortpom/wrapper/CustomSortOrderFileTest.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,58 @@ | ||
package sortpom.wrapper; | ||
|
||
import org.apache.commons.io.IOUtils; | ||
import org.jdom.Document; | ||
import org.jdom.JDOMException; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import sortpom.parameter.PluginParameters; | ||
import sortpom.util.FileUtil; | ||
import sortpom.wrapper.operation.HierarchyRootWrapper; | ||
|
||
import java.io.FileInputStream; | ||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
/** | ||
* @author bjorn | ||
* @since 2018-04-12 | ||
*/ | ||
public class CustomSortOrderFileTest { | ||
private static final String UTF_8 = "UTF-8"; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
} | ||
|
||
@Test | ||
public void compareDefaultSortOrderFileToString() throws IOException, JDOMException { | ||
String expected = IOUtils.toString(new FileInputStream("src/test/resources/sortOrderFiles/with_newline_tagsToString.txt"), UTF_8); | ||
assertEquals(expected, getToStringOnCustomSortOrderFile()); | ||
} | ||
|
||
private String getToStringOnCustomSortOrderFile() throws IOException, JDOMException { | ||
PluginParameters pluginParameters = PluginParameters.builder() | ||
.setPomFile(null).setFileOutput(false, ".bak", null) | ||
.setEncoding("UTF-8") | ||
.setFormatting("\r\n", true, true) | ||
.setIndent(2, false) | ||
.setSortOrder("src/test/resources/sortOrderFiles/with_newline_tags.xml", null) | ||
.setSortEntities("scope,groupId,artifactId", "groupId,artifactId", true, true).build(); | ||
|
||
FileUtil fileUtil = new FileUtil(); | ||
fileUtil.setup(pluginParameters); | ||
|
||
WrapperFactoryImpl wrapperFactory = new WrapperFactoryImpl(fileUtil); | ||
|
||
Document documentFromDefaultSortOrderFile = wrapperFactory.createDocumentFromDefaultSortOrderFile(); | ||
new HierarchyRootWrapper(wrapperFactory.create(documentFromDefaultSortOrderFile.getRootElement())); | ||
|
||
HierarchyRootWrapper rootWrapper = new HierarchyRootWrapper(wrapperFactory.create(documentFromDefaultSortOrderFile.getRootElement())); | ||
rootWrapper.createWrappedStructure(wrapperFactory); | ||
|
||
return rootWrapper.toString(); | ||
} | ||
|
||
|
||
} |
21 changes: 21 additions & 0 deletions
21
sorter/src/test/resources/sortOrderFiles/with_newline_tags.xml
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,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | ||
<modelVersion/> | ||
<newLine/> | ||
<groupId/> | ||
<artifactId/> | ||
<version/> | ||
<newLine/> | ||
<name/> | ||
<url/> | ||
<dependencies> | ||
<dependency> | ||
<groupId/> | ||
<artifactId/> | ||
<version/> | ||
<classifier/> | ||
</dependency> | ||
<newLine/> | ||
</dependencies> | ||
</project> |
51 changes: 51 additions & 0 deletions
51
sorter/src/test/resources/sortOrderFiles/with_newline_tagsToString.txt
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,51 @@ | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <project [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
children= | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <modelVersion [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <newLine [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <groupId [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <artifactId [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <version [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <newLine [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <name [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <url [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <dependencies [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
children= | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <dependency [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
children= | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <groupId [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <artifactId [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <version [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <classifier [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
} | ||
HierarchyWrapper{ | ||
elementContent=UnsortedWrapper{content=[Element: <newLine [Namespace: http://maven.apache.org/POM/4.0.0]/>]} | ||
} | ||
} | ||
} |