File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public class RepertoireCommune {
3939 private static final Log log = LogFactory .getLog (RepertoireCommune .class );
4040
4141 private RepertoireCommune () {
42- throw new IllegalStateException ("Class utilitaire" );
42+ throw new IllegalStateException ("Classe utilitaire" );
4343 }
4444
4545 private static final List <Commune > COMMUNES = initCommunes ();
Original file line number Diff line number Diff line change 11package fr .france ;
22
3+ import java .lang .reflect .InvocationTargetException ;
4+ import java .lang .reflect .Constructor ;
35import java .util .Collections ;
46import java .util .List ;
57
911
1012class RepertoireCommuneTest {
1113
14+ @ Test
15+ void test_ConstructionJetteIllegalStateException () throws NoSuchMethodException {
16+ Constructor <RepertoireCommune > constructor = RepertoireCommune .class .getDeclaredConstructor ();
17+ constructor .setAccessible (true );
18+
19+ // On vérifie qu'il jette une erreur
20+ assertThrows (InvocationTargetException .class , constructor ::newInstance );
21+ try {
22+ constructor .newInstance ();
23+ } catch (InvocationTargetException | InstantiationException | IllegalAccessException e ) {
24+ // On vérifie que la cause est bien une IllegalStateException
25+ assertEquals ("java.lang.IllegalStateException: Classe utilitaire" , e .getCause ().toString ());
26+ }
27+ }
28+
1229 @ Test
1330 void test_CommunesInitialise () {
1431 assertNotEquals (Collections .emptyList (), RepertoireCommune .getCommunes ());
You can’t perform that action at this time.
0 commit comments