Skip to content

Commit

Permalink
Add indent test (failing)
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Feb 16, 2024
1 parent 1139d44 commit 1b3c0bd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/test/java/io/fabric8/maven/merge/SmartModelMergerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

import static org.assertj.core.api.Assertions.assertThat;

import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;

import io.fabric8.maven.Maven;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.Profile;
Expand Down Expand Up @@ -89,4 +93,28 @@ public void should_merge_profiles() {
assertThat(target.getProfiles().get(0).getModules()).containsExactly("A", "B", "C", "D", "E", "F");
}

@Test
void should_keep_target_indent_2() throws URISyntaxException {
ModelMerger merger = new SmartModelMerger();
final Model source = Maven.readModel(Paths.get(getClass().getResource("indent/source-pom.xml").toURI()));
final Path targetFile = Paths.get(getClass().getResource("indent/pom-2.xml").toURI());
final Model target = Maven.readModel(targetFile);
merger.merge(target, source, false, null);
Maven.writeModel(target, targetFile);
assertThat(targetFile).hasSameBinaryContentAs(Paths.get(getClass().getResource("indent/result-pom-2.xml").toURI()));
}

@Test
void should_keep_target_indent_4() throws URISyntaxException {
ModelMerger merger = new SmartModelMerger();
final Model source = Maven.readModel(Paths.get(getClass().getResource("indent/source-pom.xml").toURI()));
final Path targetFile = Paths.get(getClass().getResource("indent/pom-4.xml").toURI());
final Model target = Maven.readModel(targetFile);
merger.merge(target, source, true, null);
Maven.writeModel(target, targetFile);
assertThat(targetFile).hasSameBinaryContentAs(Paths.get(getClass().getResource("indent/result-pom-4.xml").toURI()));
}



}
15 changes: 15 additions & 0 deletions src/test/resources/io/fabric8/maven/merge/indent/source-pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?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/xsd/maven-4.0.0.xsd">
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model-builder</artifactId>
<version>3.5.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.5.4</version>
</dependency>
</dependencies>
</project>

0 comments on commit 1b3c0bd

Please sign in to comment.