[jboss-cvs] jboss-seam/examples/itext/src/org/jboss/seam/example/pdf/test ...
Norman Richards
norman.richards at jboss.com
Thu Oct 11 19:33:10 EDT 2007
User: nrichards
Date: 07/10/11 19:33:10
Added: examples/itext/src/org/jboss/seam/example/pdf/test
DocumentTests.java testng.xml
Log:
JBSEAM-2069
Revision Changes Path
1.1 date: 2007/10/11 23:33:10; author: nrichards; state: Exp;jboss-seam/examples/itext/src/org/jboss/seam/example/pdf/test/DocumentTests.java
Index: DocumentTests.java
===================================================================
package org.jboss.seam.example.pdf.test;
import org.jboss.seam.contexts.Contexts;
import org.jboss.seam.core.Conversation;
import org.jboss.seam.mock.SeamTest;
import org.jboss.seam.pdf.DocumentData;
import org.jboss.seam.pdf.DocumentStore;
import org.jboss.seam.pdf.DocumentData.DocType;
import org.testng.annotations.Test;
/**
* This is just a placeholder until I can find a way to actually test the
* UI components.
*/
public class DocumentTests
extends SeamTest
{
@Test
public void documentStore()
throws Exception
{
String conversationId = new FacesRequest("/whyseam.xhtml") {
@Override
protected void invokeApplication() throws Exception {
Conversation.instance().begin();
DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.pdf.documentStore}");
String docId = store.newId();
Contexts.getSessionContext().set("docId", docId);
DocumentData documentData = new DocumentData("base", DocType.PDF, new byte[100]);
store.saveData(docId, documentData);
}
@Override
protected void renderResponse() throws Exception {
String docId = (String) getValue("#{docId}");
assert docId != null;
DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.pdf.documentStore}");
assert store.idIsValid(docId);
}
}.run();
// different conversation
new FacesRequest("/whyseam.xhtml") {
@Override
protected void renderResponse() throws Exception {
String docId = (String) getValue("#{docId}");
assert docId != null;
DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.pdf.documentStore}");
assert !store.idIsValid(docId);
}
}.run();
new FacesRequest("/whyseam.xhtml", conversationId) {
@Override
protected void renderResponse() throws Exception {
String docId = (String) getValue("#{docId}");
assert docId != null;
DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.pdf.documentStore}");
assert store.idIsValid(docId);
DocumentData data = store.getDocumentData(docId);
assert data.getDocType().equals(DocType.PDF);
assert data.getData().length == 100;
}
}.run();
}
}
1.1 date: 2007/10/11 23:33:10; author: nrichards; state: Exp;jboss-seam/examples/itext/src/org/jboss/seam/example/pdf/test/testng.xml
Index: testng.xml
===================================================================
<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="itext" verbose="2" parallel="false">
<test name="pdf tests">
<classes>
<class
name="org.jboss.seam.example.pdf.test.DocumentTests" />
</classes>
</test>
</suite>
More information about the jboss-cvs-commits
mailing list