}
public byte[] createDatabaseForLocalMode() {
- // serverFileSystem.getTempDir()
- String name = System.getenv("java.io") + System.nanoTime(); // TODO
+ String name = serverFileSystem.getTempDir().getAbsolutePath() + "db-" + System.nanoTime();
try {
BasicDataSource destination = create(DIALECT, DRIVER, USER, PASSWORD, URL + name);
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
+import org.sonar.api.platform.ServerFileSystem;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import static org.fest.assertions.Assertions.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class LocalDatabaseFactoryTest extends AbstractDaoTestCase {
private LocalDatabaseFactory localDatabaseFactory;
+
+ private ServerFileSystem serverFileSystem = mock(ServerFileSystem.class);
private BasicDataSource dataSource;
@Rule
@Before
public void setUp() {
- localDatabaseFactory = new LocalDatabaseFactory(getDatabase(), null);
+ localDatabaseFactory = new LocalDatabaseFactory(getDatabase(), serverFileSystem);
}
@After
public void should_create_database() throws IOException {
setupData("should_create_database");
+ when(serverFileSystem.getTempDir()).thenReturn(temporaryFolder.getRoot());
+
byte[] database = localDatabaseFactory.createDatabaseForLocalMode();
dataSource = createDatabase(database);