Merge branch 'master' of ssh://kielweek.web4sap.com/home/trac/git

This commit is contained in:
Marcus Kammer committed 2012-06-08 14:16:20 +02:00
commit 0762454b65
4 files changed
+24 -5

No files matched your search

@@ -1,5 +1,6 @@
package com.sap.sailing.kiworesultimport.test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.io.File;
@@ -16,6 +17,10 @@ import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
import com.sap.sailing.kiworesultimport.ResultList;
import com.sap.sailing.kiworesultimport.ResultListParser;
import com.sap.sailing.kiworesultimport.ResultListParserFactory;
public class ParserTest {
private static final String RESOURCES = "resources/";
@@ -30,9 +35,22 @@ public class ParserTest {
@Test
public void testLoadingSampleXML() throws SAXException, IOException, ParserConfigurationException {
Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder()
.parse(getInputStream("2011-06-18_49er_Wettfahrt_2_Extra.xml"));
.parse(getSampleInputStream());
assertNotNull(doc);
Node resultList = doc.getElementsByTagName("ResultList").item(0);
assertNotNull(resultList);
}
private InputStream getSampleInputStream() throws FileNotFoundException, IOException {
return getInputStream("2011-06-18_49er_Wettfahrt_2_Extra.xml");
}
@Test
public void testObtainingResultList() throws FileNotFoundException, SAXException, IOException, ParserConfigurationException {
ResultListParser parser = ResultListParserFactory.INSTANCE.createResultListParser();
ResultList resultList = parser.parse(getSampleInputStream());
assertNotNull(resultList);
assertEquals("D:\\Programme\\KWSailing\\eventlogos\\KielerWoche_Ergebnislistenkopf_2011.jpg", resultList.getImagePfad());
assertEquals(new String(new byte[] { (byte) 160 /* non-breaking space */}), resultList.getLegende());
}
}
@@ -11,14 +11,12 @@ public class ResultListImpl extends AbstractNodeWrapper implements ResultList {
@Override
public String getLegende() {
// TODO Auto-generated method stub
return null;
return getNode().getAttributes().getNamedItem("legende").getNodeValue();
}
@Override
public String getImagePfad() {
// TODO Auto-generated method stub
return null;
return getNode().getAttributes().getNamedItem("imagePfad").getNodeValue();
}
@Override
@@ -143,6 +143,7 @@ public class TestStoringAndLoadingEventsAndRegattas extends AbstractMongoDBTest
addRaceColumns(numberOfQualifyingRaces, numberOfFinalRaces, regatta);
logColumnsInRegatta(regatta);
RegattaLeaderboard regattaLeaderboard = res.addRegattaLeaderboard(regatta.getRegattaIdentifier(), new int[] { 3, 5 });
assertSame(regatta, regattaLeaderboard.getRegatta());
final RaceColumnInSeries q2 = regatta.getSeriesByName("Qualifying").getRaceColumnByName("Q2");
final Fleet yellow = q2.getFleetByName("Yellow");
logColumnsInRegatta(regatta);
@@ -663,6 +663,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
*/
private void cacheAndReplicateSpecificRegattaWithoutRaceColumns(Regatta regatta) {
if (!regattasByName.containsKey(regatta.getName())) {
logger.info("putting regatta "+regatta.getName()+" ("+regatta.hashCode()+") into regattasByName");
regattasByName.put(regatta.getName(), regatta);
regatta.addRegattaListener(this);
replicate(new AddSpecificRegatta(regatta.getBaseName(), regatta.getBoatClass() == null ? null : regatta
@@ -694,6 +695,7 @@ public class RacingEventServiceImpl implements RacingEventService, RegattaListen
*/
private void cacheAndReplicateDefaultRegatta(Regatta regatta) {
if (!regattasByName.containsKey(regatta.getName())) {
logger.info("putting regatta "+regatta.getName()+" ("+regatta.hashCode()+") into regattasByName");
regattasByName.put(regatta.getName(), regatta);
regatta.addRegattaListener(this);
replicate(new AddDefaultRegatta(regatta.getBaseName(), regatta.getBoatClass() == null ? null : regatta.getBoatClass().getName()));