Skip to content

Instantly share code, notes, and snippets.

@josephtaylor
Created December 12, 2018 02:15
Show Gist options
  • Save josephtaylor/02c2872b5ea6c2e8673dcc8d98a6fb60 to your computer and use it in GitHub Desktop.
Save josephtaylor/02c2872b5ea6c2e8673dcc8d98a6fb60 to your computer and use it in GitHub Desktop.
embedded-mysql-4
package com.singlemusic.example;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import javax.annotation.Resource;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import java.math.BigInteger;
import static org.junit.Assert.assertEquals;
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("test")
public class DatabaseTest {
@Resource
private EntityManager entityManager;
@Test
public void testDatabase() {
Query query = entityManager.createNativeQuery("SELECT 1");
assertEquals(BigInteger.valueOf(1L), query.getSingleResult());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment