first commit
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* 11/19/04 1.0 moved to LGPL.
|
||||
*-----------------------------------------------------------------------
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published
|
||||
* by the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import javazoom.jl.decoder.BitstreamTest;
|
||||
import javazoom.jl.player.jlpTest;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
/**
|
||||
* JavaLayer test suite.
|
||||
*/
|
||||
public class AllTests
|
||||
{
|
||||
public static Test suite()
|
||||
{
|
||||
TestSuite suite = new TestSuite("Test for javazoom.jl.decoder");
|
||||
//$JUnit-BEGIN$
|
||||
suite.addTest(new TestSuite(BitstreamTest.class));
|
||||
suite.addTest(new TestSuite(jlpTest.class));
|
||||
//$JUnit-END$
|
||||
return suite;
|
||||
}
|
||||
}
|
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* 11/19/2004 : 1.0 moved to LGPL.
|
||||
* 01/01/2004 : Initial version by E.B javalayer@javazoom.net
|
||||
*-----------------------------------------------------------------------
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published
|
||||
* by the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
package javazoom.jl.decoder;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Bitstream unit test.
|
||||
* It matches test.mp3 properties to test.mp3.properties expected results.
|
||||
* As we don't ship test.mp3, you have to generate your own test.mp3.properties
|
||||
* Uncomment out = System.out; in setUp() method to generated it on stdout from
|
||||
* your own MP3 file.
|
||||
* @since 0.4
|
||||
*/
|
||||
public class BitstreamTest extends TestCase
|
||||
{
|
||||
private String basefile = null;
|
||||
private String name = null;
|
||||
private String filename = null;
|
||||
private PrintStream out = null;
|
||||
private Properties props = null;
|
||||
private FileInputStream mp3in = null;
|
||||
private Bitstream in = null;
|
||||
|
||||
/**
|
||||
* Constructor for BitstreamTest.
|
||||
* @param arg0
|
||||
*/
|
||||
public BitstreamTest(String arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
/*
|
||||
* @see TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
props = new Properties();
|
||||
InputStream pin = getClass().getClassLoader().getResourceAsStream("test.mp3.properties");
|
||||
props.load(pin);
|
||||
basefile = (String) props.getProperty("basefile");
|
||||
name = (String) props.getProperty("filename");
|
||||
filename = basefile + name;
|
||||
mp3in = new FileInputStream(filename);
|
||||
in = new Bitstream(mp3in);
|
||||
//out = System.out;
|
||||
}
|
||||
/*
|
||||
* @see TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
in.close();
|
||||
mp3in.close();
|
||||
}
|
||||
|
||||
public void testStream()
|
||||
{
|
||||
try
|
||||
{
|
||||
InputStream id3in = in.getRawID3v2();
|
||||
int size = id3in.available();
|
||||
Header header = in.readFrame();
|
||||
if (out != null)
|
||||
{
|
||||
out.println("--- "+filename+" ---");
|
||||
out.println("ID3v2Size="+size);
|
||||
out.println("version="+header.version());
|
||||
out.println("version_string="+header.version_string());
|
||||
out.println("layer="+header.layer());
|
||||
out.println("frequency="+header.frequency());
|
||||
out.println("frequency_string="+header.sample_frequency_string());
|
||||
out.println("bitrate="+header.bitrate());
|
||||
out.println("bitrate_string="+header.bitrate_string());
|
||||
out.println("mode="+header.mode());
|
||||
out.println("mode_string="+header.mode_string());
|
||||
out.println("slots="+header.slots());
|
||||
out.println("vbr="+header.vbr());
|
||||
out.println("vbr_scale="+header.vbr_scale());
|
||||
out.println("max_number_of_frames="+header.max_number_of_frames(mp3in.available()));
|
||||
out.println("min_number_of_frames="+header.min_number_of_frames(mp3in.available()));
|
||||
out.println("ms_per_frame="+header.ms_per_frame());
|
||||
out.println("frames_per_second="+(float) ((1.0 / (header.ms_per_frame())) * 1000.0));
|
||||
out.println("total_ms="+header.total_ms(mp3in.available()));
|
||||
out.println("SyncHeader="+header.getSyncHeader());
|
||||
out.println("checksums="+header.checksums());
|
||||
out.println("copyright="+header.copyright());
|
||||
out.println("original="+header.original());
|
||||
out.println("padding="+header.padding());
|
||||
out.println("framesize="+header.calculate_framesize());
|
||||
out.println("number_of_subbands="+header.number_of_subbands());
|
||||
}
|
||||
assertEquals("ID3v2Size",Integer.parseInt((String)props.getProperty("ID3v2Size")),size);
|
||||
assertEquals("version",Integer.parseInt((String)props.getProperty("version")),header.version());
|
||||
assertEquals("version_string",(String)props.getProperty("version_string"),header.version_string());
|
||||
assertEquals("layer",Integer.parseInt((String)props.getProperty("layer")),header.layer());
|
||||
assertEquals("frequency",Integer.parseInt((String)props.getProperty("frequency")),header.frequency());
|
||||
assertEquals("frequency_string",(String)props.getProperty("frequency_string"),header.sample_frequency_string());
|
||||
assertEquals("bitrate",Integer.parseInt((String)props.getProperty("bitrate")),header.bitrate());
|
||||
assertEquals("bitrate_string",(String)props.getProperty("bitrate_string"),header.bitrate_string());
|
||||
assertEquals("mode",Integer.parseInt((String)props.getProperty("mode")),header.mode());
|
||||
assertEquals("mode_string",(String)props.getProperty("mode_string"),header.mode_string());
|
||||
assertEquals("slots",Integer.parseInt((String)props.getProperty("slots")),header.slots());
|
||||
assertEquals("vbr",Boolean.valueOf((String)props.getProperty("vbr")),new Boolean(header.vbr()));
|
||||
assertEquals("vbr_scale",Integer.parseInt((String)props.getProperty("vbr_scale")),header.vbr_scale());
|
||||
assertEquals("max_number_of_frames",Integer.parseInt((String)props.getProperty("max_number_of_frames")),header.max_number_of_frames(mp3in.available()));
|
||||
assertEquals("min_number_of_frames",Integer.parseInt((String)props.getProperty("min_number_of_frames")),header.min_number_of_frames(mp3in.available()));
|
||||
assertTrue("ms_per_frame",Float.parseFloat((String)props.getProperty("ms_per_frame"))==header.ms_per_frame());
|
||||
assertTrue("frames_per_second",Float.parseFloat((String)props.getProperty("frames_per_second"))==(float) ((1.0 / (header.ms_per_frame())) * 1000.0));
|
||||
assertTrue("total_ms",Float.parseFloat((String)props.getProperty("total_ms"))==header.total_ms(mp3in.available()));
|
||||
assertEquals("SyncHeader",Integer.parseInt((String)props.getProperty("SyncHeader")),header.getSyncHeader());
|
||||
assertEquals("checksums",Boolean.valueOf((String)props.getProperty("checksums")),new Boolean(header.checksums()));
|
||||
assertEquals("copyright",Boolean.valueOf((String)props.getProperty("copyright")),new Boolean(header.copyright()));
|
||||
assertEquals("original",Boolean.valueOf((String)props.getProperty("original")),new Boolean(header.original()));
|
||||
assertEquals("padding",Boolean.valueOf((String)props.getProperty("padding")),new Boolean(header.padding()));
|
||||
assertEquals("framesize",Integer.parseInt((String)props.getProperty("framesize")),header.calculate_framesize());
|
||||
assertEquals("number_of_subbands",Integer.parseInt((String)props.getProperty("number_of_subbands")),header.number_of_subbands());
|
||||
in.closeFrame();
|
||||
}
|
||||
catch (BitstreamException e)
|
||||
{
|
||||
assertTrue("BitstreamException : "+e.getMessage(),false);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
assertTrue("IOException : "+e.getMessage(),false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* 11/19/2004 : 1.0 moved to LGPL.
|
||||
* 01/01/2004 : Initial version by E.B javalayer@javazoom.net
|
||||
*-----------------------------------------------------------------------
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Library General Public License as published
|
||||
* by the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
package javazoom.jl.player;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import javazoom.jl.decoder.JavaLayerException;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Simple player unit test.
|
||||
* It takes around 3-6% of CPU and 10MB RAM under Win2K/PIII/1GHz/JDK1.5.0
|
||||
* It takes around 10-12% of CPU and 10MB RAM under Win2K/PIII/1GHz/JDK1.4.1
|
||||
* It takes around 08-10% of CPU and 10MB RAM under Win2K/PIII/1GHz/JDK1.3.1
|
||||
* @since 0.4
|
||||
*/
|
||||
public class jlpTest extends TestCase
|
||||
{
|
||||
private Properties props = null;
|
||||
private String filename = null;
|
||||
|
||||
/**
|
||||
* Constructor for jlpTest.
|
||||
* @param arg0
|
||||
*/
|
||||
public jlpTest(String arg0)
|
||||
{
|
||||
super(arg0);
|
||||
}
|
||||
/*
|
||||
* @see TestCase#setUp()
|
||||
*/
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
props = new Properties();
|
||||
InputStream pin = getClass().getClassLoader().getResourceAsStream("test.mp3.properties");
|
||||
props.load(pin);
|
||||
String basefile = (String) props.getProperty("basefile");
|
||||
String name = (String) props.getProperty("filename");
|
||||
filename = basefile + name;
|
||||
//out = System.out;
|
||||
}
|
||||
/*
|
||||
* @see TestCase#tearDown()
|
||||
*/
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testPlay()
|
||||
{
|
||||
String[] args = new String[1];
|
||||
args[0] = filename;
|
||||
jlp player = jlp.createInstance(args);
|
||||
try
|
||||
{
|
||||
player.play();
|
||||
assertTrue("Play",true);
|
||||
}
|
||||
catch (JavaLayerException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
assertTrue("JavaLayerException : "+e.getMessage(),false);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,30 @@
|
||||
# MP3 file
|
||||
basefile=c:/data/
|
||||
filename=test.mp3
|
||||
|
||||
# BitStream properties
|
||||
ID3v2Size=2150
|
||||
version=1
|
||||
version_string=MPEG-1
|
||||
layer=3
|
||||
frequency=44100
|
||||
frequency_string=44.1 kHz
|
||||
bitrate=229000
|
||||
bitrate_string=229 kb/s
|
||||
mode=1
|
||||
mode_string=Joint stereo
|
||||
slots=381
|
||||
vbr=true
|
||||
vbr_scale=78
|
||||
max_number_of_frames=8122
|
||||
min_number_of_frames=8122
|
||||
ms_per_frame=26.12245
|
||||
frames_per_second=38.28125
|
||||
total_ms=212166.53
|
||||
SyncHeader=-290752
|
||||
checksums=false
|
||||
copyright=false
|
||||
original=false
|
||||
padding=false
|
||||
framesize=413
|
||||
number_of_subbands=27
|
Reference in New Issue
Block a user