Preparing for internationalization as well as responding to the tighter

Eclipse 3.0 code checks. As these are tests, the internationalization
piece basically was adding a comment to get rid of warnings.
This commit is contained in:
Robert Greene 2004-07-11 15:11:32 +00:00
parent 3b926360ef
commit a51fda792f
3 changed files with 134 additions and 123 deletions

View File

@ -19,19 +19,21 @@
*/ */
package com.webcodepro.applecommander.compiler; package com.webcodepro.applecommander.compiler;
import com.webcodepro.applecommander.storage.Disk;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.os.dos33.DosFormatDisk;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import junit.framework.TestCase; import junit.framework.TestCase;
import com.webcodepro.applecommander.storage.Disk;
import com.webcodepro.applecommander.storage.FileEntry;
import com.webcodepro.applecommander.storage.os.dos33.DosFormatDisk;
import com.webcodepro.applecommander.testconfig.TestConfig;
/** /**
* Test the ApplesoftCompiler. * Test the ApplesoftCompiler.
* @author Rob * @author Rob
*/ */
public class ApplesoftCompilerTest extends TestCase { public class ApplesoftCompilerTest extends TestCase {
private TestConfig config = TestConfig.getInstance();
/** /**
* Constructor for ApplesoftCompilerTest. * Constructor for ApplesoftCompilerTest.
* @param arg0 * @param arg0
@ -46,13 +48,14 @@ public class ApplesoftCompilerTest extends TestCase {
public void testCompileColors() throws Exception { public void testCompileColors() throws Exception {
DosFormatDisk disk = (DosFormatDisk) DosFormatDisk disk = (DosFormatDisk)
new Disk("C:/My Apple2/Disks/MASTER.DSK").getFormattedDisks()[0]; new Disk(config.getDiskDir() + "/MASTER.DSK").getFormattedDisks()[0]; //$NON-NLS-1$
FileEntry fileEntry = disk.getFile("COLORS"); FileEntry fileEntry = disk.getFile("COLORS"); //$NON-NLS-1$
ApplesoftCompiler compiler = new ApplesoftCompiler(fileEntry); ApplesoftCompiler compiler = new ApplesoftCompiler(fileEntry);
compiler.setIntegerOnlyMath(true); compiler.setIntegerOnlyMath(true);
byte[] assembly = compiler.compile(); byte[] assembly = compiler.compile();
System.out.println(new String(assembly)); System.out.println(new String(assembly));
FileOutputStream output = new FileOutputStream("C:/Temp/COLORS.s"); FileOutputStream output = new FileOutputStream(config.getTempDir()
+ "/COLORS.s"); //$NON-NLS-1$
output.write(assembly); output.write(assembly);
output.close(); output.close();
} }

View File

@ -19,17 +19,18 @@
*/ */
package com.webcodepro.applecommander.storage; package com.webcodepro.applecommander.storage;
import java.io.IOException;
import java.util.List;
import junit.framework.TestCase;
import com.webcodepro.applecommander.storage.FormattedDisk.DiskUsage; import com.webcodepro.applecommander.storage.FormattedDisk.DiskUsage;
import com.webcodepro.applecommander.storage.filters.ApplesoftFileFilter; import com.webcodepro.applecommander.storage.filters.ApplesoftFileFilter;
import com.webcodepro.applecommander.storage.filters.BinaryFileFilter; import com.webcodepro.applecommander.storage.filters.BinaryFileFilter;
import com.webcodepro.applecommander.storage.filters.GraphicsFileFilter; import com.webcodepro.applecommander.storage.filters.GraphicsFileFilter;
import com.webcodepro.applecommander.storage.filters.IntegerBasicFileFilter; import com.webcodepro.applecommander.storage.filters.IntegerBasicFileFilter;
import com.webcodepro.applecommander.storage.filters.TextFileFilter; import com.webcodepro.applecommander.storage.filters.TextFileFilter;
import com.webcodepro.applecommander.testconfig.TestConfig;
import java.io.IOException;
import java.util.List;
import junit.framework.TestCase;
/** /**
* Test Disk and FormattedDisk for read. * Test Disk and FormattedDisk for read.
@ -38,6 +39,7 @@ import junit.framework.TestCase;
* @author Rob Greene * @author Rob Greene
*/ */
public class DiskHelperTest extends TestCase { public class DiskHelperTest extends TestCase {
private TestConfig config = TestConfig.getInstance();
public DiskHelperTest(String name) { public DiskHelperTest(String name) {
super(name); super(name);
@ -48,75 +50,81 @@ public class DiskHelperTest extends TestCase {
} }
public void testLoadDos33() throws IOException { public void testLoadDos33() throws IOException {
FormattedDisk[] disks = showDirectory("C:/My Apple2/Disks/DOS 3.3.po"); FormattedDisk[] disks = showDirectory(config.getDiskDir() +
assertApplesoftFile(disks[0], "HELLO"); "/DOS 3.3.po"); //$NON-NLS-1$
assertIntegerFile(disks[0], "ANIMALS"); assertApplesoftFile(disks[0], "HELLO"); //$NON-NLS-1$
assertTextFile(disks[0], "APPLE PROMS"); assertIntegerFile(disks[0], "ANIMALS"); //$NON-NLS-1$
assertBinaryFile(disks[0], "BOOT13"); assertTextFile(disks[0], "APPLE PROMS"); //$NON-NLS-1$
assertBinaryFile(disks[0], "BOOT13"); //$NON-NLS-1$
} }
public void testLoadMaster() throws IOException { public void testLoadMaster() throws IOException {
showDirectory("C:/My Apple2/Disks/MASTER.DSK"); showDirectory(config.getDiskDir() + "/MASTER.DSK"); //$NON-NLS-1$
} }
public void testLoadGalacticAttack1() throws IOException { public void testLoadGalacticAttack1() throws IOException {
showDirectory("C:/My Apple2/Disks/galatt.dsk"); showDirectory(config.getDiskDir() + "/galatt.dsk"); //$NON-NLS-1$
} }
public void testLoadProdos() throws IOException { public void testLoadProdos() throws IOException {
FormattedDisk[] disks = showDirectory("C:/My Apple2/Disks/Prodos.dsk"); FormattedDisk[] disks = showDirectory(config.getDiskDir() + "/Prodos.dsk"); //$NON-NLS-1$
assertApplesoftFile(disks[0], "COPY.ME"); assertApplesoftFile(disks[0], "COPY.ME"); //$NON-NLS-1$
assertBinaryFile(disks[0], "SETTINGS"); assertBinaryFile(disks[0], "SETTINGS"); //$NON-NLS-1$
assertBinaryFile(disks[0], "PRODOS"); assertBinaryFile(disks[0], "PRODOS"); //$NON-NLS-1$
} }
public void testLoadMarbleMadness() throws IOException { public void testLoadMarbleMadness() throws IOException {
showDirectory("C:/My Apple2/Disks/Marble Madness (1985)(Electronic Arts).2mg"); showDirectory(config.getDiskDir()
+ "/Marble Madness (1985)(Electronic Arts).2mg"); //$NON-NLS-1$
} }
public void testLoadHd1() throws IOException { public void testLoadHd1() throws IOException {
showDirectory("C:/My Apple2/ApplePC/hd1.hdv"); showDirectory("C:/My Apple2/ApplePC/hd1.hdv"); //$NON-NLS-1$
} }
public void testRdosBoot() throws IOException { public void testRdosBoot() throws IOException {
showDirectory("C:/My Apple2/Disks/RDOSboot.dsk"); showDirectory(config.getDiskDir() + "/RDOSboot.dsk"); //$NON-NLS-1$
} }
public void testSsiSave() throws IOException { public void testSsiSave() throws IOException {
showDirectory("C:/My Apple2/Disks/SSIsave.dsk"); showDirectory(config.getDiskDir() + "/SSIsave.dsk"); //$NON-NLS-1$
} }
public void testPhan2d1() throws IOException { public void testPhan2d1() throws IOException {
FormattedDisk[] disks = showDirectory("C:/My Apple2/Disks/phan2d1.dsk"); FormattedDisk[] disks = showDirectory(config.getDiskDir()
assertApplesoftFile(disks[0], "PHANTASIE II"); + "/phan2d1.dsk"); //$NON-NLS-1$
assertBinaryFile(disks[0], "TWN21"); assertApplesoftFile(disks[0], "PHANTASIE II"); //$NON-NLS-1$
assertTextFile(disks[0], "ITEM"); assertBinaryFile(disks[0], "TWN21"); //$NON-NLS-1$
assertGraphicsFile(disks[0], "ICE DRAGON"); assertTextFile(disks[0], "ITEM"); //$NON-NLS-1$
assertGraphicsFile(disks[0], "ICE DRAGON"); //$NON-NLS-1$
} }
public void testPhan2d2() throws IOException { public void testPhan2d2() throws IOException {
showDirectory("C:/My Apple2/Disks/phan2d2.dsk"); showDirectory(config.getDiskDir() + "/phan2d2.dsk"); //$NON-NLS-1$
} }
public void testPhantasie1() throws IOException { public void testPhantasie1() throws IOException {
showDirectory("C:/My Apple2/Disks/Phantasie1.dsk"); showDirectory(config.getDiskDir() + "/Phantasie1.dsk"); //$NON-NLS-1$
} }
public void testPhantasie2() throws IOException { public void testPhantasie2() throws IOException {
showDirectory("C:/My Apple2/Disks/Phantasie2.dsk"); showDirectory(config.getDiskDir() + "/Phantasie2.dsk"); //$NON-NLS-1$
} }
public void testCavernsOfFreitag() throws IOException { public void testCavernsOfFreitag() throws IOException {
FormattedDisk[] disks = showDirectory("C:/My Apple2/Disks/CavernsOfFreitag.dsk"); FormattedDisk[] disks = showDirectory(config.getDiskDir()
assertGraphicsFile(disks[0], "TITLE.PIC"); + "/CavernsOfFreitag.dsk"); //$NON-NLS-1$
assertGraphicsFile(disks[0], "TITLE.PIC"); //$NON-NLS-1$
} }
public void testUniDosD3110() throws IOException { public void testUniDosD3110() throws IOException {
showDirectory("C:/My Apple2/Disks/UniDOS/D3110.dsk"); showDirectory(config.getDiskDir()
+ "/UniDOS/D3110.dsk"); //$NON-NLS-1$
} }
public void testUniDosD3151() throws IOException { public void testUniDosD3151() throws IOException {
showDirectory("C:/My Apple2/Disks/UniDOS/D3151.dsk"); showDirectory(config.getDiskDir()
+ "/UniDOS/D3151.dsk"); //$NON-NLS-1$
} }
protected FormattedDisk[] showDirectory(String imageName) throws IOException { protected FormattedDisk[] showDirectory(String imageName) throws IOException {
@ -128,13 +136,13 @@ public class DiskHelperTest extends TestCase {
System.out.println(formattedDisk.getDiskName()); System.out.println(formattedDisk.getDiskName());
List files = formattedDisk.getFiles(); List files = formattedDisk.getFiles();
if (files != null) { if (files != null) {
showFiles(files, ""); showFiles(files, ""); //$NON-NLS-1$
} }
System.out.println(formattedDisk.getFreeSpace() + " bytes free."); System.out.println(formattedDisk.getFreeSpace() + " bytes free."); //$NON-NLS-1$
System.out.println(formattedDisk.getUsedSpace() + " bytes used."); System.out.println(formattedDisk.getUsedSpace() + " bytes used."); //$NON-NLS-1$
System.out.println("This disk " + (formattedDisk.canHaveDirectories() ? "does" : "does not") + System.out.println("This disk " + (formattedDisk.canHaveDirectories() ? "does" : "does not") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
" support directories."); " support directories."); //$NON-NLS-1$
System.out.println("This disk is formatted in the " + formattedDisk.getFormat() + " format."); System.out.println("This disk is formatted in the " + formattedDisk.getFormat() + " format."); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(); System.out.println();
showDiskUsage(formattedDisk); showDiskUsage(formattedDisk);
@ -150,12 +158,12 @@ public class DiskHelperTest extends TestCase {
System.out.print(indent); System.out.print(indent);
for (int d=0; d<data.size(); d++) { for (int d=0; d<data.size(); d++) {
System.out.print(data.get(d)); System.out.print(data.get(d));
System.out.print(" "); System.out.print(" "); //$NON-NLS-1$
} }
System.out.println(); System.out.println();
} }
if (entry.isDirectory()) { if (entry.isDirectory()) {
showFiles(((DirectoryEntry)entry).getFiles(), indent + " "); showFiles(((DirectoryEntry)entry).getFiles(), indent + " "); //$NON-NLS-1$
} }
} }
} }
@ -164,7 +172,7 @@ public class DiskHelperTest extends TestCase {
int[] dimensions = disk.getBitmapDimensions(); int[] dimensions = disk.getBitmapDimensions();
DiskUsage usage = disk.getDiskUsage(); DiskUsage usage = disk.getDiskUsage();
if (usage == null) { if (usage == null) {
System.out.println("A bitmap is not available."); System.out.println("A bitmap is not available."); //$NON-NLS-1$
return; return;
} }
if (dimensions == null) { if (dimensions == null) {
@ -172,7 +180,7 @@ public class DiskHelperTest extends TestCase {
while (usage.hasNext()) { while (usage.hasNext()) {
if (i > 0 && i % 80 == 0) System.out.println(); if (i > 0 && i % 80 == 0) System.out.println();
usage.next(); usage.next();
System.out.print(usage.isFree() ? "." : "U"); System.out.print(usage.isFree() ? "." : "U"); //$NON-NLS-1$ //$NON-NLS-2$
i++; i++;
} }
System.out.println(); System.out.println();
@ -180,51 +188,51 @@ public class DiskHelperTest extends TestCase {
for (int y=dimensions[0]-1; y>=0; y--) { for (int y=dimensions[0]-1; y>=0; y--) {
for (int x=0; x<dimensions[1]; x++) { for (int x=0; x<dimensions[1]; x++) {
usage.next(); usage.next();
System.out.print(usage.isFree() ? "." : "U"); System.out.print(usage.isFree() ? "." : "U"); //$NON-NLS-1$ //$NON-NLS-2$
} }
System.out.println(); System.out.println();
} }
} }
System.out.println("U = used, . = free"); System.out.println("U = used, . = free"); //$NON-NLS-1$
} }
protected void assertApplesoftFile(FormattedDisk disk, String filename) { protected void assertApplesoftFile(FormattedDisk disk, String filename) {
assertNotNull(filename + " test: Disk should not be null", disk); assertNotNull(filename + " test: Disk should not be null", disk); //$NON-NLS-1$
FileEntry fileEntry = disk.getFile(filename); FileEntry fileEntry = disk.getFile(filename);
assertNotNull(filename + " test: File not found", disk); assertNotNull(filename + " test: File not found", disk); //$NON-NLS-1$
assertTrue("ApplesoftFileFilter was not chosen", assertTrue("ApplesoftFileFilter was not chosen", //$NON-NLS-1$
fileEntry.getSuggestedFilter() instanceof ApplesoftFileFilter); fileEntry.getSuggestedFilter() instanceof ApplesoftFileFilter);
} }
protected void assertIntegerFile(FormattedDisk disk, String filename) { protected void assertIntegerFile(FormattedDisk disk, String filename) {
assertNotNull(filename + " test: Disk should not be null", disk); assertNotNull(filename + " test: Disk should not be null", disk); //$NON-NLS-1$
FileEntry fileEntry = disk.getFile(filename); FileEntry fileEntry = disk.getFile(filename);
assertNotNull(filename + " test: File not found", disk); assertNotNull(filename + " test: File not found", disk); //$NON-NLS-1$
assertTrue("IntegerBasicFileFilter was not chosen", assertTrue("IntegerBasicFileFilter was not chosen", //$NON-NLS-1$
fileEntry.getSuggestedFilter() instanceof IntegerBasicFileFilter); fileEntry.getSuggestedFilter() instanceof IntegerBasicFileFilter);
} }
protected void assertTextFile(FormattedDisk disk, String filename) { protected void assertTextFile(FormattedDisk disk, String filename) {
assertNotNull(filename + " test: Disk should not be null", disk); assertNotNull(filename + " test: Disk should not be null", disk); //$NON-NLS-1$
FileEntry fileEntry = disk.getFile(filename); FileEntry fileEntry = disk.getFile(filename);
assertNotNull(filename + " test: File not found", disk); assertNotNull(filename + " test: File not found", disk); //$NON-NLS-1$
assertTrue("TextFileFilter was not chosen", assertTrue("TextFileFilter was not chosen", //$NON-NLS-1$
fileEntry.getSuggestedFilter() instanceof TextFileFilter); fileEntry.getSuggestedFilter() instanceof TextFileFilter);
} }
protected void assertBinaryFile(FormattedDisk disk, String filename) { protected void assertBinaryFile(FormattedDisk disk, String filename) {
assertNotNull(filename + " test: Disk should not be null", disk); assertNotNull(filename + " test: Disk should not be null", disk); //$NON-NLS-1$
FileEntry fileEntry = disk.getFile(filename); FileEntry fileEntry = disk.getFile(filename);
assertNotNull(filename + " test: File not found", disk); assertNotNull(filename + " test: File not found", disk); //$NON-NLS-1$
assertTrue("BinaryFileFilter was not chosen", assertTrue("BinaryFileFilter was not chosen", //$NON-NLS-1$
fileEntry.getSuggestedFilter() instanceof BinaryFileFilter); fileEntry.getSuggestedFilter() instanceof BinaryFileFilter);
} }
protected void assertGraphicsFile(FormattedDisk disk, String filename) { protected void assertGraphicsFile(FormattedDisk disk, String filename) {
assertNotNull(filename + " test: Disk should not be null", disk); assertNotNull(filename + " test: Disk should not be null", disk); //$NON-NLS-1$
FileEntry fileEntry = disk.getFile(filename); FileEntry fileEntry = disk.getFile(filename);
assertNotNull(filename + " test: File not found", disk); assertNotNull(filename + " test: File not found", disk); //$NON-NLS-1$
assertTrue("GraphicsFileFilter was not chosen", assertTrue("GraphicsFileFilter was not chosen", //$NON-NLS-1$
fileEntry.getSuggestedFilter() instanceof GraphicsFileFilter); fileEntry.getSuggestedFilter() instanceof GraphicsFileFilter);
} }
} }

View File

@ -68,8 +68,8 @@ public class DiskWriterTest extends TestCase {
public void testWriteToDos33() throws DiskFullException, IOException { public void testWriteToDos33() throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout); ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create("write-test-dos33.dsk", imageOrder); FormattedDisk[] disks = DosFormatDisk.create("write-test-dos33.dsk", imageOrder); //$NON-NLS-1$
writeFiles(disks, "B", "T", false); writeFiles(disks, "B", "T", false); //$NON-NLS-1$ //$NON-NLS-2$
saveDisks(disks); saveDisks(disks);
} }
@ -79,8 +79,8 @@ public class DiskWriterTest extends TestCase {
public void testWriteToDos33Nibble() throws DiskFullException, IOException { public void testWriteToDos33Nibble() throws DiskFullException, IOException {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_NIBBLE_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_NIBBLE_DISK);
ImageOrder imageOrder = new NibbleOrder(imageLayout); ImageOrder imageOrder = new NibbleOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create("write-test-dos33.nib", imageOrder); FormattedDisk[] disks = DosFormatDisk.create("write-test-dos33.nib", imageOrder); //$NON-NLS-1$
writeFiles(disks, "B", "T", false); writeFiles(disks, "B", "T", false); //$NON-NLS-1$ //$NON-NLS-2$
saveImage = true; saveImage = true;
saveDisks(disks); saveDisks(disks);
saveImage = false; saveImage = false;
@ -93,8 +93,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout); ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create( FormattedDisk[] disks = ProdosFormatDisk.create(
"write-test-prodos-140k.dsk", "TEST", imageOrder); "write-test-prodos-140k.dsk", "TEST", imageOrder); //$NON-NLS-1$ //$NON-NLS-2$
writeFiles(disks, "BIN", "TXT", true); writeFiles(disks, "BIN", "TXT", true); //$NON-NLS-1$ //$NON-NLS-2$
saveDisks(disks); saveDisks(disks);
} }
@ -105,8 +105,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout); ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create( FormattedDisk[] disks = ProdosFormatDisk.create(
"write-test-prodos-800k.po", "TEST", imageOrder); "write-test-prodos-800k.po", "TEST", imageOrder); //$NON-NLS-1$ //$NON-NLS-2$
writeFiles(disks, "BIN", "TXT", true); writeFiles(disks, "BIN", "TXT", true); //$NON-NLS-1$ //$NON-NLS-2$
saveDisks(disks); saveDisks(disks);
} }
@ -117,8 +117,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_5MB_HARDDISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_5MB_HARDDISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout); ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create( FormattedDisk[] disks = ProdosFormatDisk.create(
"write-test-prodos-5mb.hdv", "TEST", imageOrder); "write-test-prodos-5mb.hdv", "TEST", imageOrder); //$NON-NLS-1$ //$NON-NLS-2$
writeFiles(disks, "BIN", "TXT", true); writeFiles(disks, "BIN", "TXT", true); //$NON-NLS-1$ //$NON-NLS-2$
saveDisks(disks); saveDisks(disks);
} }
@ -129,8 +129,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout); ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create( FormattedDisk[] disks = DosFormatDisk.create(
"createanddelete-test-dos33.dsk", imageOrder); "createanddelete-test-dos33.dsk", imageOrder); //$NON-NLS-1$
createAndDeleteFiles(disks, "B"); createAndDeleteFiles(disks, "B"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -141,8 +141,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout); ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = OzDosFormatDisk.create( FormattedDisk[] disks = OzDosFormatDisk.create(
"createanddelete-test-ozdos.po", imageOrder); "createanddelete-test-ozdos.po", imageOrder); //$NON-NLS-1$
createAndDeleteFiles(disks, "B"); createAndDeleteFiles(disks, "B"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -153,8 +153,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout); ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = UniDosFormatDisk.create( FormattedDisk[] disks = UniDosFormatDisk.create(
"createanddelete-test-unidos.dsk", imageOrder); "createanddelete-test-unidos.dsk", imageOrder); //$NON-NLS-1$
createAndDeleteFiles(disks, "B"); createAndDeleteFiles(disks, "B"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -165,9 +165,9 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout); ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create( FormattedDisk[] disks = ProdosFormatDisk.create(
"createanddelete-test-prodos-140k.dsk", "TEST", "createanddelete-test-prodos-140k.dsk", "TEST", //$NON-NLS-1$ //$NON-NLS-2$
imageOrder); imageOrder);
createAndDeleteFiles(disks, "BIN"); createAndDeleteFiles(disks, "BIN"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -178,9 +178,9 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout); ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create( FormattedDisk[] disks = ProdosFormatDisk.create(
"createanddelete-test-prodos-800k.dsk", "TEST", "createanddelete-test-prodos-800k.dsk", "TEST", //$NON-NLS-1$ //$NON-NLS-2$
imageOrder); imageOrder);
createAndDeleteFiles(disks, "BIN"); createAndDeleteFiles(disks, "BIN"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -193,8 +193,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new DosOrder(imageLayout); ImageOrder imageOrder = new DosOrder(imageLayout);
FormattedDisk[] disks = DosFormatDisk.create( FormattedDisk[] disks = DosFormatDisk.create(
"createdeletecreate-test-dos-140k.dsk", imageOrder); "createdeletecreate-test-dos-140k.dsk", imageOrder); //$NON-NLS-1$
createDeleteCreate(disks, "B"); createDeleteCreate(disks, "B"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -207,8 +207,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_800KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout); ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = OzDosFormatDisk.create( FormattedDisk[] disks = OzDosFormatDisk.create(
"createdeletecreate-test-ozdos-800k.po", imageOrder); "createdeletecreate-test-ozdos-800k.po", imageOrder); //$NON-NLS-1$
createDeleteCreate(disks, "B"); createDeleteCreate(disks, "B"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -221,8 +221,8 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout); ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = UniDosFormatDisk.create( FormattedDisk[] disks = UniDosFormatDisk.create(
"createdeletecreate-test-unidos-800k.dsk", imageOrder); "createdeletecreate-test-unidos-800k.dsk", imageOrder); //$NON-NLS-1$
createDeleteCreate(disks, "B"); createDeleteCreate(disks, "B"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -235,9 +235,9 @@ public class DiskWriterTest extends TestCase {
ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK); ByteArrayImageLayout imageLayout = new ByteArrayImageLayout(Disk.APPLE_140KB_DISK);
ImageOrder imageOrder = new ProdosOrder(imageLayout); ImageOrder imageOrder = new ProdosOrder(imageLayout);
FormattedDisk[] disks = ProdosFormatDisk.create( FormattedDisk[] disks = ProdosFormatDisk.create(
"createdeletecreate-test-prodos-140k.dsk", "TEST", "createdeletecreate-test-prodos-140k.dsk", "TEST", //$NON-NLS-1$ //$NON-NLS-2$
imageOrder); imageOrder);
createDeleteCreate(disks, "BIN"); createDeleteCreate(disks, "BIN"); //$NON-NLS-1$
saveDisks(disks); saveDisks(disks);
} }
@ -250,7 +250,7 @@ public class DiskWriterTest extends TestCase {
protected void writeFiles(FormattedDisk[] disks, String binaryType, protected void writeFiles(FormattedDisk[] disks, String binaryType,
String textType, boolean testText) throws DiskFullException { String textType, boolean testText) throws DiskFullException {
FormattedDisk disk = disks[0]; FormattedDisk disk = disks[0];
showDirectory(disks, "BEFORE FILE CREATION"); showDirectory(disks, "BEFORE FILE CREATION"); //$NON-NLS-1$
writeFile(disk, 1, binaryType, true); writeFile(disk, 1, binaryType, true);
writeFile(disk, 2, binaryType, true); writeFile(disk, 2, binaryType, true);
writeFile(disk, 4, binaryType, true); writeFile(disk, 4, binaryType, true);
@ -261,7 +261,7 @@ public class DiskWriterTest extends TestCase {
writeFile(disk, 1234, binaryType, true); writeFile(disk, 1234, binaryType, true);
writeFile(disk, 54321, binaryType, true); writeFile(disk, 54321, binaryType, true);
writeFile(disk, writeFile(disk,
"This is a test text file create from the DiskWriterTest".getBytes(), "This is a test text file create from the DiskWriterTest".getBytes(), //$NON-NLS-1$
textType, testText); textType, testText);
if (disk.getPhysicalSize() > Disk.APPLE_140KB_DISK if (disk.getPhysicalSize() > Disk.APPLE_140KB_DISK
&& disk.getPhysicalSize() != Disk.APPLE_140KB_NIBBLE_DISK) { && disk.getPhysicalSize() != Disk.APPLE_140KB_NIBBLE_DISK) {
@ -269,7 +269,7 @@ public class DiskWriterTest extends TestCase {
writeFile(disk, 150000, binaryType, true); writeFile(disk, 150000, binaryType, true);
writeFile(disk, 300000, binaryType, true); writeFile(disk, 300000, binaryType, true);
} }
showDirectory(disks, "AFTER FILE CREATION"); showDirectory(disks, "AFTER FILE CREATION"); //$NON-NLS-1$
} }
/** /**
@ -293,15 +293,15 @@ public class DiskWriterTest extends TestCase {
protected void writeFile(FormattedDisk disk, byte[] data, String fileType, protected void writeFile(FormattedDisk disk, byte[] data, String fileType,
boolean test) throws DiskFullException { boolean test) throws DiskFullException {
FileEntry entry = disk.createFile(); FileEntry entry = disk.createFile();
entry.setFilename("file-" + data.length); entry.setFilename("file-" + data.length); //$NON-NLS-1$
entry.setFiletype(fileType); entry.setFiletype(fileType);
entry.setFileData(data); entry.setFileData(data);
byte[] data2 = entry.getFileData(); byte[] data2 = entry.getFileData();
if (test) { if (test) {
assertTrue("File lengths do not match", data.length == data2.length); assertTrue("File lengths do not match", data.length == data2.length); //$NON-NLS-1$
//assertTrue("File contents do not match", Arrays.equals(data, data2)); //assertTrue("File contents do not match", Arrays.equals(data, data2));
for (int i=0; i<data.length; i++) { for (int i=0; i<data.length; i++) {
assertTrue("File contents differ at " + i, data[i] == data2[i]); assertTrue("File contents differ at " + i, data[i] == data2[i]); //$NON-NLS-1$
} }
} }
} }
@ -311,7 +311,7 @@ public class DiskWriterTest extends TestCase {
*/ */
protected void showDirectory(FormattedDisk[] formattedDisks, String title) { protected void showDirectory(FormattedDisk[] formattedDisks, String title) {
System.out.println(); System.out.println();
System.out.println("************************************************"); System.out.println("************************************************"); //$NON-NLS-1$
System.out.println(title); System.out.println(title);
for (int i=0; i<formattedDisks.length; i++) { for (int i=0; i<formattedDisks.length; i++) {
FormattedDisk formattedDisk = formattedDisks[i]; FormattedDisk formattedDisk = formattedDisks[i];
@ -319,19 +319,19 @@ public class DiskWriterTest extends TestCase {
System.out.println(formattedDisk.getDiskName()); System.out.println(formattedDisk.getDiskName());
List files = formattedDisk.getFiles(); List files = formattedDisk.getFiles();
if (files != null) { if (files != null) {
showFiles(files, "", false); showFiles(files, "", false); //$NON-NLS-1$
} }
System.out.println(formattedDisk.getFreeSpace() + " bytes free."); System.out.println(formattedDisk.getFreeSpace() + " bytes free."); //$NON-NLS-1$
System.out.println(formattedDisk.getUsedSpace() + " bytes used."); System.out.println(formattedDisk.getUsedSpace() + " bytes used."); //$NON-NLS-1$
System.out.println("This disk " + (formattedDisk.canHaveDirectories() ? "does" : "does not") + System.out.println("This disk " + (formattedDisk.canHaveDirectories() ? "does" : "does not") + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
" support directories."); " support directories."); //$NON-NLS-1$
System.out.println("This disk is formatted in the " + formattedDisk.getFormat() + " format."); System.out.println("This disk is formatted in the " + formattedDisk.getFormat() + " format."); //$NON-NLS-1$ //$NON-NLS-2$
System.out.println(); System.out.println();
showDiskUsage(formattedDisk); showDiskUsage(formattedDisk);
} }
System.out.println(); System.out.println();
System.out.println("************************************************"); System.out.println("************************************************"); //$NON-NLS-1$
System.out.println(); System.out.println();
} }
@ -346,13 +346,13 @@ public class DiskWriterTest extends TestCase {
System.out.print(indent); System.out.print(indent);
for (int d=0; d<data.size(); d++) { for (int d=0; d<data.size(); d++) {
System.out.print(data.get(d)); System.out.print(data.get(d));
System.out.print(" "); System.out.print(" "); //$NON-NLS-1$
} }
System.out.println(); System.out.println();
} }
if (entry.isDirectory()) { if (entry.isDirectory()) {
showFiles(((DirectoryEntry)entry).getFiles(), showFiles(((DirectoryEntry)entry).getFiles(),
indent + " ", showDeleted); indent + " ", showDeleted); //$NON-NLS-1$
} }
} }
} }
@ -364,7 +364,7 @@ public class DiskWriterTest extends TestCase {
int[] dimensions = disk.getBitmapDimensions(); int[] dimensions = disk.getBitmapDimensions();
DiskUsage usage = disk.getDiskUsage(); DiskUsage usage = disk.getDiskUsage();
if (usage == null) { if (usage == null) {
System.out.println("A bitmap is not available."); System.out.println("A bitmap is not available."); //$NON-NLS-1$
return; return;
} }
if (dimensions == null) { if (dimensions == null) {
@ -372,7 +372,7 @@ public class DiskWriterTest extends TestCase {
while (usage.hasNext()) { while (usage.hasNext()) {
if (i > 0 && i % 80 == 0) System.out.println(); if (i > 0 && i % 80 == 0) System.out.println();
usage.next(); usage.next();
System.out.print(usage.isFree() ? "." : "U"); System.out.print(usage.isFree() ? "." : "U"); //$NON-NLS-1$ //$NON-NLS-2$
i++; i++;
} }
System.out.println(); System.out.println();
@ -380,12 +380,12 @@ public class DiskWriterTest extends TestCase {
for (int y=dimensions[0]-1; y>=0; y--) { for (int y=dimensions[0]-1; y>=0; y--) {
for (int x=0; x<dimensions[1]; x++) { for (int x=0; x<dimensions[1]; x++) {
usage.next(); usage.next();
System.out.print(usage.isFree() ? "." : "U"); System.out.print(usage.isFree() ? "." : "U"); //$NON-NLS-1$ //$NON-NLS-2$
} }
System.out.println(); System.out.println();
} }
} }
System.out.println("U = used, . = free"); System.out.println("U = used, . = free"); //$NON-NLS-1$
} }
/** /**
@ -400,9 +400,9 @@ public class DiskWriterTest extends TestCase {
} }
for (int d=0; d<disks.length; d++) { for (int d=0; d<disks.length; d++) {
FormattedDisk disk = disks[d]; FormattedDisk disk = disks[d];
System.out.println("Excercising create and delete on disk " System.out.println("Excercising create and delete on disk " //$NON-NLS-1$
+ disk.getDiskName() + " in the " + disk.getFormat() + disk.getDiskName() + " in the " + disk.getFormat() //$NON-NLS-1$
+ " format."); + " format."); //$NON-NLS-1$
int originalUsed = disk.getUsedSpace(); int originalUsed = disk.getUsedSpace();
int originalFree = disk.getFreeSpace(); int originalFree = disk.getFreeSpace();
for (int count=0; count<5; count++) { for (int count=0; count<5; count++) {
@ -421,9 +421,9 @@ public class DiskWriterTest extends TestCase {
entry.delete(); entry.delete();
} }
// Verify that we're back to what we started with: // Verify that we're back to what we started with:
assertTrue("Free space does not match", assertTrue("Free space does not match", //$NON-NLS-1$
originalFree == disk.getFreeSpace()); originalFree == disk.getFreeSpace());
assertTrue("Used space does not match", assertTrue("Used space does not match", //$NON-NLS-1$
originalUsed == disk.getUsedSpace()); originalUsed == disk.getUsedSpace());
} }
} }
@ -437,8 +437,8 @@ public class DiskWriterTest extends TestCase {
throws DiskFullException { throws DiskFullException {
for (int d=0; d<disks.length; d++) { for (int d=0; d<disks.length; d++) {
FormattedDisk disk = disks[d]; FormattedDisk disk = disks[d];
System.out.println("Exercising create, delete, create sequence " System.out.println("Exercising create, delete, create sequence " //$NON-NLS-1$
+ "on disk " + disk.getDiskName() + "."); + "on disk " + disk.getDiskName() + "."); //$NON-NLS-1$ //$NON-NLS-2$
writeFile(disk, 5432, filetype, false); writeFile(disk, 5432, filetype, false);
List files = disk.getFiles(); List files = disk.getFiles();
for (int i=0; i<files.size(); i++) { for (int i=0; i<files.size(); i++) {
@ -450,8 +450,8 @@ public class DiskWriterTest extends TestCase {
for (int i=0; i<files.size(); i++) { for (int i=0; i<files.size(); i++) {
FileEntry entry = (FileEntry) files.get(i); FileEntry entry = (FileEntry) files.get(i);
if (entry.isDeleted()) { if (entry.isDeleted()) {
showFiles(files, "", true); showFiles(files, "", true); //$NON-NLS-1$
fail("There should be no deleted files"); fail("There should be no deleted files"); //$NON-NLS-1$
} }
} }
} }