forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail at build time if SpEL is used in @value
Fixes: quarkusio#19368 (cherry picked from commit 224c9c1)
- Loading branch information
Showing
2 changed files
with
47 additions
and
1 deletion.
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
40 changes: 40 additions & 0 deletions
40
extensions/spring-di/deployment/src/test/java/io/quarkus/spring/di/deployment/SpelTest.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,40 @@ | ||
package io.quarkus.spring.di.deployment; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
import static org.junit.jupiter.api.Assertions.fail; | ||
|
||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
|
||
public class SpelTest { | ||
|
||
@RegisterExtension | ||
static final QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class).addClasses(SomeService.class)) | ||
.assertException(e -> { | ||
assertEquals(IllegalArgumentException.class, e.getClass()); | ||
assertTrue(e.getMessage().contains("#{'${values.list}'.split(',')}")); | ||
}); | ||
|
||
@Test | ||
public void shouldNotBeInvoked() { | ||
// This method should not be invoked | ||
fail(); | ||
} | ||
|
||
@Service | ||
public static class SomeService { | ||
|
||
@Value("#{'${values.list}'.split(',')}") | ||
List<String> fieldUsingList; // does not work | ||
} | ||
} |