Skip to content

Commit

Permalink
springframeworkguru#7.2 : assignment adding properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Michiel Van Huyck committed Sep 20, 2022
1 parent 21eac3c commit 39fd847
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Created by jt on 2019-02-18.
*/
@Component
@Profile("externalized")
@Profile({"externalized", "laurel-properties"})
@Primary
public class PropertiesWordProducer implements WordProducer {

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/laurel.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
say.word=LAUrel
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package org.springframework.samples.petclinic.sfg.junit5;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.samples.petclinic.sfg.HearingInterpreter;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

import static org.junit.jupiter.api.Assertions.assertEquals;

/**
* Created by jt on 2019-02-18.
*/
@TestPropertySource("classpath:laurel.properties")
@ActiveProfiles("laurel-properties")
@SpringJUnitConfig(classes = PropertiesLaurelTest.TestConfig.class)
public class PropertiesLaurelTest {

@Configuration
@ComponentScan("org.springframework.samples.petclinic.sfg")
static class TestConfig {

}

@Autowired
HearingInterpreter hearingInterpreter;

@Test
void whatIheard() {
String word = hearingInterpreter.whatIheard();

assertEquals("LAUrel", word);
}
}

0 comments on commit 39fd847

Please sign in to comment.