Author: nickarls
Date: 2010-07-21 07:58:20 -0400 (Wed, 21 Jul 2010)
New Revision: 13460
Added:
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/jxl/EventObserver.java
Modified:
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/jxl/JXLSpreadsheetWriterTest.java
Log:
event tests
Added:
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/jxl/EventObserver.java
===================================================================
---
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/jxl/EventObserver.java
(rev 0)
+++
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/jxl/EventObserver.java 2010-07-21
11:58:20 UTC (rev 13460)
@@ -0,0 +1,47 @@
+package org.jboss.seam.spreadsheet.jxl;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+
+import org.jboss.seam.spreadsheet.model.Cell;
+import org.jboss.seam.spreadsheet.model.Worksheet;
+import org.jboss.seam.spreadsheet.model.command.Command;
+
+@ApplicationScoped
+public class EventObserver
+{
+ private boolean cellAdded;
+ private boolean worksheetCreated;
+ private boolean commandExecuted;
+
+ public void observeCellAdded(@Observes @BeforeAdded Cell cell)
+ {
+ cellAdded = true;
+ }
+
+ public void observeWorksheetCreated(@Observes @BeforeCreated Worksheet worksheet)
+ {
+ worksheetCreated = true;
+ }
+
+ public void observeCommandExecuted(@Observes @BeforeExecuted Command command)
+ {
+ commandExecuted = true;
+ }
+
+ public boolean isCellAdded()
+ {
+ return cellAdded;
+ }
+
+ public boolean isWorksheetCreated()
+ {
+ return worksheetCreated;
+ }
+
+ public boolean isCommandExecuted()
+ {
+ return commandExecuted;
+ }
+
+}
Modified:
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/jxl/JXLSpreadsheetWriterTest.java
===================================================================
---
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/jxl/JXLSpreadsheetWriterTest.java 2010-07-21
11:45:02 UTC (rev 13459)
+++
sandbox/modules/spreadsheet/src/test/java/org/jboss/seam/spreadsheet/jxl/JXLSpreadsheetWriterTest.java 2010-07-21
11:58:20 UTC (rev 13460)
@@ -2,6 +2,8 @@
import java.util.Date;
+import javax.inject.Inject;
+
import junit.framework.Assert;
import jxl.CellType;
import jxl.Sheet;
@@ -12,6 +14,7 @@
import org.jboss.seam.spreadsheet.model.Coordinate;
import org.jboss.seam.spreadsheet.model.Workbook;
import org.jboss.seam.spreadsheet.model.Worksheet;
+import org.jboss.seam.spreadsheet.model.command.ColumnWidthCommand;
import org.jboss.seam.spreadsheet.model.formatting.SpreadsheetTest;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.ShrinkWrap;
@@ -23,12 +26,28 @@
@RunWith(Arquillian.class)
public class JXLSpreadsheetWriterTest extends SpreadsheetTest
{
-
+
@Deployment
public static JavaArchive getArchive()
{
- return ShrinkWrap.create("test.jar",
JavaArchive.class).addClass(JXLSpreadsheetWriter.class).addManifestResource(new
ByteArrayAsset("<beans/>".getBytes()),
ArchivePaths.create("beans.xml"));
+ return ShrinkWrap.create("test.jar",
JavaArchive.class).addClasses(JXLSpreadsheetWriter.class,
EventObserver.class).addManifestResource(new
ByteArrayAsset("<beans/>".getBytes()),
ArchivePaths.create("beans.xml"));
}
+
+ @Inject EventObserver eventObserver;
+
+ @Test
+ public void testCellAddedEvent()
+ {
+ Workbook workbook = new Workbook();
+ Worksheet worksheet = Worksheet.named("foo");
+ workbook.getWorksheets().add(worksheet);
+ worksheet.getCells().add(Cell.of("foo", Coordinate.of(0, 0)));
+ worksheet.getCommands().add(new ColumnWidthCommand(1, 100));
+ jxl.Workbook jxlWorkbook = getWorkbook(workbook);
+ Assert.assertTrue(eventObserver.isCellAdded());
+ Assert.assertTrue(eventObserver.isWorksheetCreated());
+ Assert.assertTrue(eventObserver.isCommandExecuted());
+ }
@Test
public void testAddWorksheet()
Show replies by date