Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed org.eclipse.birt.core unit tests #293

Merged
merged 1 commit into from
Apr 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
import java.io.DataOutputStream;
import java.io.IOException;

import junit.framework.TestCase;

import org.eclipse.birt.core.archive.compound.ArchiveEntry;
import org.eclipse.birt.core.archive.compound.ArchiveFile;

public class ArchiveFileCacheTest extends TestCase
{
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;

public class ArchiveFileCacheTest
{
@Test
public void testMemoryCache( ) throws IOException
{
long used1 = ArchiveFile.getTotalUsedCache( );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
import java.io.IOException;
import java.io.RandomAccessFile;

import junit.framework.TestCase;

import org.eclipse.birt.core.archive.compound.ArchiveEntry;
import org.eclipse.birt.core.archive.compound.ArchiveFile;

public class ArchiveFileSaveTest extends TestCase
{
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;

public void testSave( ) throws IOException
public class ArchiveFileSaveTest
{
@Test
public void testSave( ) throws IOException
{
ArchiveFile file = new ArchiveFile( "test.archive", "rwt" );
ArchiveEntry entry = file.createEntry( "/name" );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
import org.junit.Ignore;
import org.junit.Test;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;

public class ArchiveFlushTest
{

Expand All @@ -45,7 +51,7 @@ public class ArchiveFlushTest
* <li>read the data from the input stream, same.</li>
* </ol>
*/
@Test
@Test
public void testFlush( ) throws IOException
{

Expand Down Expand Up @@ -81,7 +87,7 @@ public void testFlush( ) throws IOException
/**
* Demonstrate how to use the archive entry and input/output stream
*/
@Test
@Test
public void testReadWrite( ) throws IOException
{
ArchiveFile af = new ArchiveFile( "test.dat", "rw+" );
Expand Down Expand Up @@ -128,8 +134,8 @@ public void testReadWrite( ) throws IOException
*
* @throws IOException
*/
@Test
@Ignore("Ignore long run test")
@Test
public void testMultipleThread( ) throws IOException
{
final Boolean[] hasErrors = new Boolean[]{Boolean.FALSE, Boolean.FALSE};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
import java.io.File;
import java.io.IOException;

import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;

public class ArchiveUtilTest extends TestCase
public class ArchiveUtilTest
{

static final String ARCHIVE_FILE = "./utest/test.file";
Expand All @@ -34,7 +38,7 @@ protected void removeFile( File file )
}
file.delete( );
}

@Test
public void testArchive( ) throws IOException
{
removeFile( new File( ARCHIVE_FOLDER ) );
Expand All @@ -53,7 +57,7 @@ public void testArchive( ) throws IOException
reader.close( );

}

@Test
public void testExpand( ) throws IOException
{
removeFile( new File( ARCHIVE_FOLDER ) );
Expand Down Expand Up @@ -89,7 +93,7 @@ protected void checkArchive( IDocArchiveReader reader ) throws IOException
{
RAInputStream in = reader.getStream( "/core.txt" );
assertTrue( in != null );
assertEquals( 100, in.readLong( ) );
org.junit.Assert.assertEquals( 100, in.readLong( ) );
in.seek( 1024 * 1024 );
assertEquals( 100, in.readLong( ) );
in.close( );
Expand All @@ -99,18 +103,18 @@ protected void checkArchive( IDocArchiveReader reader ) throws IOException
assertEquals( 100, in.readLong( ) );
in.close( );
}
@Test
public void testSplit()
{
assertEquals(new String[]{""}, ArchiveUtil.split("", '/'));
assertEquals(new String[]{"",""}, ArchiveUtil.split("/", '/'));
assertEquals(new String[]{"","",""}, ArchiveUtil.split("//", '/'));
assertEquals(new String[]{"abc"}, ArchiveUtil.split("abc", '/'));
assertEquals(new String[]{"abc", ""}, ArchiveUtil.split("abc/", '/'));
assertEquals(new String[]{"","abc" }, ArchiveUtil.split("/abc", '/'));
assertEquals(new String[]{"","abc", "" }, ArchiveUtil.split("/abc/", '/'));
assertEQ(new String[]{""}, ArchiveUtil.split("", '/'));
assertEQ(new String[]{"",""}, ArchiveUtil.split("/", '/'));
assertEQ(new String[]{"","",""}, ArchiveUtil.split("//", '/'));
assertEQ(new String[]{"abc"}, ArchiveUtil.split("abc", '/'));
assertEQ(new String[]{"abc", ""}, ArchiveUtil.split("abc/", '/'));
assertEQ(new String[]{"","abc" }, ArchiveUtil.split("/abc", '/'));
assertEQ(new String[]{"","abc", "" }, ArchiveUtil.split("/abc/", '/'));
}

@Test
public void testRelativePath( )
{
String[][] tests = new String[][]{new String[]{"/test", "/", "/test"},
Expand All @@ -132,7 +136,7 @@ public void testRelativePath( )
assertEquals( relative, ArchiveUtil.getRelativePath( root, path ) );
}
}

@Test
public void testFullPath( )
{
String[][] tests = new String[][]{new String[]{"/root/", "/root", "/"},
Expand All @@ -154,7 +158,7 @@ public void testFullPath( )
assertEquals( path, ArchiveUtil.getFullPath( root, relative ) );
}
}

@Test
public void testEntryToFile( )
{
assertEquals( "/", ArchiveUtil.getFilePath( "/" ) );
Expand All @@ -170,7 +174,7 @@ public void testEntryToFile( )
assertEquals( "/%2F/", ArchiveUtil.getFilePath( "//" ) );
assertEquals( "/%2F/%2F/", ArchiveUtil.getFilePath( "///" ) );
}

@Test
public void testFileToEntry( )
{
assertEquals( "/", ArchiveUtil.getEntryName( "/" ) );
Expand All @@ -184,7 +188,7 @@ public void testFileToEntry( )
assertEquals( "///", ArchiveUtil.getEntryName( "/%2F/%2F/" ) );
}

private void assertEquals( String[] v1, String[] v2 )
private void assertEQ( String[] v1, String[] v2 )
{
assertEquals( v1.length, v2.length );
for ( int i = 0; i < v1.length; i++ )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,26 @@
import org.junit.Assert;
import org.junit.Ignore;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;

public class DocArchiveLockManagerTest
{

static final String LOCK_FILE_NAME = "./utest/lock.lck";
static final int THREAD_COUNT = 20;

@Ignore("ignore multple thread test")
@Test
public void testThread( )
{
TestTask task = new TestTask( );
task.doTest( );
Assert.assertTrue( task.errorThreads == 0 );
Assert.assertTrue( !new File( LOCK_FILE_NAME ).exists( ) );
assertTrue( task.errorThreads == 0 );
assertTrue( !new File( LOCK_FILE_NAME ).exists( ) );
}

static void sleep( long millis )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
import java.io.File;
import java.io.IOException;

import junit.framework.TestCase;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.Ignore;
import static org.junit.Assert.*;

public class DocumentArchiveTest extends TestCase
public class DocumentArchiveTest
{

static final String ARCHIVE_DOCUMENT_NAME = "org.eclipse.birt.core.archive.archive.zip"; //$NON-NLS-1$
Expand All @@ -18,11 +22,10 @@ public class DocumentArchiveTest extends TestCase
*/
public DocumentArchiveTest( String name )
{
super( name );
delete( new File( ARCHIVE_DOCUMENT_NAME ) );
}

public void tearDown( )
@After
public void tearDown()
{
File file = new File( ARCHIVE_DOCUMENT_NAME );
if ( file.exists( ) )
Expand Down Expand Up @@ -79,8 +82,8 @@ private void delete( File dir )
static final String Random1StreamContent = "This is string for testing random stream 1."; //$NON-NLS-1$
static final String Random2StreamContent = "This is string for testing random stream 2."; //$NON-NLS-1$
static final String ContentStreamContent = "This is string for testing nested folder."; //$NON-NLS-1$

public void testArchiveWriterAndArchiveReader() throws Exception
@Test
public void testArchiveWriterAndArchiveReader() throws Exception
{
///////////////// Testing FileArchiveWriter /////////////////////////////
FileArchiveWriter compoundWriter = new FileArchiveWriter( fileArchiveName );
Expand Down Expand Up @@ -226,8 +229,8 @@ private String readStreamContent( RAInputStream in ) throws IOException
int runningThread;
int THREAD_COUNT = 5;
int VALUE_COUNT = 10000;

public void testReadMutipleThreads( ) throws IOException
@Test
public void testReadMutipleThreads( ) throws IOException
{
// create a stream
FileArchiveWriter writer = new FileArchiveWriter( fileArchiveName );
Expand Down
Loading