@Override public void startCounts(final Counts counts, final BufferedWriter out) throws IOException { out.write("<counts "); out.write("xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"); out.write("xsi:noNamespaceSchemaLocation=\"http://matsim.org/files/dtd/counts_v1.xsd\"\n"); if (counts.getName() != null) { out.write(" name=\"" + counts.getName() + "\""); } else { out.write(" name=\"\""); } if (counts.getDescription() != null) { out.write(" desc=\"" + counts.getDescription() + "\""); } out.write(" year=\"" + counts.getYear() + "\" "); out.write(" > \n"); }
Assert.assertTrue(fixture.counts.getYear()>2000); Assert.assertNotNull(fixture.counts.getName());
public void testSEElementCounts() throws SAXException { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); MatsimCountsReader reader = new MatsimCountsReader(counts); reader.setDoctype("counts_v1.xsd"); reader.startElement("", "counts", "counts", attributeFactory.createCountsAttributes()); assertEquals("Counts attribute setting failed", "testName", counts.getName()); assertEquals("Counts attribute setting failed", "testDesc", counts.getDescription()); assertEquals("Counts attribute setting failed", 2000, counts.getYear()); try { reader.endElement("", "counts", "counts"); } catch (SAXException e) { throw new RuntimeException(e); } }
public void testSECounts() { AttributeFactory attributeFactory = new AttributeFactory(); final Counts counts = new Counts(); CountsReaderMatsimV1 reader = new CountsReaderMatsimV1(counts); reader.startTag("counts", attributeFactory.createCountsAttributes(), null); assertEquals("Counts attribute setting failed", "testName", counts.getName()); assertEquals("Counts attribute setting failed", "testDesc", counts.getDescription()); assertEquals("Counts attribute setting failed", 2000, counts.getYear()); }