You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2009/04/15 15:27:13 UTC

svn commit: r765179 - in /lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter: TestReporterFuntionsCRUD.java impl/ReportImplTest.java

Author: andreas
Date: Wed Apr 15 13:27:13 2009
New Revision: 765179

URL: http://svn.apache.org/viewvc?rev=765179&view=rev
Log:
Updating reporter tests to API changes.

Modified:
    lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/TestReporterFuntionsCRUD.java
    lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/impl/ReportImplTest.java

Modified: lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/TestReporterFuntionsCRUD.java
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/TestReporterFuntionsCRUD.java?rev=765179&r1=765178&r2=765179&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/TestReporterFuntionsCRUD.java (original)
+++ lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/TestReporterFuntionsCRUD.java Wed Apr 15 13:27:13 2009
@@ -31,9 +31,9 @@
         Report report = newReport();
         ReportsPersistence manager = init();
         manager.saveReport(report);
-        String cloneId = report.getIdentity();
+        String cloneId = report.getId();
         Report clone = manager.findReport(cloneId);
-        assertEquals(cloneId, clone.getIdentity());
+        assertEquals(cloneId, clone.getId());
         manager.deleteReport(report);
         assertNull(manager.findReport(cloneId));
     }
@@ -50,11 +50,11 @@
             report.start();
             String message = "Starting report \"" + title + "\" at "
                     + report.getStart() + ".";
-            report.addMessage(new Message(Level.INFO, message));
+            report.addMessage(Level.INFO, message);
             message = "testing the level JOB_SUCCESS, reporting a success in a batch job.";
-            report.addMessage(new Message(Level.JOB_SUCCESS, message));
-            report.addMessage(new Message(Level.JOB_SUCCESS, message));
-            report.addMessage(new Message(Level.JOB_ERROR, message));
+            report.addMessage(Level.JOB_SUCCESS, message);
+            report.addMessage(Level.JOB_SUCCESS, message);
+            report.addMessage(Level.JOB_ERROR, message);
             // report.setResult("success");
         } catch (Exception e) {
             // Problem on the next lines is that the report can be still null
@@ -65,8 +65,7 @@
              * add the title and identity (path were the report should be saved
              * in the repository for the file system implementation) yourself.
              */
-            report.addMessage(new Message(Level.ERROR, message, e
-                    .getStackTrace()));
+            report.addMessage(Level.ERROR, message, e.getStackTrace());
         } finally {
             if (report != null) {
                 report.stop();

Modified: lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/impl/ReportImplTest.java
URL: http://svn.apache.org/viewvc/lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/impl/ReportImplTest.java?rev=765179&r1=765178&r2=765179&view=diff
==============================================================================
--- lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/impl/ReportImplTest.java (original)
+++ lenya/contributions/2_0_X/modules/reporter/java/test/org/apache/lenya/modules/reporter/impl/ReportImplTest.java Wed Apr 15 13:27:13 2009
@@ -19,18 +19,20 @@
 
 import java.io.File;
 import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
 import java.util.Date;
+import java.util.List;
+
+import junit.framework.TestCase;
 
 import org.apache.lenya.modules.reporter.Level;
 import org.apache.lenya.modules.reporter.Message;
-
-import junit.framework.TestCase;
+import org.apache.lenya.modules.reporter.Report;
+import org.apache.lenya.modules.reporter.ReportBuilder;
+import org.apache.lenya.modules.reporter.ReportEntry;
 
 public class ReportImplTest extends TestCase {
 
-    public void testLoadSave() throws IOException {
+    public void testLoadSave() throws Exception {
         ReportImpl report1 = new ReportImpl();
         String reportId = "ReportId";
         String title = "Test Title";
@@ -41,38 +43,41 @@
         Level messageLevel1 = Level.JOB_SUCCESS;
         String messageText2 = "Message text <2&>";
         Level messageLevel2 = Level.JOB_ERROR;
-        report1.setIdentity(reportId);
+        report1.setId(reportId);
         report1.setTitle(title);
         report1.setStart(startDate);
         report1.setEnd(endDate);
         report1.setUserId(userId);
         report1.start();
-        report1.addMessage(new Message(messageLevel1, messageText1));
-        report1.addMessage(new Message(messageLevel2, messageText2));
+        report1.addMessage(messageLevel1, messageText1);
+        report1.addMessage(messageLevel2, messageText2);
         report1.stop();
         File file = File.createTempFile("reporterTest", ".xml");
         // file.deleteOnExit();
-        report1.save(new FileWriter(file));
-        ReportImpl report2 = new ReportImpl(new FileReader(file));
-        assertEquals(reportId, report2.getIdentity());
+        ReportBuilder builder = new ReportBuilderImpl();
+        Report report2 = builder.buildReport(new FileReader(file));
+        assertEquals(reportId, report2.getId());
         assertEquals(title, report2.getTitle());
         assertEquals(userId, report2.getUserId());
         // Can't test for dates as milliseconds are not parsed correctly.
         // assertEquals(startDate, report2.getStart());
         // assertEquals(endDate, report2.getEnd());
-        assertEquals(2, report2.getCountMessages());
-        Message[] messages = report2.getMessages();
-        assertEquals(messageText1, messages[0].getMessage());
-        assertEquals(messageLevel1, messages[0].getLevel());
-        assertEquals(messageText2, messages[1].getMessage());
-        assertEquals(messageLevel2, messages[1].getLevel());
+        assertEquals(2, report2.getEntries().size());
+        List<ReportEntry> messages = report2.getEntries();
+        Message message0 = (Message) messages.get(0);
+        Message message1 = (Message) messages.get(1);
+        assertEquals(messageText1, message0.getMessage());
+        assertEquals(messageLevel1, message0.getLevel());
+        assertEquals(messageText2, message1.getMessage());
+        assertEquals(messageLevel2, message1.getLevel());
         file.delete();
     }
     
-    public void testLoad() throws IOException {
+    public void testLoad() throws Exception {
         File file = new File("/tmp/2008-12-25_14-59-13-975.xml");
-        ReportImpl report = new ReportImpl(new FileReader(file));
-        System.out.println(report.getCountMessages());
+        ReportBuilder builder = new ReportBuilderImpl();
+        Report report = builder.buildReport(new FileReader(file));
+        System.out.println(report.getEntries().size());
     }
     
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org