mercredi 13 mars 2019

datajpatest + springframework test Sql encoding special characters fail on Windows

On Windows (+ Maven), I have a problem with é of Métro word. My sql file is encoded in UTF-8. I do dot have this problem on Unix server.

My JUnit code:

@RunWith(SpringRunner.class)
@DataJpaTest
@ActiveProfiles("test")
public class MyRepositoryTest {

    @Autowired
    private MyRepository myRepository;

    @Test
    @Sql("/data/myRepositoryTest.sql")
    public void testFindById() {
        Optional<My> my= myRepository.findById(99999);
        assertTrue(my.isPresent());
        assertEquals("Métro Ligne 6, station Bel-Air", my.get().getItinerary());
    }

}

My sql file:

INSERT INTO MY(ID, NAME, CODE, ITINERARY)
  VALUES (99999, 'foo', 'abc', 'Métro Ligne 6, station Bel-Air');

Aucun commentaire:

Enregistrer un commentaire