[Schmitzm-commits] r1073 - trunk/src_junit/schmitzm/jfree/feature/style

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 5 10:46:06 CEST 2010


Author: mojays
Date: 2010-10-05 10:45:59 +0200 (Tue, 05 Oct 2010)
New Revision: 1073

Modified:
   trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
Log:
FeatureChartStyleTest: new test for copyTo(..)

Modified: trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java
===================================================================
--- trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java	2010-10-05 08:32:02 UTC (rev 1072)
+++ trunk/src_junit/schmitzm/jfree/feature/style/FeatureChartStyleTest.java	2010-10-05 08:45:59 UTC (rev 1073)
@@ -57,6 +57,39 @@
 	FeatureChartStyleXMLFactory xmlFactoryFeature = new FeatureChartStyleXMLFactory();
 	ChartStyleXMLFactory xmlFactoryBasic = new ChartStyleXMLFactory();
 
+    @Test
+    public void testChartStyleCopyTo() throws IOException, CQLException,
+            InterruptedException {
+
+        FeatureCollection<SimpleFeatureType, SimpleFeature> testFeatures = TestingUtil2.getTestFeatures();
+        FeatureChartStyle style1 = new FeatureBasicChartStyle("1", ChartType.BAR);
+        style1.setAttributeName(0, "jahr");
+        style1.setAttributeName(1, "w_bev");
+        JFreeChart chart = style1.applyToFeatureCollection(testFeatures);
+        assertNotNull("applyToFeatureCollection lieferte null!", chart);
+        assertXMLOutputAndInput(xmlFactoryFeature, style1, "testCopyTo_01");
+        
+        
+        FeatureChartStyle style2 =  new FeatureBasicChartStyle(style1.getID(), ChartType.BAR);
+        style1.copyTo( style2 );
+        assertXMLOutputAndInput(xmlFactoryFeature, style2, "testCopyTo_02");
+        
+        assertXMLEqual(xmlFactoryFeature, style1, style2, "testCopyTo_Eq");
+        
+        
+        if (INTERACTIVE) {
+          ChartFrame chartFrame = new ChartFrame(
+            "Sechs Linien (3x2), Zwei Achsen", chart);
+          chartFrame.pack();
+          chartFrame.setVisible(true);
+          while (chartFrame.isVisible()) {
+            Thread.sleep(100);
+          }
+        }
+
+        
+    }
+    
 	@Ignore
 	@Test
 	public void testLineChartDualAxis() throws IOException, CQLException,
@@ -957,6 +990,28 @@
          assertEquals(
                  "Nachdem das Style geschrieben, gelesen und wieder geschrieben wurde ist das XML nicht gleich!",
                  writtenXML, readXML);
+    }
 
- }
+    private <S extends ChartStyle> void assertXMLEqual(ChartStyleXMLFactory<S> xmlFactory, S style1, S style2, String fileName) throws IOException {
+         File testFile1 = File.createTempFile(fileName, ".xml");
+         xmlFactory.writeStyleToFile(style1, fileName, testFile1);
+         assertTrue(testFile1.getAbsolutePath() + " wurde nicht geschrieben!", testFile1.exists());
+         String writtenXML1 = IOUtil.readFileAsString(testFile1);
+         
+         File testFile2 = File.createTempFile(fileName, ".xml");
+         xmlFactory.writeStyleToFile(style1, fileName, testFile2);
+         assertTrue(testFile2.getAbsolutePath() + " wurde nicht geschrieben!", testFile2.exists());
+         String writtenXML2 = IOUtil.readFileAsString(testFile2);
+         
+         System.out.println("##### STYLE 1 #####");
+         System.out.println(writtenXML1);
+         System.out.println("##### STYLE 2 #####");
+         System.out.println(writtenXML2);
+         System.out.println("#######################");
+
+         assertEquals(
+                 "Nachdem Style 1 und 2 geschrieben und als String wieder eingelesen wurden, ist das XML nicht gleich!",
+                 writtenXML1, writtenXML2);
+    }
+
 }



More information about the Schmitzm-commits mailing list