2222import java .util .Optional ;
2323
2424import org .eclipse .aether .repository .RemoteRepository ;
25+ import org .junit .jupiter .api .Nested ;
2526import org .junit .jupiter .api .Test ;
2627
2728import org .springframework .boot .SpringBootVersion ;
29+ import org .springframework .boot .test .context .SpringBootTest ;
30+ import org .springframework .boot .test .web .server .LocalServerPort ;
31+ import org .springframework .experimental .boot .server .exec .imports .GenericSpringBootApplicationMain ;
32+ import org .springframework .test .context .TestPropertySource ;
2833
2934import static org .assertj .core .api .Assertions .assertThat ;
3035import static org .assertj .core .api .Assertions .assertThatNoException ;
@@ -98,18 +103,6 @@ void jdk() {
98103 // + configServerPartialPath)
99104 }
100105
101- @ Test
102- void resolveDependencyWhenCustomRepository () {
103- List <RemoteRepository > repositories = new ArrayList <>();
104- repositories .add (
105- new RemoteRepository .Builder ("central" , "default" , "https://repo.maven.apache.org/maven2/" ).build ());
106- repositories .add (new RemoteRepository .Builder ("sonatype-snapshot" , "default" ,
107- "https://oss.sonatype.org/content/repositories/snapshots/" ).build ());
108- MavenClasspathEntry classpathEntry = new MavenClasspathEntry ("org.junit:junit5-api:5.0.0-SNAPSHOT" ,
109- repositories );
110- assertThatNoException ().isThrownBy (() -> classpathEntry .resolve ());
111- }
112-
113106 @ Test
114107 void resolveDependencyWhenOrgSpringframeworkSnapshotThenDoesNotRequireCustomRepository () {
115108 MavenClasspathEntry classpathEntry = new MavenClasspathEntry ("org.springframework:spring-core:6.2.0-SNAPSHOT" );
@@ -128,4 +121,28 @@ void resolveDependencyWhenOrgSpringframeworkM1ThenDoesNotRequireCustomRepository
128121 assertThatNoException ().isThrownBy (() -> classpathEntry .resolve ());
129122 }
130123
124+ @ Nested
125+ @ SpringBootTest (webEnvironment = SpringBootTest .WebEnvironment .RANDOM_PORT ,
126+ classes = GenericSpringBootApplicationMain .class )
127+ @ TestPropertySource (
128+ properties = "spring.web.resources.static-locations=classpath:/org/springframework/experimental/boot/server/exec/maven/" )
129+ class MockRepositoryTests {
130+
131+ @ LocalServerPort
132+ int port ;
133+
134+ @ Test
135+ void resolveDependencyWhenCustomRepository () {
136+ List <RemoteRepository > repositories = new ArrayList <>();
137+ repositories .add (new RemoteRepository .Builder ("central" , "default" , "https://repo.maven.apache.org/maven2/" )
138+ .build ());
139+ repositories
140+ .add (new RemoteRepository .Builder ("custom" , "default" , "http://localhost:" + this .port ).build ());
141+ MavenClasspathEntry classpathEntry = new MavenClasspathEntry ("org.example:example-api:1.0.0-SNAPSHOT" ,
142+ repositories );
143+ assertThatNoException ().isThrownBy (() -> classpathEntry .resolve ());
144+ }
145+
146+ }
147+
131148}
0 commit comments