X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fext%2Ftest%2Forg%2Fargeo%2Fcms%2Ftabular%2FJcrTabularTest.java;fp=org.argeo.cms%2Fext%2Ftest%2Forg%2Fargeo%2Fcms%2Ftabular%2FJcrTabularTest.java;h=0000000000000000000000000000000000000000;hb=1a0d5ca243bc86a5f54448186178e5fb04c623e9;hp=8da6148009259b0ee41e26d52c9acab8b871599d;hpb=d169026cb1939009fd90ac46a11f480cb3d803c0;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/ext/test/org/argeo/cms/tabular/JcrTabularTest.java b/org.argeo.cms/ext/test/org/argeo/cms/tabular/JcrTabularTest.java deleted file mode 100644 index 8da614800..000000000 --- a/org.argeo.cms/ext/test/org/argeo/cms/tabular/JcrTabularTest.java +++ /dev/null @@ -1,70 +0,0 @@ -package org.argeo.cms.tabular; - -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.List; - -import javax.jcr.Node; -import javax.jcr.PropertyType; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.apache.jackrabbit.commons.cnd.CndImporter; -import org.argeo.api.tabular.TabularColumn; -import org.argeo.api.tabular.TabularRow; -import org.argeo.api.tabular.TabularRowIterator; -import org.argeo.api.tabular.TabularWriter; -import org.argeo.cms.ArgeoTypes; -import org.argeo.jackrabbit.unit.AbstractJackrabbitTestCase; - -public class JcrTabularTest extends AbstractJackrabbitTestCase { - private final static Log log = LogFactory.getLog(JcrTabularTest.class); - - public void testWriteReadCsv() throws Exception { - // session().setNamespacePrefix("argeo", ArgeoNames.ARGEO_NAMESPACE); - InputStreamReader reader = new InputStreamReader(getClass().getResourceAsStream("/org/argeo/api/ldap.cnd")); - CndImporter.registerNodeTypes(reader, session()); - reader.close(); - reader = new InputStreamReader(getClass().getResourceAsStream("/org/argeo/cms/argeo.cnd")); - CndImporter.registerNodeTypes(reader, session()); - reader.close(); -// reader = new InputStreamReader(getClass().getResourceAsStream("/org/argeo/cms/cms.cnd")); -// CndImporter.registerNodeTypes(reader, session()); -// reader.close(); - - // write - Integer columnCount = 15; - Long rowCount = 1000l; - String stringValue = "test, \ntest"; - - List header = new ArrayList(); - for (int i = 0; i < columnCount; i++) { - header.add(new TabularColumn("col" + i, PropertyType.STRING)); - } - Node tableNode = session().getRootNode().addNode("table", ArgeoTypes.ARGEO_TABLE); - TabularWriter writer = new JcrTabularWriter(tableNode, header, ArgeoTypes.ARGEO_CSV); - for (int i = 0; i < rowCount; i++) { - List objs = new ArrayList(); - for (int j = 0; j < columnCount; j++) { - objs.add(stringValue); - } - writer.appendRow(objs.toArray()); - } - writer.close(); - session().save(); - - if (log.isDebugEnabled()) - log.debug("Wrote tabular content " + rowCount + " rows, " + columnCount + " columns"); - // read - TabularRowIterator rowIt = new JcrTabularRowIterator(tableNode); - Long count = 0l; - while (rowIt.hasNext()) { - TabularRow tr = rowIt.next(); - assertEquals(header.size(), tr.size()); - count++; - } - assertEquals(rowCount, count); - if (log.isDebugEnabled()) - log.debug("Read tabular content " + rowCount + " rows, " + columnCount + " columns"); - } -}