edu.rice.cs.drjava
Class CommandLineTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by edu.rice.cs.drjava.DrJavaTestCase
              extended by edu.rice.cs.drjava.CommandLineTest
All Implemented Interfaces:
junit.framework.Test

public final class CommandLineTest
extends DrJavaTestCase

Tests opening/creating files specified as command line arguments.

Version:
$Id: CommandLineTest.java 5175 2010-01-20 08:46:32Z mgricken $

Nested Class Summary
 
Nested classes/interfaces inherited from class junit.framework.TestCase
junit.framework.TestCase.WrappedException
 
Field Summary
private  Log _log
           
private  MainFrame _mf
          The MainFrame we're working with.
private  File f1
          Files that exist, and the filenames that represent them.
private  String f1_contents
           
private  String f1_name
           
private  File f2
           
private  String f2_contents
           
private  String f2_name
           
private  File f3
           
private  String f3_contents
           
private  String f3_name
           
private  File f4
           
private  String f4_contents
           
private  String f4_name
           
private  File f5
           
private  String f5_contents
           
private  String f5_name
           
private  File f6
           
private  String f6_contents
           
private  String f6_name
           
private  File f7
           
private  String f7_contents
           
private  String f7_name
           
private  File f8
           
private  String f8_contents
           
private  String f8_name
           
private static char FS
          File separator, i.e.
private  File nof1
          Files that do not exist (constructor deletes them), and their filenames.
private  String nof1_name
           
private  File nof2
           
private  String nof2_name
           
private  File nof3
           
private  String nof3_name
           
private  File nof4
           
private  String nof4_name
           
private  File nof5
           
private  String nof5_name
           
 
Constructor Summary
CommandLineTest(String name)
          Constructor.
 
Method Summary
private  void checkFile(File relativeFile, String funnyName)
          Helper for testRelativeFile and testDotPaths.
private  File mkTempDir(String funnyName)
          Helper for testRelativeFile and testDotPaths.
 void setUp()
          Set up for every test.
 void tearDown()
          Clean up for every test case.
 void testDotPaths()
          Tests paths with "." and ".." in them.
 void testDups()
          Test duplicate files.
 void testMixed()
          Supplying both valid and invalid filenames on the command line.
 void testNE()
          A nonexistent file.
 void testNone()
          Tests DrJava with no command line arguments.
 void testOpenMany()
          Many files on the command line.
 void testOpenOne()
          Open one file on the command line.
 void testRelativePath()
          A regression test for bug #542747, which related to opening a file via the command line using a relative path.
 
Methods inherited from class edu.rice.cs.drjava.DrJavaTestCase
setConfigSetting, setDocText
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FS

private static final char FS
File separator, i.e. '/' or '\\'.


_mf

private MainFrame _mf
The MainFrame we're working with.


f1

private volatile File f1
Files that exist, and the filenames that represent them.


f1_name

private volatile String f1_name

f1_contents

private volatile String f1_contents

f2

private volatile File f2

f2_name

private volatile String f2_name

f2_contents

private volatile String f2_contents

f3

private volatile File f3

f3_name

private volatile String f3_name

f3_contents

private volatile String f3_contents

f4

private volatile File f4

f4_name

private volatile String f4_name

f4_contents

private volatile String f4_contents

f5

private volatile File f5

f5_name

private volatile String f5_name

f5_contents

private volatile String f5_contents

f6

private volatile File f6

f6_name

private volatile String f6_name

f6_contents

private volatile String f6_contents

f7

private volatile File f7

f7_name

private volatile String f7_name

f7_contents

private volatile String f7_contents

f8

private volatile File f8

f8_name

private volatile String f8_name

f8_contents

private volatile String f8_contents

nof1

private volatile File nof1
Files that do not exist (constructor deletes them), and their filenames.


nof2

private volatile File nof2

nof3

private volatile File nof3

nof4

private volatile File nof4

nof5

private volatile File nof5

nof1_name

private volatile String nof1_name

nof2_name

private volatile String nof2_name

nof3_name

private volatile String nof3_name

nof4_name

private volatile String nof4_name

nof5_name

private volatile String nof5_name

_log

private Log _log
Constructor Detail

CommandLineTest

public CommandLineTest(String name)
Constructor. Sets up test files for us to use: (i) three files that exist and can be opened; (ii) three files that don't exist

Parameters:
name - the name of the test case
Method Detail

setUp

public void setUp()
           throws Exception
Description copied from class: DrJavaTestCase
Set up for every test.

Overrides:
setUp in class DrJavaTestCase
Throws:
Exception - This convention is mandated by JUnit.TestCase, the superclass of this class.

tearDown

public void tearDown()
              throws Exception
Description copied from class: DrJavaTestCase
Clean up for every test case. Only used in unit tests. Added because Windows would intermittently throw a java.util.concurrent.RejectedExecutionException during cleanup.

Overrides:
tearDown in class DrJavaTestCase
Throws:
Exception

testNone

public void testNone()
Tests DrJava with no command line arguments. Should open a new, untitled document.


testOpenOne

public void testOpenOne()
                 throws BadLocationException
Open one file on the command line. Should (obviously) open that file.

Throws:
BadLocationException

testNE

public void testNE()
A nonexistent file. Should open a new, untitled document.


testOpenMany

public void testOpenMany()
                  throws BadLocationException
Many files on the command line. Should open all of them, displaying the last one.

Throws:
BadLocationException

testMixed

public void testMixed()
               throws BadLocationException
Supplying both valid and invalid filenames on the command line. Should open only the valid ones.

Throws:
BadLocationException

testDups

public void testDups()
              throws BadLocationException
Test duplicate files.

Throws:
BadLocationException

testRelativePath

public void testRelativePath()
                      throws IOException,
                             InvalidPackageException
A regression test for bug #542747, which related to opening a file via the command line using a relative path. The problem was that getSourceRoot() would fail on the document, because the filename was not absolute. (The fix will be to absolutize file paths when opening files.)

Throws:
IOException
InvalidPackageException

testDotPaths

public void testDotPaths()
Tests paths with "." and ".." in them. Windows will blow up if you use one in a JFileChooser without converting it to a canonical filename.


mkTempDir

private File mkTempDir(String funnyName)
Helper for testRelativeFile and testDotPaths.


checkFile

private void checkFile(File relativeFile,
                       String funnyName)
                throws IOException,
                       InvalidPackageException
Helper for testRelativeFile and testDotPaths.

Throws:
IOException
InvalidPackageException