You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@chemistry.apache.org by fm...@apache.org on 2013/08/07 18:44:25 UTC
svn commit: r1511386 - in /chemistry/opencmis/trunk:
chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/
chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/...
Author: fmui
Date: Wed Aug 7 16:44:24 2013
New Revision: 1511386
URL: http://svn.apache.org/r1511386
Log:
more code clean up
Modified:
chemistry/opencmis/trunk/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.java
chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/AbstractParserTest.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserExt.java
chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java
chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/test/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsumTest.java
Modified: chemistry/opencmis/trunk/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.java?rev=1511386&r1=1511385&r2=1511386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-android/chemistry-opencmis-android-client/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/atompub/RepositoryServiceImpl.java Wed Aug 7 16:44:24 2013
@@ -25,13 +25,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.chemistry.opencmis.client.bindings.impl.CmisBindingsHelper;
import org.apache.chemistry.opencmis.client.bindings.spi.BindingSession;
import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomElement;
import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomEntry;
import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomFeed;
import org.apache.chemistry.opencmis.client.bindings.spi.atompub.objects.AtomLink;
-import org.apache.chemistry.opencmis.client.bindings.spi.http.HttpInvoker;
import org.apache.chemistry.opencmis.client.bindings.spi.http.Output;
import org.apache.chemistry.opencmis.client.bindings.spi.http.Response;
import org.apache.chemistry.opencmis.commons.data.ExtensionsData;
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.java?rev=1511386&r1=1511385&r2=1511386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-bindings/src/main/java/org/apache/chemistry/opencmis/client/bindings/spi/http/ApacheClientHttpInvoker.java Wed Aug 7 16:44:24 2013
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
-import java.net.UnknownHostException;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.SSLSocket;
Modified: chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java?rev=1511386&r1=1511385&r2=1511386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-client/chemistry-opencmis-client-impl/src/test/java/org/apache/chemistry/opencmis/client/runtime/CacheTest.java Wed Aug 7 16:44:24 2013
@@ -18,6 +18,12 @@
*/
package org.apache.chemistry.opencmis.client.runtime;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
@@ -25,7 +31,6 @@ import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;
-
import org.apache.chemistry.opencmis.client.api.CmisObject;
import org.apache.chemistry.opencmis.client.runtime.cache.Cache;
import org.apache.chemistry.opencmis.client.runtime.cache.CacheImpl;
@@ -33,8 +38,6 @@ import org.apache.chemistry.opencmis.com
import org.junit.Before;
import org.junit.Test;
-import static junit.framework.Assert.*;
-
public class CacheTest {
@Before
@@ -144,7 +147,7 @@ public class CacheTest {
/**
* Create a Mock for testing Cache is sufficient.
- *
+ *
* @param id
* @return a mocked object
*/
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/AbstractParserTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/AbstractParserTest.java?rev=1511386&r1=1511385&r2=1511386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/AbstractParserTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/AbstractParserTest.java Wed Aug 7 16:44:24 2013
@@ -28,7 +28,6 @@ import org.antlr.runtime.BaseRecognizer;
import org.antlr.runtime.CharStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.Lexer;
-import org.antlr.runtime.RecognizerSharedState;
import org.antlr.runtime.TokenStream;
import org.antlr.runtime.tree.CommonTree;
import org.antlr.stringtemplate.StringTemplate;
@@ -36,12 +35,12 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * This class is clone of org.antlr.gunit.gUnitBase class adapted to Java style
- * Because the original class can't deal with composite grammar this is a replacement
- * working around this antlr bug.
- *
+ * This class is clone of org.antlr.gunit.gUnitBase class adapted to Java style
+ * Because the original class can't deal with composite grammar this is a
+ * replacement working around this antlr bug.
+ *
*/
-public class AbstractParserTest{
+public class AbstractParserTest {
private static final Logger log = LoggerFactory.getLogger(AbstractParserTest.class);
@@ -51,7 +50,7 @@ public class AbstractParserTest{
Class<?> parser;
protected String treeParserPath;
- protected void setUp(Class<?> lexerClass, Class<?> parserClass, String baseGrammar, String baseLexer) {
+ protected void setUp(Class<?> lexerClass, Class<?> parserClass, String baseGrammar, String baseLexer) {
lexer = lexerClass;
parser = parserClass;
this.superGrammarName = baseGrammar;
@@ -63,52 +62,51 @@ public class AbstractParserTest{
protected void testLexerOk(String rule, String statement) {
// test input: "a"
- try {
- Object retval = execLexer(rule, statement, false);
- log.debug("testing rule " + rule + " parsed to: " + retval);
- } catch (Exception e) {
- fail("testing rule " + rule + ": " + e.toString());
- }
+ try {
+ Object retval = execLexer(rule, statement, false);
+ log.debug("testing rule " + rule + " parsed to: " + retval);
+ } catch (Exception e) {
+ fail("testing rule " + rule + ": " + e.toString());
+ }
}
protected void testLexerFail(String rule, String statement) {
// test input: "a"
- try {
- Object retval = execLexer(rule, statement, false);
- fail("testing rule should fail " + rule);
- } catch (Exception e) {
- log.debug("testing rule " + rule + " parsed with exception: " + e);
- }
+ try {
+ Object retval = execLexer(rule, statement, false);
+ fail("testing rule should fail " + rule);
+ } catch (Exception e) {
+ log.debug("testing rule " + rule + " parsed with exception: " + e);
+ }
}
protected void testParserOk(String rule, String statement) {
- try {
- Object retval = execParser(rule, statement, false);
- log.debug("testing rule " + rule + " parsed to: " + retval);
- } catch (Exception e) {
- fail("testing rule "+rule + " failed: " + e.toString());
- }
+ try {
+ Object retval = execParser(rule, statement, false);
+ log.debug("testing rule " + rule + " parsed to: " + retval);
+ } catch (Exception e) {
+ fail("testing rule " + rule + " failed: " + e.toString());
+ }
}
protected void testParserFail(String rule, String statement) {
- try {
- Object retval = execParser(rule, statement, false);
- fail("testing rule should fail " + rule);
- } catch (Exception e) {
- log.debug("testing rule "+rule + " failed: " + e.toString());
- }
+ try {
+ Object retval = execParser(rule, statement, false);
+ fail("testing rule should fail " + rule);
+ } catch (Exception e) {
+ log.debug("testing rule " + rule + " failed: " + e.toString());
+ }
}
protected void testParser(String rule, String statement, String expectedResult) {
- try {
- Object actual = execParser(rule, statement, false);
- log.debug("testing rule " + rule + " parsed to: " + actual);
- } catch (Exception e) {
- fail("testing rule " + rule + " failed: " + e);
- }
+ try {
+ Object actual = execParser(rule, statement, false);
+ log.debug("testing rule " + rule + " parsed to: " + actual);
+ } catch (Exception e) {
+ fail("testing rule " + rule + " failed: " + e);
+ }
}
-
// Invoke target lexer.rule
public String execLexer(String testRuleName, String testInput, boolean isFile) throws Exception {
String result = null;
@@ -117,30 +115,37 @@ public class AbstractParserTest{
input = new ANTLRStringStream(testInput);
/** Use Reflection to create instances of lexer and parser */
- Class<?>[] lexArgTypes = new Class[]{CharStream.class}; // assign type to lexer's args
+ Class<?>[] lexArgTypes = new Class[] { CharStream.class }; // assign
+ // type to
+ // lexer's
+ // args
Constructor<?> lexConstructor = lexer.getConstructor(lexArgTypes);
- Object[] lexArgs = new Object[]{input}; // assign value to lexer's args
- Object lexObj = lexConstructor.newInstance(lexArgs); // makes new instance of lexer
+ Object[] lexArgs = new Object[] { input }; // assign value to lexer's
+ // args
+ Object lexObj = lexConstructor.newInstance(lexArgs); // makes new
+ // instance of
+ // lexer
Method ruleName = null;
-
+
try {
- ruleName = lexer.getMethod("m"+testRuleName, new Class[0]);
+ ruleName = lexer.getMethod("m" + testRuleName, new Class[0]);
} catch (NoSuchMethodException e) {
// try superclass lexers
- Class<?>lexerSuper = Class.forName(lexer.getName() + "_" + baseLexerName);
- ruleName = lexerSuper.getMethod("m"+testRuleName, new Class[0]);
- lexArgTypes = new Class[]{CharStream.class, CmisQlStrictLexer.class};
- lexArgs = new Object[]{input, lexObj };
+ Class<?> lexerSuper = Class.forName(lexer.getName() + "_" + baseLexerName);
+ ruleName = lexerSuper.getMethod("m" + testRuleName, new Class[0]);
+ lexArgTypes = new Class[] { CharStream.class, CmisQlStrictLexer.class };
+ lexArgs = new Object[] { input, lexObj };
lexConstructor = lexerSuper.getConstructor(lexArgTypes);
- lexObj = lexConstructor.newInstance(lexArgs);
+ lexObj = lexConstructor.newInstance(lexArgs);
}
/** Invoke lexer rule, and get the current index in CharStream */
ruleName.invoke(lexObj, new Object[0]);
Method ruleName2 = lexer.getMethod("getCharIndex", new Class[0]);
int currentIndex = (Integer) ruleName2.invoke(lexObj, new Object[0]);
- if ( currentIndex!=input.size() ) {
- throw new RuntimeException("extra text found, '"+input.substring(currentIndex, input.size()-1)+"'");
-// System.out.println("extra text found, '"+input.substring(currentIndex, input.size()-1)+"'");
+ if (currentIndex != input.size()) {
+ throw new RuntimeException("extra text found, '" + input.substring(currentIndex, input.size() - 1) + "'");
+ // System.out.println("extra text found, '"+input.substring(currentIndex,
+ // input.size()-1)+"'");
}
return result;
@@ -154,16 +159,28 @@ public class AbstractParserTest{
input = new ANTLRStringStream(testInput);
/** Use Reflection to create instances of lexer and parser */
- Class<?>[] lexArgTypes = new Class[]{CharStream.class}; // assign type to lexer's args
+ Class<?>[] lexArgTypes = new Class[] { CharStream.class }; // assign
+ // type to
+ // lexer's
+ // args
Constructor<?> lexConstructor = lexer.getConstructor(lexArgTypes);
- Object[] lexArgs = new Object[]{input}; // assign value to lexer's args
- Object lexObj = lexConstructor.newInstance(lexArgs); // makes new instance of lexer
+ Object[] lexArgs = new Object[] { input }; // assign value to lexer's
+ // args
+ Object lexObj = lexConstructor.newInstance(lexArgs); // makes new
+ // instance of
+ // lexer
CommonTokenStream tokens = new CommonTokenStream((Lexer) lexObj);
- Class<?>[] parArgTypes = new Class[]{TokenStream.class}; // assign type to parser's args
+ Class<?>[] parArgTypes = new Class[] { TokenStream.class }; // assign
+ // type to
+ // parser's
+ // args
Constructor<?> parConstructor = parser.getConstructor(parArgTypes);
- Object[] parArgs = new Object[]{tokens}; // assign value to parser's args
- Object parObj = parConstructor.newInstance(parArgs); // makes new instance of parser
+ Object[] parArgs = new Object[] { tokens }; // assign value to parser's
+ // args
+ Object parObj = parConstructor.newInstance(parArgs); // makes new
+ // instance of
+ // parser
Method ruleName = parser.getMethod(testRuleName);
@@ -171,45 +188,43 @@ public class AbstractParserTest{
Object ruleReturn = ruleName.invoke(parObj);
/** If rule has return value, determine if it contains an AST or a ST */
- if ( ruleReturn!=null ) {
- if ( ruleReturn.getClass().toString().indexOf(testRuleName+"_return")>0 ) {
- try { // NullPointerException may happen here...
+ if (ruleReturn != null) {
+ if (ruleReturn.getClass().toString().indexOf(testRuleName + "_return") > 0) {
+ try { // NullPointerException may happen here...
String classPath = parser.getName();
if (null != superGrammarName) {
classPath += "_" + superGrammarName;
}
- Class<?> _return = Class.forName(classPath+"$"+testRuleName+"_return");
+ Class<?> _return = Class.forName(classPath + "$" + testRuleName + "_return");
Method[] methods = _return.getDeclaredMethods();
- for(Method method : methods) {
- if ( method.getName().equals("getTree") ) {
+ for (Method method : methods) {
+ if (method.getName().equals("getTree")) {
Method returnName = _return.getMethod("getTree");
CommonTree tree = (CommonTree) returnName.invoke(ruleReturn);
result = tree.toStringTree();
- }
- else if ( method.getName().equals("getTemplate") ) {
+ } else if (method.getName().equals("getTemplate")) {
Method returnName = _return.getMethod("getTemplate");
StringTemplate st = (StringTemplate) returnName.invoke(ruleReturn);
result = st.toString();
}
}
- }
- catch(Exception e) {
- throw(e); // Note: If any exception occurs, the test is viewed as failed.
+ } catch (Exception e) {
+ throw (e); // Note: If any exception occurs, the test is
+ // viewed as failed.
}
}
}
-
/** Invalid input */
- if ( tokens.index()!=tokens.size() ) {
+ if (tokens.index() != tokens.size()) {
throw new RuntimeException("Invalid input.");
}
/** Check for syntax errors */
- if (((BaseRecognizer)parObj).getNumberOfSyntaxErrors() > 0) {
+ if (((BaseRecognizer) parObj).getNumberOfSyntaxErrors() > 0) {
throw new RuntimeException("Syntax error occured");
}
return result;
}
- }
+}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserExt.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserExt.java?rev=1511386&r1=1511385&r2=1511386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserExt.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserExt.java Wed Aug 7 16:44:24 2013
@@ -18,16 +18,12 @@
*/
package org.apache.chemistry.opencmis.server.support.query;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class TestParserExt extends AbstractParserTest {
- private static final Logger log = LoggerFactory.getLogger(TestParserStrict.class);
-
@Before
public void setUp() throws Exception {
super.setUp(CmisQlExtLexer.class, CmisQlExtParser.class, null, "CmisBaseLexer");
@@ -46,23 +42,20 @@ public class TestParserExt extends Abstr
@Test
public void test_query1() {
- testParser("query", "SELECT DISTINCT a, b, c FROM Document", "(SELECT DISTINCT (LIST (COL a) (COL b) (COL c)) (FROM (TABLE Document)))");
+ testParser("query", "SELECT DISTINCT a, b, c FROM Document",
+ "(SELECT DISTINCT (LIST (COL a) (COL b) (COL c)) (FROM (TABLE Document)))");
}
@Test
public void test_query2() {
- testParserOk("query",
- "SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES " +
- "FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM " +
- " WHERE ( 100000 <= ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )");
+ testParserOk("query", "SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES "
+ + "FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM "
+ + " WHERE ( 100000 <= ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )");
}
-
@Test
public void test_query3() {
- testParserOk("query",
- "SELECT OBJECT_ID, SCORE() AS X, DESTINATION, DEPARTURE_DATES " +
- "FROM TRAVEL_BROCHURE " +
- "WHERE ( CONTAINS('CARIBBEAN CENTRAL AMERICA CRUISE TOUR') ) AND( '2010-1-1' < ANY DEPARTURE_DATES )");
+ testParserOk("query", "SELECT OBJECT_ID, SCORE() AS X, DESTINATION, DEPARTURE_DATES " + "FROM TRAVEL_BROCHURE "
+ + "WHERE ( CONTAINS('CARIBBEAN CENTRAL AMERICA CRUISE TOUR') ) AND( '2010-1-1' < ANY DEPARTURE_DATES )");
}
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java?rev=1511386&r1=1511385&r2=1511386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-server/chemistry-opencmis-server-support/src/test/java/org/apache/chemistry/opencmis/server/support/query/TestParserStrict.java Wed Aug 7 16:44:24 2013
@@ -18,19 +18,15 @@
*/
package org.apache.chemistry.opencmis.server.support.query;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author Jens
- *
+ *
*/
-public class TestParserStrict extends AbstractParserTest{
-
- private static final Logger log = LoggerFactory.getLogger(TestParserStrict.class);
+public class TestParserStrict extends AbstractParserTest {
@Before
public void setUp() {
@@ -45,13 +41,13 @@ public class TestParserStrict extends Ab
// ----- Lexer tests -----
- // ID:
+ // ID:
@Test
public void testID1() {
- testLexerOk("ID", "a");
+ testLexerOk("ID", "a");
}
-// "toto" OK
+ // "toto" OK
@Test
public void testID2() {
testLexerFail("ID", "!");
@@ -62,217 +58,218 @@ public class TestParserStrict extends Ab
testLexerOk("ID", "toto");
}
-// "toto123" OK
+ // "toto123" OK
@Test
public void testID4() throws Exception {
testLexerOk("ID", "toto123");
}
-// "toto123_" OK
+ // "toto123_" OK
@Test
public void testID5() throws Exception {
testLexerOk("ID", "toto123_");
}
-// "_foo" OK
+ // "_foo" OK
@Test
public void testID6() throws Exception {
testLexerOk("ID", "_foo");
}
-// "foo:bar" OK
+ // "foo:bar" OK
@Test
public void testID7() throws Exception {
testLexerOk("ID", "foo:bar");
}
-// "123" FAIL
+ // "123" FAIL
@Test
public void testID8() throws Exception {
testLexerFail("ID", "123");
}
-// "123abc" FAIL
+
+ // "123abc" FAIL
@Test
public void testID9() throws Exception {
testLexerFail("ID", "123abc");
}
-// NUM_LIT:
-// "123" OK
+ // NUM_LIT:
+ // "123" OK
@Test
public void testNUM_LIT1() throws Exception {
testLexerOk("NUM_LIT", "123");
}
-// "0" OK
+ // "0" OK
@Test
public void testNUM_LIT2() throws Exception {
testLexerOk("NUM_LIT", "0");
}
-// "-0" OK
+ // "-0" OK
@Test
public void testNUM_LIT3() throws Exception {
testLexerOk("NUM_LIT", "-0");
}
-// "1" OK
+ // "1" OK
@Test
public void testNUM_LIT4() throws Exception {
testLexerOk("NUM_LIT", "1");
}
-// "-1" OK
+ // "-1" OK
@Test
public void testNUM_LIT5() throws Exception {
testLexerOk("NUM_LIT", "-1");
}
-// "-123" OK
+ // "-123" OK
@Test
public void testNUM_LIT6() throws Exception {
testLexerOk("NUM_LIT", "123");
}
-// "0123" OK
+ // "0123" OK
@Test
public void testNUM_LIT7() throws Exception {
testLexerOk("NUM_LIT", "0123");
}
-// "-0123" OK
+ // "-0123" OK
@Test
public void testNUM_LIT8() throws Exception {
testLexerOk("NUM_LIT", "-0123");
}
-// "123abc" FAIL
+ // "123abc" FAIL
@Test
public void testNUM_LIT9() throws Exception {
testLexerFail("NUM_LIT", "123abc");
}
-// "123E" FAIL
+ // "123E" FAIL
@Test
public void testNUM_LIT10() throws Exception {
testLexerFail("NUM_LIT", "123E");
}
-// "123.456" OK
+ // "123.456" OK
@Test
public void testNUM_LIT11() throws Exception {
testLexerOk("NUM_LIT", "123.456");
}
-// "+123.456" OK
+ // "+123.456" OK
@Test
public void testNUM_LIT12() throws Exception {
testLexerOk("NUM_LIT", "+123.456");
}
-// "-123.456" OK
+ // "-123.456" OK
@Test
public void testNUM_LIT13() throws Exception {
testLexerOk("NUM_LIT", "-123.456");
}
-// ".456" OK
+ // ".456" OK
@Test
public void testNUM_LIT14() throws Exception {
testLexerOk("NUM_LIT", ".456");
}
-// "+.456" OK
+ // "+.456" OK
@Test
public void testNUM_LIT15() throws Exception {
testLexerOk("NUM_LIT", "+.456");
}
-// "-.456" OK
+ // "-.456" OK
@Test
public void testNUM_LIT16() throws Exception {
testLexerOk("NUM_LIT", "-.456");
}
-// "123." OK
+ // "123." OK
@Test
public void testNUM_LIT17() throws Exception {
testLexerOk("NUM_LIT", "123.");
}
-// "+123." OK
+ // "+123." OK
@Test
public void testNUM_LIT18() throws Exception {
testLexerOk("NUM_LIT", "+123.");
}
-// "-123." OK
+ // "-123." OK
@Test
public void testNUM_LIT19() throws Exception {
testLexerOk("NUM_LIT", "-123.");
}
-// "+123.456E78" OK
+ // "+123.456E78" OK
@Test
public void testNUM_LIT20() throws Exception {
testLexerOk("NUM_LIT", "+123.456E78");
}
-// "-123.456E-78" OK
+ // "-123.456E-78" OK
@Test
public void testNUM_LIT21() throws Exception {
testLexerOk("NUM_LIT", "-123.456E-78");
}
-// ".456E78" OK
+ // ".456E78" OK
@Test
public void testNUM_LIT22() throws Exception {
testLexerOk("NUM_LIT", ".456E78");
}
-// "+123.E+78" OK
+ // "+123.E+78" OK
@Test
public void testNUM_LIT23() throws Exception {
testLexerOk("NUM_LIT", "+123.E+78");
}
-// STRING_LIT:
-// "'abc'" OK
+ // STRING_LIT:
+ // "'abc'" OK
@Test
public void testSTRING_LIT1() throws Exception {
testLexerOk("STRING_LIT", "'abc'");
}
-// "'a''bc'" OK
+ // "'a''bc'" OK
@Test
public void testSTRING_LIT2() throws Exception {
testLexerOk("STRING_LIT", "'a''bc'");
}
-// "'abc" FAIL
+ // "'abc" FAIL
@Test
public void testSTRING_LIT3() throws Exception {
testLexerFail("STRING_LIT", "'abc");
}
-// "abc'" FAIL
+ // "abc'" FAIL
@Test
public void testSTRING_LIT4() throws Exception {
testLexerFail("STRING_LIT", "abc'");
}
-// "'ab'c'" FAIL
+ // "'ab'c'" FAIL
@Test
public void testSTRING_LIT5() throws Exception {
testLexerFail("STRING_LIT", "'ab'c'");
}
-
+
@Test
public void testSTRING_LIT6() throws Exception {
testLexerOk("STRING_LIT", "'That''s'");
testLexerOk("STRING_LIT", "'Gus'''");
}
-
+
@Test
public void testSTRING_LIT7() throws Exception {
testLexerOk("STRING_LIT", "'That\\\'s'");
@@ -283,490 +280,484 @@ public class TestParserStrict extends Ab
public void testSTRING_LIT8() throws Exception {
testLexerOk("STRING_LIT", "'c:\\\\temp'");
}
-
+
@Test
public void testSTRING_LIT9() throws Exception {
testLexerOk("STRING_LIT", "'Like%String'");
}
-
+
@Test
public void testSTRING_LIT10() throws Exception {
testLexerOk("STRING_LIT", "'Like_String'");
}
-
+
@Test
public void testSTRING_LIT11() throws Exception {
testLexerOk("STRING_LIT", "'Like\\%String'");
}
-
+
@Test
public void testSTRING_LIT12() throws Exception {
testLexerOk("STRING_LIT", "'Like\\_String'");
}
-
-// BOOL_LIT:
-// "TRUE" OK
+ // BOOL_LIT:
+ // "TRUE" OK
@Test
public void testBOOL_LIT1() throws Exception {
testLexerOk("BOOL_LIT", "TRUE");
}
-// "true" OK
+ // "true" OK
@Test
public void testSBOOL_LIT2() throws Exception {
testLexerOk("BOOL_LIT", "true");
}
-// "FALSE" OK
+ // "FALSE" OK
@Test
public void testBOOL_LIT3() throws Exception {
testLexerOk("BOOL_LIT", "FALSE");
}
-// "false" OK
+ // "false" OK
@Test
public void testBOOL_LIT4() throws Exception {
testLexerOk("BOOL_LIT", "false");
}
-
-// TIME_LIT:
-// "TIMESTAMP '2010-01-01Z01:01:01.000Z'" OK
+ // TIME_LIT:
+ // "TIMESTAMP '2010-01-01Z01:01:01.000Z'" OK
@Test
public void testTIME_LIT1() throws Exception {
testLexerOk("TIME_LIT", "TIMESTAMP '2010-01-01Z01:01:01.000Z'");
}
-// "timestamp '123'" OK
+ // "timestamp '123'" OK
@Test
public void testTIME_LIT2() throws Exception {
testLexerOk("TIME_LIT", "timestamp '123'");
}
-// "TIMESTAMP 123" FAIL
+ // "TIMESTAMP 123" FAIL
@Test
public void testTIME_LIT3() throws Exception {
testLexerFail("TIME_LIT", "TIMESTAMP 123");
}
-
// ----- Parser tests -----
-// literal:
-// "123" OK
+ // literal:
+ // "123" OK
@Test
public void testLiteral1() throws Exception {
testParserOk("literal", "123");
}
-// "-123" OK
+ // "-123" OK
@Test
public void testLiteral2() throws Exception {
testParserOk("literal", "123");
}
-// "0" OK
+ // "0" OK
@Test
public void testLiteral3() throws Exception {
testParserOk("literal", "0");
}
-// "0123" OK
+ // "0123" OK
@Test
public void testLiteral4() throws Exception {
testParserOk("literal", "0123");
}
// "abc123" OK
-// "123abc" FAIL
+ // "123abc" FAIL
@Test
public void testLiteral5() throws Exception {
testParserFail("literal", "123abc");
}
-// "'abc'" OK
+ // "'abc'" OK
@Test
public void testLiteral6() throws Exception {
testParserOk("literal", "'abc'");
}
-// "123.345E78" OK
+ // "123.345E78" OK
@Test
public void testLiteral7() throws Exception {
testParserOk("literal", "123.345E78");
}
-
-// order_by_clause:
-// "ORDER BY foo" -> (ORDER_BY (COL foo) ASC)
+ // order_by_clause:
+ // "ORDER BY foo" -> (ORDER_BY (COL foo) ASC)
@Test
public void testOrderBy1() throws Exception {
testParser("order_by_clause", "ORDER BY foo", "(ORDER_BY (COL foo) ASC)");
}
-// "ORDER BY foo ASC" -> (ORDER_BY (COL foo) ASC)
+ // "ORDER BY foo ASC" -> (ORDER_BY (COL foo) ASC)
@Test
public void testOrderBy2() throws Exception {
- testParser("order_by_clause", "ORDER BY foo ASC", "ORDER_BY (COL foo) ASC)");
+ testParser("order_by_clause", "ORDER BY foo ASC", "ORDER_BY (COL foo) ASC)");
}
-// "ORDER BY foo DESC" -> (ORDER_BY (COL foo) DESC)
+ // "ORDER BY foo DESC" -> (ORDER_BY (COL foo) DESC)
@Test
public void testOrderBy3() throws Exception {
testParser("order_by_clause", "ORDER BY foo DESC", "(ORDER_BY (COL foo) DESC)");
}
-// "ORDER BY t.foo, bar DESC" -> (ORDER_BY (COL t foo) ASC (COL bar) DESC)
+ // "ORDER BY t.foo, bar DESC" -> (ORDER_BY (COL t foo) ASC (COL bar) DESC)
@Test
public void testOrderBy4() throws Exception {
testParser("order_by_clause", "ORDER BY t.foo, bar DESC", "(ORDER_BY (COL t foo) ASC (COL bar) DESC)");
}
-
-// column_reference:
-// "foo" -> (COL foo)
+ // column_reference:
+ // "foo" -> (COL foo)
@Test
public void test_column_reference1() throws Exception {
testParser("column_reference", "foo", "(COL foo)");
}
-// "bar.foo" -> (COL bar foo)
+ // "bar.foo" -> (COL bar foo)
@Test
public void test_column_reference2() throws Exception {
testParser("column_reference", "bar.foo", "(COL bar foo)");
}
-
-// from_clause:
-// "FROM foo JOIN bar ON x = y" -> (FROM (TABLE foo) (JOIN INNER (TABLE bar) (ON (COL x) = (COL y))))
+ // from_clause:
+ // "FROM foo JOIN bar ON x = y" -> (FROM (TABLE foo) (JOIN INNER (TABLE bar)
+ // (ON (COL x) = (COL y))))
@Test
public void testFrom() throws Exception {
- testParser("from_clause", "FROM foo JOIN bar ON x = y", "(FROM (TABLE foo) (JOIN INNER (TABLE bar) (ON (COL x) = (COL y))))");
+ testParser("from_clause", "FROM foo JOIN bar ON x = y",
+ "(FROM (TABLE foo) (JOIN INNER (TABLE bar) (ON (COL x) = (COL y))))");
}
-// table_join:
-// "LEFT OUTER JOIN foo ON x = y" -> (JOIN LEFT (TABLE foo) (ON (COL x) = (COL y)))
+ // table_join:
+ // "LEFT OUTER JOIN foo ON x = y" -> (JOIN LEFT (TABLE foo) (ON (COL x) =
+ // (COL y)))
@Test
public void test_column_reference11() throws Exception {
testParser("table_join", "LEFT OUTER JOIN foo ON x = y", "(JOIN LEFT (TABLE foo) (ON (COL x) = (COL y)))");
}
-// "INNER JOIN foo" -> (JOIN INNER (TABLE foo))
+ // "INNER JOIN foo" -> (JOIN INNER (TABLE foo))
@Test
- public void test_column_reference12() throws Exception {
- testParser("table_join", "INNER JOIN foo" , "(JOIN INNER (TABLE foo))");
+ public void test_column_reference12() throws Exception {
+ testParser("table_join", "INNER JOIN foo", "(JOIN INNER (TABLE foo))");
}
-// one_table:
-// "foo" -> (TABLE foo)
+ // one_table:
+ // "foo" -> (TABLE foo)
@Test
- public void test_column_reference3() throws Exception {
+ public void test_column_reference3() throws Exception {
testParser("one_table", "foo", "(TABLE foo)");
}
-// "foo bar" -> (TABLE foo bar)
+ // "foo bar" -> (TABLE foo bar)
@Test
- public void test_column_reference4() throws Exception {
+ public void test_column_reference4() throws Exception {
testParser("one_table", "foo bar", "(TABLE foo bar)");
}
-// "foo AS bar" -> (TABLE foo bar)
+ // "foo AS bar" -> (TABLE foo bar)
@Test
- public void test_column_reference5() throws Exception {
+ public void test_column_reference5() throws Exception {
testParser("one_table", "foo AS bar", "(TABLE foo bar)");
}
-// "(foo)" -> (TABLE foo)
+ // "(foo)" -> (TABLE foo)
@Test
- public void test_column_reference6() throws Exception {
+ public void test_column_reference6() throws Exception {
testParser("one_table", "(foo)", "(TABLE foo)");
}
-// in_predicate:
-// "foo IN ( 'a', 'b', 'c')" -> (IN (COL foo) (IN_LIST 'a' 'b' 'c'))
+ // in_predicate:
+ // "foo IN ( 'a', 'b', 'c')" -> (IN (COL foo) (IN_LIST 'a' 'b' 'c'))
@Test
public void test_in_predicate1() throws Exception {
testParser("in_predicate", "foo IN ( 'a', 'b', 'c')", "(IN (COL foo) (IN_LIST 'a' 'b' 'c'))");
}
-// "foo NOT IN ( 1, 2, 3)" -> (NOT_IN (COL foo) (IN_LIST 1 2 3))
+ // "foo NOT IN ( 1, 2, 3)" -> (NOT_IN (COL foo) (IN_LIST 1 2 3))
@Test
public void test_in_predicate2() throws Exception {
testParser("in_predicate", "foo NOT IN ( 1, 2, 3)", "(NOT_IN (COL foo) (IN_LIST 1 2 3))");
}
-
-// quantified_in_predicate:
-// "ANY foo IN ('a', 1)" -> (IN_ANY (COL foo) (IN_LIST 'a' 1))
+ // quantified_in_predicate:
+ // "ANY foo IN ('a', 1)" -> (IN_ANY (COL foo) (IN_LIST 'a' 1))
@Test
public void tes_quantified_in_predicate() throws Exception {
testParser("quantified_in_predicate", "ANY foo IN ('a', 1)", "(IN_ANY (COL foo) (IN_LIST 'a' 1))");
}
-
-// comparison_predicate:
-// "foo = 1" -> (= (COL foo) 1)
+ // comparison_predicate:
+ // "foo = 1" -> (= (COL foo) 1)
@Test
public void test_comparison_predicate1() throws Exception {
testParser("comparison_predicate", "foo = 1", "(= (COL foo) 1)");
}
-// "foo <> 1" -> (<> (COL foo) 1)
+ // "foo <> 1" -> (<> (COL foo) 1)
@Test
public void test_comparison_predicate2() throws Exception {
- testParser("comparison_predicate", "foo <> 1", "(<> (COL foo) 1)");
+ testParser("comparison_predicate", "foo <> 1", "(<> (COL foo) 1)");
}
-//
-// predicate:
-// "foo = 1" -> (= (COL foo) 1)
+ //
+ // predicate:
+ // "foo = 1" -> (= (COL foo) 1)
@Test
public void test_predicate1() throws Exception {
testParser("predicate", "foo = 1", "(= (COL foo) 1)");
}
-// "foo IN ('bar')" -> (IN (COL foo) (IN_LIST 'bar'))
+ // "foo IN ('bar')" -> (IN (COL foo) (IN_LIST 'bar'))
@Test
public void test_predicate2() throws Exception {
testParser("predicate", "foo IN ('bar')", "(IN (COL foo) (IN_LIST 'bar'))");
}
-// "foo IS NULL" -> (IS_NULL (COL foo))
+ // "foo IS NULL" -> (IS_NULL (COL foo))
@Test
public void test_predicate3() throws Exception {
- testParser("predicate","foo IS NULL", "(IS_NULL (COL foo))");
+ testParser("predicate", "foo IS NULL", "(IS_NULL (COL foo))");
}
-// "foo IS NOT NULL" -> (IS_NOT_NULL (COL foo))
+ // "foo IS NOT NULL" -> (IS_NOT_NULL (COL foo))
@Test
public void test_predicate4() throws Exception {
testParser("predicate", "foo IS NOT NULL", "(IS_NOT_NULL (COL foo))");
}
-// "1 = ANY foo" -> (EQ_ANY 1 (COL foo))
+ // "1 = ANY foo" -> (EQ_ANY 1 (COL foo))
@Test
public void test_predicate5() throws Exception {
testParser("predicate", "1 = ANY foo", "(EQ_ANY 1 (COL foo))");
}
-// "SCORE() = 'bar'" -> (= SCORE 'bar')
+ // "SCORE() = 'bar'" -> (= SCORE 'bar')
@Test
public void test_predicate6() throws Exception {
testParser("predicate", "SCORE() = 'bar'", "(= SCORE 'bar')");
}
-
-// boolean_term:
-// "c >= 3 AND d <= 4" -> (AND (>= (COL c) 3) (<= (COL d) 4))
+ // boolean_term:
+ // "c >= 3 AND d <= 4" -> (AND (>= (COL c) 3) (<= (COL d) 4))
@Test
public void boolean_term1() throws Exception {
testParser("boolean_term", "c >= 3 AND d <= 4", "(AND (>= (COL c) 3) (<= (COL d) 4))");
}
-// "c >= 3 AND NOT d <= 4" -> (AND (>= (COL c) 3) (NOT (<= (COL d) 4)))
+ // "c >= 3 AND NOT d <= 4" -> (AND (>= (COL c) 3) (NOT (<= (COL d) 4)))
@Test
public void boolean_term2() throws Exception {
testParser("boolean_term", "c >= 3 AND NOT d <= 4", "(AND (>= (COL c) 3) (NOT (<= (COL d) 4)))");
}
-
-// folder_predicate:
-// "IN_FOLDER(foo,'ID123')" -> (IN_FOLDER foo 'ID123')
+ // folder_predicate:
+ // "IN_FOLDER(foo,'ID123')" -> (IN_FOLDER foo 'ID123')
@Test
public void folder_predicate1() throws Exception {
testParser("folder_predicate", "IN_FOLDER(foo,'ID123')", "(IN_FOLDER foo 'ID123')");
}
-// "IN_FOLDER('ID123')" -> (IN_FOLDER 'ID123')
+ // "IN_FOLDER('ID123')" -> (IN_FOLDER 'ID123')
@Test
public void folder_predicate2() throws Exception {
testParser("folder_predicate", "IN_FOLDER('ID123')", "(IN_FOLDER 'ID123')");
}
-// "IN_TREE(foo,'ID123')" -> (IN_TREE foo 'ID123')
+ // "IN_TREE(foo,'ID123')" -> (IN_TREE foo 'ID123')
@Test
public void folder_predicate3() throws Exception {
testParser("folder_predicate", "IN_TREE(foo,'ID123')", "(IN_FOLDER 'ID123')");
}
-// "IN_TREE('ID123')" -> (IN_TREE 'ID123')
+ // "IN_TREE('ID123')" -> (IN_TREE 'ID123')
@Test
public void folder_predicate4() throws Exception {
- testParser("folder_predicate","IN_TREE('ID123')" , " (IN_TREE 'ID123')");
+ testParser("folder_predicate", "IN_TREE('ID123')", " (IN_TREE 'ID123')");
}
@Test
public void folder_predicate() throws Exception {
- testParser("search_condition", "id456 LIKE 'Foo%' AND IN_FOLDER('abc')", "(AND (LIKE 'id456' 'Foo%') (IN_FOLDER 'abc')");
+ testParser("search_condition", "id456 LIKE 'Foo%' AND IN_FOLDER('abc')",
+ "(AND (LIKE 'id456' 'Foo%') (IN_FOLDER 'abc')");
}
-// text_search_predicate:
-// "CONTAINS('foo')" -> (CONTAINS 'foo')
+ // text_search_predicate:
+ // "CONTAINS('foo')" -> (CONTAINS 'foo')
@Test
public void text_search_predicate1() throws Exception {
testParser("text_search_predicate", "CONTAINS('foo')", "(CONTAINS 'foo')");
}
-// "CONTAINS(bar, 'foo')" -> (CONTAINS bar 'foo')
+ // "CONTAINS(bar, 'foo')" -> (CONTAINS bar 'foo')
@Test
public void text_search_predicate2() throws Exception {
testParser("text_search_predicate", "CONTAINS(bar, 'foo')", "(CONTAINS bar 'foo')");
}
-
-// where_clause:
-// "WHERE foo = 1" -> (WHERE (= (COL foo) 1))
+ // where_clause:
+ // "WHERE foo = 1" -> (WHERE (= (COL foo) 1))
@Test
public void test_where_clause1() throws Exception {
testParser("where_clause", "WHERE foo = 1", "(WHERE (= (COL foo) 1))");
}
-// "WHERE a = 1 AND b <> 2 OR c >= 3" -> (WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (>= (COL c) 3)))
+ // "WHERE a = 1 AND b <> 2 OR c >= 3" -> (WHERE (OR (AND (= (COL a) 1) (<>
+ // (COL b) 2)) (>= (COL c) 3)))
@Test
public void test_where_clause2() throws Exception {
- testParser("where_clause", "WHERE a = 1 AND b <> 2 OR c >= 3", "(WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (>= (COL c) 3)))");
+ testParser("where_clause", "WHERE a = 1 AND b <> 2 OR c >= 3",
+ "(WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (>= (COL c) 3)))");
}
-// "WHERE a = 1 AND b <> 2 OR c >= 3 AND d <= 4" -> (WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (AND (>= (COL c) 3) (<= (COL d) 4))))
+ // "WHERE a = 1 AND b <> 2 OR c >= 3 AND d <= 4" -> (WHERE (OR (AND (= (COL
+ // a) 1) (<> (COL b) 2)) (AND (>= (COL c) 3) (<= (COL d) 4))))
@Test
public void test_where_clause3() throws Exception {
- testParser("where_clause", "WHERE a = 1 AND b <> 2 OR c >= 3 AND d <= 4", "(WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (AND (>= (COL c) 3) (<= (COL d) 4))))");
+ testParser("where_clause", "WHERE a = 1 AND b <> 2 OR c >= 3 AND d <= 4",
+ "(WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (AND (>= (COL c) 3) (<= (COL d) 4))))");
}
-// "WHERE a = 1 AND b <> 2 OR c >= 3 AND NOT d <= 4" -> (WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (AND (>= (COL c) 3) (NOT (<= (COL d) 4)))))
+ // "WHERE a = 1 AND b <> 2 OR c >= 3 AND NOT d <= 4" -> (WHERE (OR (AND (=
+ // (COL a) 1) (<> (COL b) 2)) (AND (>= (COL c) 3) (NOT (<= (COL d) 4)))))
@Test
public void test_where_clause4() throws Exception {
- testParser("where_clause", "WHERE a = 1 AND b <> 2 OR c >= 3 AND NOT d <= 4", "(WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (AND (>= (COL c) 3) (NOT (<= (COL d) 4)))))");
+ testParser("where_clause", "WHERE a = 1 AND b <> 2 OR c >= 3 AND NOT d <= 4",
+ "(WHERE (OR (AND (= (COL a) 1) (<> (COL b) 2)) (AND (>= (COL c) 3) (NOT (<= (COL d) 4)))))");
}
-
-// query:
-// "SELECT * FROM Document" -> (SELECT * (FROM (TABLE Document)))
+ // query:
+ // "SELECT * FROM Document" -> (SELECT * (FROM (TABLE Document)))
@Test
public void test_query1() throws Exception {
testParser("query", "SELECT * FROM Document", "(SELECT * (FROM (TABLE Document)))");
}
-// "SELECT a, b, c FROM Document" -> (SELECT (SEL_LIST (COL a) (COL b) (COL c)) (FROM (TABLE Document)))
+ // "SELECT a, b, c FROM Document" -> (SELECT (SEL_LIST (COL a) (COL b) (COL
+ // c)) (FROM (TABLE Document)))
@Test
public void test_query2() throws Exception {
- testParser("query", "SELECT a, b, c FROM Document", "(SELECT (SEL_LIST (COL a) (COL b) (COL c)) (FROM (TABLE Document)))");
+ testParser("query", "SELECT a, b, c FROM Document",
+ "(SELECT (SEL_LIST (COL a) (COL b) (COL c)) (FROM (TABLE Document)))");
}
-// "SELECT a, b FROM Document ORDER BY a, b" -> (SELECT (SEL_LIST (COL a) (COL b)) (FROM (TABLE Document)) (ORDER_BY (COL a) ASC (COL b) ASC))
+ // "SELECT a, b FROM Document ORDER BY a, b" -> (SELECT (SEL_LIST (COL a)
+ // (COL b)) (FROM (TABLE Document)) (ORDER_BY (COL a) ASC (COL b) ASC))
@Test
public void test_query3() throws Exception {
- testParser("query", "SELECT a, b FROM Document ORDER BY a, b", "(SELECT (SEL_LIST (COL a) (COL b)) (FROM (TABLE Document)) (ORDER_BY (COL a) ASC (COL b) ASC))");
+ testParser("query", "SELECT a, b FROM Document ORDER BY a, b",
+ "(SELECT (SEL_LIST (COL a) (COL b)) (FROM (TABLE Document)) (ORDER_BY (COL a) ASC (COL b) ASC))");
}
-
-// where_clause:
-// "WHERE IN_TREE('ID00093854763') AND ('SMITH' = ANY AUTHORS)" -> (WHERE (AND (IN_TREE 'ID00093854763') (EQ_ANY 'SMITH' (COL AUTHORS))))
+ // where_clause:
+ // "WHERE IN_TREE('ID00093854763') AND ('SMITH' = ANY AUTHORS)" -> (WHERE
+ // (AND (IN_TREE 'ID00093854763') (EQ_ANY 'SMITH' (COL AUTHORS))))
@Test
public void test_where_clause5() throws Exception {
- testParser("where_clause", "WHERE IN_TREE('ID00093854763') AND ('SMITH' = ANY AUTHORS)", "(WHERE (AND (IN_TREE 'ID00093854763') (EQ_ANY 'SMITH' (COL AUTHORS))))");
+ testParser("where_clause", "WHERE IN_TREE('ID00093854763') AND ('SMITH' = ANY AUTHORS)",
+ "(WHERE (AND (IN_TREE 'ID00093854763') (EQ_ANY 'SMITH' (COL AUTHORS))))");
}
-
-// query:
-//
-// <<
-// SELECT * FROM Document WHERE foo = 1
-// >> -> (SELECT * (FROM (TABLE Document)) (WHERE (= (COL foo) 1)))
+ // query:
+ //
+ // <<
+ // SELECT * FROM Document WHERE foo = 1
+ // >> -> (SELECT * (FROM (TABLE Document)) (WHERE (= (COL foo) 1)))
@Test
public void query1() throws Exception {
testParser("query", "SELECT * FROM Document WHERE foo = 1",
"(SELECT * (FROM (TABLE Document)) (WHERE (= (COL foo) 1)))");
}
-
// Examples from older versions of the specs.
-
-// <<
-// SELECT * FROM WHITE_PAPER
-// >> -> (SELECT * (FROM (TABLE WHITE_PAPER)))
+ // <<
+ // SELECT * FROM WHITE_PAPER
+ // >> -> (SELECT * (FROM (TABLE WHITE_PAPER)))
@Test
public void query2() throws Exception {
testParser("query", "SELECT * FROM WHITE_PAPER", "(SELECT * (FROM (TABLE WHITE_PAPER)))");
}
-
-// <<
-// SELECT TITLE, AUTHORS, DATE
-// FROM WHITE_PAPER
-// WHERE ( IN_TREE('ID00093854763') ) AND ( 'SMITH' = ANY AUTHORS )
-// >> -> (SELECT (SEL_LIST (COL TITLE) (COL AUTHORS) (COL DATE)) (FROM (TABLE WHITE_PAPER)) (WHERE (AND (IN_TREE 'ID00093854763') (EQ_ANY 'SMITH' (COL AUTHORS)))))
+ // <<
+ // SELECT TITLE, AUTHORS, DATE
+ // FROM WHITE_PAPER
+ // WHERE ( IN_TREE('ID00093854763') ) AND ( 'SMITH' = ANY AUTHORS )
+ // >> -> (SELECT (SEL_LIST (COL TITLE) (COL AUTHORS) (COL DATE)) (FROM
+ // (TABLE WHITE_PAPER)) (WHERE (AND (IN_TREE 'ID00093854763') (EQ_ANY
+ // 'SMITH' (COL AUTHORS)))))
@Test
public void query3() throws Exception {
- testParser("query",
- "SELECT TITLE, AUTHORS, DATE " +
- "FROM WHITE_PAPER " +
- "WHERE ( IN_TREE('ID00093854763') ) AND ( 'SMITH' = ANY AUTHORS )",
+ testParser(
+ "query",
+ "SELECT TITLE, AUTHORS, DATE " + "FROM WHITE_PAPER "
+ + "WHERE ( IN_TREE('ID00093854763') ) AND ( 'SMITH' = ANY AUTHORS )",
"(SELECT (SEL_LIST (COL TITLE) (COL AUTHORS) (COL DATE)) (FROM (TABLE WHITE_PAPER)) (WHERE (AND (IN_TREE 'ID00093854763') (EQ_ANY 'SMITH' (COL AUTHORS)))))");
}
-
-// <<
-// SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES
-// FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM
-// WHERE ( 100000 = ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )
-// >> OK
+ // <<
+ // SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES
+ // FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM
+ // WHERE ( 100000 = ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE
+ // '%Katrina%' )
+ // >> OK
@Test
public void query4() throws Exception {
- testParserOk("query",
- "SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES " +
- "FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM " +
- "WHERE ( 100000 = ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )");
+ testParserOk("query", "SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES "
+ + "FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM "
+ + "WHERE ( 100000 = ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )");
}
-
-// <<
-// SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES
-// FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM
-// WHERE ( 100000 <= ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )
-// >> FAIL
+ // <<
+ // SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES
+ // FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM
+ // WHERE ( 100000 <= ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE
+ // '%Katrina%' )
+ // >> FAIL
@Test
public void query5() throws Exception {
- testParserFail("query",
- "SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES " +
- "FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM " +
- " WHERE ( 100000 <= ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )");
+ testParserFail("query", "SELECT Y.CLAIM_NUM, X.PROPERTY_ADDRESS, Y.DAMAGE_ESTIMATES "
+ + "FROM POLICY AS X JOIN CLAIMS AS Y ON X.POLICY_NUM = Y.POLICY_NUM "
+ + " WHERE ( 100000 <= ANY Y.DAMAGE_ESTIMATES ) AND ( Y.CAUSE NOT LIKE '%Katrina%' )");
}
-
-// <<
-// SELECT *
-// FROM CAR_REVIEW
-// WHERE ANY FEATURES IN ('NAVIGATION SYSTEM', 'SATELLITE RADIO', 'MP3' )
-// >> OK
+ // <<
+ // SELECT *
+ // FROM CAR_REVIEW
+ // WHERE ANY FEATURES IN ('NAVIGATION SYSTEM', 'SATELLITE RADIO', 'MP3' )
+ // >> OK
@Test
public void query6() throws Exception {
- testParserOk("query", " SELECT * FROM CAR_REVIEW WHERE ANY FEATURES IN ('NAVIGATION SYSTEM', 'SATELLITE RADIO', 'MP3' )");
+ testParserOk("query",
+ " SELECT * FROM CAR_REVIEW WHERE ANY FEATURES IN ('NAVIGATION SYSTEM', 'SATELLITE RADIO', 'MP3' )");
}
-
-// <<
-// SELECT OBJECT_ID, SCORE() AS X, DESTINATION, DEPARTURE_DATES
-// FROM TRAVEL_BROCHURE
-// WHERE ( CONTAINS('CARIBBEAN CENTRAL AMERICA CRUISE TOUR') ) AND
-// ( '2010-1-1' = ANY DEPARTURE_DATES )
-// ORDER BY X DESC
-// >> OK
+ // <<
+ // SELECT OBJECT_ID, SCORE() AS X, DESTINATION, DEPARTURE_DATES
+ // FROM TRAVEL_BROCHURE
+ // WHERE ( CONTAINS('CARIBBEAN CENTRAL AMERICA CRUISE TOUR') ) AND
+ // ( '2010-1-1' = ANY DEPARTURE_DATES )
+ // ORDER BY X DESC
+ // >> OK
@Test
public void query7() throws Exception {
- testParserOk("query",
- "SELECT OBJECT_ID, SCORE() AS X, DESTINATION, DEPARTURE_DATES " +
- "FROM TRAVEL_BROCHURE " +
- "WHERE ( CONTAINS('CARIBBEAN CENTRAL AMERICA CRUISE TOUR') ) AND( '2010-1-1' = ANY DEPARTURE_DATES )");
+ testParserOk("query", "SELECT OBJECT_ID, SCORE() AS X, DESTINATION, DEPARTURE_DATES " + "FROM TRAVEL_BROCHURE "
+ + "WHERE ( CONTAINS('CARIBBEAN CENTRAL AMERICA CRUISE TOUR') ) AND( '2010-1-1' = ANY DEPARTURE_DATES )");
}
-
+
@Test
public void queryEsc1() throws Exception {
- testParserOk("query",
- "SELECT * FROM cmis:document " +
- "WHERE cmis:name LIKE 'abc\\%'");
+ testParserOk("query", "SELECT * FROM cmis:document " + "WHERE cmis:name LIKE 'abc\\%'");
}
-
+
}
Modified: chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/test/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsumTest.java
URL: http://svn.apache.org/viewvc/chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/test/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsumTest.java?rev=1511386&r1=1511385&r2=1511386&view=diff
==============================================================================
--- chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/test/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsumTest.java (original)
+++ chemistry/opencmis/trunk/chemistry-opencmis-test/chemistry-opencmis-test-util/src/test/java/org/apache/chemistry/opencmis/util/content/loremipsum/LoremIpsumTest.java Wed Aug 7 16:44:24 2013
@@ -24,317 +24,310 @@ import static org.junit.Assert.assertFal
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringWriter;
-import java.io.Writer;
-import org.apache.chemistry.opencmis.util.content.loremipsum.LoremIpsum;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class LoremIpsumTest {
private static final Logger LOG = LoggerFactory.getLogger(LoremIpsumTest.class);
- String sample = "One two three four five six. Seven eight nine ten eleven twelve. "
- + "\n\n"
- + "Thirteen fourteen fifteen sixteen. Seventeen eighteen nineteen twenty.";
-
+ String sample = "One two three four five six. Seven eight nine ten eleven twelve. " + "\n\n"
+ + "Thirteen fourteen fifteen sixteen. Seventeen eighteen nineteen twenty.";
+
String dictionary = "a bb ccc dddd eeeee ffffff ggggggg hhhhhhhh iiiiiiiii jjjjjjjjjj kkkkkkkkkkk llllllllllll";
LoremIpsum generator = new LoremIpsum(sample, dictionary);
-
- @Before
- public void setUp() throws Exception {
- dictionary.split(" ");
- }
-
- @After
- public void tearDown() throws Exception {
- }
-
- @Test
- public void test_mean() {
- int[] ia1 = {1, 2, 3, 4};
+
+ @Before
+ public void setUp() throws Exception {
+ dictionary.split(" ");
+ }
+
+ @After
+ public void tearDown() throws Exception {
+ }
+
+ @Test
+ public void test_mean() {
+ int[] ia1 = { 1, 2, 3, 4 };
assertEquals(2.5d, LoremIpsum.mean(ia1), 0.01d);
- int[] ia2 = {6, 6, 4, 4};
+ int[] ia2 = { 6, 6, 4, 4 };
assertEquals(5.0d, LoremIpsum.mean(ia2), 0.01d);
- }
-
+ }
+
@Test
- public void test_mean_empty() {
- int[] ia1 = {};
+ public void test_mean_empty() {
+ int[] ia1 = {};
assertEquals(0.0d, LoremIpsum.mean(ia1), 0.01d);
}
-
+
@Test
- public void test_variance() {
- double[] ia1 = {6.0d, 6.0d, 4.0d, 4.0d};
+ public void test_variance() {
+ double[] ia1 = { 6.0d, 6.0d, 4.0d, 4.0d };
assertEquals(1.0d, LoremIpsum.variance(ia1), 0.01d);
- double[] ia2 = {1.0d, 2.0d, 3.0d, 4.0d};
+ double[] ia2 = { 1.0d, 2.0d, 3.0d, 4.0d };
assertEquals(1.25d, LoremIpsum.variance(ia2), 0.01d);
}
-
+
@Test
- public void test_sigma() {
- double[] ia1 = {6.0d, 6.0d, 4.0d, 4.0d};
- double[] ia2 = {1.0d, 2.0d, 3.0d, 4.0d};
+ public void test_sigma() {
+ double[] ia1 = { 6.0d, 6.0d, 4.0d, 4.0d };
+ double[] ia2 = { 1.0d, 2.0d, 3.0d, 4.0d };
assertEquals(1.0d, LoremIpsum.sigma(ia1), 0.01d);
assertEquals(Math.sqrt(1.25), LoremIpsum.sigma(ia2), 0.01d);
}
-
+
@Test
- public void test_sigma_empty() {
- int[] ia1 = {};
+ public void test_sigma_empty() {
+ int[] ia1 = {};
assertEquals(0.0d, LoremIpsum.sigma(ia1), 0.01d);
}
-
+
@Test
- public void test_split_sentences() {
- String[] sentences1 = {"Hello", "Hi"};
- assertArrayEquals (sentences1, LoremIpsum.splitSentences("Hello. Hi."));
- String[] sentences2 = {"One two three four five six",
- "Seven eight nine ten eleven twelve",
- "Thirteen fourteen fifteen sixteen",
- "Seventeen eighteen nineteen twenty"};
+ public void test_split_sentences() {
+ String[] sentences1 = { "Hello", "Hi" };
+ assertArrayEquals(sentences1, LoremIpsum.splitSentences("Hello. Hi."));
+ String[] sentences2 = { "One two three four five six", "Seven eight nine ten eleven twelve",
+ "Thirteen fourteen fifteen sixteen", "Seventeen eighteen nineteen twenty" };
assertArrayEquals(sentences2, LoremIpsum.splitSentences(sample));
}
-
+
@Test
- public void test_split_sentences_empty() {
- String[] sentences = {};
- assertArrayEquals(sentences, LoremIpsum.splitSentences(""));
- }
-
- @Test
- public void test_split_sentences_trailing() {
- String[] sentences1 = {"Hello", "Hi", "Hello"};
- assertArrayEquals(sentences1, LoremIpsum.splitSentences("Hello. Hi. Hello"));
- String[] sentences2 = {"Hello", "Hi", "Hello"};
- assertArrayEquals(sentences2, LoremIpsum.splitSentences(" Hello. Hi. Hello "));
- String[] sentences3 = {"Hello", "Hi", "Hello"};
- assertArrayEquals(sentences3, LoremIpsum.splitSentences(".. Hello... Hi.... Hello "));
+ public void test_split_sentences_empty() {
+ String[] sentences = {};
+ assertArrayEquals(sentences, LoremIpsum.splitSentences(""));
}
@Test
- public void test_split_paragraphs() {
- String[] paragraphs = {"One two three four five six. Seven eight nine ten eleven twelve.",
- "Thirteen fourteen fifteen sixteen. Seventeen eighteen nineteen twenty."};
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs(sample));
- }
-
- @Test
- public void test_split_paragraphs_empty() {
- String[] paragraphs = {};
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs(""));
- }
-
- @Test
- public void test_split_paragraphs_trailing() {
- String[] paragraphs = {"Hello", "Hi"};
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi"));
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi\n"));
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi\n\n"));
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi\n\n\n"));
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi\n\n\n\n\n\n"));
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("\nHello\n\nHi"));
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("\n\nHello\n\nHi"));
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("\n\n\nHello\n\nHi"));
- assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("\n\n\n\n\n\nHello\n\nHi"));
- }
-
- @Test
- public void test_split_words() {
- String[] words = {"One", "two", "three", "four"};
- assertArrayEquals(words, LoremIpsum.splitWords("One two three four"));
- assertArrayEquals(words, LoremIpsum.splitWords(" One two three four "));
- }
-
- @Test
- public void test_split_words_empty() {
- String[] words = {};
- assertArrayEquals(words, LoremIpsum.splitWords(""));
- }
-
+ public void test_split_sentences_trailing() {
+ String[] sentences1 = { "Hello", "Hi", "Hello" };
+ assertArrayEquals(sentences1, LoremIpsum.splitSentences("Hello. Hi. Hello"));
+ String[] sentences2 = { "Hello", "Hi", "Hello" };
+ assertArrayEquals(sentences2, LoremIpsum.splitSentences(" Hello. Hi. Hello "));
+ String[] sentences3 = { "Hello", "Hi", "Hello" };
+ assertArrayEquals(sentences3, LoremIpsum.splitSentences(".. Hello... Hi.... Hello "));
+ }
+
@Test
- public void test_choose_closest() {
- Integer[] intArray1 ={1,2,3,4};
+ public void test_split_paragraphs() {
+ String[] paragraphs = { "One two three four five six. Seven eight nine ten eleven twelve.",
+ "Thirteen fourteen fifteen sixteen. Seventeen eighteen nineteen twenty." };
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs(sample));
+ }
+
+ @Test
+ public void test_split_paragraphs_empty() {
+ String[] paragraphs = {};
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs(""));
+ }
+
+ @Test
+ public void test_split_paragraphs_trailing() {
+ String[] paragraphs = { "Hello", "Hi" };
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi"));
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi\n"));
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi\n\n"));
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi\n\n\n"));
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("Hello\n\nHi\n\n\n\n\n\n"));
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("\nHello\n\nHi"));
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("\n\nHello\n\nHi"));
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("\n\n\nHello\n\nHi"));
+ assertArrayEquals(paragraphs, LoremIpsum.splitParagraphs("\n\n\n\n\n\nHello\n\nHi"));
+ }
+
+ @Test
+ public void test_split_words() {
+ String[] words = { "One", "two", "three", "four" };
+ assertArrayEquals(words, LoremIpsum.splitWords("One two three four"));
+ assertArrayEquals(words, LoremIpsum.splitWords(" One two three four "));
+ }
+
+ @Test
+ public void test_split_words_empty() {
+ String[] words = {};
+ assertArrayEquals(words, LoremIpsum.splitWords(""));
+ }
+
+ @Test
+ public void test_choose_closest() {
+ Integer[] intArray1 = { 1, 2, 3, 4 };
assertEquals(1, LoremIpsum.chooseClosest(intArray1, 1));
- Integer[] intArray2 ={1,2,3,4};
+ Integer[] intArray2 = { 1, 2, 3, 4 };
assertEquals(4, LoremIpsum.chooseClosest(intArray2, 4));
assertEquals(4, LoremIpsum.chooseClosest(intArray2, 20));
assertEquals(1, LoremIpsum.chooseClosest(intArray2, -10));
- Integer[] intArray3 ={1,4};
+ Integer[] intArray3 = { 1, 4 };
assertEquals(1, LoremIpsum.chooseClosest(intArray3, 2));
assertEquals(4, LoremIpsum.chooseClosest(intArray3, 3));
- Integer[] intArray4 ={1,3};
+ Integer[] intArray4 = { 1, 3 };
assertEquals(1, LoremIpsum.chooseClosest(intArray4, 2));
- Integer[] intArray5 ={3,1};
+ Integer[] intArray5 = { 3, 1 };
assertEquals(3, LoremIpsum.chooseClosest(intArray5, 2));
- Integer[] intArray6 ={1};
+ Integer[] intArray6 = { 1 };
assertEquals(1, LoremIpsum.chooseClosest(intArray6, 200));
}
@Test
- public void test_sentence_mean() {
+ public void test_sentence_mean() {
assertEquals(5.0d, generator.getSentenceMean(), 0.01d);
- }
-
+ }
+
@Test
- public void test_paragraph_mean() {
- assertEquals(2.0d, generator.getParagraphMean(), 0.01d);
+ public void test_paragraph_mean() {
+ assertEquals(2.0d, generator.getParagraphMean(), 0.01d);
}
-
+
@Test
- public void test_sentence_sigma() {
+ public void test_sentence_sigma() {
assertEquals(1.0d, generator.getSentenceSigma(), 0.01d);
}
-
+
@Test
- public void test_paragraph_sigma() {
+ public void test_paragraph_sigma() {
assertEquals(0.0d, generator.getParagraphSigma(), 0.01d);
}
-
+
@Test
- public void test_sample() {
+ public void test_sample() {
assertEquals(generator.getSample(), sample);
}
@Test
- public void test_dictionary() {
+ public void test_dictionary() {
assertEquals(generator.getDictionary(), dictionary);
}
@Test
- public void test_set_dictionary() {
+ public void test_set_dictionary() {
String newdict = "a b c";
generator.setDictionary(newdict);
assertEquals(generator.getDictionary(), newdict);
- }
-
- @Test
+ }
+
+ @Test
public void test_init_no_sample() {
- doGenerate("");
- doGenerate(" ");
- doGenerate("\n\n");
- doGenerate(" \n\n ");
- doGenerate(" .\n\n .");
+ doGenerate("");
+ doGenerate(" ");
+ doGenerate("\n\n");
+ doGenerate(" \n\n ");
+ doGenerate(" .\n\n .");
}
-
+
private void doGenerate(String text) {
- try {
- generator = new LoremIpsum(text, dictionary);
- generator.generateParagraph(false);
- fail("Sample text " + text + " should generate exception.");
- } catch (RuntimeException e) {
- assertTrue(e.getMessage().contains("Invalid sample text"));
- }
+ try {
+ generator = new LoremIpsum(text, dictionary);
+ generator.generateParagraph(false);
+ fail("Sample text " + text + " should generate exception.");
+ } catch (RuntimeException e) {
+ assertTrue(e.getMessage().contains("Invalid sample text"));
+ }
}
-
- @Test
+
+ @Test
public void test_init_no_dict() {
- doGenerateNoDict("");
- doGenerateNoDict(" ");
- doGenerateNoDict("\n\n");
- doGenerateNoDict(" \n\n ");
+ doGenerateNoDict("");
+ doGenerateNoDict(" ");
+ doGenerateNoDict("\n\n");
+ doGenerateNoDict(" \n\n ");
}
-
+
private void doGenerateNoDict(String dict) {
- try {
- generator = new LoremIpsum(sample, dict);
- generator.generateParagraph(false);
- fail("Dictionary " + dict + " should generate exception.");
- } catch (RuntimeException e) {
- assertEquals(e.getMessage(), "Invalid dictionary.");
- }
+ try {
+ generator = new LoremIpsum(sample, dict);
+ generator.generateParagraph(false);
+ fail("Dictionary " + dict + " should generate exception.");
+ } catch (RuntimeException e) {
+ assertEquals(e.getMessage(), "Invalid dictionary.");
+ }
}
- @Test
+ @Test
public void testGenerate() {
- LOG.debug("Generate new text: ");
- String newDict = "me you he the One two three four five six Seven eight nine ten eleven twelve "
- + "Thirteen fourteen fifteen sixteen Seventeen eighteen nineteen twenty joe fred some";
- String[] newParagraphs = new String[4];
- generator.setDictionary(newDict);
- for (int i=0; i<newParagraphs.length; i++) {
- newParagraphs[i] = generator.generateParagraph(false);
- LOG.debug(newParagraphs[i]);
- LOG.debug("");
- }
- assertFalse(newParagraphs[0].equals(newParagraphs[1]));
- assertFalse(newParagraphs[0].equals(newParagraphs[2]));
- assertFalse(newParagraphs[0].equals(newParagraphs[3]));
- assertFalse(newParagraphs[1].equals(newParagraphs[2]));
- assertFalse(newParagraphs[1].equals(newParagraphs[3]));
- assertFalse(newParagraphs[2].equals(newParagraphs[3]));
+ LOG.debug("Generate new text: ");
+ String newDict = "me you he the One two three four five six Seven eight nine ten eleven twelve "
+ + "Thirteen fourteen fifteen sixteen Seventeen eighteen nineteen twenty joe fred some";
+ String[] newParagraphs = new String[4];
+ generator.setDictionary(newDict);
+ for (int i = 0; i < newParagraphs.length; i++) {
+ newParagraphs[i] = generator.generateParagraph(false);
+ LOG.debug(newParagraphs[i]);
+ LOG.debug("");
+ }
+ assertFalse(newParagraphs[0].equals(newParagraphs[1]));
+ assertFalse(newParagraphs[0].equals(newParagraphs[2]));
+ assertFalse(newParagraphs[0].equals(newParagraphs[3]));
+ assertFalse(newParagraphs[1].equals(newParagraphs[2]));
+ assertFalse(newParagraphs[1].equals(newParagraphs[3]));
+ assertFalse(newParagraphs[2].equals(newParagraphs[3]));
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsum() {
- LOG.debug("Generate new Lore Ipsum text: ");
- LoremIpsum ipsum = new LoremIpsum();
- String[] newParagraphs = new String[4];
- for (int i=0; i<newParagraphs.length; i++) {
- newParagraphs[i] = ipsum.generateParagraph(false);
- LOG.debug(newParagraphs[i]);
- LOG.debug("");
- LOG.debug("");
- }
+ LOG.debug("Generate new Lore Ipsum text: ");
+ LoremIpsum ipsum = new LoremIpsum();
+ String[] newParagraphs = new String[4];
+ for (int i = 0; i < newParagraphs.length; i++) {
+ newParagraphs[i] = ipsum.generateParagraph(false);
+ LOG.debug(newParagraphs[i]);
+ LOG.debug("");
+ LOG.debug("");
+ }
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsumHtml1() {
- LOG.debug("Generate new Lore Ipsum as html paragraphs:");
- LoremIpsum ipsum = new LoremIpsum();
- String output = ipsum.generateParagraphsHtml(2048, true);
- LOG.debug(output);
- LOG.debug("");
+ LOG.debug("Generate new Lore Ipsum as html paragraphs:");
+ LoremIpsum ipsum = new LoremIpsum();
+ String output = ipsum.generateParagraphsHtml(2048, true);
+ LOG.debug(output);
+ LOG.debug("");
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsumHtml2() {
- LOG.debug("Generate new Lore Ipsum as one html paragraph:");
- LoremIpsum ipsum = new LoremIpsum();
- String output = ipsum.generateOneParagraphHtml(2048, true);
- LOG.debug(output);
- LOG.debug("");
+ LOG.debug("Generate new Lore Ipsum as one html paragraph:");
+ LoremIpsum ipsum = new LoremIpsum();
+ String output = ipsum.generateOneParagraphHtml(2048, true);
+ LOG.debug(output);
+ LOG.debug("");
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsumHtml3() {
LOG.debug("Generate new Lore Ipsum as full html document: ");
- LoremIpsum ipsum = new LoremIpsum();
- String output = ipsum.generateParagraphsFullHtml(2048, true);
- LOG.debug(output);
- LOG.debug("");
+ LoremIpsum ipsum = new LoremIpsum();
+ String output = ipsum.generateParagraphsFullHtml(2048, true);
+ LOG.debug(output);
+ LOG.debug("");
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsumPlainText() {
- LOG.debug("Generate new Lore Ipsum as plain text: ");
- LoremIpsum ipsum = new LoremIpsum();
- String output = ipsum.generateParagraphsPlainText(2048, true);
- LOG.debug(output);
- LOG.debug("");
+ LOG.debug("Generate new Lore Ipsum as plain text: ");
+ LoremIpsum ipsum = new LoremIpsum();
+ String output = ipsum.generateParagraphsPlainText(2048, true);
+ LOG.debug(output);
+ LOG.debug("");
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsumPlainTextFormatted() {
- LOG.debug("Generate new Lore Ipsum as plain text with 60 columns: ");
- LoremIpsum ipsum = new LoremIpsum();
- String output = ipsum.generateParagraphsPlainText(256, 60, false);
- LOG.debug(output);
- LOG.debug("");
+ LOG.debug("Generate new Lore Ipsum as plain text with 60 columns: ");
+ LoremIpsum ipsum = new LoremIpsum();
+ String output = ipsum.generateParagraphsPlainText(256, 60, false);
+ LOG.debug(output);
+ LOG.debug("");
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsumHtml1Writer() throws IOException {
LOG.debug("Generate new Lore Ipsum as html paragraphs with PrintWriter:");
LoremIpsum ipsum = new LoremIpsum();
@@ -343,9 +336,9 @@ public class LoremIpsumTest {
LOG.debug(writer.toString());
LOG.debug("End Test.");
}
-
- @Test
- public void testGenerateLoreIpsumHtml2Writer() throws IOException {
+
+ @Test
+ public void testGenerateLoreIpsumHtml2Writer() throws IOException {
LOG.debug("Generate new Lore Ipsum as full html paragraph with PrintWriter:");
LoremIpsum ipsum = new LoremIpsum();
StringWriter writer = new StringWriter();
@@ -353,9 +346,9 @@ public class LoremIpsumTest {
LOG.debug(writer.toString());
LOG.debug("End Test.");
}
-
- @Test
- public void testGenerateLoreIpsumPlainTextWriter() throws IOException {
+
+ @Test
+ public void testGenerateLoreIpsumPlainTextWriter() throws IOException {
LOG.debug("Generate new Lore Ipsum as plain text with PrintWriter: ");
LoremIpsum ipsum = new LoremIpsum();
StringWriter writer = new StringWriter();
@@ -363,8 +356,8 @@ public class LoremIpsumTest {
LOG.debug(writer.toString());
LOG.debug("End Test.");
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsumPlainTextFormattedWriter() throws IOException {
LOG.debug("Generate new Lore Ipsum as plain text with 60 columns with PrintWriter: ");
LoremIpsum ipsum = new LoremIpsum();
@@ -373,29 +366,28 @@ public class LoremIpsumTest {
LOG.debug(writer.toString());
LOG.debug("End Test.");
}
-
- @Test
+
+ @Test
public void testGenerateLoreIpsumGerman() throws Exception {
- LOG.debug("Generate new Lore Ipsum Ferry Tale: ");
- InputStream is = this.getClass().getResourceAsStream("/HaenselUndGretel.txt");
-
- // read stream into a string
- final char[] buffer = new char[0x10000];
- StringBuilder sample = new StringBuilder();
- Reader in = new InputStreamReader(is, "ISO-8859-1");
- int read;
- do {
- read = in.read(buffer, 0, buffer.length);
- if (read>0) {
- sample.append(buffer, 0, read);
- }
- } while (read>=0);
-
-
- LoremIpsum ipsum = new LoremIpsum(sample.toString());
- String output = ipsum.generateParagraphsPlainText(4096, 80, false);
- LOG.debug(output);
+ LOG.debug("Generate new Lore Ipsum Ferry Tale: ");
+ InputStream is = this.getClass().getResourceAsStream("/HaenselUndGretel.txt");
+
+ // read stream into a string
+ final char[] buffer = new char[0x10000];
+ StringBuilder sample = new StringBuilder();
+ Reader in = new InputStreamReader(is, "ISO-8859-1");
+ int read;
+ do {
+ read = in.read(buffer, 0, buffer.length);
+ if (read > 0) {
+ sample.append(buffer, 0, read);
+ }
+ } while (read >= 0);
+
+ LoremIpsum ipsum = new LoremIpsum(sample.toString());
+ String output = ipsum.generateParagraphsPlainText(4096, 80, false);
+ LOG.debug(output);
LOG.debug("End Test.");
}
-
+
}