Skip to content

Commit

Permalink
Add test for Progress, add Windows extractor binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
dsabsay committed Dec 10, 2016
1 parent 6d631d1 commit e0eb8be
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 1 deletion.
Binary file modified .DS_Store
Binary file not shown.
Binary file modified essentia/.DS_Store
Binary file not shown.
Binary file modified essentia/essentia-extractors/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified src/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ public class EssentiaExtractorLauncher {
= "essentia_streaming_rhythmextractor_multifeature";
private static final String OSX_EXTRACTOR_FOLDER = "essentia-extractors/osx_x86_64/";
private static final String LINUX_EXTRACTOR_FOLDER = "essentia-extractors/linux_x86_64/";
private static final String WINDOWS_EXTRACTOR_FOLDER = "essentia-extractors/win_i686/";
private static final int EXIT_SUCCESS = 0;

private String getExtractorFolder() throws ExtractorException {

System.out.println(System.getProperty("os.arch"));
// don't know if windows extractor binaries are 32 or 64 bit
if (!System.getProperty("os.arch").contains("x86")
&& !System.getProperty("os.arch").contains("64")) {
&& !System.getProperty("os.arch").contains("64") && !SystemUtils.IS_OS_WINDOWS) {
throw new ExtractorException("The extractor binaries only work on an x86_64 architecture.");
}

Expand All @@ -46,6 +48,8 @@ private String getExtractorFolder() throws ExtractorException {
return OSX_EXTRACTOR_FOLDER;
} else if (SystemUtils.IS_OS_LINUX) {
return LINUX_EXTRACTOR_FOLDER;
} else if (SystemUtils.IS_OS_WINDOWS) {
return WINDOWS_EXTRACTOR_FOLDER;
} else {
throw new ExtractorException("The " + SystemUtils.OS_NAME + " is not supported.");
}
Expand Down
66 changes: 66 additions & 0 deletions src/test/java/com/dsabsay/model/TestProgress.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.dsabsay.model;

import static org.junit.Assert.assertEquals;

import com.dsabsay.repo.DefaultPerformanceRecordRepo;
import com.dsabsay.repo.PerformanceRecordRepo;

import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class TestProgress {
private static UserConfiguration config;
private PerformanceRecordRepo repo;
private static final String SIGHT_SINGING_RECORD_PATH = "sightSingingRecords.ser";
private static final String RHYTHM_RECORD_PATH = "rhythmRecords.ser";

/**
* Set up test suite.
* @throws IOException if IO error occurs
*/
@BeforeClass
public static void setupSuite() throws IOException {
config = new UserConfiguration();
config.setRhythmRecordsPath(RHYTHM_RECORD_PATH);
config.setSightSingingRecordsPath(SIGHT_SINGING_RECORD_PATH);
}

@Before
public void setup() throws ClassNotFoundException, IOException {
this.repo = new DefaultPerformanceRecordRepo(config);
}

@After
public void teardown() {
new File(SIGHT_SINGING_RECORD_PATH).delete();
new File(RHYTHM_RECORD_PATH).delete();
}

@Test
public void testGetDefaultStatsForRhythm() throws IOException, ClassNotFoundException {
RhythmRecord record1 = new RhythmRecord(1, "rhythmType", "rhythmName", 1, 1, new Date(), 10);
RhythmRecord record2 = new RhythmRecord(1, "rhythmType", "rhythmName", (float) .5, (float) .5,
new Date(), 10);
this.repo.savePerformanceRecord(record1);
this.repo.savePerformanceRecord(record2);

// if we reinstantiate the repo to read from disk, it should still be there
this.repo = new DefaultPerformanceRecordRepo(config);

Progress progress = new Progress();
List<String> expected = new ArrayList<String>();
expected.add("Total number of attempts: " + 2);
expected.add("Total number attempts passed (at least 80%): " + 1);

assertEquals(expected, progress.getDefaultStatsForRhythm(this.repo));
}

}

0 comments on commit e0eb8be

Please sign in to comment.