Author: konstantin.mishin
Date: 2008-09-29 10:33:38 -0400 (Mon, 29 Sep 2008)
New Revision: 10602
Added:
trunk/framework/impl/src/main/java/org/ajax4jsf/model/
trunk/framework/impl/src/main/java/org/ajax4jsf/model/QueueImpl.java
trunk/framework/test/src/test/java/org/ajax4jsf/model/QueueImplTest.java
Log:
Implementation Queue and its test.
Added: trunk/framework/impl/src/main/java/org/ajax4jsf/model/QueueImpl.java
===================================================================
--- trunk/framework/impl/src/main/java/org/ajax4jsf/model/QueueImpl.java
(rev 0)
+++ trunk/framework/impl/src/main/java/org/ajax4jsf/model/QueueImpl.java 2008-09-29
14:33:38 UTC (rev 10602)
@@ -0,0 +1,96 @@
+package org.ajax4jsf.model;
+
+import javax.el.ValueExpression;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class QueueImpl implements Queue {
+
+ private FacesContext context;
+
+ private ValueExpression nameExpression;
+
+ private ValueExpression requestDelayExpression;
+
+ private ValueExpression timeoutExpression;
+
+ private ValueExpression ignoreDupResponsesExpression;
+
+ private ValueExpression limitToListExpression;
+
+ public QueueImpl() {
+ this(null);
+ }
+
+ public QueueImpl(FacesContext context) {
+ if(context == null) {
+ this.context = FacesContext.getCurrentInstance();
+ } else {
+ this.context = context;
+ }
+ }
+
+ public String getName() {
+ String name = null;
+ if (nameExpression != null) {
+ name = (String) nameExpression.getValue(context.getELContext());
+ }
+ return name;
+ }
+
+ public Integer getRequestDelay() {
+ Integer requestDelay = null;
+ if (requestDelayExpression != null) {
+ requestDelay = (Integer) requestDelayExpression.getValue(context.getELContext());
+ }
+ return requestDelay;
+ }
+
+ public Integer getTimeout() {
+ Integer timeout = null;
+ if (timeoutExpression != null) {
+ timeout = (Integer) timeoutExpression.getValue(context.getELContext());
+ }
+ return timeout;
+ }
+
+ public Boolean getIgnoreDupResponses() {
+ Boolean ignoreDupResponses = null;
+ if (ignoreDupResponsesExpression != null) {
+ ignoreDupResponses = (Boolean)
ignoreDupResponsesExpression.getValue(context.getELContext());
+ }
+ return ignoreDupResponses;
+ }
+
+ public Boolean getLimitToList() {
+ Boolean limitToList = null;
+ if (limitToListExpression != null) {
+ limitToList = (Boolean) limitToListExpression.getValue(context.getELContext());
+ }
+ return limitToList;
+ }
+
+ public void setNameExpression(ValueExpression nameExpression) {
+ this.nameExpression = nameExpression;
+ }
+
+ public void setRequestDelayExpression(ValueExpression requestDelayExpression) {
+ this.requestDelayExpression = requestDelayExpression;
+ }
+
+ public void setTimeoutExpression(ValueExpression timeoutExpression) {
+ this.timeoutExpression = timeoutExpression;
+ }
+
+ public void setIgnoreDupResponsesExpression(
+ ValueExpression ignoreDupResponsesExpression) {
+ this.ignoreDupResponsesExpression = ignoreDupResponsesExpression;
+ }
+
+ public void setLimitToListExpression(ValueExpression limitToListExpression) {
+ this.limitToListExpression = limitToListExpression;
+ }
+}
Added: trunk/framework/test/src/test/java/org/ajax4jsf/model/QueueImplTest.java
===================================================================
--- trunk/framework/test/src/test/java/org/ajax4jsf/model/QueueImplTest.java
(rev 0)
+++ trunk/framework/test/src/test/java/org/ajax4jsf/model/QueueImplTest.java 2008-09-29
14:33:38 UTC (rev 10602)
@@ -0,0 +1,100 @@
+/**
+ *
+ */
+package org.ajax4jsf.model;
+
+import javax.el.ValueExpression;
+
+import org.ajax4jsf.tests.AbstractAjax4JsfTestCase;
+import org.ajax4jsf.tests.MockQueue;
+
+/**
+ * @author Konstantin Mishin
+ *
+ */
+public class QueueImplTest extends AbstractAjax4JsfTestCase {
+
+
+ MockQueue mockQueue;
+ QueueImpl queue;
+
+ /**
+ * @param name
+ */
+ public QueueImplTest(String name) {
+ super(name);
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#setUp()
+ */
+ public void setUp() throws Exception {
+ super.setUp();
+ mockQueue = new MockQueue();
+ externalContext.getRequestMap().put("queue", mockQueue);
+ queue = new QueueImpl();
+ }
+
+ /* (non-Javadoc)
+ * @see org.ajax4jsf.tests.AbstractAjax4JsfTestCase#tearDown()
+ */
+ public void tearDown() throws Exception {
+ queue = null;
+ externalContext.getRequestMap().remove("queue");
+ mockQueue = null;
+ super.tearDown();
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.model.QueueImpl#QueueImpl()}.
+ */
+ public void testQueueImpl() {
+ assertNotNull(new QueueImpl());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.model.QueueImpl#getName()}.
+ */
+ public void testGetName() {
+ ValueExpression expression = expressionFactory.createValueExpression(elContext,
"#{queue.name}", String.class);
+ queue.setNameExpression(expression);
+ assertEquals(mockQueue.getName(), queue.getName());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.model.QueueImpl#getRequestDelay()}.
+ */
+ public void testGetRequestDelay() {
+ ValueExpression expression = expressionFactory.createValueExpression(elContext,
"#{queue.requestDelay}", Integer.class);
+ queue.setRequestDelayExpression(expression);
+ assertEquals(mockQueue.getRequestDelay(), queue.getRequestDelay());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.model.QueueImpl#getTimeout()}.
+ */
+ public void testGetTimeout() {
+ ValueExpression expression = expressionFactory.createValueExpression(elContext,
"#{queue.timeout}", Integer.class);
+ queue.setTimeoutExpression(expression);
+ assertEquals(mockQueue.getTimeout(), queue.getTimeout());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.model.QueueImpl#isIgnoreDupResponses()}.
+ */
+ public void testIsIgnoreDupResponses() {
+ ValueExpression expression = expressionFactory.createValueExpression(elContext,
"#{queue.ignoreDupResponses}", Boolean.class);
+ queue.setIgnoreDupResponsesExpression(expression);
+ assertEquals(mockQueue.getIgnoreDupResponses(), queue.getIgnoreDupResponses());
+ }
+
+ /**
+ * Test method for {@link org.ajax4jsf.model.QueueImpl#isLimitToList()}.
+ */
+ public void testIsLimitToList() {
+ ValueExpression expression = expressionFactory.createValueExpression(elContext,
"#{queue.limitToList}", Boolean.class);
+ queue.setLimitToListExpression(expression);
+ assertEquals(mockQueue.getLimitToList(), queue.getLimitToList());
+ }
+
+}
Show replies by date