Im trying to some of my classes with Eclipse's JUnit but I'm keeping getting the error:ExceptionInInitializerError
. It also says "caused by java.lang.RuntimeException: issues with stringToMap. java.io.FileNotFoundException:TEST.FILES\ephemeral_testing_file.txt(The system cannot find the path specified)
. I've never had such type of error in Eclipse, how can I fix it?
Here is the trace followed by the code of some classes:
java.lang.ExceptionInInitializerError
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:195)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:244)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:241)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.RuntimeException: issues with stringToMap. java.io.FileNotFoundException: TEST_FILES\ephemeral_testing_file.txt (The system cannot find the path specified)
at P4Tests.stringToMap(P4Tests.java:329)
at P4Tests.<clinit>(P4Tests.java:760)
... 23 more
import java.io.*;
import java.util.Scanner;
public class Map {
Spot[][] floorPlan;
Thing[] things;
java.io.PrintStream log;
Map(String fileName, PrintStream log) throws IOException
{
String line = "";
String eachToken = "";
int cols = 0;
int rows = 0;
Scanner data = new Scanner(new File(fileName));
while(data.hasNext())
{
eachToken = data.next();
if(eachToken != "|" ||
eachToken != "a" ||
eachToken != "f" ||
eachToken != "z" ||
eachToken != "g" ||
eachToken != "~" ||
eachToken != "." ||
eachToken != "e" ||
eachToken != "^" ||
eachToken != ">" ||
eachToken != "v" ||
eachToken != "<")
{
System.exit(0);
}
line = data.nextLine();
cols = line.length();
rows++;
}
floorPlan = new Spot[rows][cols];
things = new Thing[cols];
}
public boolean onMap(Coord c)
{
for(int i = 0; i < floorPlan.length; i ++)
for(int j = 0; j < floorPlan[i].length; j++)
{
if(i == c.r && j == c.c)
return true;
}
return false;
}
public Spot spotAt(Coord c)
{
for(int i = 0; i < floorPlan.length; i ++)
for(int j = 0; j < floorPlan[i].length; j++)
{
if(i == c.r && j == c.c)
{
if(floorPlan[i][j] == Spot.Open)
return floorPlan[i][j];
else if(floorPlan[i][j] == Spot.Wall)
return floorPlan[i][j];
else if(floorPlan[i][j] == Spot.Exit)
return floorPlan[i][j];
else if(floorPlan[i][j] == Spot.SignN)
return floorPlan[i][j];
else if(floorPlan[i][j] == Spot.SignE)
return floorPlan[i][j];
else if(floorPlan[i][j] == Spot.SignS)
return floorPlan[i][j];
else if(floorPlan[i][j] == Spot.SignW)
return floorPlan[i][j];
}
}
return null;
}
public int peopeRemaining()
{
return -1;
}
public void addThing(Thing a)
{
int thingSize = things.length;
Thing[] temp = new Thing[thingSize + 1];
for (int i = temp.length - 1; i < temp.length; i++)
{
temp[i] = a;
}
temp = things;
}
public Thing[] thingsAt(Coord c)
{
return ;
}
}
import java.io.PrintStream;
public abstract class Thing implements Representable, Passable {
private Coord loc;
private Coord prevLoc;
public final String repr;
protected java.io.PrintStream log;
protected Map map;
public Thing(Coord c, String repr, Map map, PrintStream log)
{
this.loc = c;
this.prevLoc = c;
this.repr = repr;
this.map = map;
this.log = log;
}
public abstract void doAction();
public Coord getLoc()
{
return this.loc;
}
public Coord getPrevLoc()
{
return this.prevLoc;
}
public void setLoc(Coord c)
{
this.prevLoc = c;
this.loc = c;
}
@Override
public String repr()
{
return repr;
}
@Override
public String toString()
{
return "\"repr()"+"@"+"getLoc()\"";
}
}