Commented out obsolete tests, may be useful if refactored.
#story[881]
This commit is contained in:
@@ -1,87 +1,87 @@
|
||||
package seng302.Data;
|
||||
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
import seng302.DataInput.RaceDataSource;
|
||||
import seng302.DataInput.RaceXMLReader;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
/**
|
||||
* Created by esa46 on 25/04/17.
|
||||
*/
|
||||
public class BoatDataTest {
|
||||
|
||||
|
||||
private static final String ROOT_TAG = "BoatConfig";
|
||||
private static final String[] REQUIRED_TAGS = new String[]{
|
||||
"Boats", "GPSposition"
|
||||
};
|
||||
private static final String[] REQUIRED_ATTRIBUTES = new String[]{
|
||||
"SourceID", "ShapeID", "HullNum", "StoweName",
|
||||
"ShortName", "BoatName"
|
||||
};
|
||||
|
||||
String result;
|
||||
RaceDataSource raceDataSource;
|
||||
|
||||
@Before
|
||||
public void initReader() {
|
||||
try {
|
||||
raceDataSource = new RaceXMLReader("raceXML/bermuda_AC35.xml");
|
||||
BoatData boatData = new BoatData(raceDataSource.getBoats());
|
||||
result = boatData.createXML();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlHasAllNecessaryTags() {
|
||||
|
||||
assertTrue(result.contains("<" + ROOT_TAG + ">"));
|
||||
for (String tag : REQUIRED_TAGS) {
|
||||
assertTrue(result.contains("<" + tag + ">") || result.contains("<" + tag + " "));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlHasAllNecessaryAttributes() {
|
||||
|
||||
for (String attribute : REQUIRED_ATTRIBUTES) {
|
||||
assertTrue(result.contains(attribute + "="));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allTagsAreTerminated() {
|
||||
|
||||
for (String tag : REQUIRED_TAGS) {
|
||||
int lastIndex = 0;
|
||||
String openTag = "<" + tag + ">";
|
||||
String closeTag = "</" + tag + ">";
|
||||
while (lastIndex < result.length() && lastIndex > 0) {
|
||||
lastIndex = result.indexOf(openTag, lastIndex);
|
||||
if (lastIndex > 0) {
|
||||
|
||||
lastIndex = result.indexOf(closeTag, lastIndex);
|
||||
assertTrue(lastIndex > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
//package seng302.Data;
|
||||
//
|
||||
//
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Test;
|
||||
//import org.xml.sax.SAXException;
|
||||
//import seng302.DataInput.RaceDataSource;
|
||||
//import seng302.DataInput.RaceXMLReader;
|
||||
//
|
||||
//import javax.xml.parsers.ParserConfigurationException;
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//import static junit.framework.TestCase.assertTrue;
|
||||
//
|
||||
///**
|
||||
// * Created by esa46 on 25/04/17.
|
||||
// */
|
||||
//public class BoatDataTest {
|
||||
//
|
||||
//
|
||||
// private static final String ROOT_TAG = "BoatConfig";
|
||||
// private static final String[] REQUIRED_TAGS = new String[]{
|
||||
// "Boats", "GPSposition"
|
||||
// };
|
||||
// private static final String[] REQUIRED_ATTRIBUTES = new String[]{
|
||||
// "SourceID", "ShapeID", "HullNum", "StoweName",
|
||||
// "ShortName", "BoatName"
|
||||
// };
|
||||
//
|
||||
// String result;
|
||||
// RaceDataSource raceDataSource;
|
||||
//
|
||||
// @Before
|
||||
// public void initReader() {
|
||||
// try {
|
||||
// raceDataSource = new RaceXMLReader("raceXML/bermuda_AC35.xml");
|
||||
// BoatData boatData = new BoatData(raceDataSource.getBoats());
|
||||
// result = boatData.createXML();
|
||||
//
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (SAXException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (ParserConfigurationException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void xmlHasAllNecessaryTags() {
|
||||
//
|
||||
// assertTrue(result.contains("<" + ROOT_TAG + ">"));
|
||||
// for (String tag : REQUIRED_TAGS) {
|
||||
// assertTrue(result.contains("<" + tag + ">") || result.contains("<" + tag + " "));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void xmlHasAllNecessaryAttributes() {
|
||||
//
|
||||
// for (String attribute : REQUIRED_ATTRIBUTES) {
|
||||
// assertTrue(result.contains(attribute + "="));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void allTagsAreTerminated() {
|
||||
//
|
||||
// for (String tag : REQUIRED_TAGS) {
|
||||
// int lastIndex = 0;
|
||||
// String openTag = "<" + tag + ">";
|
||||
// String closeTag = "</" + tag + ">";
|
||||
// while (lastIndex < result.length() && lastIndex > 0) {
|
||||
// lastIndex = result.indexOf(openTag, lastIndex);
|
||||
// if (lastIndex > 0) {
|
||||
//
|
||||
// lastIndex = result.indexOf(closeTag, lastIndex);
|
||||
// assertTrue(lastIndex > 0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,83 +1,83 @@
|
||||
package seng302.Data;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.xml.sax.SAXException;
|
||||
import seng302.DataInput.RaceDataSource;
|
||||
import seng302.DataInput.RaceXMLReader;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.IOException;
|
||||
|
||||
import static junit.framework.TestCase.assertTrue;
|
||||
|
||||
/**
|
||||
* Created by esa46 on 25/04/17.
|
||||
*/
|
||||
public class RaceDataTest {
|
||||
|
||||
private static final String ROOT_TAG = "Race";
|
||||
private static final String[] REQUIRED_TAGS = new String[]{
|
||||
"RaceID", "RaceType", "CreationTimeDate", "RaceStartTime", "Participants", "Yacht",
|
||||
"CompoundMarkSequence", "Course", "CompoundMark", "Mark", "CourseLimit", "Limit"
|
||||
};
|
||||
String result;
|
||||
RaceDataSource raceDataSource;
|
||||
|
||||
@Before
|
||||
public void initReader() {
|
||||
try {
|
||||
raceDataSource = new RaceXMLReader("raceXML/bermuda_AC35.xml");
|
||||
RaceData raceData = new RaceData(raceDataSource);
|
||||
result = raceData.createXML();
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} catch (SAXException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void xmlHasAllNecessaryFields() {
|
||||
|
||||
assertTrue(result.contains("<" + ROOT_TAG + ">"));
|
||||
for (String tag : REQUIRED_TAGS) {
|
||||
System.out.println(tag);
|
||||
assertTrue(result.contains("<" + tag + ">") || result.contains("<" + tag + " "));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void allTagsAreTerminated() {
|
||||
|
||||
for (String tag : REQUIRED_TAGS) {
|
||||
int lastIndex = 0;
|
||||
String openTag = "<" + tag + ">";
|
||||
String closeTag = "</" + tag + ">";
|
||||
while (lastIndex < result.length() && lastIndex > 0) {
|
||||
lastIndex = result.indexOf(openTag, lastIndex);
|
||||
if (lastIndex > 0) {
|
||||
|
||||
lastIndex = result.indexOf(closeTag, lastIndex);
|
||||
assertTrue(lastIndex > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void idAndTypeAreEquivalent() {
|
||||
String newId = result.substring(result.indexOf("<RaceID>") + 8, result.indexOf("</RaceID>"));
|
||||
String newRaceType = result.substring(result.indexOf("<RaceType>") + 10, result.indexOf("</RaceType>"));
|
||||
|
||||
assertTrue(raceDataSource.getRaceId() == Integer.parseInt(newId));
|
||||
assertTrue(raceDataSource.getRaceType().equals(newRaceType));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//package seng302.Data;
|
||||
//
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Test;
|
||||
//import org.xml.sax.SAXException;
|
||||
//import seng302.DataInput.RaceDataSource;
|
||||
//import seng302.DataInput.RaceXMLReader;
|
||||
//
|
||||
//import javax.xml.parsers.ParserConfigurationException;
|
||||
//import java.io.IOException;
|
||||
//
|
||||
//import static junit.framework.TestCase.assertTrue;
|
||||
//
|
||||
///**
|
||||
// * Created by esa46 on 25/04/17.
|
||||
// */
|
||||
//public class RaceDataTest {
|
||||
//
|
||||
// private static final String ROOT_TAG = "Race";
|
||||
// private static final String[] REQUIRED_TAGS = new String[]{
|
||||
// "RaceID", "RaceType", "CreationTimeDate", "RaceStartTime", "Participants", "Yacht",
|
||||
// "CompoundMarkSequence", "Course", "CompoundMark", "Mark", "CourseLimit", "Limit"
|
||||
// };
|
||||
// String result;
|
||||
// RaceDataSource raceDataSource;
|
||||
//
|
||||
// @Before
|
||||
// public void initReader() {
|
||||
// try {
|
||||
// raceDataSource = new RaceXMLReader("raceXML/bermuda_AC35.xml");
|
||||
// RaceData raceData = new RaceData(raceDataSource);
|
||||
// result = raceData.createXML();
|
||||
//
|
||||
//
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (SAXException e) {
|
||||
// e.printStackTrace();
|
||||
// } catch (ParserConfigurationException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void xmlHasAllNecessaryFields() {
|
||||
//
|
||||
// assertTrue(result.contains("<" + ROOT_TAG + ">"));
|
||||
// for (String tag : REQUIRED_TAGS) {
|
||||
// System.out.println(tag);
|
||||
// assertTrue(result.contains("<" + tag + ">") || result.contains("<" + tag + " "));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void allTagsAreTerminated() {
|
||||
//
|
||||
// for (String tag : REQUIRED_TAGS) {
|
||||
// int lastIndex = 0;
|
||||
// String openTag = "<" + tag + ">";
|
||||
// String closeTag = "</" + tag + ">";
|
||||
// while (lastIndex < result.length() && lastIndex > 0) {
|
||||
// lastIndex = result.indexOf(openTag, lastIndex);
|
||||
// if (lastIndex > 0) {
|
||||
//
|
||||
// lastIndex = result.indexOf(closeTag, lastIndex);
|
||||
// assertTrue(lastIndex > 0);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// @Test
|
||||
// public void idAndTypeAreEquivalent() {
|
||||
// String newId = result.substring(result.indexOf("<RaceID>") + 8, result.indexOf("</RaceID>"));
|
||||
// String newRaceType = result.substring(result.indexOf("<RaceType>") + 10, result.indexOf("</RaceType>"));
|
||||
//
|
||||
// assertTrue(raceDataSource.getRaceId() == Integer.parseInt(newId));
|
||||
// assertTrue(raceDataSource.getRaceType().equals(newRaceType));
|
||||
// }
|
||||
//
|
||||
//
|
||||
//}
|
||||
|
||||
@@ -1,96 +1,96 @@
|
||||
package seng302.Model;/**
|
||||
* Created by Gondr on 26/03/2017.
|
||||
*/
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import seng302.DataInput.RaceXMLReader;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class RaceXMLTest {
|
||||
RaceXMLReader raceXMLReader;
|
||||
|
||||
@Test
|
||||
public void canFindFile() {
|
||||
try {
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
} catch (Exception e) {
|
||||
fail("Cannot find raceXML/bermuda_AC35.xml in the resources folder");
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void canReadBoats() {
|
||||
try {
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
raceXMLReader.readBoats();
|
||||
List<Boat> boats = raceXMLReader.getBoats();
|
||||
assertTrue(boats.size() == 6);
|
||||
//test boat 1
|
||||
assertEquals(boats.get(0).getName(), "ORACLE TEAM USA");
|
||||
assertTrue(boats.get(0).getVelocity() == 20);
|
||||
//test boat 2
|
||||
assertEquals(boats.get(1).getName(), "Land Rover BAR");
|
||||
assertTrue(boats.get(1).getVelocity() == 30);
|
||||
assertEquals(boats.get(1).getCountry(), "GBR");
|
||||
//test boat 3
|
||||
assertEquals(boats.get(2).getName(), "SoftBank Team Japan");
|
||||
assertTrue(boats.get(2).getVelocity() == 25);
|
||||
assertEquals(boats.get(2).getCountry(), "JPN");
|
||||
//test boat 4
|
||||
assertEquals(boats.get(3).getName(), "Groupama Team France");
|
||||
assertTrue(boats.get(3).getVelocity() == 20);
|
||||
assertEquals(boats.get(3).getCountry(), "FRA");
|
||||
//test boat 5
|
||||
assertEquals(boats.get(4).getName(), "Artemis Racing");
|
||||
assertTrue(boats.get(4).getVelocity() == 29);
|
||||
assertEquals(boats.get(4).getCountry(), "SWE");
|
||||
//test boat 6
|
||||
assertEquals(boats.get(5).getName(), "Emirates Team New Zealand");
|
||||
assertTrue(boats.get(5).getVelocity() == 62);
|
||||
assertEquals(boats.get(5).getCountry(), "NZL");
|
||||
} catch (Exception e) {
|
||||
fail("Boat Unreadable");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canReadLegs() {
|
||||
try {
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
raceXMLReader.readLegs();
|
||||
assertTrue(raceXMLReader.getLegs().size() == 5);
|
||||
} catch (Exception e) {
|
||||
fail("Legs Unreadable");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void canReadCourse() {
|
||||
try {
|
||||
RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
raceXMLReader.readCourse();
|
||||
assertTrue(raceXMLReader.getMapTopLeft() != null);
|
||||
assertTrue(raceXMLReader.getMapBottomRight() != null);
|
||||
assertTrue(raceXMLReader.getFinishPt1() != null);
|
||||
assertTrue(raceXMLReader.getFinishPt2() != null);
|
||||
assertTrue(raceXMLReader.getStartPt1() != null);
|
||||
assertTrue(raceXMLReader.getStartPt2() != null);
|
||||
assertTrue(raceXMLReader.getLeewardPt1() != null);
|
||||
assertTrue(raceXMLReader.getLeewardPt2() != null);
|
||||
assertTrue(raceXMLReader.getWindwardPt1() != null);
|
||||
assertTrue(raceXMLReader.getWindwardPt2() != null);
|
||||
assertTrue(raceXMLReader.getMark() != null);
|
||||
assertTrue(raceXMLReader.getBoundary().size() == 11);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail("Course Unreadable");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
//package seng302.Model;/**
|
||||
// * Created by Gondr on 26/03/2017.
|
||||
// */
|
||||
//
|
||||
//import org.junit.Ignore;
|
||||
//import org.junit.Test;
|
||||
//import seng302.DataInput.RaceXMLReader;
|
||||
//
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
//import static org.junit.Assert.*;
|
||||
//
|
||||
//public class RaceXMLTest {
|
||||
// RaceXMLReader raceXMLReader;
|
||||
//
|
||||
// @Test
|
||||
// public void canFindFile() {
|
||||
// try {
|
||||
// RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
// } catch (Exception e) {
|
||||
// fail("Cannot find raceXML/bermuda_AC35.xml in the resources folder");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Ignore
|
||||
// @Test
|
||||
// public void canReadBoats() {
|
||||
// try {
|
||||
// RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
// raceXMLReader.readBoats();
|
||||
// List<Boat> boats = raceXMLReader.getBoats();
|
||||
// assertTrue(boats.size() == 6);
|
||||
// //test boat 1
|
||||
// assertEquals(boats.get(0).getName(), "ORACLE TEAM USA");
|
||||
// assertTrue(boats.get(0).getVelocity() == 20);
|
||||
// //test boat 2
|
||||
// assertEquals(boats.get(1).getName(), "Land Rover BAR");
|
||||
// assertTrue(boats.get(1).getVelocity() == 30);
|
||||
// assertEquals(boats.get(1).getCountry(), "GBR");
|
||||
// //test boat 3
|
||||
// assertEquals(boats.get(2).getName(), "SoftBank Team Japan");
|
||||
// assertTrue(boats.get(2).getVelocity() == 25);
|
||||
// assertEquals(boats.get(2).getCountry(), "JPN");
|
||||
// //test boat 4
|
||||
// assertEquals(boats.get(3).getName(), "Groupama Team France");
|
||||
// assertTrue(boats.get(3).getVelocity() == 20);
|
||||
// assertEquals(boats.get(3).getCountry(), "FRA");
|
||||
// //test boat 5
|
||||
// assertEquals(boats.get(4).getName(), "Artemis Racing");
|
||||
// assertTrue(boats.get(4).getVelocity() == 29);
|
||||
// assertEquals(boats.get(4).getCountry(), "SWE");
|
||||
// //test boat 6
|
||||
// assertEquals(boats.get(5).getName(), "Emirates Team New Zealand");
|
||||
// assertTrue(boats.get(5).getVelocity() == 62);
|
||||
// assertEquals(boats.get(5).getCountry(), "NZL");
|
||||
// } catch (Exception e) {
|
||||
// fail("Boat Unreadable");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void canReadLegs() {
|
||||
// try {
|
||||
// RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
// raceXMLReader.readLegs();
|
||||
// assertTrue(raceXMLReader.getLegs().size() == 5);
|
||||
// } catch (Exception e) {
|
||||
// fail("Legs Unreadable");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void canReadCourse() {
|
||||
// try {
|
||||
// RaceXMLReader raceXMLReader = new RaceXMLReader("raceXML/bermuda_AC35.xml", false);
|
||||
// raceXMLReader.readCourse();
|
||||
// assertTrue(raceXMLReader.getMapTopLeft() != null);
|
||||
// assertTrue(raceXMLReader.getMapBottomRight() != null);
|
||||
// assertTrue(raceXMLReader.getFinishPt1() != null);
|
||||
// assertTrue(raceXMLReader.getFinishPt2() != null);
|
||||
// assertTrue(raceXMLReader.getStartPt1() != null);
|
||||
// assertTrue(raceXMLReader.getStartPt2() != null);
|
||||
// assertTrue(raceXMLReader.getLeewardPt1() != null);
|
||||
// assertTrue(raceXMLReader.getLeewardPt2() != null);
|
||||
// assertTrue(raceXMLReader.getWindwardPt1() != null);
|
||||
// assertTrue(raceXMLReader.getWindwardPt2() != null);
|
||||
// assertTrue(raceXMLReader.getMark() != null);
|
||||
// assertTrue(raceXMLReader.getBoundary().size() == 11);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// fail("Course Unreadable");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
Reference in New Issue
Block a user